@shware/analytics 0.3.3 → 0.3.5
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/next/index.cjs +9 -20
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.mjs +9 -20
- package/dist/next/index.mjs.map +1 -1
- package/dist/react-router/index.cjs +8 -19
- package/dist/react-router/index.cjs.map +1 -1
- package/dist/react-router/index.mjs +8 -19
- package/dist/react-router/index.mjs.map +1 -1
- package/dist/schema/index.cjs +21 -3
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +9 -9
- package/dist/schema/index.d.ts +9 -9
- package/dist/schema/index.mjs +21 -3
- package/dist/schema/index.mjs.map +1 -1
- package/dist/web/index.cjs +8 -2
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +5 -1
- package/dist/web/index.d.ts +5 -1
- package/dist/web/index.mjs +6 -1
- package/dist/web/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/next/index.cjs
CHANGED
|
@@ -120,14 +120,13 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
120
120
|
}
|
|
121
121
|
)
|
|
122
122
|
] }),
|
|
123
|
-
pixelId && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
__html: `
|
|
123
|
+
pixelId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
124
|
+
import_script.default,
|
|
125
|
+
{
|
|
126
|
+
id: "pixel",
|
|
127
|
+
strategy: "afterInteractive",
|
|
128
|
+
dangerouslySetInnerHTML: {
|
|
129
|
+
__html: `
|
|
131
130
|
!(function (f, b, e, v, n, t, s) {
|
|
132
131
|
if (f.fbq) return;
|
|
133
132
|
n = f.fbq = function () {
|
|
@@ -146,19 +145,9 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
146
145
|
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
147
146
|
fbq('init', '${pixelId}');
|
|
148
147
|
fbq('track', 'PageView');`
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("noscript", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
153
|
-
"img",
|
|
154
|
-
{
|
|
155
|
-
width: "1",
|
|
156
|
-
height: "1",
|
|
157
|
-
style: { display: "none" },
|
|
158
|
-
src: `https://www.facebook.com/tr?id=${pixelId}&ev=PageView&noscript=1`
|
|
159
148
|
}
|
|
160
|
-
|
|
161
|
-
|
|
149
|
+
}
|
|
150
|
+
) })
|
|
162
151
|
] });
|
|
163
152
|
}
|
|
164
153
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/next/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport Script from 'next/script';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const pathname = usePathname();\n\n useEffect(() => {\n const params = new URLSearchParams(document.location.search);\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <Script\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <Script\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <Script\n id=\"pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n
|
|
1
|
+
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport Script from 'next/script';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const pathname = usePathname();\n\n useEffect(() => {\n const params = new URLSearchParams(document.location.search);\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <Script\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <Script\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <Script\n id=\"pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n </>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;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,4CAAmB,CAAC,WAAW;AAC7B,UAAM,aAAa;AAAA,MACjB,IAAI,OAAO;AAAA,MACX,QAAQ,OAAO;AAAA,MACf,OAAO,OAAO;AAAA,MACd,OAAO,OAAO;AAAA,MACd,iBAAiB,OAAO;AAAA,MACxB,iBAAiB;AAAA;AAAA,IACnB;AACA,4BAAM,OAAO,MAAM,UAAU;AAAA,EAC/B,CAAC;AAED,SACE,4EACG;AAAA,qBAAiB,4CAAC,UAAK,UAAS,aAAY,SAAS,eAAe;AAAA,IACpE,QACC,4EACE;AAAA;AAAA,QAAC,cAAAA;AAAA,QAAA;AAAA,UACC,IAAG;AAAA,UACH;AAAA,UACA,KAAK,+CAA+C,IAAI;AAAA;AAAA,MAC1D;AAAA,MACA;AAAA,QAAC,cAAAA;AAAA,QAAA;AAAA,UACC;AAAA,UACA,IAAG;AAAA,UACH,yBAAyB;AAAA,YACvB,QAAQ;AAAA;AAAA;AAAA;AAAA,gCAIU,IAAI,IAAI,YAAY,6BAA6B,EAAE;AAAA;AAAA,UAEvE;AAAA;AAAA,MACF;AAAA,OACF;AAAA,IAED,WACC,2EACE;AAAA,MAAC,cAAAA;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAiBO,OAAO;AAAA;AAAA,QAExB;AAAA;AAAA,IACF,GACF;AAAA,KAEJ;AAEJ;","names":["Script"]}
|
package/dist/next/index.mjs
CHANGED
|
@@ -85,14 +85,13 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
85
85
|
}
|
|
86
86
|
)
|
|
87
87
|
] }),
|
|
88
|
-
pixelId && /* @__PURE__ */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
__html: `
|
|
88
|
+
pixelId && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
89
|
+
Script,
|
|
90
|
+
{
|
|
91
|
+
id: "pixel",
|
|
92
|
+
strategy: "afterInteractive",
|
|
93
|
+
dangerouslySetInnerHTML: {
|
|
94
|
+
__html: `
|
|
96
95
|
!(function (f, b, e, v, n, t, s) {
|
|
97
96
|
if (f.fbq) return;
|
|
98
97
|
n = f.fbq = function () {
|
|
@@ -111,19 +110,9 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
111
110
|
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
112
111
|
fbq('init', '${pixelId}');
|
|
113
112
|
fbq('track', 'PageView');`
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
),
|
|
117
|
-
/* @__PURE__ */ jsx("noscript", { children: /* @__PURE__ */ jsx(
|
|
118
|
-
"img",
|
|
119
|
-
{
|
|
120
|
-
width: "1",
|
|
121
|
-
height: "1",
|
|
122
|
-
style: { display: "none" },
|
|
123
|
-
src: `https://www.facebook.com/tr?id=${pixelId}&ev=PageView&noscript=1`
|
|
124
113
|
}
|
|
125
|
-
|
|
126
|
-
|
|
114
|
+
}
|
|
115
|
+
) })
|
|
127
116
|
] });
|
|
128
117
|
}
|
|
129
118
|
export {
|
package/dist/next/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport Script from 'next/script';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const pathname = usePathname();\n\n useEffect(() => {\n const params = new URLSearchParams(document.location.search);\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <Script\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <Script\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <Script\n id=\"pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n
|
|
1
|
+
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport Script from 'next/script';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const pathname = usePathname();\n\n useEffect(() => {\n const params = new URLSearchParams(document.location.search);\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <Script\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <Script\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <Script\n id=\"pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n </>\n )}\n </>\n );\n}\n"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,OAAO,YAAY;AACnB,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAkFH,SAEhB,UAFgB,KAEhB,YAFgB;AAhEjB,SAAS,YACd,MACA,YACA;AACA,MAAI,CAAC,OAAO,MAAM;AAChB,YAAQ,KAAK,6BAA6B;AAC1C;AAAA,EACF;AACA,SAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEO,SAAS,YACd,MACA,YACA,UACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,YAAQ,KAAK,8BAA8B;AAC3C;AAAA,EACF;AACA,QAAM,EAAE,IAAI,IAAI;AAChB,QAAM,UAAU,EAAE,SAAS,SAAS;AACpC,QAAM,CAAC,MAAM,aAAa,iBAAiB,IAAI,WAAW,MAAM,UAAU;AAC1E,MAAI,SAAS,SAAS;AACpB,QAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EACnD,OAAO;AACL,QAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EACnD;AACF;AAEO,SAAS,UAAU,EAAE,MAAM,OAAO,WAAW,SAAS,cAAc,GAAU;AACnF,QAAM,WAAW,YAAY;AAE7B,YAAU,MAAM;AACd,UAAM,SAAS,IAAI,gBAAgB,SAAS,SAAS,MAAM;AAC3D,UAAM,aAAa;AAAA,MACjB;AAAA,MACA,UAAU,SAAS;AAAA,MACnB,OAAO,OAAO,IAAI,OAAO;AAAA,MACzB,QAAQ,OAAO,IAAI,QAAQ;AAAA,MAC3B,YAAY,OAAO,IAAI,YAAY;AAAA,MACnC,YAAY,OAAO,IA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|
|
|
120
120
|
}
|
|
121
121
|
)
|
|
122
122
|
] }),
|
|
123
|
-
pixelId && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
__html: `
|
|
123
|
+
pixelId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
124
|
+
"script",
|
|
125
|
+
{
|
|
126
|
+
id: "pixel",
|
|
127
|
+
dangerouslySetInnerHTML: {
|
|
128
|
+
__html: `
|
|
130
129
|
!(function (f, b, e, v, n, t, s) {
|
|
131
130
|
if (f.fbq) return;
|
|
132
131
|
n = f.fbq = function () {
|
|
@@ -145,19 +144,9 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
145
144
|
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
146
145
|
fbq('init', '${pixelId}');
|
|
147
146
|
fbq('track', 'PageView');`
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("noscript", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
-
"img",
|
|
153
|
-
{
|
|
154
|
-
width: "1",
|
|
155
|
-
height: "1",
|
|
156
|
-
style: { display: "none" },
|
|
157
|
-
src: `https://www.facebook.com/tr?id=${pixelId}&ev=PageView&noscript=1`
|
|
158
147
|
}
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
}
|
|
149
|
+
) })
|
|
161
150
|
] });
|
|
162
151
|
}
|
|
163
152
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation, useSearchParams } from 'react-router';\nimport { onLCP, onFID, onCLS, onINP, onFCP, onTTFB, type Metric } from 'web-vitals';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onFID(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('gtag has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const { pathname } = useLocation();\n const [params] = useSearchParams();\n\n useEffect(() => {\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n /**\n * Pixel:\n * Each time the Pixel loads, it automatically calls fbq('track', 'PageView') to track a\n * PageView standard event.\n */\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname, params]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <script\n id=\"pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n
|
|
1
|
+
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation, useSearchParams } from 'react-router';\nimport { onLCP, onFID, onCLS, onINP, onFCP, onTTFB, type Metric } from 'web-vitals';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onFID(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('gtag has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const { pathname } = useLocation();\n const [params] = useSearchParams();\n\n useEffect(() => {\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n /**\n * Pixel:\n * Each time the Pixel loads, it automatically calls fbq('track', 'PageView') to track a\n * PageView standard event.\n */\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname, params]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <script\n id=\"pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n </>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,0BAA6C;AAC7C,wBAAuE;AACvE,mBAAsB;AACtB,iBAA2B;AAkGH;AA7FxB,SAAS,mBAAmB,mBAA6C;AACvE,8BAAU,MAAM;AACd,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACv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AAU,MAAM,CAAC;AAErB,qBAAmB,CAAC,WAAW;AAC7B,UAAM,aAAa;AAAA,MACjB,IAAI,OAAO;AAAA,MACX,QAAQ,OAAO;AAAA,MACf,OAAO,OAAO;AAAA,MACd,OAAO,OAAO;AAAA,MACd,iBAAiB,OAAO;AAAA,MACxB,iBAAiB;AAAA;AAAA,IACnB;AACA,4BAAM,OAAO,MAAM,UAAU;AAAA,EAC/B,CAAC;AAED,SACE,4EACG;AAAA,qBAAiB,4CAAC,UAAK,UAAS,aAAY,SAAS,eAAe;AAAA,IACpE,QACC,4EACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAK;AAAA,UACL,IAAG;AAAA,UACH;AAAA,UACA,KAAK,+CAA+C,IAAI;AAAA;AAAA,MAC1D;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,OAAK;AAAA,UACL;AAAA,UACA,IAAG;AAAA,UACH,yBAAyB;AAAA,YACvB,QAAQ;AAAA;AAAA;AAAA;AAAA,gCAIU,IAAI,IAAI,YAAY,6BAA6B,EAAE;AAAA;AAAA,UAEvE;AAAA;AAAA,MACF;AAAA,OACF;AAAA,IAED,WACC,2EACE;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAiBO,OAAO;AAAA;AAAA,QAExB;AAAA;AAAA,IACF,GACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -94,13 +94,12 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
94
94
|
}
|
|
95
95
|
)
|
|
96
96
|
] }),
|
|
97
|
-
pixelId && /* @__PURE__ */
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
__html: `
|
|
97
|
+
pixelId && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
98
|
+
"script",
|
|
99
|
+
{
|
|
100
|
+
id: "pixel",
|
|
101
|
+
dangerouslySetInnerHTML: {
|
|
102
|
+
__html: `
|
|
104
103
|
!(function (f, b, e, v, n, t, s) {
|
|
105
104
|
if (f.fbq) return;
|
|
106
105
|
n = f.fbq = function () {
|
|
@@ -119,19 +118,9 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
119
118
|
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
120
119
|
fbq('init', '${pixelId}');
|
|
121
120
|
fbq('track', 'PageView');`
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
),
|
|
125
|
-
/* @__PURE__ */ jsx("noscript", { children: /* @__PURE__ */ jsx(
|
|
126
|
-
"img",
|
|
127
|
-
{
|
|
128
|
-
width: "1",
|
|
129
|
-
height: "1",
|
|
130
|
-
style: { display: "none" },
|
|
131
|
-
src: `https://www.facebook.com/tr?id=${pixelId}&ev=PageView&noscript=1`
|
|
132
121
|
}
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
}
|
|
123
|
+
) })
|
|
135
124
|
] });
|
|
136
125
|
}
|
|
137
126
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation, useSearchParams } from 'react-router';\nimport { onLCP, onFID, onCLS, onINP, onFCP, onTTFB, type Metric } from 'web-vitals';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onFID(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('gtag has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const { pathname } = useLocation();\n const [params] = useSearchParams();\n\n useEffect(() => {\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n /**\n * Pixel:\n * Each time the Pixel loads, it automatically calls fbq('track', 'PageView') to track a\n * PageView standard event.\n */\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname, params]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <script\n id=\"pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n
|
|
1
|
+
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation, useSearchParams } from 'react-router';\nimport { onLCP, onFID, onCLS, onINP, onFCP, onTTFB, type Metric } from 'web-vitals';\nimport { track } from '../track/index';\nimport { mapFBEvent } from '../track/fbq';\nimport type { Gtag, GaId, GtmId } from '../track/gtag';\nimport type { Pixel, PixelId } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onFID(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ndeclare global {\n interface Window extends Gtag, Pixel {}\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n pixelId?: PixelId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('gtag has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n const { fbq } = window;\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n fbq(type, fbEventName, fbEventProperties, options);\n } else {\n fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }: Props) {\n const { pathname } = useLocation();\n const [params] = useSearchParams();\n\n useEffect(() => {\n const properties = {\n pathname,\n referrer: document.referrer,\n gclid: params.get('gclid'),\n fbclid: params.get('fbclid'),\n utm_source: params.get('utm_source'),\n utm_medium: params.get('utm_medium'),\n utm_campaign: params.get('utm_campaign'),\n utm_term: params.get('utm_term'),\n utm_content: params.get('utm_content'),\n };\n\n /**\n * Pixel:\n * Each time the Pixel loads, it automatically calls fbq('track', 'PageView') to track a\n * PageView standard event.\n */\n track('page_view', properties, { enableThirdPartyTracking: false });\n }, [pathname, params]);\n\n useReportWebVitals((metric) => {\n const properties = {\n id: metric.id,\n rating: metric.rating,\n value: metric.value,\n delta: metric.delta,\n navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {pixelId && (\n <>\n <script\n id=\"pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${pixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n </>\n )}\n </>\n );\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,uBAAuB;AAC7C,SAAS,OAAO,OAAO,OAAO,OAAO,OAAO,cAA2B;AACvE,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAkGH,SAEhB,UAFgB,KAEhB,YAFgB;AA7FxB,SAAS,mBAAmB,mBAA6C;AACvE,YAAU,MAAM;AACd,UAAM,iBAAiB;AACvB,UAAM,iBAAiB;AACvB,UAAM,iBAAiB;AACvB,UAAM,iBAAiB;AACvB,UAAM,iBAAiB;AACvB,WAAO,iBAAiB;AAAA,EAC1B,GAAG,CAAC,iBAAiB,CAAC;AACxB;AAeO,SAAS,YACd,MACA,YACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;AACjD,YAAQ,KAAK,+BAA+B;AAC5C;AAAA,EACF;AACA,SAAO,KAAK,SAAS,MAAM,UAAU;AAC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qBAAiB,oBAAC,UAAK,UAAS,aAAY,SAAS,eAAe;AAAA,IACpE,QACC,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAK;AAAA,UACL,IAAG;AAAA,UACH;AAAA,UACA,KAAK,+CAA+C,IAAI;AAAA;AAAA,MAC1D;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,OAAK;AAAA,UACL;AAAA,UACA,IAAG;AAAA,UACH,yBAAyB;AAAA,YACvB,QAAQ;AAAA;AAAA;AAAA;AAAA,gCAIU,IAAI,IAAI,YAAY,6BAA6B,EAAE;AAAA;AAAA,UAEvE;AAAA;AAAA,MACF;AAAA,OACF;AAAA,IAED,WACC,gCACE;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAiBO,OAAO;AAAA;AAAA,QAExB;AAAA;AAAA,IACF,GACF;AAAA,KAEJ;AAEJ;","names":[]}
|
package/dist/schema/index.cjs
CHANGED
|
@@ -62,20 +62,38 @@ var createTrackEventSchema = import_zod.z.object({
|
|
|
62
62
|
}),
|
|
63
63
|
properties: import_zod.z.record(
|
|
64
64
|
import_zod.z.string().trim().min(1).max(128),
|
|
65
|
-
import_zod.z.union([
|
|
65
|
+
import_zod.z.union([
|
|
66
|
+
import_zod.z.string().max(512),
|
|
67
|
+
import_zod.z.number(),
|
|
68
|
+
import_zod.z.boolean(),
|
|
69
|
+
import_zod.z.null(),
|
|
70
|
+
import_zod.z.array(import_zod.z.union([import_zod.z.string().max(512), import_zod.z.number(), import_zod.z.boolean(), import_zod.z.null()]))
|
|
71
|
+
])
|
|
66
72
|
).refine((data) => Object.keys(data).length <= 64).optional()
|
|
67
73
|
}).array().min(1).max(100);
|
|
68
74
|
var createVisitorSchema = import_zod.z.object({
|
|
69
75
|
device_id: import_zod.z.string().trim().min(1).max(36),
|
|
70
76
|
properties: import_zod.z.record(
|
|
71
77
|
import_zod.z.string().trim().min(1).max(128),
|
|
72
|
-
import_zod.z.union([
|
|
78
|
+
import_zod.z.union([
|
|
79
|
+
import_zod.z.string().max(512),
|
|
80
|
+
import_zod.z.number(),
|
|
81
|
+
import_zod.z.boolean(),
|
|
82
|
+
import_zod.z.null(),
|
|
83
|
+
import_zod.z.array(import_zod.z.union([import_zod.z.string().max(512), import_zod.z.number(), import_zod.z.boolean(), import_zod.z.null()]))
|
|
84
|
+
])
|
|
73
85
|
).refine((data) => Object.keys(data).length <= 64).optional()
|
|
74
86
|
});
|
|
75
87
|
var updateVisitorSchema = import_zod.z.object({
|
|
76
88
|
properties: import_zod.z.record(
|
|
77
89
|
import_zod.z.string().trim().min(1).max(128),
|
|
78
|
-
import_zod.z.union([
|
|
90
|
+
import_zod.z.union([
|
|
91
|
+
import_zod.z.string().max(512),
|
|
92
|
+
import_zod.z.number(),
|
|
93
|
+
import_zod.z.boolean(),
|
|
94
|
+
import_zod.z.null(),
|
|
95
|
+
import_zod.z.array(import_zod.z.union([import_zod.z.string().max(512), import_zod.z.number(), import_zod.z.boolean(), import_zod.z.null()]))
|
|
96
|
+
])
|
|
79
97
|
).refine((data) => Object.keys(data).length <= 64)
|
|
80
98
|
});
|
|
81
99
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/index.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const createTrackEventSchema = z\n .object({\n name: z.string().trim().min(1).max(64),\n visitor_id: z.coerce.bigint(),\n timestamp: z.string().datetime(),\n tags: z.object({\n os: z.string().optional(),\n os_name: z.string().optional(),\n os_version: z.string().optional(),\n browser: z.string().optional(),\n browser_name: z.string().optional(),\n browser_version: z.string().optional(),\n platform: z\n .enum(['ios', 'android', 'web', 'macos', 'windows', 'linux', 'unknown'])\n .optional(),\n device: z.string().optional(),\n device_id: z.string().trim().min(1).max(36).optional(),\n device_type: z.string().optional(),\n device_vendor: z.string().optional(),\n device_pixel_ratio: z.string().optional(),\n screen_resolution: z\n .string()\n .regex(/^\\d+x\\d+$/)\n .transform((v) => v as `${number}x${number}`)\n .optional(),\n release: z.string().optional(),\n language: z.string().optional(),\n timezone: z.string().optional(),\n environment: z.enum(['development', 'production']).optional(),\n source_url: z.string().optional(),\n source: z.enum(['web', 'app', 'offline']).optional(),\n fbc: z.string().optional(),\n fbp: z.string().optional(),\n gclid: z.string().optional(),\n advertising_id: z.string().optional(),\n utm_source: z.string().optional(),\n utm_medium: z.string().optional(),\n utm_campaign: z.string().optional(),\n utm_term: z.string().optional(),\n utm_content: z.string().optional(),\n }),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([z.string().max(512), z.number(), z.boolean(), z.null()])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n })\n .array()\n .min(1)\n .max(100);\n\nexport const createVisitorSchema = z.object({\n device_id: z.string().trim().min(1).max(36),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([z.string().max(512), z.number(), z.boolean(), z.null()])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n});\n\nexport const updateVisitorSchema = z.object({\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([z.string().max(512), z.number(), z.boolean(), z.null()])\n )\n .refine((data) => Object.keys(data).length <= 64),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAEX,IAAM,yBAAyB,aACnC,OAAO;AAAA,EACN,MAAM,aAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;AAAA,EACrC,YAAY,aAAE,OAAO,OAAO;AAAA,EAC5B,WAAW,aAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,MAAM,aAAE,OAAO;AAAA,IACb,IAAI,aAAE,OAAO,EAAE,SAAS;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AAS;AAAA,IAChC,cAAc,aAAE,OAAO,EAAE,SAAS;AAAA,IAClC,UAAU,aAAE,OAAO,EAAE,SAAS;AAAA,IAC9B,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACnC,CAAC;AAAA,EACD,YAAY,aACT;AAAA,IACC,aAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,IAChC,aAAE,MAAM,CAAC,aAAE,OAAO,EAAE,IAAI,GAAG,GAAG,aAAE,OAAO,GAAG,aAAE,QAAQ,GAAG,aAAE,KAAK,CAAC,CAAC;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/schema/index.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const createTrackEventSchema = z\n .object({\n name: z.string().trim().min(1).max(64),\n visitor_id: z.coerce.bigint(),\n timestamp: z.string().datetime(),\n tags: z.object({\n os: z.string().optional(),\n os_name: z.string().optional(),\n os_version: z.string().optional(),\n browser: z.string().optional(),\n browser_name: z.string().optional(),\n browser_version: z.string().optional(),\n platform: z\n .enum(['ios', 'android', 'web', 'macos', 'windows', 'linux', 'unknown'])\n .optional(),\n device: z.string().optional(),\n device_id: z.string().trim().min(1).max(36).optional(),\n device_type: z.string().optional(),\n device_vendor: z.string().optional(),\n device_pixel_ratio: z.string().optional(),\n screen_resolution: z\n .string()\n .regex(/^\\d+x\\d+$/)\n .transform((v) => v as `${number}x${number}`)\n .optional(),\n release: z.string().optional(),\n language: z.string().optional(),\n timezone: z.string().optional(),\n environment: z.enum(['development', 'production']).optional(),\n source_url: z.string().optional(),\n source: z.enum(['web', 'app', 'offline']).optional(),\n fbc: z.string().optional(),\n fbp: z.string().optional(),\n gclid: z.string().optional(),\n advertising_id: z.string().optional(),\n utm_source: z.string().optional(),\n utm_medium: z.string().optional(),\n utm_campaign: z.string().optional(),\n utm_term: z.string().optional(),\n utm_content: z.string().optional(),\n }),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([\n z.string().max(512),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()])),\n ])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n })\n .array()\n .min(1)\n .max(100);\n\nexport const createVisitorSchema = z.object({\n device_id: z.string().trim().min(1).max(36),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([\n z.string().max(512),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()])),\n ])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n});\n\nexport const updateVisitorSchema = z.object({\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([\n z.string().max(512),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()])),\n ])\n )\n .refine((data) => Object.keys(data).length <= 64),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAEX,IAAM,yBAAyB,aACnC,OAAO;AAAA,EACN,MAAM,aAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;AAAA,EACrC,YAAY,aAAE,OAAO,OAAO;AAAA,EAC5B,WAAW,aAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,MAAM,aAAE,OAAO;AAAA,IACb,IAAI,aAAE,OAAO,EAAE,SAAS;AAAA,IACxB,SAAS,aAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,YAAY,aAAE,OAAO,EAAE,SAAS;AAAA,IAChC,SAAS,aAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,cAAc,aAAE,OAAO,EAAE,SAAS;AAAA,IAClC,iBAAiB,aAAE,OAAO,EAAE,SAAS;AAAA,IACrC,UAAU,aACP,KAAK,CAAC,OAAO,WAAW,OAAO,SAAS,WAAW,SAAS,SAAS,CAAC,EACtE,SAAS;AAAA,IACZ,QAAQ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,MAAM,aAAE,MAAM,CAAC,aAAE,OAAO,EAAE,IAAI,GAAG,GAAG,aAAE,OAAO,GAAG,aAAE,QAAQ,GAAG,aAAE,KAAK,CAAC,CAAC,CAAC;AAAA,IAC3E,CAAC;AAAA,EACH,EACC,OAAO,CAAC,SAAS,OAAO,KAAK,IAAI,EAAE,UAAU,EAAE;AACpD,CAAC;","names":[]}
|
package/dist/schema/index.d.cts
CHANGED
|
@@ -92,7 +92,7 @@ declare const createTrackEventSchema: z.ZodArray<z.ZodObject<{
|
|
|
92
92
|
utm_term?: string | undefined;
|
|
93
93
|
utm_content?: string | undefined;
|
|
94
94
|
}>;
|
|
95
|
-
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
95
|
+
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>>>;
|
|
96
96
|
}, "strip", z.ZodTypeAny, {
|
|
97
97
|
visitor_id: bigint;
|
|
98
98
|
name: string;
|
|
@@ -127,7 +127,7 @@ declare const createTrackEventSchema: z.ZodArray<z.ZodObject<{
|
|
|
127
127
|
utm_term?: string | undefined;
|
|
128
128
|
utm_content?: string | undefined;
|
|
129
129
|
};
|
|
130
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
130
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
131
131
|
}, {
|
|
132
132
|
visitor_id: bigint;
|
|
133
133
|
name: string;
|
|
@@ -162,24 +162,24 @@ declare const createTrackEventSchema: z.ZodArray<z.ZodObject<{
|
|
|
162
162
|
utm_term?: string | undefined;
|
|
163
163
|
utm_content?: string | undefined;
|
|
164
164
|
};
|
|
165
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
165
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
166
166
|
}>, "many">;
|
|
167
167
|
declare const createVisitorSchema: z.ZodObject<{
|
|
168
168
|
device_id: z.ZodString;
|
|
169
|
-
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
169
|
+
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>>>;
|
|
170
170
|
}, "strip", z.ZodTypeAny, {
|
|
171
171
|
device_id: string;
|
|
172
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
172
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
173
173
|
}, {
|
|
174
174
|
device_id: string;
|
|
175
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
175
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
176
176
|
}>;
|
|
177
177
|
declare const updateVisitorSchema: z.ZodObject<{
|
|
178
|
-
properties: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>;
|
|
178
|
+
properties: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>>;
|
|
179
179
|
}, "strip", z.ZodTypeAny, {
|
|
180
|
-
properties: Record<string, string | number | boolean | null>;
|
|
180
|
+
properties: Record<string, string | number | boolean | (string | number | boolean | null)[] | null>;
|
|
181
181
|
}, {
|
|
182
|
-
properties: Record<string, string | number | boolean | null>;
|
|
182
|
+
properties: Record<string, string | number | boolean | (string | number | boolean | null)[] | null>;
|
|
183
183
|
}>;
|
|
184
184
|
|
|
185
185
|
export { createTrackEventSchema, createVisitorSchema, updateVisitorSchema };
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ declare const createTrackEventSchema: z.ZodArray<z.ZodObject<{
|
|
|
92
92
|
utm_term?: string | undefined;
|
|
93
93
|
utm_content?: string | undefined;
|
|
94
94
|
}>;
|
|
95
|
-
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
95
|
+
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>>>;
|
|
96
96
|
}, "strip", z.ZodTypeAny, {
|
|
97
97
|
visitor_id: bigint;
|
|
98
98
|
name: string;
|
|
@@ -127,7 +127,7 @@ declare const createTrackEventSchema: z.ZodArray<z.ZodObject<{
|
|
|
127
127
|
utm_term?: string | undefined;
|
|
128
128
|
utm_content?: string | undefined;
|
|
129
129
|
};
|
|
130
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
130
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
131
131
|
}, {
|
|
132
132
|
visitor_id: bigint;
|
|
133
133
|
name: string;
|
|
@@ -162,24 +162,24 @@ declare const createTrackEventSchema: z.ZodArray<z.ZodObject<{
|
|
|
162
162
|
utm_term?: string | undefined;
|
|
163
163
|
utm_content?: string | undefined;
|
|
164
164
|
};
|
|
165
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
165
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
166
166
|
}>, "many">;
|
|
167
167
|
declare const createVisitorSchema: z.ZodObject<{
|
|
168
168
|
device_id: z.ZodString;
|
|
169
|
-
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
169
|
+
properties: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>>>;
|
|
170
170
|
}, "strip", z.ZodTypeAny, {
|
|
171
171
|
device_id: string;
|
|
172
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
172
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
173
173
|
}, {
|
|
174
174
|
device_id: string;
|
|
175
|
-
properties?: Record<string, string | number | boolean | null> | undefined;
|
|
175
|
+
properties?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
176
176
|
}>;
|
|
177
177
|
declare const updateVisitorSchema: z.ZodObject<{
|
|
178
|
-
properties: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>;
|
|
178
|
+
properties: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>, Record<string, string | number | boolean | (string | number | boolean | null)[] | null>>;
|
|
179
179
|
}, "strip", z.ZodTypeAny, {
|
|
180
|
-
properties: Record<string, string | number | boolean | null>;
|
|
180
|
+
properties: Record<string, string | number | boolean | (string | number | boolean | null)[] | null>;
|
|
181
181
|
}, {
|
|
182
|
-
properties: Record<string, string | number | boolean | null>;
|
|
182
|
+
properties: Record<string, string | number | boolean | (string | number | boolean | null)[] | null>;
|
|
183
183
|
}>;
|
|
184
184
|
|
|
185
185
|
export { createTrackEventSchema, createVisitorSchema, updateVisitorSchema };
|
package/dist/schema/index.mjs
CHANGED
|
@@ -36,20 +36,38 @@ var createTrackEventSchema = z.object({
|
|
|
36
36
|
}),
|
|
37
37
|
properties: z.record(
|
|
38
38
|
z.string().trim().min(1).max(128),
|
|
39
|
-
z.union([
|
|
39
|
+
z.union([
|
|
40
|
+
z.string().max(512),
|
|
41
|
+
z.number(),
|
|
42
|
+
z.boolean(),
|
|
43
|
+
z.null(),
|
|
44
|
+
z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()]))
|
|
45
|
+
])
|
|
40
46
|
).refine((data) => Object.keys(data).length <= 64).optional()
|
|
41
47
|
}).array().min(1).max(100);
|
|
42
48
|
var createVisitorSchema = z.object({
|
|
43
49
|
device_id: z.string().trim().min(1).max(36),
|
|
44
50
|
properties: z.record(
|
|
45
51
|
z.string().trim().min(1).max(128),
|
|
46
|
-
z.union([
|
|
52
|
+
z.union([
|
|
53
|
+
z.string().max(512),
|
|
54
|
+
z.number(),
|
|
55
|
+
z.boolean(),
|
|
56
|
+
z.null(),
|
|
57
|
+
z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()]))
|
|
58
|
+
])
|
|
47
59
|
).refine((data) => Object.keys(data).length <= 64).optional()
|
|
48
60
|
});
|
|
49
61
|
var updateVisitorSchema = z.object({
|
|
50
62
|
properties: z.record(
|
|
51
63
|
z.string().trim().min(1).max(128),
|
|
52
|
-
z.union([
|
|
64
|
+
z.union([
|
|
65
|
+
z.string().max(512),
|
|
66
|
+
z.number(),
|
|
67
|
+
z.boolean(),
|
|
68
|
+
z.null(),
|
|
69
|
+
z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()]))
|
|
70
|
+
])
|
|
53
71
|
).refine((data) => Object.keys(data).length <= 64)
|
|
54
72
|
});
|
|
55
73
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/index.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const createTrackEventSchema = z\n .object({\n name: z.string().trim().min(1).max(64),\n visitor_id: z.coerce.bigint(),\n timestamp: z.string().datetime(),\n tags: z.object({\n os: z.string().optional(),\n os_name: z.string().optional(),\n os_version: z.string().optional(),\n browser: z.string().optional(),\n browser_name: z.string().optional(),\n browser_version: z.string().optional(),\n platform: z\n .enum(['ios', 'android', 'web', 'macos', 'windows', 'linux', 'unknown'])\n .optional(),\n device: z.string().optional(),\n device_id: z.string().trim().min(1).max(36).optional(),\n device_type: z.string().optional(),\n device_vendor: z.string().optional(),\n device_pixel_ratio: z.string().optional(),\n screen_resolution: z\n .string()\n .regex(/^\\d+x\\d+$/)\n .transform((v) => v as `${number}x${number}`)\n .optional(),\n release: z.string().optional(),\n language: z.string().optional(),\n timezone: z.string().optional(),\n environment: z.enum(['development', 'production']).optional(),\n source_url: z.string().optional(),\n source: z.enum(['web', 'app', 'offline']).optional(),\n fbc: z.string().optional(),\n fbp: z.string().optional(),\n gclid: z.string().optional(),\n advertising_id: z.string().optional(),\n utm_source: z.string().optional(),\n utm_medium: z.string().optional(),\n utm_campaign: z.string().optional(),\n utm_term: z.string().optional(),\n utm_content: z.string().optional(),\n }),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([z.string().max(512), z.number(), z.boolean(), z.null()])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n })\n .array()\n .min(1)\n .max(100);\n\nexport const createVisitorSchema = z.object({\n device_id: z.string().trim().min(1).max(36),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([z.string().max(512), z.number(), z.boolean(), z.null()])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n});\n\nexport const updateVisitorSchema = z.object({\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([z.string().max(512), z.number(), z.boolean(), z.null()])\n )\n .refine((data) => Object.keys(data).length <= 64),\n});\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,yBAAyB,EACnC,OAAO;AAAA,EACN,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;AAAA,EACrC,YAAY,EAAE,OAAO,OAAO;AAAA,EAC5B,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,MAAM,EAAE,OAAO;AAAA,IACb,IAAI,EAAE,OAAO,EAAE,SAAS;AAAA,IACxB,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,IAChC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,IAClC,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,IACrC,UAAU,EACP,KAAK,CAAC,OAAO,WAAW,OAAO,SAAS,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AAE,OAAO,EAAE,IAAI,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/schema/index.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const createTrackEventSchema = z\n .object({\n name: z.string().trim().min(1).max(64),\n visitor_id: z.coerce.bigint(),\n timestamp: z.string().datetime(),\n tags: z.object({\n os: z.string().optional(),\n os_name: z.string().optional(),\n os_version: z.string().optional(),\n browser: z.string().optional(),\n browser_name: z.string().optional(),\n browser_version: z.string().optional(),\n platform: z\n .enum(['ios', 'android', 'web', 'macos', 'windows', 'linux', 'unknown'])\n .optional(),\n device: z.string().optional(),\n device_id: z.string().trim().min(1).max(36).optional(),\n device_type: z.string().optional(),\n device_vendor: z.string().optional(),\n device_pixel_ratio: z.string().optional(),\n screen_resolution: z\n .string()\n .regex(/^\\d+x\\d+$/)\n .transform((v) => v as `${number}x${number}`)\n .optional(),\n release: z.string().optional(),\n language: z.string().optional(),\n timezone: z.string().optional(),\n environment: z.enum(['development', 'production']).optional(),\n source_url: z.string().optional(),\n source: z.enum(['web', 'app', 'offline']).optional(),\n fbc: z.string().optional(),\n fbp: z.string().optional(),\n gclid: z.string().optional(),\n advertising_id: z.string().optional(),\n utm_source: z.string().optional(),\n utm_medium: z.string().optional(),\n utm_campaign: z.string().optional(),\n utm_term: z.string().optional(),\n utm_content: z.string().optional(),\n }),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([\n z.string().max(512),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()])),\n ])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n })\n .array()\n .min(1)\n .max(100);\n\nexport const createVisitorSchema = z.object({\n device_id: z.string().trim().min(1).max(36),\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([\n z.string().max(512),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()])),\n ])\n )\n .refine((data) => Object.keys(data).length <= 64)\n .optional(),\n});\n\nexport const updateVisitorSchema = z.object({\n properties: z\n .record(\n z.string().trim().min(1).max(128),\n z.union([\n z.string().max(512),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string().max(512), z.number(), z.boolean(), z.null()])),\n ])\n )\n .refine((data) => Object.keys(data).length <= 64),\n});\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,yBAAyB,EACnC,OAAO;AAAA,EACN,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;AAAA,EACrC,YAAY,EAAE,OAAO,OAAO;AAAA,EAC5B,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,MAAM,EAAE,OAAO;AAAA,IACb,IAAI,EAAE,OAAO,EAAE,SAAS;AAAA,IACxB,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,IAChC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,IAClC,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,IACrC,UAAU,EACP,KAAK,CAAC,OAAO,WAAW,OAAO,SAAS,WAAW,SAAS,SAAS,CAAC,EACtE,SAAS;AAAA,IACZ,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,IAC5B,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,IACrD,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,IACjC,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,IACnC,oBAAoB,EAAE,OAAO,EAAE,SAAS;AAAA,IACxC,mBAAmB,EAChB,OAAO,EACP,MAAM,WAAW,EACjB,UAAU,CAAC,MAAM,CAA0B,EAC3C,SA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
|
31
31
|
var web_exports = {};
|
|
32
32
|
__export(web_exports, {
|
|
33
33
|
getDeviceId: () => getDeviceId,
|
|
34
|
-
getTags: () => getTags
|
|
34
|
+
getTags: () => getTags,
|
|
35
|
+
storage: () => storage
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(web_exports);
|
|
37
38
|
var import_bowser = __toESM(require("bowser"), 1);
|
|
@@ -84,9 +85,14 @@ function getTags(release) {
|
|
|
84
85
|
};
|
|
85
86
|
return tags;
|
|
86
87
|
}
|
|
88
|
+
var storage = {
|
|
89
|
+
getItem: (key) => localStorage.getItem(key),
|
|
90
|
+
setItem: (key, value) => localStorage.setItem(key, value)
|
|
91
|
+
};
|
|
87
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
88
93
|
0 && (module.exports = {
|
|
89
94
|
getDeviceId,
|
|
90
|
-
getTags
|
|
95
|
+
getTags,
|
|
96
|
+
storage
|
|
91
97
|
});
|
|
92
98
|
//# sourceMappingURL=index.cjs.map
|
package/dist/web/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport * as cookie from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { TrackTags } from '../track/types';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem('device_id');\n if (cached) return cached;\n const id = crypto?.randomUUID ? crypto.randomUUID() : uuidv4();\n localStorage.setItem('device_id', id);\n return id;\n}\n\nexport function getTags(release: string) {\n const parser = Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = cookie.parse(document.cookie);\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n platform: 'web',\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: `${window.devicePixelRatio}`,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n release,\n language: navigator.language,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',\n source: 'web',\n source_url: window.location.origin + window.location.pathname,\n fbc: parsed._fbc,\n fbp: parsed._fbp,\n gclid: params.get('gclid') ?? undefined,\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n };\n return tags;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,aAAwB;AACxB,kBAA6B;
|
|
1
|
+
{"version":3,"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport * as cookie from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { TrackTags } from '../track/types';\nimport type { Storage } from '../setup/index';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem('device_id');\n if (cached) return cached;\n const id = crypto?.randomUUID ? crypto.randomUUID() : uuidv4();\n localStorage.setItem('device_id', id);\n return id;\n}\n\nexport function getTags(release: string) {\n const parser = Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = cookie.parse(document.cookie);\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n platform: 'web',\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: `${window.devicePixelRatio}`,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n release,\n language: navigator.language,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',\n source: 'web',\n source_url: window.location.origin + window.location.pathname,\n fbc: parsed._fbc,\n fbp: parsed._fbp,\n gclid: params.get('gclid') ?? undefined,\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n };\n return tags;\n}\n\nexport const storage: Storage = {\n getItem: (key) => localStorage.getItem(key),\n setItem: (key, value) => localStorage.setItem(key, value),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,aAAwB;AACxB,kBAA6B;AAItB,SAAS,cAAc;AAC5B,QAAM,SAAS,aAAa,QAAQ,WAAW;AAC/C,MAAI,OAAQ,QAAO;AACnB,QAAM,MAAK,iCAAQ,cAAa,OAAO,WAAW,QAAI,YAAAA,IAAO;AAC7D,eAAa,QAAQ,aAAa,EAAE;AACpC,SAAO;AACT;AAEO,SAAS,QAAQ,SAAiB;AACvC,QAAM,SAAS,cAAAC,QAAO,UAAU,OAAO,UAAU,SAAS;AAC1D,QAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACzD,QAAM,KAAK,OAAO,MAAM;AACxB,QAAM,UAAU,OAAO,WAAW;AAClC,QAAM,WAAW,OAAO,YAAY;AACpC,QAAM,SAAgB,aAAM,SAAS,MAAM;AAC3C,QAAM,OAAkB;AAAA,IACtB,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,OAAO;AAAA,IAC5B,SAAS,GAAG;AAAA,IACZ,YAAY,GAAG;AAAA,IACf,SAAS,GAAG,QAAQ,IAAI,IAAI,QAAQ,OAAO;AAAA,IAC3C,cAAc,QAAQ;AAAA,IACtB,iBAAiB,QAAQ;AAAA,IACzB,UAAU;AAAA,IACV,QAAQ,SAAS;AAAA,IACjB,WAAW,YAAY;AAAA,IACvB,aAAa,SAAS;AAAA,IACtB,eAAe,SAAS;AAAA,IACxB,oBAAoB,GAAG,OAAO,gBAAgB;AAAA,IAC9C,cAAc,OAAO,OAAO;AAAA,IAC5B,eAAe,OAAO,OAAO;AAAA,IAC7B,mBAAmB,GAAG,OAAO,OAAO,KAAK,IAAI,OAAO,OAAO,MAAM;AAAA,IACjE;AAAA,IACA,UAAU,UAAU;AAAA,IACpB,UAAU,KAAK,eAAe,EAAE,gBAAgB,EAAE;AAAA,IAClD,aAAa,QAAQ,IAAI,aAAa,gBAAgB,gBAAgB;AAAA,IACtE,QAAQ;AAAA,IACR,YAAY,OAAO,SAAS,SAAS,OAAO,SAAS;AAAA,IACrD,KAAK,OAAO;AAAA,IACZ,KAAK,OAAO;AAAA,IACZ,OAAO,OAAO,IAAI,OAAO,KAAK;AAAA,IAC9B,YAAY,OAAO,IAAI,YAAY,KAAK;AAAA,IACxC,YAAY,OAAO,IAAI,YAAY,KAAK;AAAA,IACxC,cAAc,OAAO,IAAI,cAAc,KAAK;AAAA,IAC5C,UAAU,OAAO,IAAI,UAAU,KAAK;AAAA,IACpC,aAAa,OAAO,IAAI,aAAa,KAAK;AAAA,EAC5C;AACA,SAAO;AACT;AAEO,IAAM,UAAmB;AAAA,EAC9B,SAAS,CAAC,QAAQ,aAAa,QAAQ,GAAG;AAAA,EAC1C,SAAS,CAAC,KAAK,UAAU,aAAa,QAAQ,KAAK,KAAK;AAC1D;","names":["uuidv4","Bowser"]}
|
package/dist/web/index.d.cts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { TrackTags } from '../track/types.cjs';
|
|
2
|
+
import { Storage } from '../setup/index.cjs';
|
|
2
3
|
import '../track/gtag.cjs';
|
|
4
|
+
import 'axios';
|
|
5
|
+
import '../visitor/types.cjs';
|
|
3
6
|
|
|
4
7
|
declare function getDeviceId(): string;
|
|
5
8
|
declare function getTags(release: string): TrackTags;
|
|
9
|
+
declare const storage: Storage;
|
|
6
10
|
|
|
7
|
-
export { getDeviceId, getTags };
|
|
11
|
+
export { getDeviceId, getTags, storage };
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { TrackTags } from '../track/types.js';
|
|
2
|
+
import { Storage } from '../setup/index.js';
|
|
2
3
|
import '../track/gtag.js';
|
|
4
|
+
import 'axios';
|
|
5
|
+
import '../visitor/types.js';
|
|
3
6
|
|
|
4
7
|
declare function getDeviceId(): string;
|
|
5
8
|
declare function getTags(release: string): TrackTags;
|
|
9
|
+
declare const storage: Storage;
|
|
6
10
|
|
|
7
|
-
export { getDeviceId, getTags };
|
|
11
|
+
export { getDeviceId, getTags, storage };
|
package/dist/web/index.mjs
CHANGED
|
@@ -49,8 +49,13 @@ function getTags(release) {
|
|
|
49
49
|
};
|
|
50
50
|
return tags;
|
|
51
51
|
}
|
|
52
|
+
var storage = {
|
|
53
|
+
getItem: (key) => localStorage.getItem(key),
|
|
54
|
+
setItem: (key, value) => localStorage.setItem(key, value)
|
|
55
|
+
};
|
|
52
56
|
export {
|
|
53
57
|
getDeviceId,
|
|
54
|
-
getTags
|
|
58
|
+
getTags,
|
|
59
|
+
storage
|
|
55
60
|
};
|
|
56
61
|
//# sourceMappingURL=index.mjs.map
|
package/dist/web/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport * as cookie from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { TrackTags } from '../track/types';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem('device_id');\n if (cached) return cached;\n const id = crypto?.randomUUID ? crypto.randomUUID() : uuidv4();\n localStorage.setItem('device_id', id);\n return id;\n}\n\nexport function getTags(release: string) {\n const parser = Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = cookie.parse(document.cookie);\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n platform: 'web',\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: `${window.devicePixelRatio}`,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n release,\n language: navigator.language,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',\n source: 'web',\n source_url: window.location.origin + window.location.pathname,\n fbc: parsed._fbc,\n fbp: parsed._fbp,\n gclid: params.get('gclid') ?? undefined,\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n };\n return tags;\n}\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,YAAY,YAAY;AACxB,SAAS,MAAM,cAAc;
|
|
1
|
+
{"version":3,"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport * as cookie from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { TrackTags } from '../track/types';\nimport type { Storage } from '../setup/index';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem('device_id');\n if (cached) return cached;\n const id = crypto?.randomUUID ? crypto.randomUUID() : uuidv4();\n localStorage.setItem('device_id', id);\n return id;\n}\n\nexport function getTags(release: string) {\n const parser = Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = cookie.parse(document.cookie);\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n platform: 'web',\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: `${window.devicePixelRatio}`,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n release,\n language: navigator.language,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',\n source: 'web',\n source_url: window.location.origin + window.location.pathname,\n fbc: parsed._fbc,\n fbp: parsed._fbp,\n gclid: params.get('gclid') ?? undefined,\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n };\n return tags;\n}\n\nexport const storage: Storage = {\n getItem: (key) => localStorage.getItem(key),\n setItem: (key, value) => localStorage.setItem(key, value),\n};\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,YAAY,YAAY;AACxB,SAAS,MAAM,cAAc;AAItB,SAAS,cAAc;AAC5B,QAAM,SAAS,aAAa,QAAQ,WAAW;AAC/C,MAAI,OAAQ,QAAO;AACnB,QAAM,MAAK,iCAAQ,cAAa,OAAO,WAAW,IAAI,OAAO;AAC7D,eAAa,QAAQ,aAAa,EAAE;AACpC,SAAO;AACT;AAEO,SAAS,QAAQ,SAAiB;AACvC,QAAM,SAAS,OAAO,UAAU,OAAO,UAAU,SAAS;AAC1D,QAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACzD,QAAM,KAAK,OAAO,MAAM;AACxB,QAAM,UAAU,OAAO,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