@vercel/analytics 0.1.10 → 1.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Analytics](https://github.com/vercel/analytics/blob/main/.github/banner.png)
2
2
 
3
- <div align="center"><strong>Vercel Analytics for Audiences</strong></div>
3
+ <div align="center"><strong>Vercel Web Analytics</strong></div>
4
4
  <div align="center">Privacy-friendly, real-time traffic insights</div>
5
5
  <br />
6
6
  <div align="center">
@@ -21,13 +21,13 @@ This package does **not** track data in development mode.
21
21
 
22
22
  ## Quickstart
23
23
 
24
- 1. Enable Vercel Analytics for a project in the [Vercel Dashboard](https://vercel.com/dashboard).
24
+ 1. Enable Vercel Web Analytics for a project in the [Vercel Dashboard](https://vercel.com/dashboard).
25
25
  2. Add the `@vercel/analytics` package to your project
26
26
  3. Inject the Analytics script to your app
27
27
 
28
28
  - If you are using **Next.js** or **React**, you can use the `<Analytics />` component to inject the script into your app.
29
29
  - For other frameworks, you can use the `inject` function add the tracking script to your app.
30
- - If you want to use Vercel Analytics on a static site without npm, follow the instructions in the [documentation](https://vercel.com/docs/concepts/analytics/audiences/quickstart).
30
+ - If you want to use Vercel Web Analytics on a static site without npm, follow the instructions in the [documentation](https://vercel.com/docs/concepts/analytics/audiences/quickstart).
31
31
 
32
32
  4. Deploy your app to Vercel and see data flowing in.
33
33
 
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") {
@@ -20,10 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/generic.ts
21
21
  var generic_exports = {};
22
22
  __export(generic_exports, {
23
- inject: () => inject
23
+ default: () => generic_default,
24
+ inject: () => inject,
25
+ track: () => track
24
26
  });
25
27
  module.exports = __toCommonJS(generic_exports);
26
28
 
29
+ // package.json
30
+ var name = "@vercel/analytics";
31
+ var version = "1.0.0";
32
+
27
33
  // src/queue.ts
28
34
  var initQueue = () => {
29
35
  if (window.va)
@@ -37,43 +43,115 @@ var initQueue = () => {
37
43
  function isBrowser() {
38
44
  return typeof window !== "undefined";
39
45
  }
40
- function isDevelopment() {
41
- if (typeof process === "undefined")
42
- return false;
43
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
46
+ function detectEnvironment() {
47
+ try {
48
+ const env = process.env.NODE_ENV;
49
+ if (env === "development" || env === "test") {
50
+ return "development";
51
+ }
52
+ } catch (e) {
53
+ }
54
+ return "production";
44
55
  }
45
- function getMode(mode = "auto") {
56
+ function setMode(mode = "auto") {
46
57
  if (mode === "auto") {
47
- return isDevelopment() ? "development" : "production";
58
+ window.vam = detectEnvironment();
59
+ return;
48
60
  }
49
- return mode;
61
+ window.vam = mode;
62
+ }
63
+ function getMode() {
64
+ return window.vam || "production";
65
+ }
66
+ function isProduction() {
67
+ return getMode() === "production";
68
+ }
69
+ function isDevelopment() {
70
+ return getMode() === "development";
71
+ }
72
+ function removeKey(key, { [key]: _, ...rest }) {
73
+ return rest;
74
+ }
75
+ function parseProperties(properties, options) {
76
+ let props = properties;
77
+ const errorProperties = [];
78
+ for (const [key, value] of Object.entries(properties)) {
79
+ if (typeof value === "object" && value !== null) {
80
+ if (options.strip) {
81
+ props = removeKey(key, props);
82
+ } else {
83
+ errorProperties.push(key);
84
+ }
85
+ }
86
+ }
87
+ if (errorProperties.length > 0 && !options.strip) {
88
+ throw Error(
89
+ `The following properties are not valid: ${errorProperties.join(
90
+ ", "
91
+ )}. Only strings, numbers, booleans, and null are allowed.`
92
+ );
93
+ }
94
+ return props;
50
95
  }
51
96
 
52
97
  // src/generic.ts
53
- var inject = (props = {
98
+ function inject(props = {
54
99
  debug: true
55
- }) => {
100
+ }) {
56
101
  var _a;
57
102
  if (!isBrowser())
58
103
  return;
59
- const mode = getMode(props.mode);
104
+ setMode(props.mode);
60
105
  initQueue();
61
106
  if (props.beforeSend) {
62
107
  (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend);
63
108
  }
64
- const src = mode === "development" ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
109
+ const src = isDevelopment() ? "https://va.vercel-scripts.com/v1/script.debug.js" : "/_vercel/insights/script.js";
65
110
  if (document.head.querySelector(`script[src*="${src}"]`))
66
111
  return;
67
112
  const script = document.createElement("script");
68
113
  script.src = src;
69
114
  script.defer = true;
70
- if (mode === "development" && props.debug === false) {
115
+ script.setAttribute("data-sdkn", name);
116
+ script.setAttribute("data-sdkv", version);
117
+ if (isDevelopment() && props.debug === false) {
71
118
  script.setAttribute("data-debug", "false");
72
119
  }
73
120
  document.head.appendChild(script);
121
+ }
122
+ function track(name2, properties) {
123
+ var _a, _b;
124
+ if (!isBrowser()) {
125
+ console.warn(
126
+ "[Vercel Web Analytics] Server-side execution of `track()` is currently not supported."
127
+ );
128
+ return;
129
+ }
130
+ if (!properties) {
131
+ (_a = window.va) == null ? void 0 : _a.call(window, "event", { name: name2 });
132
+ return;
133
+ }
134
+ try {
135
+ const props = parseProperties(properties, {
136
+ strip: isProduction()
137
+ });
138
+ (_b = window.va) == null ? void 0 : _b.call(window, "event", {
139
+ name: name2,
140
+ data: props
141
+ });
142
+ } catch (err) {
143
+ if (err instanceof Error && isDevelopment()) {
144
+ console.error(err);
145
+ }
146
+ }
147
+ }
148
+ var generic_default = {
149
+ inject,
150
+ track
74
151
  };
75
152
  // Annotate the CommonJS export names for ESM import in node:
76
153
  0 && (module.exports = {
77
- inject
154
+ inject,
155
+ track
78
156
  });
79
157
  //# sourceMappingURL=index.cjs.map
@@ -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 as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AllowedPropertyValues, AnalyticsProps } from './types';\nimport {\n isBrowser,\n parseProperties,\n setMode,\n isDevelopment,\n isProduction,\n} from './utils';\n\nexport function inject(\n props: AnalyticsProps = {\n debug: true,\n },\n): void {\n if (!isBrowser()) return;\n\n setMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src = isDevelopment()\n ? 'https://va.vercel-scripts.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', packageName);\n script.setAttribute('data-sdkv', version);\n\n if (isDevelopment() && props.debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n}\n\nexport function track(\n name: string,\n properties?: Record<string, AllowedPropertyValues>,\n): void {\n if (!isBrowser()) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Vercel Web Analytics] Server-side execution of `track()` is currently not supported.',\n );\n return;\n }\n\n if (!properties) {\n window.va?.('event', { name });\n return;\n }\n\n try {\n const props = parseProperties(properties, {\n strip: isProduction(),\n });\n\n window.va?.('event', {\n name,\n data: props,\n });\n } catch (err) {\n if (err instanceof Error && isDevelopment()) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n }\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n inject,\n track,\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 { AllowedPropertyValues, Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function setMode(mode: Mode = 'auto'): void {\n if (mode === 'auto') {\n window.vam = detectEnvironment();\n return;\n }\n\n window.vam = mode;\n}\n\nexport function getMode(): Mode {\n return window.vam || 'production';\n}\n\nexport function isProduction(): boolean {\n return getMode() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return getMode() === 'development';\n}\n\nfunction removeKey(\n key: string,\n { [key]: _, ...rest },\n): Record<string, unknown> {\n return rest;\n}\n\nexport function parseProperties(\n properties: Record<string, unknown>,\n options: {\n strip?: boolean;\n },\n): Error | Record<string, AllowedPropertyValues> | undefined {\n let props = properties;\n const errorProperties: string[] = [];\n for (const [key, value] of Object.entries(properties)) {\n if (typeof value === 'object' && value !== null) {\n if (options.strip) {\n props = removeKey(key, props);\n } else {\n errorProperties.push(key);\n }\n }\n }\n\n if (errorProperties.length > 0 && !options.strip) {\n throw Error(\n `The following properties are not valid: ${errorProperties.join(\n ', ',\n )}. Only strings, numbers, booleans, and null are allowed.`,\n );\n }\n return props as Record<string, AllowedPropertyValues>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;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;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAP;AAAA,EAEF;AACA,SAAO;AACT;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,MAAM,kBAAkB;AAC/B;AAAA,EACF;AAEA,SAAO,MAAM;AACf;AAEO,SAAS,UAAgB;AAC9B,SAAO,OAAO,OAAO;AACvB;AAEO,SAAS,eAAwB;AACtC,SAAO,QAAQ,MAAM;AACvB;AAEO,SAAS,gBAAyB;AACvC,SAAO,QAAQ,MAAM;AACvB;AAEA,SAAS,UACP,KACA,GAAG,MAAM,MAAM,KAAK,GACK;AACzB,SAAO;AACT;AAEO,SAAS,gBACd,YACA,SAG2D;AAC3D,MAAI,QAAQ;AACZ,QAAM,kBAA4B,CAAC;AACnC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,UAAU,GAAG;AACrD,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,UAAI,QAAQ,OAAO;AACjB,gBAAQ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AG;AAE3C,cAAQ,MAAM,GAAG;AAAA,IACnB;AAAA,EACF;AACF;AAGA,IAAO,kBAAQ;AAAA,EACb;AAAA,EACA;AACF;","names":["name"]}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ interface PageViewEvent {
4
4
  }
5
5
  declare type Event = PageViewEvent;
6
6
  declare type Mode = 'auto' | 'development' | 'production';
7
+ declare type AllowedPropertyValues = string | number | boolean | null;
7
8
  declare type BeforeSend = (event: Event) => Event | null;
8
9
  interface AnalyticsProps {
9
10
  beforeSend?: BeforeSend;
@@ -12,12 +13,18 @@ interface AnalyticsProps {
12
13
  }
13
14
  declare global {
14
15
  interface Window {
15
- va?: (event: string, properties?: unknown) => void;
16
+ va?: (event: 'beforeSend' | 'event', properties?: unknown) => void;
16
17
  vaq?: [string, unknown?][];
17
18
  vai?: boolean;
19
+ vam?: Mode;
18
20
  }
19
21
  }
20
22
 
21
- declare const inject: (props?: AnalyticsProps) => void;
23
+ declare function inject(props?: AnalyticsProps): void;
24
+ declare function track(name: string, properties?: Record<string, AllowedPropertyValues>): void;
25
+ declare const _default: {
26
+ inject: typeof inject;
27
+ track: typeof track;
28
+ };
22
29
 
23
- export { inject };
30
+ export { _default as default, inject, track };
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ // package.json
2
+ var name = "@vercel/analytics";
3
+ var version = "1.0.0";
4
+
1
5
  // src/queue.ts
2
6
  var initQueue = () => {
3
7
  if (window.va)
@@ -11,42 +15,115 @@ var initQueue = () => {
11
15
  function isBrowser() {
12
16
  return typeof window !== "undefined";
13
17
  }
14
- function isDevelopment() {
15
- if (typeof process === "undefined")
16
- return false;
17
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
18
+ function detectEnvironment() {
19
+ try {
20
+ const env = process.env.NODE_ENV;
21
+ if (env === "development" || env === "test") {
22
+ return "development";
23
+ }
24
+ } catch (e) {
25
+ }
26
+ return "production";
18
27
  }
19
- function getMode(mode = "auto") {
28
+ function setMode(mode = "auto") {
20
29
  if (mode === "auto") {
21
- return isDevelopment() ? "development" : "production";
30
+ window.vam = detectEnvironment();
31
+ return;
22
32
  }
23
- return mode;
33
+ window.vam = mode;
34
+ }
35
+ function getMode() {
36
+ return window.vam || "production";
37
+ }
38
+ function isProduction() {
39
+ return getMode() === "production";
40
+ }
41
+ function isDevelopment() {
42
+ return getMode() === "development";
43
+ }
44
+ function removeKey(key, { [key]: _, ...rest }) {
45
+ return rest;
46
+ }
47
+ function parseProperties(properties, options) {
48
+ let props = properties;
49
+ const errorProperties = [];
50
+ for (const [key, value] of Object.entries(properties)) {
51
+ if (typeof value === "object" && value !== null) {
52
+ if (options.strip) {
53
+ props = removeKey(key, props);
54
+ } else {
55
+ errorProperties.push(key);
56
+ }
57
+ }
58
+ }
59
+ if (errorProperties.length > 0 && !options.strip) {
60
+ throw Error(
61
+ `The following properties are not valid: ${errorProperties.join(
62
+ ", "
63
+ )}. Only strings, numbers, booleans, and null are allowed.`
64
+ );
65
+ }
66
+ return props;
24
67
  }
25
68
 
26
69
  // src/generic.ts
27
- var inject = (props = {
70
+ function inject(props = {
28
71
  debug: true
29
- }) => {
72
+ }) {
30
73
  var _a;
31
74
  if (!isBrowser())
32
75
  return;
33
- const mode = getMode(props.mode);
76
+ setMode(props.mode);
34
77
  initQueue();
35
78
  if (props.beforeSend) {
36
79
  (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend);
37
80
  }
38
- const src = mode === "development" ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
81
+ const src = isDevelopment() ? "https://va.vercel-scripts.com/v1/script.debug.js" : "/_vercel/insights/script.js";
39
82
  if (document.head.querySelector(`script[src*="${src}"]`))
40
83
  return;
41
84
  const script = document.createElement("script");
42
85
  script.src = src;
43
86
  script.defer = true;
44
- if (mode === "development" && props.debug === false) {
87
+ script.setAttribute("data-sdkn", name);
88
+ script.setAttribute("data-sdkv", version);
89
+ if (isDevelopment() && props.debug === false) {
45
90
  script.setAttribute("data-debug", "false");
46
91
  }
47
92
  document.head.appendChild(script);
93
+ }
94
+ function track(name2, properties) {
95
+ var _a, _b;
96
+ if (!isBrowser()) {
97
+ console.warn(
98
+ "[Vercel Web Analytics] Server-side execution of `track()` is currently not supported."
99
+ );
100
+ return;
101
+ }
102
+ if (!properties) {
103
+ (_a = window.va) == null ? void 0 : _a.call(window, "event", { name: name2 });
104
+ return;
105
+ }
106
+ try {
107
+ const props = parseProperties(properties, {
108
+ strip: isProduction()
109
+ });
110
+ (_b = window.va) == null ? void 0 : _b.call(window, "event", {
111
+ name: name2,
112
+ data: props
113
+ });
114
+ } catch (err) {
115
+ if (err instanceof Error && isDevelopment()) {
116
+ console.error(err);
117
+ }
118
+ }
119
+ }
120
+ var generic_default = {
121
+ inject,
122
+ track
48
123
  };
49
124
  export {
50
- inject
125
+ generic_default as default,
126
+ inject,
127
+ track
51
128
  };
52
129
  //# sourceMappingURL=index.js.map
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 { AllowedPropertyValues, Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function setMode(mode: Mode = 'auto'): void {\n if (mode === 'auto') {\n window.vam = detectEnvironment();\n return;\n }\n\n window.vam = mode;\n}\n\nexport function getMode(): Mode {\n return window.vam || 'production';\n}\n\nexport function isProduction(): boolean {\n return getMode() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return getMode() === 'development';\n}\n\nfunction removeKey(\n key: string,\n { [key]: _, ...rest },\n): Record<string, unknown> {\n return rest;\n}\n\nexport function parseProperties(\n properties: Record<string, unknown>,\n options: {\n strip?: boolean;\n },\n): Error | Record<string, AllowedPropertyValues> | undefined {\n let props = properties;\n const errorProperties: string[] = [];\n for (const [key, value] of Object.entries(properties)) {\n if (typeof value === 'object' && value !== null) {\n if (options.strip) {\n props = removeKey(key, props);\n } else {\n errorProperties.push(key);\n }\n }\n }\n\n if (errorProperties.length > 0 && !options.strip) {\n throw Error(\n `The following properties are not valid: ${errorProperties.join(\n ', ',\n )}. Only strings, numbers, booleans, and null are allowed.`,\n );\n }\n return props as Record<string, AllowedPropertyValues>;\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AllowedPropertyValues, AnalyticsProps } from './types';\nimport {\n isBrowser,\n parseProperties,\n setMode,\n isDevelopment,\n isProduction,\n} from './utils';\n\nexport function inject(\n props: AnalyticsProps = {\n debug: true,\n },\n): void {\n if (!isBrowser()) return;\n\n setMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src = isDevelopment()\n ? 'https://va.vercel-scripts.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', packageName);\n script.setAttribute('data-sdkv', version);\n\n if (isDevelopment() && props.debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n}\n\nexport function track(\n name: string,\n properties?: Record<string, AllowedPropertyValues>,\n): void {\n if (!isBrowser()) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Vercel Web Analytics] Server-side execution of `track()` is currently not supported.',\n );\n return;\n }\n\n if (!properties) {\n window.va?.('event', { name });\n return;\n }\n\n try {\n const props = parseProperties(properties, {\n strip: isProduction(),\n });\n\n window.va?.('event', {\n name,\n data: props,\n });\n } catch (err) {\n if (err instanceof Error && isDevelopment()) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n }\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n inject,\n track,\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;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAP;AAAA,EAEF;AACA,SAAO;AACT;AAEO,SAAS,QAAQ,OAAa,QAAc;AACjD,MAAI,SAAS,QAAQ;AACnB,WAAO,MAAM,kBAAkB;AAC/B;AAAA,EACF;AAEA,SAAO,MAAM;A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Y,MAAM;AAClC;AAEO,SAAS,MACdA,OACA,YACM;AAhDR;AAiDE,MAAI,CAAC,UAAU,GAAG;AAEhB,YAAQ;AAAA,MACN;AAAA,IACF;AACA;AAAA,EACF;AAEA,MAAI,CAAC,YAAY;AACf,iBAAO,OAAP,gCAAY,SAAS,EAAE,MAAAA,MAAK;AAC5B;AAAA,EACF;AAEA,MAAI;AACF,UAAM,QAAQ,gBAAgB,YAAY;AAAA,MACxC,OAAO,aAAa;AAAA,IACtB,CAAC;AAED,iBAAO,OAAP,gCAAY,SAAS;AAAA,MACnB,MAAAA;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF,SAAS,KAAP;AACA,QAAI,eAAe,SAAS,cAAc,GAAG;AAE3C,cAAQ,MAAM,GAAG;AAAA,IACnB;AAAA,EACF;AACF;AAGA,IAAO,kBAAQ;AAAA,EACb;AAAA,EACA;AACF;","names":["name"]}
@@ -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") {
@@ -21,11 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/react.tsx
22
22
  var react_exports = {};
23
23
  __export(react_exports, {
24
- Analytics: () => Analytics
24
+ Analytics: () => Analytics,
25
+ default: () => react_default,
26
+ track: () => track
25
27
  });
26
28
  module.exports = __toCommonJS(react_exports);
27
29
  var import_react = require("react");
28
30
 
31
+ // package.json
32
+ var name = "@vercel/analytics";
33
+ var version = "1.0.0";
34
+
29
35
  // src/queue.ts
30
36
  var initQueue = () => {
31
37
  if (window.va)
@@ -39,41 +45,108 @@ var initQueue = () => {
39
45
  function isBrowser() {
40
46
  return typeof window !== "undefined";
41
47
  }
42
- function isDevelopment() {
43
- if (typeof process === "undefined")
44
- return false;
45
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
48
+ function detectEnvironment() {
49
+ try {
50
+ const env = process.env.NODE_ENV;
51
+ if (env === "development" || env === "test") {
52
+ return "development";
53
+ }
54
+ } catch (e) {
55
+ }
56
+ return "production";
46
57
  }
47
- function getMode(mode = "auto") {
58
+ function setMode(mode = "auto") {
48
59
  if (mode === "auto") {
49
- return isDevelopment() ? "development" : "production";
60
+ window.vam = detectEnvironment();
61
+ return;
62
+ }
63
+ window.vam = mode;
64
+ }
65
+ function getMode() {
66
+ return window.vam || "production";
67
+ }
68
+ function isProduction() {
69
+ return getMode() === "production";
70
+ }
71
+ function isDevelopment() {
72
+ return getMode() === "development";
73
+ }
74
+ function removeKey(key, { [key]: _, ...rest }) {
75
+ return rest;
76
+ }
77
+ function parseProperties(properties, options) {
78
+ let props = properties;
79
+ const errorProperties = [];
80
+ for (const [key, value] of Object.entries(properties)) {
81
+ if (typeof value === "object" && value !== null) {
82
+ if (options.strip) {
83
+ props = removeKey(key, props);
84
+ } else {
85
+ errorProperties.push(key);
86
+ }
87
+ }
50
88
  }
51
- return mode;
89
+ if (errorProperties.length > 0 && !options.strip) {
90
+ throw Error(
91
+ `The following properties are not valid: ${errorProperties.join(
92
+ ", "
93
+ )}. Only strings, numbers, booleans, and null are allowed.`
94
+ );
95
+ }
96
+ return props;
52
97
  }
53
98
 
54
99
  // src/generic.ts
55
- var inject = (props = {
100
+ function inject(props = {
56
101
  debug: true
57
- }) => {
102
+ }) {
58
103
  var _a;
59
104
  if (!isBrowser())
60
105
  return;
61
- const mode = getMode(props.mode);
106
+ setMode(props.mode);
62
107
  initQueue();
63
108
  if (props.beforeSend) {
64
109
  (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend);
65
110
  }
66
- const src = mode === "development" ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
111
+ const src = isDevelopment() ? "https://va.vercel-scripts.com/v1/script.debug.js" : "/_vercel/insights/script.js";
67
112
  if (document.head.querySelector(`script[src*="${src}"]`))
68
113
  return;
69
114
  const script = document.createElement("script");
70
115
  script.src = src;
71
116
  script.defer = true;
72
- if (mode === "development" && props.debug === false) {
117
+ script.setAttribute("data-sdkn", name);
118
+ script.setAttribute("data-sdkv", version);
119
+ if (isDevelopment() && props.debug === false) {
73
120
  script.setAttribute("data-debug", "false");
74
121
  }
75
122
  document.head.appendChild(script);
76
- };
123
+ }
124
+ function track(name2, properties) {
125
+ var _a, _b;
126
+ if (!isBrowser()) {
127
+ console.warn(
128
+ "[Vercel Web Analytics] Server-side execution of `track()` is currently not supported."
129
+ );
130
+ return;
131
+ }
132
+ if (!properties) {
133
+ (_a = window.va) == null ? void 0 : _a.call(window, "event", { name: name2 });
134
+ return;
135
+ }
136
+ try {
137
+ const props = parseProperties(properties, {
138
+ strip: isProduction()
139
+ });
140
+ (_b = window.va) == null ? void 0 : _b.call(window, "event", {
141
+ name: name2,
142
+ data: props
143
+ });
144
+ } catch (err) {
145
+ if (err instanceof Error && isDevelopment()) {
146
+ console.error(err);
147
+ }
148
+ }
149
+ }
77
150
 
78
151
  // src/react.tsx
79
152
  function Analytics({
@@ -86,8 +159,13 @@ function Analytics({
86
159
  }, [beforeSend, debug, mode]);
87
160
  return null;
88
161
  }
162
+ var react_default = {
163
+ Analytics,
164
+ track
165
+ };
89
166
  // Annotate the CommonJS export names for ESM import in node:
90
167
  0 && (module.exports = {
91
- Analytics
168
+ Analytics,
169
+ track
92
170
  });
93
171
  //# sourceMappingURL=index.cjs.map
@@ -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, track } from './generic';\nimport type { AnalyticsProps } from './types';\n\nfunction 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}\nexport { track, Analytics };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n Analytics,\n track,\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 { AllowedPropertyValues, Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function setMode(mode: Mode = 'auto'): void {\n if (mode === 'auto') {\n window.vam = detectEnvironment();\n return;\n }\n\n window.vam = mode;\n}\n\nexport function getMode(): Mode {\n return window.vam || 'production';\n}\n\nexport function isProduction(): boolean {\n return getMode() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return getMode() === 'development';\n}\n\nfunction removeKey(\n key: string,\n { [key]: _, ...rest },\n): Record<string, unknown> {\n return rest;\n}\n\nexport function parseProperties(\n properties: Record<string, unknown>,\n options: {\n strip?: boolean;\n },\n): Error | Record<string, AllowedPropertyValues> | undefined {\n let props = properties;\n const errorProperties: string[] = [];\n for (const [key, value] of Object.entries(properties)) {\n if (typeof value === 'object' && value !== null) {\n if (options.strip) {\n props = removeKey(key, props);\n } else {\n errorProperties.push(key);\n }\n }\n }\n\n if (errorProperties.length > 0 && !options.strip) {\n throw Error(\n `The following properties are not valid: ${errorProperties.join(\n ', ',\n )}. Only strings, numbers, booleans, and null are allowed.`,\n );\n }\n return props as Record<string, AllowedPropertyValues>;\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AllowedPropertyValues, AnalyticsProps } from './types';\nimport {\n isBrowser,\n parseProperties,\n setMode,\n isDevelopment,\n isProduction,\n} from './utils';\n\nexport function inject(\n props: AnalyticsProps = {\n debug: true,\n },\n): void {\n if (!isBrowser()) return;\n\n setMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src = isDevelopment()\n ? 'https://va.vercel-scripts.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', packageName);\n script.setAttribute('data-sdkv', version);\n\n if (isDevelopment() && props.debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n}\n\nexport function track(\n name: string,\n properties?: Record<string, AllowedPropertyValues>,\n): void {\n if (!isBrowser()) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Vercel Web Analytics] Server-side execution of `track()` is currently not supported.',\n );\n return;\n }\n\n if (!properties) {\n window.va?.('event', { name });\n return;\n }\n\n try {\n const props = parseProperties(properties, {\n strip: isProduction(),\n });\n\n window.va?.('event', {\n name,\n data: props,\n });\n } catch (err) {\n if (err instanceof Error && isDevelopment()) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n }\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n inject,\n track,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;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;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAP;AAAA,EAEF;AACA,SAAO;AACT;AAEO,SAAS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;AAExC,MAAI,cAAc,KAAK,MAAM,UAAU,OAAO;AAC5C,WAAO,aAAa,cAAc,OAAO;AAAA,EAC3C;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;AAEO,SAAS,MACdA,OACA,YACM;AAhDR;AAiDE,MAAI,CAAC,UAAU,GAAG;AAEhB,YAAQ;AAAA,MACN;AAAA,IACF;AACA;AAAA,EACF;AAEA,MAAI,CAAC,YAAY;AACf,iBAAO,OAAP,gCAAY,SAAS,EAAE,MAAAA,MAAK;AAC5B;AAAA,EACF;AAEA,MAAI;AACF,UAAM,QAAQ,gBAAgB,YAAY;AAAA,MACxC,OAAO,aAAa;AAAA,IACtB,CAAC;AAED,iBAAO,OAAP,gCAAY,SAAS;AAAA,MACnB,MAAAA;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF,SAAS,KAAP;AACA,QAAI,eAAe,SAAS,cAAc,GAAG;AAE3C,cAAQ,MAAM,GAAG;AAAA,IACnB;AAAA,EACF;AACF;;;AHzEA,SAAS,UAAU;AAAA,EACjB;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;AAKA,IAAO,gBAAQ;AAAA,EACb;AAAA,EACA;AACF;","names":["name"]}
@@ -4,6 +4,7 @@ interface PageViewEvent {
4
4
  }
5
5
  declare type Event = PageViewEvent;
6
6
  declare type Mode = 'auto' | 'development' | 'production';
7
+ declare type AllowedPropertyValues = string | number | boolean | null;
7
8
  declare type BeforeSend = (event: Event) => Event | null;
8
9
  interface AnalyticsProps {
9
10
  beforeSend?: BeforeSend;
@@ -12,12 +13,20 @@ interface AnalyticsProps {
12
13
  }
13
14
  declare global {
14
15
  interface Window {
15
- va?: (event: string, properties?: unknown) => void;
16
+ va?: (event: 'beforeSend' | 'event', properties?: unknown) => void;
16
17
  vaq?: [string, unknown?][];
17
18
  vai?: boolean;
19
+ vam?: Mode;
18
20
  }
19
21
  }
20
22
 
23
+ declare function track(name: string, properties?: Record<string, AllowedPropertyValues>): void;
24
+
21
25
  declare function Analytics({ beforeSend, debug, mode, }: AnalyticsProps): null;
22
26
 
23
- export { Analytics, AnalyticsProps };
27
+ declare const _default: {
28
+ Analytics: typeof Analytics;
29
+ track: typeof track;
30
+ };
31
+
32
+ export { Analytics, AnalyticsProps, _default as default, track };
@@ -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 = "1.0.0";
9
+
6
10
  // src/queue.ts
7
11
  var initQueue = () => {
8
12
  if (window.va)
@@ -16,41 +20,108 @@ var initQueue = () => {
16
20
  function isBrowser() {
17
21
  return typeof window !== "undefined";
18
22
  }
19
- function isDevelopment() {
20
- if (typeof process === "undefined")
21
- return false;
22
- return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
23
+ function detectEnvironment() {
24
+ try {
25
+ const env = process.env.NODE_ENV;
26
+ if (env === "development" || env === "test") {
27
+ return "development";
28
+ }
29
+ } catch (e) {
30
+ }
31
+ return "production";
23
32
  }
24
- function getMode(mode = "auto") {
33
+ function setMode(mode = "auto") {
25
34
  if (mode === "auto") {
26
- return isDevelopment() ? "development" : "production";
35
+ window.vam = detectEnvironment();
36
+ return;
37
+ }
38
+ window.vam = mode;
39
+ }
40
+ function getMode() {
41
+ return window.vam || "production";
42
+ }
43
+ function isProduction() {
44
+ return getMode() === "production";
45
+ }
46
+ function isDevelopment() {
47
+ return getMode() === "development";
48
+ }
49
+ function removeKey(key, { [key]: _, ...rest }) {
50
+ return rest;
51
+ }
52
+ function parseProperties(properties, options) {
53
+ let props = properties;
54
+ const errorProperties = [];
55
+ for (const [key, value] of Object.entries(properties)) {
56
+ if (typeof value === "object" && value !== null) {
57
+ if (options.strip) {
58
+ props = removeKey(key, props);
59
+ } else {
60
+ errorProperties.push(key);
61
+ }
62
+ }
27
63
  }
28
- return mode;
64
+ if (errorProperties.length > 0 && !options.strip) {
65
+ throw Error(
66
+ `The following properties are not valid: ${errorProperties.join(
67
+ ", "
68
+ )}. Only strings, numbers, booleans, and null are allowed.`
69
+ );
70
+ }
71
+ return props;
29
72
  }
30
73
 
31
74
  // src/generic.ts
32
- var inject = (props = {
75
+ function inject(props = {
33
76
  debug: true
34
- }) => {
77
+ }) {
35
78
  var _a;
36
79
  if (!isBrowser())
37
80
  return;
38
- const mode = getMode(props.mode);
81
+ setMode(props.mode);
39
82
  initQueue();
40
83
  if (props.beforeSend) {
41
84
  (_a = window.va) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend);
42
85
  }
43
- const src = mode === "development" ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
86
+ const src = isDevelopment() ? "https://va.vercel-scripts.com/v1/script.debug.js" : "/_vercel/insights/script.js";
44
87
  if (document.head.querySelector(`script[src*="${src}"]`))
45
88
  return;
46
89
  const script = document.createElement("script");
47
90
  script.src = src;
48
91
  script.defer = true;
49
- if (mode === "development" && props.debug === false) {
92
+ script.setAttribute("data-sdkn", name);
93
+ script.setAttribute("data-sdkv", version);
94
+ if (isDevelopment() && props.debug === false) {
50
95
  script.setAttribute("data-debug", "false");
51
96
  }
52
97
  document.head.appendChild(script);
53
- };
98
+ }
99
+ function track(name2, properties) {
100
+ var _a, _b;
101
+ if (!isBrowser()) {
102
+ console.warn(
103
+ "[Vercel Web Analytics] Server-side execution of `track()` is currently not supported."
104
+ );
105
+ return;
106
+ }
107
+ if (!properties) {
108
+ (_a = window.va) == null ? void 0 : _a.call(window, "event", { name: name2 });
109
+ return;
110
+ }
111
+ try {
112
+ const props = parseProperties(properties, {
113
+ strip: isProduction()
114
+ });
115
+ (_b = window.va) == null ? void 0 : _b.call(window, "event", {
116
+ name: name2,
117
+ data: props
118
+ });
119
+ } catch (err) {
120
+ if (err instanceof Error && isDevelopment()) {
121
+ console.error(err);
122
+ }
123
+ }
124
+ }
54
125
 
55
126
  // src/react.tsx
56
127
  function Analytics({
@@ -63,7 +134,13 @@ function Analytics({
63
134
  }, [beforeSend, debug, mode]);
64
135
  return null;
65
136
  }
137
+ var react_default = {
138
+ Analytics,
139
+ track
140
+ };
66
141
  export {
67
- Analytics
142
+ Analytics,
143
+ react_default as default,
144
+ track
68
145
  };
69
146
  //# sourceMappingURL=index.js.map
@@ -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, track } from './generic';\nimport type { AnalyticsProps } from './types';\n\nfunction 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}\nexport { track, Analytics };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n Analytics,\n track,\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 { AllowedPropertyValues, Mode } from './types';\n\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function setMode(mode: Mode = 'auto'): void {\n if (mode === 'auto') {\n window.vam = detectEnvironment();\n return;\n }\n\n window.vam = mode;\n}\n\nexport function getMode(): Mode {\n return window.vam || 'production';\n}\n\nexport function isProduction(): boolean {\n return getMode() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return getMode() === 'development';\n}\n\nfunction removeKey(\n key: string,\n { [key]: _, ...rest },\n): Record<string, unknown> {\n return rest;\n}\n\nexport function parseProperties(\n properties: Record<string, unknown>,\n options: {\n strip?: boolean;\n },\n): Error | Record<string, AllowedPropertyValues> | undefined {\n let props = properties;\n const errorProperties: string[] = [];\n for (const [key, value] of Object.entries(properties)) {\n if (typeof value === 'object' && value !== null) {\n if (options.strip) {\n props = removeKey(key, props);\n } else {\n errorProperties.push(key);\n }\n }\n }\n\n if (errorProperties.length > 0 && !options.strip) {\n throw Error(\n `The following properties are not valid: ${errorProperties.join(\n ', ',\n )}. Only strings, numbers, booleans, and null are allowed.`,\n );\n }\n return props as Record<string, AllowedPropertyValues>;\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { AllowedPropertyValues, AnalyticsProps } from './types';\nimport {\n isBrowser,\n parseProperties,\n setMode,\n isDevelopment,\n isProduction,\n} from './utils';\n\nexport function inject(\n props: AnalyticsProps = {\n debug: true,\n },\n): void {\n if (!isBrowser()) return;\n\n setMode(props.mode);\n\n initQueue();\n\n if (props.beforeSend) {\n window.va?.('beforeSend', props.beforeSend);\n }\n\n const src = isDevelopment()\n ? 'https://va.vercel-scripts.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', packageName);\n script.setAttribute('data-sdkv', version);\n\n if (isDevelopment() && props.debug === false) {\n script.setAttribute('data-debug', 'false');\n }\n\n document.head.appendChild(script);\n}\n\nexport function track(\n name: string,\n properties?: Record<string, AllowedPropertyValues>,\n): void {\n if (!isBrowser()) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Vercel Web Analytics] Server-side execution of `track()` is currently not supported.',\n );\n return;\n }\n\n if (!properties) {\n window.va?.('event', { name });\n return;\n }\n\n try {\n const props = parseProperties(properties, {\n strip: isProduction(),\n });\n\n window.va?.('event', {\n name,\n data: props,\n });\n } catch (err) {\n if (err instanceof Error && isDevelopment()) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n }\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n inject,\n track,\n};\n"],"mappings":";;;AAAA,SAAS,iBAAiB;;;;;;;ACAnB,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAA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 @@
1
1
  {
2
2
  "name": "@vercel/analytics",
3
- "version": "0.1.10",
3
+ "version": "1.0.0",
4
4
  "keywords": [
5
5
  "analytics",
6
6
  "vercel"
@@ -54,7 +54,7 @@
54
54
  "jest-environment-jsdom": "^29.3.1",
55
55
  "react": "^18.2.0",
56
56
  "react-dom": "^18.2.0",
57
- "tsup": "^6.3.0"
57
+ "tsup": "6.5.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^16.8||^17||^18"