@vercel/analytics 0.1.1 → 0.1.2

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/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -8,54 +8,52 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === 'object') || typeof from === 'function') {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
13
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, '__esModule', { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
 
24
20
  // src/generic.ts
25
21
  var generic_exports = {};
26
22
  __export(generic_exports, {
27
- inject: () => inject,
23
+ inject: () => inject
28
24
  });
29
25
  module.exports = __toCommonJS(generic_exports);
30
26
 
31
27
  // src/queue.ts
32
28
  var initQueue = () => {
33
- if (window.va) return;
29
+ if (window.va)
30
+ return;
34
31
  window.va = function a(...params) {
35
32
  (window.vaq = window.vaq || []).push(params);
36
33
  };
37
34
  };
38
35
 
39
36
  // src/generic.ts
40
- var isBrowser = typeof window !== 'undefined';
41
- var inject = ({ beforeSend } = {}) => {
37
+ var isBrowser = typeof window !== "undefined";
38
+ var inject = ({
39
+ beforeSend
40
+ } = {}) => {
42
41
  var _a;
43
- if (!isBrowser) return;
42
+ if (!isBrowser)
43
+ return;
44
44
  initQueue();
45
45
  if (beforeSend) {
46
- (_a = window.va) == null
47
- ? void 0
48
- : _a.call(window, 'beforeSend', beforeSend);
46
+ (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
49
47
  }
50
- if (document.head.querySelector('script[src="/va/script.js"]')) return;
51
- const script = document.createElement('script');
52
- script.src = '/va/script.js';
48
+ if (document.head.querySelector('script[src="/va/script.js"]'))
49
+ return;
50
+ const script = document.createElement("script");
51
+ script.src = "/va/script.js";
53
52
  script.async = true;
54
53
  document.head.appendChild(script);
55
54
  };
56
55
  // Annotate the CommonJS export names for ESM import in node:
57
- 0 &&
58
- (module.exports = {
59
- inject,
60
- });
61
- //# sourceMappingURL=index.cjs.map
56
+ 0 && (module.exports = {
57
+ inject
58
+ });
59
+ //# sourceMappingURL=index.cjs.map
package/dist/index.d.ts CHANGED
@@ -1,21 +1,19 @@
1
1
  interface PageViewEvent {
2
- type: 'pageview';
3
- url: string;
2
+ type: 'pageview';
3
+ url: string;
4
4
  }
5
5
  declare type IEvent = PageViewEvent;
6
6
  declare type BeforeSend = (event: IEvent) => IEvent | null;
7
7
  declare global {
8
- interface Window {
9
- va?: (event: string, properties?: unknown) => void;
10
- vaq?: [event: string, properties?: unknown][];
11
- vai?: boolean;
12
- }
8
+ interface Window {
9
+ va?: (event: string, properties?: unknown) => void;
10
+ vaq?: [event: string, properties?: unknown][];
11
+ vai?: boolean;
12
+ }
13
13
  }
14
14
 
15
- declare const inject: ({
16
- beforeSend,
17
- }?: {
18
- beforeSend?: BeforeSend | undefined;
15
+ declare const inject: ({ beforeSend, }?: {
16
+ beforeSend?: BeforeSend | undefined;
19
17
  }) => void;
20
18
 
21
19
  export { inject };
package/dist/index.js CHANGED
@@ -1,27 +1,32 @@
1
1
  // src/queue.ts
2
2
  var initQueue = () => {
3
- if (window.va) return;
3
+ if (window.va)
4
+ return;
4
5
  window.va = function a(...params) {
5
6
  (window.vaq = window.vaq || []).push(params);
6
7
  };
7
8
  };
8
9
 
9
10
  // src/generic.ts
10
- var isBrowser = typeof window !== 'undefined';
11
- var inject = ({ beforeSend } = {}) => {
11
+ var isBrowser = typeof window !== "undefined";
12
+ var inject = ({
13
+ beforeSend
14
+ } = {}) => {
12
15
  var _a;
13
- if (!isBrowser) return;
16
+ if (!isBrowser)
17
+ return;
14
18
  initQueue();
15
19
  if (beforeSend) {
16
- (_a = window.va) == null
17
- ? void 0
18
- : _a.call(window, 'beforeSend', beforeSend);
20
+ (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
19
21
  }
20
- if (document.head.querySelector('script[src="/va/script.js"]')) return;
21
- const script = document.createElement('script');
22
- script.src = '/va/script.js';
22
+ if (document.head.querySelector('script[src="/va/script.js"]'))
23
+ return;
24
+ const script = document.createElement("script");
25
+ script.src = "/va/script.js";
23
26
  script.async = true;
24
27
  document.head.appendChild(script);
25
28
  };
26
- export { inject };
27
- //# sourceMappingURL=index.js.map
29
+ export {
30
+ inject
31
+ };
32
+ //# sourceMappingURL=index.js.map
@@ -1,68 +1,72 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
8
10
  __defProp(target, name, { get: all[name], enumerable: true });
9
11
  };
10
12
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === 'object') || typeof from === 'function') {
13
+ if (from && typeof from === "object" || typeof from === "function") {
12
14
  for (let key of __getOwnPropNames(from))
13
15
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
17
  }
19
18
  return to;
20
19
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, '__esModule', { value: true }), mod);
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
25
 
24
26
  // src/react.tsx
25
27
  var react_exports = {};
26
28
  __export(react_exports, {
27
- Analytics: () => Analytics,
29
+ Analytics: () => Analytics
28
30
  });
29
31
  module.exports = __toCommonJS(react_exports);
30
- var import_react = require('react');
32
+ var import_react = __toESM(require("react"), 1);
31
33
 
32
34
  // src/queue.ts
33
35
  var initQueue = () => {
34
- if (window.va) return;
36
+ if (window.va)
37
+ return;
35
38
  window.va = function a(...params) {
36
39
  (window.vaq = window.vaq || []).push(params);
37
40
  };
38
41
  };
39
42
 
40
43
  // src/generic.ts
41
- var isBrowser = typeof window !== 'undefined';
42
- var inject = ({ beforeSend } = {}) => {
44
+ var isBrowser = typeof window !== "undefined";
45
+ var inject = ({
46
+ beforeSend
47
+ } = {}) => {
43
48
  var _a;
44
- if (!isBrowser) return;
49
+ if (!isBrowser)
50
+ return;
45
51
  initQueue();
46
52
  if (beforeSend) {
47
- (_a = window.va) == null
48
- ? void 0
49
- : _a.call(window, 'beforeSend', beforeSend);
53
+ (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
50
54
  }
51
- if (document.head.querySelector('script[src="/va/script.js"]')) return;
52
- const script = document.createElement('script');
53
- script.src = '/va/script.js';
55
+ if (document.head.querySelector('script[src="/va/script.js"]'))
56
+ return;
57
+ const script = document.createElement("script");
58
+ script.src = "/va/script.js";
54
59
  script.async = true;
55
60
  document.head.appendChild(script);
56
61
  };
57
62
 
58
63
  // src/react.tsx
59
- var import_jsx_runtime = require('react/jsx-runtime');
60
64
  function Analytics(props) {
61
- if (process.env.NODE_ENV !== 'production') {
62
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NoopAnalytics, {});
65
+ if (process.env.NODE_ENV !== "production") {
66
+ return /* @__PURE__ */ import_react.default.createElement(NoopAnalytics, null);
63
67
  }
64
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EnabledAnalytics, {
65
- ...props,
68
+ return /* @__PURE__ */ import_react.default.createElement(EnabledAnalytics, {
69
+ ...props
66
70
  });
67
71
  }
68
72
  function EnabledAnalytics({ beforeSend }) {
@@ -74,14 +78,13 @@ function EnabledAnalytics({ beforeSend }) {
74
78
  function NoopAnalytics() {
75
79
  (0, import_react.useEffect)(() => {
76
80
  console.warn(
77
- 'Vercel Analytics is set up, but detected a non-production environment.\n\nPlease note that no analytics events will be sent.',
81
+ "Vercel Analytics is set up, but detected a non-production environment.\n\nPlease note that no analytics events will be sent."
78
82
  );
79
83
  }, []);
80
84
  return null;
81
85
  }
82
86
  // Annotate the CommonJS export names for ESM import in node:
83
- 0 &&
84
- (module.exports = {
85
- Analytics,
86
- });
87
- //# sourceMappingURL=index.cjs.map
87
+ 0 && (module.exports = {
88
+ Analytics
89
+ });
90
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { BeforeSend } from './types';\n\ninterface AnalyticsProps {\n beforeSend?: BeforeSend;\n}\n\nexport function Analytics(props: AnalyticsProps): JSX.Element {\n if (process.env.NODE_ENV !== 'production') {\n return <NoopAnalytics />;\n }\n\n return <EnabledAnalytics {...props} />;\n}\n\nfunction EnabledAnalytics({ beforeSend }: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend });\n }, [beforeSend]);\n\n return null;\n}\n\nfunction NoopAnalytics(): null {\n useEffect(() => {\n // eslint-disable-next-line no-console\n console.warn(\n 'Vercel Analytics is set up, but detected a non-production environment.\\n\\nPlease note that no analytics events will be sent.',\n );\n }, []);\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","import { initQueue } from './queue';\nimport type { BeforeSend } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nexport const inject = ({\n beforeSend,\n}: { beforeSend?: BeforeSend } = {}): void => {\n if (!isBrowser) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n\n if (document.head.querySelector('script[src=\"/va/script.js\"]')) return;\n\n const script = document.createElement('script');\n script.src = '/va/script.js';\n script.async = true;\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;;;ACJA,IAAM,YAAY,OAAO,WAAW;AAE7B,IAAM,SAAS,CAAC;AAAA,EACrB;AACF,IAAiC,CAAC,MAAY;AAP9C;AAQE,MAAI,CAAC;AAAW;AAChB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AAEA,MAAI,SAAS,KAAK,cAAc,6BAA6B;AAAG;AAEhE,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,WAAS,KAAK,YAAY,MAAM;AAClC;;;AFZW;AAFJ,SAAS,UAAU,OAAoC;AAC5D,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAO,4CAAC,iBAAc;AAAA,EACxB;AAEA,SAAO,4CAAC;AAAA,IAAkB,GAAG;AAAA,GAAO;AACtC;AAEA,SAAS,iBAAiB,EAAE,WAAW,GAAyB;AAC9D,8BAAU,MAAM;AACd,WAAO,EAAE,WAAW,CAAC;AAAA,EACvB,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO;AACT;AAEA,SAAS,gBAAsB;AAC7B,8BAAU,MAAM;AAEd,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/generic.ts"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { BeforeSend } from './types';\n\ninterface AnalyticsProps {\n beforeSend?: BeforeSend;\n}\n\nexport function Analytics(props: AnalyticsProps): JSX.Element {\n if (process.env.NODE_ENV !== 'production') {\n return <NoopAnalytics />;\n }\n\n return <EnabledAnalytics {...props} />;\n}\n\nfunction EnabledAnalytics({ beforeSend }: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend });\n }, [beforeSend]);\n\n return null;\n}\n\nfunction NoopAnalytics(): null {\n useEffect(() => {\n // eslint-disable-next-line no-console\n console.warn(\n 'Vercel Analytics is set up, but detected a non-production environment.\\n\\nPlease note that no analytics events will be sent.',\n );\n }, []);\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","import { initQueue } from './queue';\nimport type { BeforeSend } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nexport const inject = ({\n beforeSend,\n}: { beforeSend?: BeforeSend } = {}): void => {\n if (!isBrowser) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n\n if (document.head.querySelector('script[src=\"/va/script.js\"]')) return;\n\n const script = document.createElement('script');\n script.src = '/va/script.js';\n script.async = true;\n\n document.head.appendChild(script);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;;;ACA1B,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;;;ACJA,IAAM,YAAY,OAAO,WAAW;AAE7B,IAAM,SAAS,CAAC;AAAA,EACrB;AACF,IAAiC,CAAC,MAAY;AAP9C;AAQE,MAAI,CAAC;AAAW;AAChB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AAEA,MAAI,SAAS,KAAK,cAAc,6BAA6B;AAAG;AAEhE,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,WAAS,KAAK,YAAY,MAAM;AAClC;;;AFdO,SAAS,UAAU,OAAoC;AAC5D,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAO,6BAAAA,QAAA,cAAC,mBAAc;AAAA,EACxB;AAEA,SAAO,6BAAAA,QAAA,cAAC;AAAA,IAAkB,GAAG;AAAA,GAAO;AACtC;AAEA,SAAS,iBAAiB,EAAE,WAAW,GAAyB;AAC9D,8BAAU,MAAM;AACd,WAAO,EAAE,WAAW,CAAC;AAAA,EACvB,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO;AACT;AAEA,SAAS,gBAAsB;AAC7B,8BAAU,MAAM;AAEd,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":["React"]}
@@ -1,19 +1,19 @@
1
1
  interface PageViewEvent {
2
- type: 'pageview';
3
- url: string;
2
+ type: 'pageview';
3
+ url: string;
4
4
  }
5
5
  declare type IEvent = PageViewEvent;
6
6
  declare type BeforeSend = (event: IEvent) => IEvent | null;
7
7
  declare global {
8
- interface Window {
9
- va?: (event: string, properties?: unknown) => void;
10
- vaq?: [event: string, properties?: unknown][];
11
- vai?: boolean;
12
- }
8
+ interface Window {
9
+ va?: (event: string, properties?: unknown) => void;
10
+ vaq?: [event: string, properties?: unknown][];
11
+ vai?: boolean;
12
+ }
13
13
  }
14
14
 
15
15
  interface AnalyticsProps {
16
- beforeSend?: BeforeSend;
16
+ beforeSend?: BeforeSend;
17
17
  }
18
18
  declare function Analytics(props: AnalyticsProps): JSX.Element;
19
19
 
@@ -1,40 +1,42 @@
1
1
  // src/react.tsx
2
- import { useEffect } from 'react';
2
+ import React, { useEffect } from "react";
3
3
 
4
4
  // src/queue.ts
5
5
  var initQueue = () => {
6
- if (window.va) return;
6
+ if (window.va)
7
+ return;
7
8
  window.va = function a(...params) {
8
9
  (window.vaq = window.vaq || []).push(params);
9
10
  };
10
11
  };
11
12
 
12
13
  // src/generic.ts
13
- var isBrowser = typeof window !== 'undefined';
14
- var inject = ({ beforeSend } = {}) => {
14
+ var isBrowser = typeof window !== "undefined";
15
+ var inject = ({
16
+ beforeSend
17
+ } = {}) => {
15
18
  var _a;
16
- if (!isBrowser) return;
19
+ if (!isBrowser)
20
+ return;
17
21
  initQueue();
18
22
  if (beforeSend) {
19
- (_a = window.va) == null
20
- ? void 0
21
- : _a.call(window, 'beforeSend', beforeSend);
23
+ (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", beforeSend);
22
24
  }
23
- if (document.head.querySelector('script[src="/va/script.js"]')) return;
24
- const script = document.createElement('script');
25
- script.src = '/va/script.js';
25
+ if (document.head.querySelector('script[src="/va/script.js"]'))
26
+ return;
27
+ const script = document.createElement("script");
28
+ script.src = "/va/script.js";
26
29
  script.async = true;
27
30
  document.head.appendChild(script);
28
31
  };
29
32
 
30
33
  // src/react.tsx
31
- import { jsx } from 'react/jsx-runtime';
32
34
  function Analytics(props) {
33
- if (process.env.NODE_ENV !== 'production') {
34
- return /* @__PURE__ */ jsx(NoopAnalytics, {});
35
+ if (process.env.NODE_ENV !== "production") {
36
+ return /* @__PURE__ */ React.createElement(NoopAnalytics, null);
35
37
  }
36
- return /* @__PURE__ */ jsx(EnabledAnalytics, {
37
- ...props,
38
+ return /* @__PURE__ */ React.createElement(EnabledAnalytics, {
39
+ ...props
38
40
  });
39
41
  }
40
42
  function EnabledAnalytics({ beforeSend }) {
@@ -46,10 +48,12 @@ function EnabledAnalytics({ beforeSend }) {
46
48
  function NoopAnalytics() {
47
49
  useEffect(() => {
48
50
  console.warn(
49
- 'Vercel Analytics is set up, but detected a non-production environment.\n\nPlease note that no analytics events will be sent.',
51
+ "Vercel Analytics is set up, but detected a non-production environment.\n\nPlease note that no analytics events will be sent."
50
52
  );
51
53
  }, []);
52
54
  return null;
53
55
  }
54
- export { Analytics };
55
- //# sourceMappingURL=index.js.map
56
+ export {
57
+ Analytics
58
+ };
59
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { BeforeSend } from './types';\n\ninterface AnalyticsProps {\n beforeSend?: BeforeSend;\n}\n\nexport function Analytics(props: AnalyticsProps): JSX.Element {\n if (process.env.NODE_ENV !== 'production') {\n return <NoopAnalytics />;\n }\n\n return <EnabledAnalytics {...props} />;\n}\n\nfunction EnabledAnalytics({ beforeSend }: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend });\n }, [beforeSend]);\n\n return null;\n}\n\nfunction NoopAnalytics(): null {\n useEffect(() => {\n // eslint-disable-next-line no-console\n console.warn(\n 'Vercel Analytics is set up, but detected a non-production environment.\\n\\nPlease note that no analytics events will be sent.',\n );\n }, []);\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","import { initQueue } from './queue';\nimport type { BeforeSend } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nexport const inject = ({\n beforeSend,\n}: { beforeSend?: BeforeSend } = {}): void => {\n if (!isBrowser) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n\n if (document.head.querySelector('script[src=\"/va/script.js\"]')) return;\n\n const script = document.createElement('script');\n script.src = '/va/script.js';\n script.async = true;\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;;;ACJA,IAAM,YAAY,OAAO,WAAW;AAE7B,IAAM,SAAS,CAAC;AAAA,EACrB;AACF,IAAiC,CAAC,MAAY;AAP9C;AAQE,MAAI,CAAC;AAAW;AAChB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AAEA,MAAI,SAAS,KAAK,cAAc,6BAA6B;AAAG;AAEhE,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,WAAS,KAAK,YAAY,MAAM;AAClC;;;AFZW;AAFJ,SAAS,UAAU,OAAoC;AAC5D,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAO,oBAAC,iBAAc;AAAA,EACxB;AAEA,SAAO,oBAAC;AAAA,IAAkB,GAAG;AAAA,GAAO;AACtC;AAEA,SAAS,iBAAiB,EAAE,WAAW,GAAyB;AAC9D,YAAU,MAAM;AACd,WAAO,EAAE,WAAW,CAAC;AAAA,EACvB,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO;AACT;AAEA,SAAS,gBAAsB;AAC7B,YAAU,MAAM;AAEd,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/react.tsx","../../src/queue.ts","../../src/generic.ts"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { BeforeSend } from './types';\n\ninterface AnalyticsProps {\n beforeSend?: BeforeSend;\n}\n\nexport function Analytics(props: AnalyticsProps): JSX.Element {\n if (process.env.NODE_ENV !== 'production') {\n return <NoopAnalytics />;\n }\n\n return <EnabledAnalytics {...props} />;\n}\n\nfunction EnabledAnalytics({ beforeSend }: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend });\n }, [beforeSend]);\n\n return null;\n}\n\nfunction NoopAnalytics(): null {\n useEffect(() => {\n // eslint-disable-next-line no-console\n console.warn(\n 'Vercel Analytics is set up, but detected a non-production environment.\\n\\nPlease note that no analytics events will be sent.',\n );\n }, []);\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","import { initQueue } from './queue';\nimport type { BeforeSend } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nexport const inject = ({\n beforeSend,\n}: { beforeSend?: BeforeSend } = {}): void => {\n if (!isBrowser) return;\n initQueue();\n\n if (beforeSend) {\n window.va?.('beforeSend', beforeSend);\n }\n\n if (document.head.querySelector('script[src=\"/va/script.js\"]')) return;\n\n const script = document.createElement('script');\n script.src = '/va/script.js';\n script.async = true;\n\n document.head.appendChild(script);\n};\n"],"mappings":";AAAA,OAAO,SAAS,iBAAiB;;;ACA1B,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;;;ACJA,IAAM,YAAY,OAAO,WAAW;AAE7B,IAAM,SAAS,CAAC;AAAA,EACrB;AACF,IAAiC,CAAC,MAAY;AAP9C;AAQE,MAAI,CAAC;AAAW;AAChB,YAAU;AAEV,MAAI,YAAY;AACd,iBAAO,OAAP,gCAAY,cAAc;AAAA,EAC5B;AAEA,MAAI,SAAS,KAAK,cAAc,6BAA6B;AAAG;AAEhE,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,WAAS,KAAK,YAAY,MAAM;AAClC;;;AFdO,SAAS,UAAU,OAAoC;AAC5D,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAO,oCAAC,mBAAc;AAAA,EACxB;AAEA,SAAO,oCAAC;AAAA,IAAkB,GAAG;AAAA,GAAO;AACtC;AAEA,SAAS,iBAAiB,EAAE,WAAW,GAAyB;AAC9D,YAAU,MAAM;AACd,WAAO,EAAE,WAAW,CAAC;AAAA,EACvB,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO;AACT;AAEA,SAAS,gBAAsB;AAC7B,YAAU,MAAM;AAEd,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/analytics",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "keywords": [
5
5
  "analytics",
6
6
  "vercel"