@vercel/analytics 0.1.9 → 0.1.11

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
@@ -4,8 +4,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
7
+ for (var name2 in all)
8
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") {
@@ -24,6 +24,10 @@ __export(generic_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(generic_exports);
26
26
 
27
+ // package.json
28
+ var name = "@vercel/analytics";
29
+ var version = "0.1.11";
30
+
27
31
  // src/queue.ts
28
32
  var initQueue = () => {
29
33
  if (window.va)
@@ -38,9 +42,12 @@ function isBrowser() {
38
42
  return typeof window !== "undefined";
39
43
  }
40
44
  function isDevelopment() {
41
- if (typeof process === "undefined")
45
+ try {
46
+ const env = process.env.NODE_ENV;
47
+ return env === "development" || env === "test";
48
+ } catch (e) {
42
49
  return false;
43
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
50
+ }
44
51
  }
45
52
  function getMode(mode = "auto") {
46
53
  if (mode === "auto") {
@@ -67,6 +74,8 @@ var inject = (props = {
67
74
  const script = document.createElement("script");
68
75
  script.src = src;
69
76
  script.defer = true;
77
+ script.setAttribute("data-sdkn", name);
78
+ script.setAttribute("data-sdkv", version);
70
79
  if (mode === "development" && props.debug === false) {
71
80
  script.setAttribute("data-debug", "false");
72
81
  }
@@ -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, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 (mode === 'development' && props.debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n};\n","export const initQueue = (): void => {\n // initialize 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 type { Mode } from './types';\n\nexport 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\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\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;;;ACLO,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;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;AFfO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AARX;AASE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
1
+ {"version":3,"sources":["../src/generic.ts","../src/queue.ts","../src/utils.ts"],"sourcesContent":["import { name, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (mode === 'development' && props.debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n};\n","export const initQueue = (): void => {\n // initialize 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 type { Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n try {\n const env = process.env.NODE_ENV;\n return env === 'development' || env === 'test';\n } catch (e) {\n return false;\n }\n}\n\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\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;;;ACLO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,WAAO,QAAQ,iBAAiB,QAAQ;AAAA,EAC1C,SAAS,GAAP;AACA,WAAO;AAAA,EACT;AACF;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;AFhBO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AATX;AAUE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,SAAO,aAAa,aAAa,IAAI;AACrC,SAAO,aAAa,aAAa,OAAO;AAExC,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ // package.json
2
+ var name = "@vercel/analytics";
3
+ var version = "0.1.11";
4
+
1
5
  // src/queue.ts
2
6
  var initQueue = () => {
3
7
  if (window.va)
@@ -12,9 +16,12 @@ function isBrowser() {
12
16
  return typeof window !== "undefined";
13
17
  }
14
18
  function isDevelopment() {
15
- if (typeof process === "undefined")
19
+ try {
20
+ const env = process.env.NODE_ENV;
21
+ return env === "development" || env === "test";
22
+ } catch (e) {
16
23
  return false;
17
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
24
+ }
18
25
  }
19
26
  function getMode(mode = "auto") {
20
27
  if (mode === "auto") {
@@ -41,6 +48,8 @@ var inject = (props = {
41
48
  const script = document.createElement("script");
42
49
  script.src = src;
43
50
  script.defer = true;
51
+ script.setAttribute("data-sdkn", name);
52
+ script.setAttribute("data-sdkv", version);
44
53
  if (mode === "development" && props.debug === false) {
45
54
  script.setAttribute("data-debug", "false");
46
55
  }
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 // initialize 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 type { Mode } from './types';\n\nexport 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\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\n}\n","import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 (mode === 'development' && props.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;;;ACLO,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;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;ACfO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AARX;AASE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
1
+ {"version":3,"sources":["../src/queue.ts","../src/utils.ts","../src/generic.ts"],"sourcesContent":["export const initQueue = (): void => {\n // initialize 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 type { Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n try {\n const env = process.env.NODE_ENV;\n return env === 'development' || env === 'test';\n } catch (e) {\n return false;\n }\n}\n\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\n}\n","import { name, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (mode === 'development' && props.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;;;ACLO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,WAAO,QAAQ,iBAAiB,QAAQ;AAAA,EAC1C,SAAS,GAAP;AACA,WAAO;AAAA,EACT;AACF;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;AChBO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AATX;AAUE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,SAAO,aAAa,aAAa,IAAI;AACrC,SAAO,aAAa,aAAa,OAAO;AAExC,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
@@ -5,8 +5,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
8
+ for (var name2 in all)
9
+ __defProp(target, name2, { get: all[name2], enumerable: true });
10
10
  };
11
11
  var __copyProps = (to, from, except, desc) => {
12
12
  if (from && typeof from === "object" || typeof from === "function") {
@@ -26,6 +26,10 @@ __export(react_exports, {
26
26
  module.exports = __toCommonJS(react_exports);
27
27
  var import_react = require("react");
28
28
 
29
+ // package.json
30
+ var name = "@vercel/analytics";
31
+ var version = "0.1.11";
32
+
29
33
  // src/queue.ts
30
34
  var initQueue = () => {
31
35
  if (window.va)
@@ -40,9 +44,12 @@ function isBrowser() {
40
44
  return typeof window !== "undefined";
41
45
  }
42
46
  function isDevelopment() {
43
- if (typeof process === "undefined")
47
+ try {
48
+ const env = process.env.NODE_ENV;
49
+ return env === "development" || env === "test";
50
+ } catch (e) {
44
51
  return false;
45
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
52
+ }
46
53
  }
47
54
  function getMode(mode = "auto") {
48
55
  if (mode === "auto") {
@@ -69,6 +76,8 @@ var inject = (props = {
69
76
  const script = document.createElement("script");
70
77
  script.src = src;
71
78
  script.defer = true;
79
+ script.setAttribute("data-sdkn", name);
80
+ script.setAttribute("data-sdkv", version);
72
81
  if (mode === "development" && props.debug === false) {
73
82
  script.setAttribute("data-debug", "false");
74
83
  }
@@ -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';\n\nexport type { AnalyticsProps } from './types';\n\nexport function Analytics({\n beforeSend,\n debug = true,\n mode = 'auto',\n}: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend, debug, mode });\n }, [beforeSend, debug, mode]);\n\n return null;\n}\n","export const initQueue = (): void => {\n // initialize 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 type { Mode } from './types';\n\nexport 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\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\n}\n","import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 (mode === 'development' && props.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;;;ACLO,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;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;ACfO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AARX;AASE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AH7BO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,QAAQ;AAAA,EACR,OAAO;AACT,GAAyB;AACvB,8BAAU,MAAM;AACd,WAAO,EAAE,YAAY,OAAO,KAAK,CAAC;AAAA,EACpC,GAAG,CAAC,YAAY,OAAO,IAAI,CAAC;AAE5B,SAAO;AACT;","names":[]}
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';\n\nexport type { AnalyticsProps } from './types';\n\nexport function Analytics({\n beforeSend,\n debug = true,\n mode = 'auto',\n}: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend, debug, mode });\n }, [beforeSend, debug, mode]);\n\n return null;\n}\n","export const initQueue = (): void => {\n // initialize 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 type { Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n try {\n const env = process.env.NODE_ENV;\n return env === 'development' || env === 'test';\n } catch (e) {\n return false;\n }\n}\n\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\n}\n","import { name, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (mode === 'development' && props.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;;;ACLO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,WAAO,QAAQ,iBAAiB,QAAQ;AAAA,EAC1C,SAAS,GAAP;AACA,WAAO;AAAA,EACT;AACF;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;AChBO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AATX;AAUE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,SAAO,aAAa,aAAa,IAAI;AACrC,SAAO,aAAa,aAAa,OAAO;AAExC,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AHhCO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,QAAQ;AAAA,EACR,OAAO;AACT,GAAyB;AACvB,8BAAU,MAAM;AACd,WAAO,EAAE,YAAY,OAAO,KAAK,CAAC;AAAA,EACpC,GAAG,CAAC,YAAY,OAAO,IAAI,CAAC;AAE5B,SAAO;AACT;","names":[]}
@@ -3,6 +3,10 @@
3
3
  // src/react.tsx
4
4
  import { useEffect } from "react";
5
5
 
6
+ // package.json
7
+ var name = "@vercel/analytics";
8
+ var version = "0.1.11";
9
+
6
10
  // src/queue.ts
7
11
  var initQueue = () => {
8
12
  if (window.va)
@@ -17,9 +21,12 @@ function isBrowser() {
17
21
  return typeof window !== "undefined";
18
22
  }
19
23
  function isDevelopment() {
20
- if (typeof process === "undefined")
24
+ try {
25
+ const env = process.env.NODE_ENV;
26
+ return env === "development" || env === "test";
27
+ } catch (e) {
21
28
  return false;
22
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
29
+ }
23
30
  }
24
31
  function getMode(mode = "auto") {
25
32
  if (mode === "auto") {
@@ -46,6 +53,8 @@ var inject = (props = {
46
53
  const script = document.createElement("script");
47
54
  script.src = src;
48
55
  script.defer = true;
56
+ script.setAttribute("data-sdkn", name);
57
+ script.setAttribute("data-sdkv", version);
49
58
  if (mode === "development" && props.debug === false) {
50
59
  script.setAttribute("data-debug", "false");
51
60
  }
@@ -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';\n\nexport type { AnalyticsProps } from './types';\n\nexport function Analytics({\n beforeSend,\n debug = true,\n mode = 'auto',\n}: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend, debug, mode });\n }, [beforeSend, debug, mode]);\n\n return null;\n}\n","export const initQueue = (): void => {\n // initialize 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 type { Mode } from './types';\n\nexport 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\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\n}\n","import { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 (mode === 'development' && props.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;;;ACLO,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;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;ACfO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AARX;AASE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AAEf,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AH7BO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,QAAQ;AAAA,EACR,OAAO;AACT,GAAyB;AACvB,YAAU,MAAM;AACd,WAAO,EAAE,YAAY,OAAO,KAAK,CAAC;AAAA,EACpC,GAAG,CAAC,YAAY,OAAO,IAAI,CAAC;AAE5B,SAAO;AACT;","names":[]}
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';\n\nexport type { AnalyticsProps } from './types';\n\nexport function Analytics({\n beforeSend,\n debug = true,\n mode = 'auto',\n}: AnalyticsProps): null {\n useEffect(() => {\n inject({ beforeSend, debug, mode });\n }, [beforeSend, debug, mode]);\n\n return null;\n}\n","export const initQueue = (): void => {\n // initialize 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 type { Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nexport function isDevelopment(): boolean {\n try {\n const env = process.env.NODE_ENV;\n return env === 'development' || env === 'test';\n } catch (e) {\n return false;\n }\n}\n\nexport function getMode(mode: Mode = 'auto'): Mode {\n if (mode === 'auto') {\n return isDevelopment() ? 'development' : 'production';\n }\n\n return mode;\n}\n","import { name, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser, getMode } from './utils';\n\nexport const inject = (\n props: AnalyticsProps = {\n debug: true,\n },\n): void => {\n if (!isBrowser()) return;\n\n const mode = getMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src =\n mode === 'development'\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 script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (mode === 'development' && props.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;;;ACLO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEO,SAAS,gBAAyB;AACvC,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,WAAO,QAAQ,iBAAiB,QAAQ;AAAA,EAC1C,SAAS,GAAP;AACA,WAAO;AAAA,EACT;AACF;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,cAAc,IAAI,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;AChBO,IAAM,SAAS,CACpB,QAAwB;AAAA,EACtB,OAAO;AACT,MACS;AATX;AAUE,MAAI,CAAC,UAAU;AAAG;AAElB,QAAM,OAAO,QAAQ,MAAM,IAAI;AAE/B,YAAU;AAEV,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,MACJ,SAAS,gBACL,uDACA;AAEN,MAAI,SAAS,KAAK,cAAc,gBAAgB,OAAO;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,SAAO,aAAa,aAAa,IAAI;AACrC,SAAO,aAAa,aAAa,OAAO;AAExC,MAAI,SAAS,iBAAiB,MAAM,UAAU,OAAO;AACnD,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AHhCO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,QAAQ;AAAA,EACR,OAAO;AACT,GAAyB;AACvB,YAAU,MAAM;AACd,WAAO,EAAE,YAAY,OAAO,KAAK,CAAC;AAAA,EACpC,GAAG,CAAC,YAAY,OAAO,IAAI,CAAC;AAE5B,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/analytics",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "keywords": [
5
5
  "analytics",
6
6
  "vercel"
@@ -10,14 +10,14 @@
10
10
  "exports": {
11
11
  "./package.json": "./package.json",
12
12
  ".": {
13
- "require": "./dist/index.cjs",
13
+ "browser": "./dist/index.js",
14
14
  "import": "./dist/index.js",
15
- "browser": "./dist/index.js"
15
+ "require": "./dist/index.cjs"
16
16
  },
17
17
  "./react": {
18
- "require": "./dist/react/index.cjs",
18
+ "browser": "./dist/react/index.js",
19
19
  "import": "./dist/react/index.js",
20
- "browser": "./dist/react/index.js"
20
+ "require": "./dist/react/index.cjs"
21
21
  }
22
22
  },
23
23
  "main": "dist/index.js",