@shware/analytics 0.3.2 → 0.3.4
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 +11 -22
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.mjs +12 -23
- 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/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 +6 -6
package/dist/next/index.cjs
CHANGED
|
@@ -66,8 +66,8 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
66
66
|
}
|
|
67
67
|
function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
68
68
|
const pathname = (0, import_navigation.usePathname)();
|
|
69
|
-
const params = (0, import_navigation.useSearchParams)();
|
|
70
69
|
(0, import_react.useEffect)(() => {
|
|
70
|
+
const params = new URLSearchParams(document.location.search);
|
|
71
71
|
const properties = {
|
|
72
72
|
pathname,
|
|
73
73
|
referrer: document.referrer,
|
|
@@ -80,7 +80,7 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
80
80
|
utm_content: params.get("utm_content")
|
|
81
81
|
};
|
|
82
82
|
(0, import_track.track)("page_view", properties, { enableThirdPartyTracking: false });
|
|
83
|
-
}, [pathname
|
|
83
|
+
}, [pathname]);
|
|
84
84
|
(0, import_web_vitals.useReportWebVitals)((metric) => {
|
|
85
85
|
const properties = {
|
|
86
86
|
id: metric.id,
|
|
@@ -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
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAC1B,wBAA4B;AAC5B,wBAAmC;AACnC,oBAAmB;AACnB,mBAAsB;AACtB,iBAA2B;AAkFH;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,O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;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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/next/index.tsx
|
|
4
4
|
import { useEffect } from "react";
|
|
5
|
-
import { usePathname
|
|
5
|
+
import { usePathname } from "next/navigation";
|
|
6
6
|
import { useReportWebVitals } from "next/web-vitals";
|
|
7
7
|
import Script from "next/script";
|
|
8
8
|
import { track } from "../track/index.mjs";
|
|
@@ -31,8 +31,8 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
31
31
|
}
|
|
32
32
|
function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
33
33
|
const pathname = usePathname();
|
|
34
|
-
const params = useSearchParams();
|
|
35
34
|
useEffect(() => {
|
|
35
|
+
const params = new URLSearchParams(document.location.search);
|
|
36
36
|
const properties = {
|
|
37
37
|
pathname,
|
|
38
38
|
referrer: document.referrer,
|
|
@@ -45,7 +45,7 @@ function Analytics({ gaId, nonce, debugMode, pixelId, facebookAppId }) {
|
|
|
45
45
|
utm_content: params.get("utm_content")
|
|
46
46
|
};
|
|
47
47
|
track("page_view", properties, { enableThirdPartyTracking: false });
|
|
48
|
-
}, [pathname
|
|
48
|
+
}, [pathname]);
|
|
49
49
|
useReportWebVitals((metric) => {
|
|
50
50
|
const properties = {
|
|
51
51
|
id: metric.id,
|
|
@@ -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
|
|
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;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,QAAQ,OAAO;AAAA,MACf,OAAO,OAAO;AAAA,MACd,OAAO,OAAO;AAAA,MACd,iBAAiB,OAAO;AAAA,MACxB,iBAAiB;AAAA;AAAA,IACnB;AACA,UAAM,OAAO,MAAM,UAAU;AAAA,EAC/B,CAAC;AAED,SACE,iCACG;AAAA,qBAAiB,oBAAC,UAAK,UAAS,aAAY,SAAS,eAAe;AAAA,IACpE,QACC,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,IAAG;AAAA,UACH;AAAA,UACA,KAAK,+CAA+C,IAAI;AAAA;AAAA,MAC1D;AAAA,MACA;AAAA,QAAC;AAAA;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,gCACE;AAAA,MAAC;AAAA;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":[]}
|
|
@@ -120,13 +120,12 @@ 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
|
-
__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;AACvB,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,kCAAO,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;AACvC;AAEO,SAA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,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;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,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;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/web/index.cjs
CHANGED
|
@@ -31,7 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
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,MAA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AAY,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)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tE,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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shware/analytics",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"axios": "^1.8.
|
|
48
|
+
"axios": "^1.8.4",
|
|
49
49
|
"axios-retry": "^4.5.0",
|
|
50
50
|
"bowser": "^2.11.0",
|
|
51
51
|
"cookie": "^1.0.2",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/facebook-nodejs-business-sdk": "^20.0.2",
|
|
59
|
-
"@types/node": "^22.13.
|
|
60
|
-
"@types/react": "^19.0.
|
|
61
|
-
"typescript": "5.
|
|
59
|
+
"@types/node": "^22.13.13",
|
|
60
|
+
"@types/react": "^19.0.12",
|
|
61
|
+
"typescript": "^5.8.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"facebook-nodejs-business-sdk": "^22.0.0",
|
|
65
|
-
"next": ">=
|
|
65
|
+
"next": ">= 15",
|
|
66
66
|
"react": "^19.0.0",
|
|
67
67
|
"react-router": "^7"
|
|
68
68
|
},
|