@vercel/analytics 0.1.6-beta.0 → 0.1.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +5 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +5 -14
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +8 -18
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +4 -6
- package/dist/react/index.js +8 -18
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div align="center">
|
|
7
7
|
<a href="https://vercel.com/analytics">Website</a>
|
|
8
8
|
<span> · </span>
|
|
9
|
-
<a href="https://vercel.com/docs/concepts/analytics/audiences/
|
|
9
|
+
<a href="https://vercel.com/docs/concepts/analytics/audiences/package">Documentation</a>
|
|
10
10
|
<span> · </span>
|
|
11
11
|
<a href="https://twitter.com/vercel">Twitter</a>
|
|
12
12
|
</div>
|
package/dist/index.cjs
CHANGED
|
@@ -42,32 +42,23 @@ function isDevelopment() {
|
|
|
42
42
|
return false;
|
|
43
43
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
44
44
|
}
|
|
45
|
-
function getMode(mode = "auto") {
|
|
46
|
-
if (mode === "auto") {
|
|
47
|
-
return isDevelopment() ? "development" : "production";
|
|
48
|
-
}
|
|
49
|
-
return mode;
|
|
50
|
-
}
|
|
51
45
|
|
|
52
46
|
// src/generic.ts
|
|
53
|
-
var inject = (
|
|
54
|
-
debug: true
|
|
55
|
-
}) => {
|
|
47
|
+
var inject = ({ beforeSend, debug } = { debug: isDevelopment() }) => {
|
|
56
48
|
var _a;
|
|
57
49
|
if (!isBrowser())
|
|
58
50
|
return;
|
|
59
|
-
const mode = getMode(props.__mode);
|
|
60
51
|
initQueue();
|
|
61
|
-
if (
|
|
62
|
-
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend",
|
|
52
|
+
if (beforeSend) {
|
|
53
|
+
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
|
|
63
54
|
}
|
|
64
|
-
const src =
|
|
55
|
+
const src = isDevelopment() ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
|
|
65
56
|
if (document.head.querySelector(`script[src*="${src}"]`))
|
|
66
57
|
return;
|
|
67
58
|
const script = document.createElement("script");
|
|
68
59
|
script.src = src;
|
|
69
60
|
script.defer = true;
|
|
70
|
-
if (
|
|
61
|
+
if (isDevelopment() && debug === false) {
|
|
71
62
|
script.setAttribute("data-debug", "false");
|
|
72
63
|
}
|
|
73
64
|
document.head.appendChild(script);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generic.ts","../src/queue.ts","../src/utils.ts"],"sourcesContent":["import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser,
|
|
1
|
+
{"version":3,"sources":["../src/generic.ts","../src/queue.ts","../src/utils.ts"],"sourcesContent":["import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, isDevelopment } from './utils';\n\nexport const inject = (\n { beforeSend, debug }: AnalyticsProps = { debug: isDevelopment() },\n): void => {\n if (!isBrowser()) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n const src = isDevelopment()\n ? 'https://cdn.vercel-insights.com/v1/script.debug.js'\n : '/_vercel/insights/script.js';\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n\n if (isDevelopment() && debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n};\n","export const initQueue = (): void => {\n // initialise va until script is loaded\n if (window.va) return;\n\n window.va = function a(...params): void {\n (window.vaq = window.vaq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n if (typeof process === 'undefined') return false;\n return (\n process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test'\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI,OAAO,YAAY;AAAa,WAAO;AAC3C,SACE,QAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,aAAa;AAEvE;;;AFLO,IAAM,SAAS,CACpB,EAAE,YAAY,MAAM,IAAoB,EAAE,OAAO,cAAc,EAAE,MACxD;AANX;AAOE,MAAI,CAAC,UAAU;AAAG;AAClB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AACA,QAAM,MAAM,cAAc,IACtB,uDACA;AAEJ,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,cAAc,KAAK,UAAU,OAAO;AACtC,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,11 @@ interface PageViewEvent {
|
|
|
2
2
|
type: 'pageview';
|
|
3
3
|
url: string;
|
|
4
4
|
}
|
|
5
|
-
declare type
|
|
6
|
-
declare type
|
|
7
|
-
declare type BeforeSend = (event: Event) => Event | null;
|
|
5
|
+
declare type IEvent = PageViewEvent;
|
|
6
|
+
declare type BeforeSend = (event: IEvent) => IEvent | null;
|
|
8
7
|
interface AnalyticsProps {
|
|
9
8
|
beforeSend?: BeforeSend;
|
|
10
9
|
debug?: boolean;
|
|
11
|
-
__mode?: Mode;
|
|
12
10
|
}
|
|
13
11
|
declare global {
|
|
14
12
|
interface Window {
|
|
@@ -18,6 +16,6 @@ declare global {
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
declare const inject: (
|
|
19
|
+
declare const inject: ({ beforeSend, debug }?: AnalyticsProps) => void;
|
|
22
20
|
|
|
23
21
|
export { inject };
|
package/dist/index.js
CHANGED
|
@@ -16,32 +16,23 @@ function isDevelopment() {
|
|
|
16
16
|
return false;
|
|
17
17
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
18
18
|
}
|
|
19
|
-
function getMode(mode = "auto") {
|
|
20
|
-
if (mode === "auto") {
|
|
21
|
-
return isDevelopment() ? "development" : "production";
|
|
22
|
-
}
|
|
23
|
-
return mode;
|
|
24
|
-
}
|
|
25
19
|
|
|
26
20
|
// src/generic.ts
|
|
27
|
-
var inject = (
|
|
28
|
-
debug: true
|
|
29
|
-
}) => {
|
|
21
|
+
var inject = ({ beforeSend, debug } = { debug: isDevelopment() }) => {
|
|
30
22
|
var _a;
|
|
31
23
|
if (!isBrowser())
|
|
32
24
|
return;
|
|
33
|
-
const mode = getMode(props.__mode);
|
|
34
25
|
initQueue();
|
|
35
|
-
if (
|
|
36
|
-
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend",
|
|
26
|
+
if (beforeSend) {
|
|
27
|
+
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
|
|
37
28
|
}
|
|
38
|
-
const src =
|
|
29
|
+
const src = isDevelopment() ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
|
|
39
30
|
if (document.head.querySelector(`script[src*="${src}"]`))
|
|
40
31
|
return;
|
|
41
32
|
const script = document.createElement("script");
|
|
42
33
|
script.src = src;
|
|
43
34
|
script.defer = true;
|
|
44
|
-
if (
|
|
35
|
+
if (isDevelopment() && debug === false) {
|
|
45
36
|
script.setAttribute("data-debug", "false");
|
|
46
37
|
}
|
|
47
38
|
document.head.appendChild(script);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/queue.ts","../src/utils.ts","../src/generic.ts"],"sourcesContent":["export const initQueue = (): void => {\n //
|
|
1
|
+
{"version":3,"sources":["../src/queue.ts","../src/utils.ts","../src/generic.ts"],"sourcesContent":["export const initQueue = (): void => {\n // initialise va until script is loaded\n if (window.va) return;\n\n window.va = function a(...params): void {\n (window.vaq = window.vaq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n if (typeof process === 'undefined') return false;\n return (\n process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test'\n );\n}\n","import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, isDevelopment } from './utils';\n\nexport const inject = (\n { beforeSend, debug }: AnalyticsProps = { debug: isDevelopment() },\n): void => {\n if (!isBrowser()) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n const src = isDevelopment()\n ? 'https://cdn.vercel-insights.com/v1/script.debug.js'\n : '/_vercel/insights/script.js';\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n\n if (isDevelopment() && debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n};\n"],"mappings":";AAAO,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI,OAAO,YAAY;AAAa,WAAO;AAC3C,SACE,QAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,aAAa;AAEvE;;;ACLO,IAAM,SAAS,CACpB,EAAE,YAAY,MAAM,IAAoB,EAAE,OAAO,cAAc,EAAE,MACxD;AANX;AAOE,MAAI,CAAC,UAAU;AAAG;AAClB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AACA,QAAM,MAAM,cAAc,IACtB,uDACA;AAEJ,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,cAAc,KAAK,UAAU,OAAO;AACtC,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
|
package/dist/react/index.cjs
CHANGED
|
@@ -43,32 +43,23 @@ function isDevelopment() {
|
|
|
43
43
|
return false;
|
|
44
44
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
45
45
|
}
|
|
46
|
-
function getMode(mode = "auto") {
|
|
47
|
-
if (mode === "auto") {
|
|
48
|
-
return isDevelopment() ? "development" : "production";
|
|
49
|
-
}
|
|
50
|
-
return mode;
|
|
51
|
-
}
|
|
52
46
|
|
|
53
47
|
// src/generic.ts
|
|
54
|
-
var inject = (
|
|
55
|
-
debug: true
|
|
56
|
-
}) => {
|
|
48
|
+
var inject = ({ beforeSend, debug } = { debug: isDevelopment() }) => {
|
|
57
49
|
var _a;
|
|
58
50
|
if (!isBrowser())
|
|
59
51
|
return;
|
|
60
|
-
const mode = getMode(props.__mode);
|
|
61
52
|
initQueue();
|
|
62
|
-
if (
|
|
63
|
-
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend",
|
|
53
|
+
if (beforeSend) {
|
|
54
|
+
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
|
|
64
55
|
}
|
|
65
|
-
const src =
|
|
56
|
+
const src = isDevelopment() ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
|
|
66
57
|
if (document.head.querySelector(`script[src*="${src}"]`))
|
|
67
58
|
return;
|
|
68
59
|
const script = document.createElement("script");
|
|
69
60
|
script.src = src;
|
|
70
61
|
script.defer = true;
|
|
71
|
-
if (
|
|
62
|
+
if (isDevelopment() && debug === false) {
|
|
72
63
|
script.setAttribute("data-debug", "false");
|
|
73
64
|
}
|
|
74
65
|
document.head.appendChild(script);
|
|
@@ -77,12 +68,11 @@ var inject = (props = {
|
|
|
77
68
|
// src/react.tsx
|
|
78
69
|
function Analytics({
|
|
79
70
|
beforeSend,
|
|
80
|
-
debug =
|
|
81
|
-
__mode = "auto"
|
|
71
|
+
debug = isDevelopment()
|
|
82
72
|
}) {
|
|
83
73
|
(0, import_react.useEffect)(() => {
|
|
84
|
-
inject({ beforeSend, debug
|
|
85
|
-
}, [beforeSend, debug
|
|
74
|
+
inject({ beforeSend, debug });
|
|
75
|
+
}, [beforeSend, debug]);
|
|
86
76
|
return null;
|
|
87
77
|
}
|
|
88
78
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\
|
|
1
|
+
{"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\nimport { isDevelopment } from './utils';\n\nexport function Analytics({\n beforeSend,\n debug = isDevelopment(),\n}: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend, debug });\n }, [beforeSend, debug]);\n\n return null;\n}\n","export const initQueue = (): void => {\n // initialise va until script is loaded\n if (window.va) return;\n\n window.va = function a(...params): void {\n (window.vaq = window.vaq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n if (typeof process === 'undefined') return false;\n return (\n process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test'\n );\n}\n","import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, isDevelopment } from './utils';\n\nexport const inject = (\n { beforeSend, debug }: AnalyticsProps = { debug: isDevelopment() },\n): void => {\n if (!isBrowser()) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n const src = isDevelopment()\n ? 'https://cdn.vercel-insights.com/v1/script.debug.js'\n : '/_vercel/insights/script.js';\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n\n if (isDevelopment() && debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;;;ACAnB,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI,OAAO,YAAY;AAAa,WAAO;AAC3C,SACE,QAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,aAAa;AAEvE;;;ACLO,IAAM,SAAS,CACpB,EAAE,YAAY,MAAM,IAAoB,EAAE,OAAO,cAAc,EAAE,MACxD;AANX;AAOE,MAAI,CAAC,UAAU;AAAG;AAClB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AACA,QAAM,MAAM,cAAc,IACtB,uDACA;AAEJ,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,cAAc,KAAK,UAAU,OAAO;AACtC,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AHvBO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,QAAQ,cAAc;AACxB,GAAyB;AACvB,8BAAU,MAAM;AACd,WAAO,EAAE,YAAY,MAAM,CAAC;AAAA,EAC9B,GAAG,CAAC,YAAY,KAAK,CAAC;AAEtB,SAAO;AACT;","names":[]}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,13 +2,11 @@ interface PageViewEvent {
|
|
|
2
2
|
type: 'pageview';
|
|
3
3
|
url: string;
|
|
4
4
|
}
|
|
5
|
-
declare type
|
|
6
|
-
declare type
|
|
7
|
-
declare type BeforeSend = (event: Event) => Event | null;
|
|
5
|
+
declare type IEvent = PageViewEvent;
|
|
6
|
+
declare type BeforeSend = (event: IEvent) => IEvent | null;
|
|
8
7
|
interface AnalyticsProps {
|
|
9
8
|
beforeSend?: BeforeSend;
|
|
10
9
|
debug?: boolean;
|
|
11
|
-
__mode?: Mode;
|
|
12
10
|
}
|
|
13
11
|
declare global {
|
|
14
12
|
interface Window {
|
|
@@ -18,6 +16,6 @@ declare global {
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
declare function Analytics({ beforeSend, debug,
|
|
19
|
+
declare function Analytics({ beforeSend, debug, }: AnalyticsProps): null;
|
|
22
20
|
|
|
23
|
-
export { Analytics
|
|
21
|
+
export { Analytics };
|
package/dist/react/index.js
CHANGED
|
@@ -19,32 +19,23 @@ function isDevelopment() {
|
|
|
19
19
|
return false;
|
|
20
20
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
21
21
|
}
|
|
22
|
-
function getMode(mode = "auto") {
|
|
23
|
-
if (mode === "auto") {
|
|
24
|
-
return isDevelopment() ? "development" : "production";
|
|
25
|
-
}
|
|
26
|
-
return mode;
|
|
27
|
-
}
|
|
28
22
|
|
|
29
23
|
// src/generic.ts
|
|
30
|
-
var inject = (
|
|
31
|
-
debug: true
|
|
32
|
-
}) => {
|
|
24
|
+
var inject = ({ beforeSend, debug } = { debug: isDevelopment() }) => {
|
|
33
25
|
var _a;
|
|
34
26
|
if (!isBrowser())
|
|
35
27
|
return;
|
|
36
|
-
const mode = getMode(props.__mode);
|
|
37
28
|
initQueue();
|
|
38
|
-
if (
|
|
39
|
-
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend",
|
|
29
|
+
if (beforeSend) {
|
|
30
|
+
(_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
|
|
40
31
|
}
|
|
41
|
-
const src =
|
|
32
|
+
const src = isDevelopment() ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
|
|
42
33
|
if (document.head.querySelector(`script[src*="${src}"]`))
|
|
43
34
|
return;
|
|
44
35
|
const script = document.createElement("script");
|
|
45
36
|
script.src = src;
|
|
46
37
|
script.defer = true;
|
|
47
|
-
if (
|
|
38
|
+
if (isDevelopment() && debug === false) {
|
|
48
39
|
script.setAttribute("data-debug", "false");
|
|
49
40
|
}
|
|
50
41
|
document.head.appendChild(script);
|
|
@@ -53,12 +44,11 @@ var inject = (props = {
|
|
|
53
44
|
// src/react.tsx
|
|
54
45
|
function Analytics({
|
|
55
46
|
beforeSend,
|
|
56
|
-
debug =
|
|
57
|
-
__mode = "auto"
|
|
47
|
+
debug = isDevelopment()
|
|
58
48
|
}) {
|
|
59
49
|
useEffect(() => {
|
|
60
|
-
inject({ beforeSend, debug
|
|
61
|
-
}, [beforeSend, debug
|
|
50
|
+
inject({ beforeSend, debug });
|
|
51
|
+
}, [beforeSend, debug]);
|
|
62
52
|
return null;
|
|
63
53
|
}
|
|
64
54
|
export {
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\
|
|
1
|
+
{"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\nimport { isDevelopment } from './utils';\n\nexport function Analytics({\n beforeSend,\n debug = isDevelopment(),\n}: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend, debug });\n }, [beforeSend, debug]);\n\n return null;\n}\n","export const initQueue = (): void => {\n // initialise va until script is loaded\n if (window.va) return;\n\n window.va = function a(...params): void {\n (window.vaq = window.vaq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n if (typeof process === 'undefined') return false;\n return (\n process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test'\n );\n}\n","import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, isDevelopment } from './utils';\n\nexport const inject = (\n { beforeSend, debug }: AnalyticsProps = { debug: isDevelopment() },\n): void => {\n if (!isBrowser()) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n const src = isDevelopment()\n ? 'https://cdn.vercel-insights.com/v1/script.debug.js'\n : '/_vercel/insights/script.js';\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n\n if (isDevelopment() && debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n};\n"],"mappings":";AAAA,SAAS,iBAAiB;;;ACAnB,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI,OAAO,YAAY;AAAa,WAAO;AAC3C,SACE,QAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,aAAa;AAEvE;;;ACLO,IAAM,SAAS,CACpB,EAAE,YAAY,MAAM,IAAoB,EAAE,OAAO,cAAc,EAAE,MACxD;AANX;AAOE,MAAI,CAAC,UAAU;AAAG;AAClB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AACA,QAAM,MAAM,cAAc,IACtB,uDACA;AAEJ,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,cAAc,KAAK,UAAU,OAAO;AACtC,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AHvBO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,QAAQ,cAAc;AACxB,GAAyB;AACvB,YAAU,MAAM;AACd,WAAO,EAAE,YAAY,MAAM,CAAC;AAAA,EAC9B,GAAG,CAAC,YAAY,KAAK,CAAC;AAEtB,SAAO;AACT;","names":[]}
|