@shware/analytics 2.12.4 → 2.13.1
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/feedback/index.cjs +10 -1
- package/dist/feedback/index.cjs.map +1 -1
- package/dist/feedback/index.mjs +10 -1
- package/dist/feedback/index.mjs.map +1 -1
- package/dist/hooks/use-click-id-persistence.cjs +48 -0
- package/dist/hooks/use-click-id-persistence.cjs.map +1 -0
- package/dist/hooks/use-click-id-persistence.d.cts +3 -0
- package/dist/hooks/use-click-id-persistence.d.ts +3 -0
- package/dist/hooks/use-click-id-persistence.mjs +23 -0
- package/dist/hooks/use-click-id-persistence.mjs.map +1 -0
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/link/index.cjs +22 -4
- package/dist/link/index.cjs.map +1 -1
- package/dist/link/index.mjs +22 -4
- package/dist/link/index.mjs.map +1 -1
- package/dist/native/index.d.cts +0 -1
- package/dist/native/index.d.ts +0 -1
- package/dist/native/setup.d.cts +0 -1
- package/dist/native/setup.d.ts +0 -1
- package/dist/next/index.cjs +2 -0
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.mjs +2 -0
- package/dist/next/index.mjs.map +1 -1
- package/dist/react-router/index.cjs +2 -0
- package/dist/react-router/index.cjs.map +1 -1
- package/dist/react-router/index.mjs +2 -0
- package/dist/react-router/index.mjs.map +1 -1
- package/dist/setup/index.cjs +9 -16
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +1 -2
- package/dist/setup/index.d.ts +1 -2
- package/dist/setup/index.mjs +9 -6
- package/dist/setup/index.mjs.map +1 -1
- package/dist/track/index.cjs +12 -3
- package/dist/track/index.cjs.map +1 -1
- package/dist/track/index.mjs +12 -3
- package/dist/track/index.mjs.map +1 -1
- package/dist/utils/storage.cjs +56 -0
- package/dist/utils/storage.cjs.map +1 -0
- package/dist/utils/storage.d.cts +10 -0
- package/dist/utils/storage.d.ts +10 -0
- package/dist/utils/storage.mjs +31 -0
- package/dist/utils/storage.mjs.map +1 -0
- package/dist/visitor/index.cjs +28 -19
- package/dist/visitor/index.cjs.map +1 -1
- package/dist/visitor/index.mjs +28 -19
- package/dist/visitor/index.mjs.map +1 -1
- package/dist/web/index.cjs +2 -1
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +0 -1
- package/dist/web/index.d.ts +0 -1
- package/dist/web/index.mjs +2 -1
- package/dist/web/index.mjs.map +1 -1
- package/package.json +4 -6
package/dist/feedback/index.cjs
CHANGED
|
@@ -24,8 +24,17 @@ __export(feedback_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(feedback_exports);
|
|
26
26
|
var import_setup = require("../setup/index.cjs");
|
|
27
|
+
var import_fetch = require("../utils/fetch.cjs");
|
|
27
28
|
async function sendFeedback(dto) {
|
|
28
|
-
await import_setup.config.
|
|
29
|
+
const response = await (0, import_fetch.fetch)(`${import_setup.config.endpoint}/feedback`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
credentials: "include",
|
|
32
|
+
headers: await import_setup.config.getHeaders(),
|
|
33
|
+
body: JSON.stringify(dto)
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error(`Failed to send feedback: ${response.status} ${await response.text()}`);
|
|
37
|
+
}
|
|
29
38
|
}
|
|
30
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
40
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport type { CreateFeedbackDTO } from '../schema/index';\n\nexport async function sendFeedback(dto: CreateFeedbackDTO) {\n await config.
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport { fetch } from '../utils/fetch';\nimport type { CreateFeedbackDTO } from '../schema/index';\n\nexport async function sendFeedback(dto: CreateFeedbackDTO) {\n const response = await fetch(`${config.endpoint}/feedback`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to send feedback: ${response.status} ${await response.text()}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AACvB,mBAAsB;AAGtB,eAAsB,aAAa,KAAwB;AACzD,QAAM,WAAW,UAAM,oBAAM,GAAG,oBAAO,QAAQ,aAAa;AAAA,IAC1D,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,MAAM,oBAAO,WAAW;AAAA,IACjC,MAAM,KAAK,UAAU,GAAG;AAAA,EAC1B,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,4BAA4B,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC,EAAE;AAAA,EACxF;AACF;","names":[]}
|
package/dist/feedback/index.mjs
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
// src/feedback/index.ts
|
|
2
2
|
import { config } from "../setup/index.mjs";
|
|
3
|
+
import { fetch } from "../utils/fetch.mjs";
|
|
3
4
|
async function sendFeedback(dto) {
|
|
4
|
-
await config.
|
|
5
|
+
const response = await fetch(`${config.endpoint}/feedback`, {
|
|
6
|
+
method: "POST",
|
|
7
|
+
credentials: "include",
|
|
8
|
+
headers: await config.getHeaders(),
|
|
9
|
+
body: JSON.stringify(dto)
|
|
10
|
+
});
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(`Failed to send feedback: ${response.status} ${await response.text()}`);
|
|
13
|
+
}
|
|
5
14
|
}
|
|
6
15
|
export {
|
|
7
16
|
sendFeedback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport type { CreateFeedbackDTO } from '../schema/index';\n\nexport async function sendFeedback(dto: CreateFeedbackDTO) {\n await config.
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport { fetch } from '../utils/fetch';\nimport type { CreateFeedbackDTO } from '../schema/index';\n\nexport async function sendFeedback(dto: CreateFeedbackDTO) {\n const response = await fetch(`${config.endpoint}/feedback`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to send feedback: ${response.status} ${await response.text()}`);\n }\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,eAAsB,aAAa,KAAwB;AACzD,QAAM,WAAW,MAAM,MAAM,GAAG,OAAO,QAAQ,aAAa;AAAA,IAC1D,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,MAAM,OAAO,WAAW;AAAA,IACjC,MAAM,KAAK,UAAU,GAAG;AAAA,EAC1B,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,4BAA4B,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC,EAAE;AAAA,EACxF;AACF;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/use-click-id-persistence.ts
|
|
21
|
+
var use_click_id_persistence_exports = {};
|
|
22
|
+
__export(use_click_id_persistence_exports, {
|
|
23
|
+
useClickIdPersistence: () => useClickIdPersistence
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_click_id_persistence_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_storage = require("../utils/storage.cjs");
|
|
28
|
+
function setCookie(name, value, ttlInMs) {
|
|
29
|
+
const d = /* @__PURE__ */ new Date();
|
|
30
|
+
d.setTime(d.getTime() + ttlInMs);
|
|
31
|
+
const expires = "expires=" + d.toUTCString();
|
|
32
|
+
document.cookie = `${name}=${value}; ${expires}; path=/; SameSite=Lax; Secure`;
|
|
33
|
+
}
|
|
34
|
+
function useClickIdPersistence() {
|
|
35
|
+
(0, import_react.useEffect)(() => {
|
|
36
|
+
const fbclid = new URLSearchParams(window.location.search).get("fbclid");
|
|
37
|
+
if (!fbclid) return;
|
|
38
|
+
const fbc = `fb.1.${Date.now()}.${fbclid}`;
|
|
39
|
+
const ttlMs = 90 * 24 * 60 * 60 * 1e3;
|
|
40
|
+
setCookie("_fbc", fbc, ttlMs);
|
|
41
|
+
import_storage.expiringStorage.setItem("fbc", fbc, ttlMs);
|
|
42
|
+
}, []);
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
useClickIdPersistence
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=use-click-id-persistence.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-click-id-persistence.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { expiringStorage } from '../utils/storage';\n\nfunction setCookie(name: string, value: string, ttlInMs: number) {\n const d = new Date();\n d.setTime(d.getTime() + ttlInMs);\n const expires = 'expires=' + d.toUTCString();\n document.cookie = `${name}=${value}; ${expires}; path=/; SameSite=Lax; Secure`;\n}\n\n// todo: do not set tracking cookies before the user has granted consent where required.\n// reference: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc/#3--store-clickid\n// reference: https://watsspace.com/blog/meta-conversions-api-fbc-and-fbp-parameters/\nexport function useClickIdPersistence() {\n useEffect(() => {\n const fbclid = new URLSearchParams(window.location.search).get('fbclid');\n if (!fbclid) return;\n const fbc = `fb.1.${Date.now()}.${fbclid}`;\n // common practice ~90 days\n const ttlMs = 90 * 24 * 60 * 60 * 1000;\n setCookie('_fbc', fbc, ttlMs);\n expiringStorage.setItem('fbc', fbc, ttlMs);\n }, []);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,qBAAgC;AAEhC,SAAS,UAAU,MAAc,OAAe,SAAiB;AAC/D,QAAM,IAAI,oBAAI,KAAK;AACnB,IAAE,QAAQ,EAAE,QAAQ,IAAI,OAAO;AAC/B,QAAM,UAAU,aAAa,EAAE,YAAY;AAC3C,WAAS,SAAS,GAAG,IAAI,IAAI,KAAK,KAAK,OAAO;AAChD;AAKO,SAAS,wBAAwB;AACtC,8BAAU,MAAM;AACd,UAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,QAAQ;AACvE,QAAI,CAAC,OAAQ;AACb,UAAM,MAAM,QAAQ,KAAK,IAAI,CAAC,IAAI,MAAM;AAExC,UAAM,QAAQ,KAAK,KAAK,KAAK,KAAK;AAClC,cAAU,QAAQ,KAAK,KAAK;AAC5B,mCAAgB,QAAQ,OAAO,KAAK,KAAK;AAAA,EAC3C,GAAG,CAAC,CAAC;AACP;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/hooks/use-click-id-persistence.ts
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { expiringStorage } from "../utils/storage.mjs";
|
|
4
|
+
function setCookie(name, value, ttlInMs) {
|
|
5
|
+
const d = /* @__PURE__ */ new Date();
|
|
6
|
+
d.setTime(d.getTime() + ttlInMs);
|
|
7
|
+
const expires = "expires=" + d.toUTCString();
|
|
8
|
+
document.cookie = `${name}=${value}; ${expires}; path=/; SameSite=Lax; Secure`;
|
|
9
|
+
}
|
|
10
|
+
function useClickIdPersistence() {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const fbclid = new URLSearchParams(window.location.search).get("fbclid");
|
|
13
|
+
if (!fbclid) return;
|
|
14
|
+
const fbc = `fb.1.${Date.now()}.${fbclid}`;
|
|
15
|
+
const ttlMs = 90 * 24 * 60 * 60 * 1e3;
|
|
16
|
+
setCookie("_fbc", fbc, ttlMs);
|
|
17
|
+
expiringStorage.setItem("fbc", fbc, ttlMs);
|
|
18
|
+
}, []);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
useClickIdPersistence
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=use-click-id-persistence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-click-id-persistence.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { expiringStorage } from '../utils/storage';\n\nfunction setCookie(name: string, value: string, ttlInMs: number) {\n const d = new Date();\n d.setTime(d.getTime() + ttlInMs);\n const expires = 'expires=' + d.toUTCString();\n document.cookie = `${name}=${value}; ${expires}; path=/; SameSite=Lax; Secure`;\n}\n\n// todo: do not set tracking cookies before the user has granted consent where required.\n// reference: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc/#3--store-clickid\n// reference: https://watsspace.com/blog/meta-conversions-api-fbc-and-fbp-parameters/\nexport function useClickIdPersistence() {\n useEffect(() => {\n const fbclid = new URLSearchParams(window.location.search).get('fbclid');\n if (!fbclid) return;\n const fbc = `fb.1.${Date.now()}.${fbclid}`;\n // common practice ~90 days\n const ttlMs = 90 * 24 * 60 * 60 * 1000;\n setCookie('_fbc', fbc, ttlMs);\n expiringStorage.setItem('fbc', fbc, ttlMs);\n }, []);\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAEhC,SAAS,UAAU,MAAc,OAAe,SAAiB;AAC/D,QAAM,IAAI,oBAAI,KAAK;AACnB,IAAE,QAAQ,EAAE,QAAQ,IAAI,OAAO;AAC/B,QAAM,UAAU,aAAa,EAAE,YAAY;AAC3C,WAAS,SAAS,GAAG,IAAI,IAAI,KAAK,KAAK,OAAO;AAChD;AAKO,SAAS,wBAAwB;AACtC,YAAU,MAAM;AACd,UAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,QAAQ;AACvE,QAAI,CAAC,OAAQ;AACb,UAAM,MAAM,QAAQ,KAAK,IAAI,CAAC,IAAI,MAAM;AAExC,UAAM,QAAQ,KAAK,KAAK,KAAK,KAAK;AAClC,cAAU,QAAQ,KAAK,KAAK;AAC5B,oBAAgB,QAAQ,OAAO,KAAK,KAAK;AAAA,EAC3C,GAAG,CAAC,CAAC;AACP;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -7,6 +7,5 @@ export { CreateFeedbackDTO, CreateLinkDTO, createFeedbackSchema, createLinkSchem
|
|
|
7
7
|
export { stripeMinorUnits } from './utils/stripe.cjs';
|
|
8
8
|
export { AllowedPropertyValues, TrackProperties, TrackTags, UserProvidedData } from './track/types.cjs';
|
|
9
9
|
export { VisitorProperties } from './visitor/types.cjs';
|
|
10
|
-
import 'axios';
|
|
11
10
|
import 'zod/mini';
|
|
12
11
|
import './track/gtag.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,5 @@ export { CreateFeedbackDTO, CreateLinkDTO, createFeedbackSchema, createLinkSchem
|
|
|
7
7
|
export { stripeMinorUnits } from './utils/stripe.js';
|
|
8
8
|
export { AllowedPropertyValues, TrackProperties, TrackTags, UserProvidedData } from './track/types.js';
|
|
9
9
|
export { VisitorProperties } from './visitor/types.js';
|
|
10
|
-
import 'axios';
|
|
11
10
|
import 'zod/mini';
|
|
12
11
|
import './track/gtag.js';
|
package/dist/link/index.cjs
CHANGED
|
@@ -25,15 +25,33 @@ __export(link_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(link_exports);
|
|
27
27
|
var import_setup = require("../setup/index.cjs");
|
|
28
|
+
var import_fetch = require("../utils/fetch.cjs");
|
|
28
29
|
async function createLink(dto) {
|
|
29
|
-
const response = await import_setup.config.
|
|
30
|
-
|
|
30
|
+
const response = await (0, import_fetch.fetch)(`${import_setup.config.endpoint}/links`, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
credentials: "include",
|
|
33
|
+
headers: await import_setup.config.getHeaders(),
|
|
34
|
+
body: JSON.stringify(dto)
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);
|
|
38
|
+
}
|
|
39
|
+
return response.json();
|
|
31
40
|
}
|
|
32
41
|
async function getLink(id) {
|
|
33
42
|
try {
|
|
34
|
-
const response = await import_setup.config.
|
|
35
|
-
|
|
43
|
+
const response = await (0, import_fetch.fetch)(`${import_setup.config.endpoint}/links/${id}`, {
|
|
44
|
+
method: "GET",
|
|
45
|
+
credentials: "include",
|
|
46
|
+
headers: await import_setup.config.getHeaders()
|
|
47
|
+
});
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
console.error(`Failed to get link(${id}): ${response.status} ${await response.text()}`);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return response.json();
|
|
36
53
|
} catch {
|
|
54
|
+
console.error(`Failed to get link(${id}): network error`);
|
|
37
55
|
return null;
|
|
38
56
|
}
|
|
39
57
|
}
|
package/dist/link/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/link/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport type { CreateLinkDTO } from '../schema/index';\n\nexport interface Link extends CreateLinkDTO {\n id: string;\n created_at: string;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await config.
|
|
1
|
+
{"version":3,"sources":["../../src/link/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport { fetch } from '../utils/fetch';\nimport type { CreateLinkDTO } from '../schema/index';\n\nexport interface Link extends CreateLinkDTO {\n id: string;\n created_at: string;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await fetch(`${config.endpoint}/links`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);\n }\n return response.json() as Promise<Link>;\n}\n\nexport async function getLink(id: string): Promise<Link | null> {\n try {\n const response = await fetch(`${config.endpoint}/links/${id}`, {\n method: 'GET',\n credentials: 'include',\n headers: await config.getHeaders(),\n });\n\n if (!response.ok) {\n console.error(`Failed to get link(${id}): ${response.status} ${await response.text()}`);\n return null;\n }\n return response.json() as Promise<Link>;\n } catch {\n console.error(`Failed to get link(${id}): network error`);\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AACvB,mBAAsB;AAQtB,eAAsB,WAAW,KAAoB;AACnD,QAAM,WAAW,UAAM,oBAAM,GAAG,oBAAO,QAAQ,UAAU;AAAA,IACvD,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,MAAM,oBAAO,WAAW;AAAA,IACjC,MAAM,KAAK,UAAU,GAAG;AAAA,EAC1B,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,0BAA0B,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC,EAAE;AAAA,EACtF;AACA,SAAO,SAAS,KAAK;AACvB;AAEA,eAAsB,QAAQ,IAAkC;AAC9D,MAAI;AACF,UAAM,WAAW,UAAM,oBAAM,GAAG,oBAAO,QAAQ,UAAU,EAAE,IAAI;AAAA,MAC7D,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS,MAAM,oBAAO,WAAW;AAAA,IACnC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,cAAQ,MAAM,sBAAsB,EAAE,MAAM,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC,EAAE;AACtF,aAAO;AAAA,IACT;AACA,WAAO,SAAS,KAAK;AAAA,EACvB,QAAQ;AACN,YAAQ,MAAM,sBAAsB,EAAE,kBAAkB;AACxD,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/link/index.mjs
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
// src/link/index.ts
|
|
2
2
|
import { config } from "../setup/index.mjs";
|
|
3
|
+
import { fetch } from "../utils/fetch.mjs";
|
|
3
4
|
async function createLink(dto) {
|
|
4
|
-
const response = await config.
|
|
5
|
-
|
|
5
|
+
const response = await fetch(`${config.endpoint}/links`, {
|
|
6
|
+
method: "POST",
|
|
7
|
+
credentials: "include",
|
|
8
|
+
headers: await config.getHeaders(),
|
|
9
|
+
body: JSON.stringify(dto)
|
|
10
|
+
});
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);
|
|
13
|
+
}
|
|
14
|
+
return response.json();
|
|
6
15
|
}
|
|
7
16
|
async function getLink(id) {
|
|
8
17
|
try {
|
|
9
|
-
const response = await config.
|
|
10
|
-
|
|
18
|
+
const response = await fetch(`${config.endpoint}/links/${id}`, {
|
|
19
|
+
method: "GET",
|
|
20
|
+
credentials: "include",
|
|
21
|
+
headers: await config.getHeaders()
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
console.error(`Failed to get link(${id}): ${response.status} ${await response.text()}`);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return response.json();
|
|
11
28
|
} catch {
|
|
29
|
+
console.error(`Failed to get link(${id}): network error`);
|
|
12
30
|
return null;
|
|
13
31
|
}
|
|
14
32
|
}
|
package/dist/link/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/link/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport type { CreateLinkDTO } from '../schema/index';\n\nexport interface Link extends CreateLinkDTO {\n id: string;\n created_at: string;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await config.
|
|
1
|
+
{"version":3,"sources":["../../src/link/index.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport { fetch } from '../utils/fetch';\nimport type { CreateLinkDTO } from '../schema/index';\n\nexport interface Link extends CreateLinkDTO {\n id: string;\n created_at: string;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await fetch(`${config.endpoint}/links`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);\n }\n return response.json() as Promise<Link>;\n}\n\nexport async function getLink(id: string): Promise<Link | null> {\n try {\n const response = await fetch(`${config.endpoint}/links/${id}`, {\n method: 'GET',\n credentials: 'include',\n headers: await config.getHeaders(),\n });\n\n if (!response.ok) {\n console.error(`Failed to get link(${id}): ${response.status} ${await response.text()}`);\n return null;\n }\n return response.json() as Promise<Link>;\n } catch {\n console.error(`Failed to get link(${id}): network error`);\n return null;\n }\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,aAAa;AAQtB,eAAsB,WAAW,KAAoB;AACnD,QAAM,WAAW,MAAM,MAAM,GAAG,OAAO,QAAQ,UAAU;AAAA,IACvD,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,MAAM,OAAO,WAAW;AAAA,IACjC,MAAM,KAAK,UAAU,GAAG;AAAA,EAC1B,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,0BAA0B,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC,EAAE;AAAA,EACtF;AACA,SAAO,SAAS,KAAK;AACvB;AAEA,eAAsB,QAAQ,IAAkC;AAC9D,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,GAAG,OAAO,QAAQ,UAAU,EAAE,IAAI;AAAA,MAC7D,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS,MAAM,OAAO,WAAW;AAAA,IACnC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,cAAQ,MAAM,sBAAsB,EAAE,MAAM,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC,EAAE;AACtF,aAAO;AAAA,IACT;AACA,WAAO,SAAS,KAAK;AAAA,EACvB,QAAQ;AACN,YAAQ,MAAM,sBAAsB,EAAE,kBAAkB;AACxD,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/native/index.d.cts
CHANGED
|
@@ -2,7 +2,6 @@ export { getDeviceId, getDeviceType, getTags, storage } from './setup.cjs';
|
|
|
2
2
|
export { useScreenViewAnalytics } from './analytics.cjs';
|
|
3
3
|
export { DeterministicFingerprint, ProbabilisticFingerprint, getDeterministicFingerprint, getProbabilisticFingerprint } from './fingerprint.cjs';
|
|
4
4
|
import '../setup/index.cjs';
|
|
5
|
-
import 'axios';
|
|
6
5
|
import '../track/types.cjs';
|
|
7
6
|
import '../track/gtag.cjs';
|
|
8
7
|
import '../visitor/types.cjs';
|
package/dist/native/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export { getDeviceId, getDeviceType, getTags, storage } from './setup.js';
|
|
|
2
2
|
export { useScreenViewAnalytics } from './analytics.js';
|
|
3
3
|
export { DeterministicFingerprint, ProbabilisticFingerprint, getDeterministicFingerprint, getProbabilisticFingerprint } from './fingerprint.js';
|
|
4
4
|
import '../setup/index.js';
|
|
5
|
-
import 'axios';
|
|
6
5
|
import '../track/types.js';
|
|
7
6
|
import '../track/gtag.js';
|
|
8
7
|
import '../visitor/types.js';
|
package/dist/native/setup.d.cts
CHANGED
package/dist/native/setup.d.ts
CHANGED
package/dist/next/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(next_exports);
|
|
|
37
37
|
var import_navigation = require("next/navigation");
|
|
38
38
|
var import_script = __toESM(require("next/script"), 1);
|
|
39
39
|
var import_web_vitals = require("next/web-vitals");
|
|
40
|
+
var import_use_click_id_persistence = require("../hooks/use-click-id-persistence.cjs");
|
|
40
41
|
var import_use_page_view_analytics = require("../hooks/use-page-view-analytics.cjs");
|
|
41
42
|
var import_track = require("../track/index.cjs");
|
|
42
43
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -53,6 +54,7 @@ function Analytics({
|
|
|
53
54
|
}) {
|
|
54
55
|
const pathname = (0, import_navigation.usePathname)();
|
|
55
56
|
(0, import_use_page_view_analytics.usePageViewAnalytics)(pathname);
|
|
57
|
+
(0, import_use_click_id_persistence.useClickIdPersistence)();
|
|
56
58
|
(0, import_web_vitals.useReportWebVitals)((metric) => {
|
|
57
59
|
if (!reportWebVitals) return;
|
|
58
60
|
const properties = {
|
package/dist/next/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n hotjarId?: HotjarId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n hotjarId,\n redditPixelId,\n linkedInPartnerId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const pathname = usePathname();\n usePageViewAnalytics(pathname);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <Script\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <Script\n id=\"reddit-pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <Script\n id=\"linkedin-insight-tag\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){ \n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <Script\n id=\"hotjar\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAA4B;AAC5B,oBAAmB;AACnB,wBAAmC;AACnC,qCAAqC;AACrC,mBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n hotjarId?: HotjarId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n hotjarId,\n redditPixelId,\n linkedInPartnerId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const pathname = usePathname();\n usePageViewAnalytics(pathname);\n\n useClickIdPersistence();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <Script\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <Script\n id=\"reddit-pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <Script\n id=\"linkedin-insight-tag\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){ \n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <Script\n id=\"hotjar\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAA4B;AAC5B,oBAAmB;AACnB,wBAAmC;AACnC,sCAAsC;AACtC,qCAAqC;AACrC,mBAAsB;AAmDE;AA/BjB,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAAU;AACR,QAAM,eAAW,+BAAY;AAC7B,2DAAqB,QAAQ;AAE7B,6DAAsB;AAEtB,4CAAmB,CAAC,WAAW;AAC7B,QAAI,CAAC,gBAAiB;AACtB,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,eACC;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,2BAiBO,WAAW;AAAA;AAAA,QAE5B;AAAA;AAAA,IACF;AAAA,IAED,iBACC;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,2BAcO,aAAa;AAAA;AAAA,QAE9B;AAAA;AAAA,IACF;AAAA,IAED,qBACC;AAAA,MAAC,cAAAA;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACvB,QAAQ;AAAA,wCACoB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAkB/C;AAAA;AAAA,IACF;AAAA,IAED,YACC;AAAA,MAAC,cAAAA;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA,oCAGgB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOlC;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;","names":["Script"]}
|
package/dist/next/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { usePathname } from "next/navigation";
|
|
5
5
|
import Script from "next/script";
|
|
6
6
|
import { useReportWebVitals } from "next/web-vitals";
|
|
7
|
+
import { useClickIdPersistence } from "../hooks/use-click-id-persistence.mjs";
|
|
7
8
|
import { usePageViewAnalytics } from "../hooks/use-page-view-analytics.mjs";
|
|
8
9
|
import { track } from "../track/index.mjs";
|
|
9
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -20,6 +21,7 @@ function Analytics({
|
|
|
20
21
|
}) {
|
|
21
22
|
const pathname = usePathname();
|
|
22
23
|
usePageViewAnalytics(pathname);
|
|
24
|
+
useClickIdPersistence();
|
|
23
25
|
useReportWebVitals((metric) => {
|
|
24
26
|
if (!reportWebVitals) return;
|
|
25
27
|
const properties = {
|
package/dist/next/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n hotjarId?: HotjarId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n hotjarId,\n redditPixelId,\n linkedInPartnerId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const pathname = usePathname();\n usePageViewAnalytics(pathname);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <Script\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <Script\n id=\"reddit-pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <Script\n id=\"linkedin-insight-tag\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){ \n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <Script\n id=\"hotjar\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B,OAAO,YAAY;AACnB,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,aAAa;
|
|
1
|
+
{"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n hotjarId?: HotjarId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n hotjarId,\n redditPixelId,\n linkedInPartnerId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const pathname = usePathname();\n usePageViewAnalytics(pathname);\n\n useClickIdPersistence();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <Script\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <Script\n id=\"reddit-pixel\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <Script\n id=\"linkedin-insight-tag\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){ \n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <Script\n id=\"hotjar\"\n strategy=\"afterInteractive\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B,OAAO,YAAY;AACnB,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AACrC,SAAS,aAAa;AAmDE,SAEhB,UAFgB,KAEhB,YAFgB;AA/BjB,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAAU;AACR,QAAM,WAAW,YAAY;AAC7B,uBAAqB,QAAQ;AAE7B,wBAAsB;AAEtB,qBAAmB,CAAC,WAAW;AAC7B,QAAI,CAAC,gBAAiB;AACtB,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,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,eACC;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,2BAiBO,WAAW;AAAA;AAAA,QAE5B;AAAA;AAAA,IACF;AAAA,IAED,iBACC;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,2BAcO,aAAa;AAAA;AAAA,QAE9B;AAAA;AAAA,IACF;AAAA,IAED,qBACC;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACvB,QAAQ;AAAA,wCACoB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAkB/C;AAAA;AAAA,IACF;AAAA,IAED,YACC;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA,oCAGgB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOlC;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -26,6 +26,7 @@ module.exports = __toCommonJS(react_router_exports);
|
|
|
26
26
|
var import_react = require("react");
|
|
27
27
|
var import_react_router = require("react-router");
|
|
28
28
|
var import_web_vitals = require("web-vitals");
|
|
29
|
+
var import_use_click_id_persistence = require("../hooks/use-click-id-persistence.cjs");
|
|
29
30
|
var import_use_page_view_analytics = require("../hooks/use-page-view-analytics.cjs");
|
|
30
31
|
var import_track = require("../track/index.cjs");
|
|
31
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -51,6 +52,7 @@ function Analytics({
|
|
|
51
52
|
}) {
|
|
52
53
|
const { pathname } = (0, import_react_router.useLocation)();
|
|
53
54
|
(0, import_use_page_view_analytics.usePageViewAnalytics)(pathname);
|
|
55
|
+
(0, import_use_click_id_persistence.useClickIdPersistence)();
|
|
54
56
|
useReportWebVitals((metric) => {
|
|
55
57
|
if (!reportWebVitals) return;
|
|
56
58
|
const properties = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: HotjarId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const { pathname } = useLocation();\n usePageViewAnalytics(pathname);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <script\n async\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,0BAA4B;AAC5B,wBAAgE;AAChE,qCAAqC;AACrC,mBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: HotjarId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const { pathname } = useLocation();\n usePageViewAnalytics(pathname);\n\n useClickIdPersistence();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <script\n async\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,0BAA4B;AAC5B,wBAAgE;AAChE,sCAAsC;AACtC,qCAAqC;AACrC,mBAAsB;AA6DE;AAtDxB,SAAS,mBAAmB,mBAA6C;AACvE,8BAAU,MAAM;AACd,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,kCAAO,iBAAiB;AAAA,EAC1B,GAAG,CAAC,iBAAiB,CAAC;AACxB;AAeO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAAU;AACR,QAAM,EAAE,SAAS,QAAI,iCAAY;AACjC,2DAAqB,QAAQ;AAE7B,6DAAsB;AAEtB,qBAAmB,CAAC,WAAW;AAC7B,QAAI,CAAC,gBAAiB;AACtB,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,eACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAiBO,WAAW;AAAA;AAAA,QAE5B;AAAA;AAAA,IACF;AAAA,IAED,iBACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAcO,aAAa;AAAA;AAAA,QAE9B;AAAA;AAAA,IACF;AAAA,IAED,qBACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA,sCACkB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAkB7C;AAAA;AAAA,IACF;AAAA,IAED,YACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA,oCAGgB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOlC;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { useLocation } from "react-router";
|
|
4
4
|
import { onCLS, onFCP, onINP, onLCP, onTTFB } from "web-vitals";
|
|
5
|
+
import { useClickIdPersistence } from "../hooks/use-click-id-persistence.mjs";
|
|
5
6
|
import { usePageViewAnalytics } from "../hooks/use-page-view-analytics.mjs";
|
|
6
7
|
import { track } from "../track/index.mjs";
|
|
7
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -27,6 +28,7 @@ function Analytics({
|
|
|
27
28
|
}) {
|
|
28
29
|
const { pathname } = useLocation();
|
|
29
30
|
usePageViewAnalytics(pathname);
|
|
31
|
+
useClickIdPersistence();
|
|
30
32
|
useReportWebVitals((metric) => {
|
|
31
33
|
if (!reportWebVitals) return;
|
|
32
34
|
const properties = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: HotjarId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const { pathname } = useLocation();\n usePageViewAnalytics(pathname);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <script\n async\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAsB,OAAO,OAAO,OAAO,OAAO,cAAc;AAChE,SAAS,4BAA4B;AACrC,SAAS,aAAa;
|
|
1
|
+
{"version":3,"sources":["../../src/react-router/index.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { usePageViewAnalytics } from '../hooks/use-page-view-analytics';\nimport { track } from '../track/index';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\ntype HotjarId = `${number}`;\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: HotjarId;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n nonce,\n debugMode,\n metaPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n const { pathname } = useLocation();\n usePageViewAnalytics(pathname);\n\n useClickIdPersistence();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\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 {metaPixelId && (\n <script\n async\n id=\"meta-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', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAsB,OAAO,OAAO,OAAO,OAAO,cAAc;AAChE,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AACrC,SAAS,aAAa;AA6DE,SAEhB,UAFgB,KAEhB,YAFgB;AAtDxB,SAAS,mBAAmB,mBAA6C;AACvE,YAAU,MAAM;AACd,UAAM,iBAAiB;AACvB,UAAM,iBAAiB;AACvB,UAAM,iBAAiB;AACvB,UAAM,iBAAiB;AACvB,WAAO,iBAAiB;AAAA,EAC1B,GAAG,CAAC,iBAAiB,CAAC;AACxB;AAeO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAAU;AACR,QAAM,EAAE,SAAS,IAAI,YAAY;AACjC,uBAAqB,QAAQ;AAE7B,wBAAsB;AAEtB,qBAAmB,CAAC,WAAW;AAC7B,QAAI,CAAC,gBAAiB;AACtB,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,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,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,eACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAiBO,WAAW;AAAA;AAAA,QAE5B;AAAA;AAAA,IACF;AAAA,IAED,iBACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAcO,aAAa;AAAA;AAAA,QAE9B;AAAA;AAAA,IACF;AAAA,IAED,qBACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA,sCACkB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAkB7C;AAAA;AAAA,IACF;AAAA,IAED,YACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA,oCAGgB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOlC;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;","names":[]}
|
package/dist/setup/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/setup/index.ts
|
|
@@ -34,10 +24,8 @@ __export(setup_exports, {
|
|
|
34
24
|
setupAnalytics: () => setupAnalytics
|
|
35
25
|
});
|
|
36
26
|
module.exports = __toCommonJS(setup_exports);
|
|
37
|
-
var import_axios = __toESM(require("axios"), 1);
|
|
38
|
-
var import_axios_retry = __toESM(require("axios-retry"), 1);
|
|
39
27
|
var config = {
|
|
40
|
-
|
|
28
|
+
endpoint: "",
|
|
41
29
|
release: "0.0.0",
|
|
42
30
|
storage: null,
|
|
43
31
|
getTags: null,
|
|
@@ -49,13 +37,18 @@ var config = {
|
|
|
49
37
|
function setupAnalytics(init) {
|
|
50
38
|
config.release = init.release;
|
|
51
39
|
config.storage = init.storage;
|
|
40
|
+
config.endpoint = init.endpoint;
|
|
52
41
|
config.getTags = init.getTags;
|
|
53
42
|
config.getDeviceId = init.getDeviceId;
|
|
54
|
-
config.getHeaders =
|
|
43
|
+
config.getHeaders = async () => {
|
|
44
|
+
var _a;
|
|
45
|
+
return {
|
|
46
|
+
"Content-Type": "application/json",
|
|
47
|
+
...await ((_a = init.getHeaders) == null ? void 0 : _a.call(init))
|
|
48
|
+
};
|
|
49
|
+
};
|
|
55
50
|
config.thirdPartyTrackers = init.thirdPartyTrackers ?? [];
|
|
56
51
|
config.thirdPartyUserSetters = init.thirdPartyUserSetters ?? [];
|
|
57
|
-
config.http = import_axios.default.create({ baseURL: init.endpoint, withCredentials: true, adapter: "fetch" });
|
|
58
|
-
(0, import_axios_retry.default)(config.http, { retries: 5, retryDelay: import_axios_retry.default.exponentialDelay });
|
|
59
52
|
}
|
|
60
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
54
|
0 && (module.exports = {
|