aesirx-analytics 2.2.11 → 2.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/{Consent-57MTI7TD.js → Consent-BZPDMZRF.js} +17 -12
- package/dist/ConsentCustom-JYEILOEZ.js +1178 -0
- package/dist/analytics.js +1141 -338
- package/dist/{chunk-5VSCCPP6.js → chunk-MPD57P7C.js} +1058 -309
- package/dist/chunk-N4WREXIA.js +1810 -0
- package/dist/chunk-UJTYOAT7.js +464 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +115 -471
- package/package.json +4 -4
- package/dist/ConsentCustom-EZS7JI2G.js +0 -934
- package/dist/chunk-N36VEWSG.js +0 -1388
package/dist/index.js
CHANGED
@@ -1,473 +1,24 @@
|
|
1
|
+
import {
|
2
|
+
endTracker,
|
3
|
+
endTrackerVisibilityState,
|
4
|
+
fingerprint_default,
|
5
|
+
startTracker,
|
6
|
+
trackEvent
|
7
|
+
} from "./chunk-UJTYOAT7.js";
|
1
8
|
import {
|
2
9
|
AnalyticsContext,
|
3
10
|
AnalyticsContextProvider_default,
|
4
|
-
|
5
|
-
|
11
|
+
bg_default,
|
12
|
+
getConsentTemplate,
|
13
|
+
privacy_default,
|
14
|
+
useTranslation
|
15
|
+
} from "./chunk-N4WREXIA.js";
|
6
16
|
|
7
17
|
// src/AnalyticsNext/index.tsx
|
8
18
|
import React2, { useEffect as useEffect2, useState as useState2 } from "react";
|
9
19
|
|
10
20
|
// src/AnalyticsNext/handle.tsx
|
11
21
|
import React, { useCallback, useEffect, useState } from "react";
|
12
|
-
|
13
|
-
// src/utils/services.ts
|
14
|
-
var cache;
|
15
|
-
var assign = (a, b) => {
|
16
|
-
Object.keys(b).forEach((key) => {
|
17
|
-
if (b[key] !== void 0)
|
18
|
-
a[key] = b[key];
|
19
|
-
});
|
20
|
-
return a;
|
21
|
-
};
|
22
|
-
var trackerService = async (endpoint, payload) => {
|
23
|
-
const fetchData = await fetch(endpoint, {
|
24
|
-
method: "POST",
|
25
|
-
body: JSON.stringify(payload),
|
26
|
-
headers: assign({ "Content-Type": "application/json" }, { ["x-tracker-cache"]: cache })
|
27
|
-
});
|
28
|
-
const response = await fetchData.json();
|
29
|
-
if (response.error) {
|
30
|
-
throw response.error;
|
31
|
-
} else {
|
32
|
-
return response;
|
33
|
-
}
|
34
|
-
};
|
35
|
-
|
36
|
-
// src/utils/index.ts
|
37
|
-
import Bowser from "bowser";
|
38
|
-
|
39
|
-
// src/lib/envHelper.ts
|
40
|
-
var getHashKey = () => {
|
41
|
-
let value = null;
|
42
|
-
try {
|
43
|
-
if (typeof process.env != "undefined") {
|
44
|
-
value = process.env.SECURE_LOCAL_STORAGE_HASH_KEY || process.env.REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY || process.env.VITE_SECURE_LOCAL_STORAGE_HASH_KEY;
|
45
|
-
} else {
|
46
|
-
console.warn(`react-secure-storage : process is not defined! Just a warning!`);
|
47
|
-
}
|
48
|
-
} catch (ex) {
|
49
|
-
return null;
|
50
|
-
}
|
51
|
-
return value;
|
52
|
-
};
|
53
|
-
var getStoragePrefix = () => {
|
54
|
-
let value = null;
|
55
|
-
try {
|
56
|
-
if (typeof process.env != "undefined") {
|
57
|
-
value = process.env.SECURE_LOCAL_STORAGE_PREFIX || process.env.REACT_APP_SECURE_LOCAL_STORAGE_PREFIX || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX || process.env.VITE_SECURE_LOCAL_STORAGE_PREFIX;
|
58
|
-
} else {
|
59
|
-
console.warn(`react-secure-storage : process is not defined! Just a warning!`);
|
60
|
-
}
|
61
|
-
} catch (ex) {
|
62
|
-
return null;
|
63
|
-
}
|
64
|
-
return value;
|
65
|
-
};
|
66
|
-
var getDisabledKeys = () => {
|
67
|
-
let value = null;
|
68
|
-
try {
|
69
|
-
if (typeof process.env != "undefined") {
|
70
|
-
value = process.env.SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.REACT_APP_SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.VITE_SECURE_LOCAL_STORAGE_DISABLED_KEYS;
|
71
|
-
} else {
|
72
|
-
console.warn(`react-secure-storage : process is not defined! Just a warning!`);
|
73
|
-
}
|
74
|
-
} catch (ex) {
|
75
|
-
return null;
|
76
|
-
}
|
77
|
-
return value;
|
78
|
-
};
|
79
|
-
var envHelper = {
|
80
|
-
getHashKey,
|
81
|
-
getStoragePrefix,
|
82
|
-
getDisabledKeys
|
83
|
-
};
|
84
|
-
var envHelper_default = envHelper;
|
85
|
-
|
86
|
-
// src/lib/fingerpint.lib.ts
|
87
|
-
import murmurhash3_32_gc from "murmurhash-js/murmurhash3_gc";
|
88
|
-
|
89
|
-
// src/lib/utils.ts
|
90
|
-
var FINGERPRINT_KEYS = {
|
91
|
-
USERAGENT: "UserAgent",
|
92
|
-
SCREEN_PRINT: "ScreenPrint",
|
93
|
-
PLUGINS: "Plugins",
|
94
|
-
FONTS: "Fonts",
|
95
|
-
LOCAL_STORAGE: "LocalStorage",
|
96
|
-
SESSION_STORAGE: "SessionStorage",
|
97
|
-
TIMEZONE: "TimeZone",
|
98
|
-
LANGUAGE: "Language",
|
99
|
-
SYSTEM_LANGUAGE: "SystemLanguage",
|
100
|
-
COOKIE: "Cookie",
|
101
|
-
CANVAS: "Canvas",
|
102
|
-
HOSTNAME: "Hostname"
|
103
|
-
};
|
104
|
-
var getDisabledKeys2 = () => {
|
105
|
-
const DISABLED_KEYS = envHelper_default.getDisabledKeys() || "";
|
106
|
-
if (DISABLED_KEYS === "")
|
107
|
-
return [];
|
108
|
-
const allOptions = [
|
109
|
-
FINGERPRINT_KEYS.USERAGENT,
|
110
|
-
FINGERPRINT_KEYS.SCREEN_PRINT,
|
111
|
-
FINGERPRINT_KEYS.PLUGINS,
|
112
|
-
FINGERPRINT_KEYS.FONTS,
|
113
|
-
FINGERPRINT_KEYS.LOCAL_STORAGE,
|
114
|
-
FINGERPRINT_KEYS.SESSION_STORAGE,
|
115
|
-
FINGERPRINT_KEYS.TIMEZONE,
|
116
|
-
FINGERPRINT_KEYS.LANGUAGE,
|
117
|
-
FINGERPRINT_KEYS.SYSTEM_LANGUAGE,
|
118
|
-
FINGERPRINT_KEYS.COOKIE,
|
119
|
-
FINGERPRINT_KEYS.CANVAS,
|
120
|
-
FINGERPRINT_KEYS.HOSTNAME
|
121
|
-
];
|
122
|
-
const response = [];
|
123
|
-
DISABLED_KEYS.split("|").forEach((key) => {
|
124
|
-
if (key === "") {
|
125
|
-
console.log("test");
|
126
|
-
} else if (allOptions.includes(key))
|
127
|
-
response.push(key);
|
128
|
-
else
|
129
|
-
console.warn(
|
130
|
-
`react-secure-storage : ${key} is not present in the available disabled keys options! Please go through the documentation`
|
131
|
-
);
|
132
|
-
});
|
133
|
-
return response;
|
134
|
-
};
|
135
|
-
|
136
|
-
// src/lib/fingerpint.lib.ts
|
137
|
-
var ClientJS = class {
|
138
|
-
//
|
139
|
-
// MAIN METHODS
|
140
|
-
//
|
141
|
-
// Get Fingerprint. Return a 32-bit integer representing the browsers fingerprint.
|
142
|
-
getFingerprint() {
|
143
|
-
const bar = "|";
|
144
|
-
const disabledKeys = getDisabledKeys2();
|
145
|
-
let key = "";
|
146
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.USERAGENT)) {
|
147
|
-
key += navigator.userAgent + bar;
|
148
|
-
}
|
149
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.HOSTNAME)) {
|
150
|
-
key += window.location.hostname + bar;
|
151
|
-
}
|
152
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.SCREEN_PRINT)) {
|
153
|
-
key += this.getScreenPrint() + bar;
|
154
|
-
}
|
155
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.PLUGINS)) {
|
156
|
-
key += this.getPlugins() + bar;
|
157
|
-
}
|
158
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.FONTS)) {
|
159
|
-
key += this.getFonts() + bar;
|
160
|
-
}
|
161
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.LOCAL_STORAGE)) {
|
162
|
-
key += this.isLocalStorage() + bar;
|
163
|
-
}
|
164
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.SESSION_STORAGE)) {
|
165
|
-
key += this.isSessionStorage() + bar;
|
166
|
-
}
|
167
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.TIMEZONE)) {
|
168
|
-
key += this.getTimeZone() + bar;
|
169
|
-
}
|
170
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.LANGUAGE)) {
|
171
|
-
key += this.getLanguage() + bar;
|
172
|
-
}
|
173
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.SYSTEM_LANGUAGE)) {
|
174
|
-
key += this.getSystemLanguage() + bar;
|
175
|
-
}
|
176
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.COOKIE)) {
|
177
|
-
key += this.isCookie() + bar;
|
178
|
-
}
|
179
|
-
if (!disabledKeys.includes(FINGERPRINT_KEYS.CANVAS)) {
|
180
|
-
key += this.getCanvasPrint();
|
181
|
-
}
|
182
|
-
if (key.endsWith(bar))
|
183
|
-
key = key.substring(0, key.length - 1);
|
184
|
-
const seed = 256;
|
185
|
-
return murmurhash3_32_gc(key, seed);
|
186
|
-
}
|
187
|
-
//
|
188
|
-
// SCREEN METHODS
|
189
|
-
//
|
190
|
-
// Get Screen Print. Return a string containing screen information.
|
191
|
-
getScreenPrint() {
|
192
|
-
return "Color Depth: " + this.getColorDepth() + ", Device XDPI: " + this.getDeviceXDPI() + ", Device YDPI: " + this.getDeviceYDPI();
|
193
|
-
}
|
194
|
-
// Get Color Depth. Return a string containing the color depth.
|
195
|
-
getColorDepth() {
|
196
|
-
return window.screen.colorDepth;
|
197
|
-
}
|
198
|
-
// Get Current Resolution. Return a string containing the current resolution.
|
199
|
-
getCurrentResolution() {
|
200
|
-
return window.screen.width + "x" + window.screen.height;
|
201
|
-
}
|
202
|
-
// Get Available Resolution. Return a string containing the available resolution.
|
203
|
-
getAvailableResolution() {
|
204
|
-
return window.screen.availWidth + "x" + window.screen.availHeight;
|
205
|
-
}
|
206
|
-
// Get Device XPDI. Return a string containing the device XPDI.
|
207
|
-
getDeviceXDPI() {
|
208
|
-
return "";
|
209
|
-
}
|
210
|
-
// Get Device YDPI. Return a string containing the device YDPI.
|
211
|
-
getDeviceYDPI() {
|
212
|
-
return "";
|
213
|
-
}
|
214
|
-
//
|
215
|
-
// PLUGIN METHODS
|
216
|
-
//
|
217
|
-
// Get Plugins. Return a string containing a list of installed plugins.
|
218
|
-
getPlugins() {
|
219
|
-
let pluginsList = "";
|
220
|
-
for (let i = 0; i < navigator.plugins.length; i++) {
|
221
|
-
if (i === navigator.plugins.length - 1) {
|
222
|
-
pluginsList += navigator.plugins[i].name;
|
223
|
-
} else {
|
224
|
-
pluginsList += navigator.plugins[i].name + ", ";
|
225
|
-
}
|
226
|
-
}
|
227
|
-
return pluginsList;
|
228
|
-
}
|
229
|
-
//
|
230
|
-
// FONT METHODS
|
231
|
-
//
|
232
|
-
// Get Fonts. Return a string containing a list of installed fonts.
|
233
|
-
getFonts() {
|
234
|
-
const fontString = "";
|
235
|
-
return fontString;
|
236
|
-
}
|
237
|
-
//
|
238
|
-
// STORAGE METHODS
|
239
|
-
//
|
240
|
-
// Is Local Storage. Check if local storage is enabled.
|
241
|
-
isLocalStorage() {
|
242
|
-
try {
|
243
|
-
return !!localStorage;
|
244
|
-
} catch (e) {
|
245
|
-
return true;
|
246
|
-
}
|
247
|
-
}
|
248
|
-
// Is Session Storage. Check if session storage is enabled.
|
249
|
-
isSessionStorage() {
|
250
|
-
try {
|
251
|
-
return !!sessionStorage;
|
252
|
-
} catch (e) {
|
253
|
-
return true;
|
254
|
-
}
|
255
|
-
}
|
256
|
-
// Is Cookie. Check if cookies are enabled.
|
257
|
-
isCookie() {
|
258
|
-
return navigator.cookieEnabled;
|
259
|
-
}
|
260
|
-
//
|
261
|
-
// TIME METHODS
|
262
|
-
//
|
263
|
-
// Get Time Zone. Return a string containing the time zone.
|
264
|
-
getTimeZone() {
|
265
|
-
const rightNow = /* @__PURE__ */ new Date();
|
266
|
-
let myNumber, formattedNumber, result;
|
267
|
-
myNumber = String(-(rightNow.getTimezoneOffset() / 60));
|
268
|
-
if (myNumber < 0) {
|
269
|
-
myNumber = myNumber * -1;
|
270
|
-
formattedNumber = ("0" + myNumber).slice(-2);
|
271
|
-
result = "-" + formattedNumber;
|
272
|
-
} else {
|
273
|
-
formattedNumber = ("0" + myNumber).slice(-2);
|
274
|
-
result = "+" + formattedNumber;
|
275
|
-
}
|
276
|
-
return result;
|
277
|
-
}
|
278
|
-
//
|
279
|
-
// LANGUAGE METHODS
|
280
|
-
//
|
281
|
-
// Get Language. Return a string containing the user language.
|
282
|
-
getLanguage() {
|
283
|
-
return navigator.language;
|
284
|
-
}
|
285
|
-
// Get System Language. Return a string containing the system language.
|
286
|
-
getSystemLanguage() {
|
287
|
-
return navigator.language || window.navigator.language;
|
288
|
-
}
|
289
|
-
// Get Canvas Print. Return a string containing the canvas URI data.
|
290
|
-
getCanvasPrint() {
|
291
|
-
const canvas = document.createElement("canvas");
|
292
|
-
let ctx;
|
293
|
-
try {
|
294
|
-
ctx = canvas.getContext("2d");
|
295
|
-
} catch (e) {
|
296
|
-
return "";
|
297
|
-
}
|
298
|
-
const txt = "ClientJS,org <canvas> 1.0";
|
299
|
-
ctx.textBaseline = "top";
|
300
|
-
ctx.font = "14px 'Arial'";
|
301
|
-
ctx.textBaseline = "alphabetic";
|
302
|
-
ctx.fillStyle = "#f60";
|
303
|
-
ctx.fillRect(125, 1, 62, 20);
|
304
|
-
ctx.fillStyle = "#069";
|
305
|
-
ctx.fillText(txt, 2, 15);
|
306
|
-
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
|
307
|
-
ctx.fillText(txt, 4, 17);
|
308
|
-
return canvas.toDataURL();
|
309
|
-
}
|
310
|
-
};
|
311
|
-
var clientJS = new ClientJS();
|
312
|
-
var fingerpint_lib_default = clientJS;
|
313
|
-
|
314
|
-
// src/lib/fingerprint.ts
|
315
|
-
var HASH_KEY = "E86E2612010258B35137";
|
316
|
-
var getFingerprint = () => {
|
317
|
-
const HASH_KEY_CUSTOM = envHelper_default.getHashKey() || HASH_KEY;
|
318
|
-
if (typeof window === "undefined")
|
319
|
-
return HASH_KEY_CUSTOM;
|
320
|
-
return fingerpint_lib_default.getFingerprint() + HASH_KEY_CUSTOM;
|
321
|
-
};
|
322
|
-
var fingerprint_default = getFingerprint;
|
323
|
-
|
324
|
-
// src/utils/index.ts
|
325
|
-
var createRequest = (endpoint, task) => {
|
326
|
-
return `${endpoint}/visitor/v1/${task}`;
|
327
|
-
};
|
328
|
-
var createRequestV2 = (endpoint, task) => {
|
329
|
-
return `${endpoint}/visitor/v2/${task}`;
|
330
|
-
};
|
331
|
-
var rememberFlow = (endpoint, flow) => {
|
332
|
-
return `${endpoint}/remember_flow/${flow}`;
|
333
|
-
};
|
334
|
-
var startTracker = async (endpoint, url, referer, user_agent, attributesVisit) => {
|
335
|
-
const allow = sessionStorage.getItem("aesirx-analytics-allow");
|
336
|
-
if (allow === "0") {
|
337
|
-
return null;
|
338
|
-
}
|
339
|
-
const { location, document: document2 } = window;
|
340
|
-
const { pathname, search, origin } = location;
|
341
|
-
url = `${origin}${pathname}${search}`;
|
342
|
-
referer = referer ? location.protocol + "//" + location.host + referer : document2.referrer ? document2.referrer : window["referer"] ? window["referer"] === "/" ? location.protocol + "//" + location.host : location.protocol + "//" + location.host + window["referer"] : "";
|
343
|
-
user_agent = window.navigator.userAgent;
|
344
|
-
const browser = Bowser.parse(window.navigator.userAgent);
|
345
|
-
const browser_name = browser?.browser?.name;
|
346
|
-
const browser_version = browser?.browser?.version ?? "0";
|
347
|
-
const lang = window.navigator["userLanguage"] || window.navigator.language;
|
348
|
-
const device = browser?.platform?.model ?? browser?.platform?.type;
|
349
|
-
const queryString = window.location.search;
|
350
|
-
const urlParams = new URLSearchParams(queryString);
|
351
|
-
const ip = "";
|
352
|
-
try {
|
353
|
-
const fingerprint = fingerprint_default();
|
354
|
-
const attributes = [];
|
355
|
-
for (const key of urlParams.keys()) {
|
356
|
-
if (key.startsWith("utm_")) {
|
357
|
-
urlParams.get(key) && attributes.push({ name: key, value: urlParams.get(key) });
|
358
|
-
}
|
359
|
-
}
|
360
|
-
if (attributesVisit?.length) {
|
361
|
-
attributesVisit?.forEach((element) => {
|
362
|
-
element?.name && attributes.push({ name: element?.name, value: element?.value });
|
363
|
-
});
|
364
|
-
}
|
365
|
-
const responseStart = await trackerService(createRequestV2(endpoint, "start"), {
|
366
|
-
fingerprint,
|
367
|
-
url: url?.replace(/^(https?:\/\/)?(www\.)?/, "$1"),
|
368
|
-
...referer && (referer !== url || document2.referrer) && {
|
369
|
-
referer: referer !== url ? referer?.replace(/^(https?:\/\/)?(www\.)?/, "$1") : document2.referrer?.replace(/^(https?:\/\/)?(www\.)?/, "$1")
|
370
|
-
},
|
371
|
-
user_agent,
|
372
|
-
ip,
|
373
|
-
browser_name,
|
374
|
-
browser_version,
|
375
|
-
lang,
|
376
|
-
device: device?.includes("iPhone") ? "mobile" : device?.includes("iPad") ? "tablet" : device,
|
377
|
-
...attributes?.length && {
|
378
|
-
event_name: "visit",
|
379
|
-
event_type: "action",
|
380
|
-
attributes
|
381
|
-
}
|
382
|
-
});
|
383
|
-
if (window["aesirxTrackEcommerce"] === "true" && sessionStorage.getItem("aesirx-analytics-flow") !== (await responseStart)?.flow_uuid) {
|
384
|
-
sessionStorage.setItem("aesirx-analytics-flow", (await responseStart)?.flow_uuid);
|
385
|
-
try {
|
386
|
-
await trackerService(
|
387
|
-
rememberFlow(window.location.origin, (await responseStart)?.flow_uuid),
|
388
|
-
{}
|
389
|
-
);
|
390
|
-
} catch (error) {
|
391
|
-
console.log("Remember Flow Error", error);
|
392
|
-
}
|
393
|
-
}
|
394
|
-
return responseStart;
|
395
|
-
} catch (error) {
|
396
|
-
console.error("Analytics Error: ", error);
|
397
|
-
}
|
398
|
-
};
|
399
|
-
var trackEvent = async (endpoint, referer, data) => {
|
400
|
-
const allow = sessionStorage.getItem("aesirx-analytics-allow");
|
401
|
-
if (allow === "0") {
|
402
|
-
return null;
|
403
|
-
}
|
404
|
-
const { location, document: document2 } = window;
|
405
|
-
referer = referer ? location.protocol + "//" + location.host + referer : document2.referrer.split("?")[0];
|
406
|
-
const url = location.protocol + "//" + location.host + location.pathname;
|
407
|
-
const user_agent = window.navigator.userAgent;
|
408
|
-
const browser = Bowser.parse(window.navigator.userAgent);
|
409
|
-
const browser_name = browser?.browser?.name;
|
410
|
-
const browser_version = browser?.browser?.version ?? "0";
|
411
|
-
const lang = window.navigator["userLanguage"] || window.navigator.language;
|
412
|
-
const device = browser?.platform?.model ?? browser?.platform?.type;
|
413
|
-
const ip = "";
|
414
|
-
const fingerprint = fingerprint_default();
|
415
|
-
const headers = { type: "application/json" };
|
416
|
-
const blobData = new Blob(
|
417
|
-
[
|
418
|
-
JSON.stringify({
|
419
|
-
fingerprint,
|
420
|
-
url: url?.replace(/^(https?:\/\/)?(www\.)?/, "$1"),
|
421
|
-
...referer !== "/" && referer && {
|
422
|
-
referer: referer?.replace(/^(https?:\/\/)?(www\.)?/, "$1")
|
423
|
-
},
|
424
|
-
user_agent,
|
425
|
-
ip,
|
426
|
-
browser_name,
|
427
|
-
browser_version,
|
428
|
-
lang,
|
429
|
-
device: device?.includes("iPhone") ? "mobile" : device?.includes("iPad") ? "tablet" : device,
|
430
|
-
...data
|
431
|
-
})
|
432
|
-
],
|
433
|
-
headers
|
434
|
-
);
|
435
|
-
const responseStart = navigator.sendBeacon(createRequestV2(endpoint, "start"), blobData);
|
436
|
-
return responseStart;
|
437
|
-
};
|
438
|
-
var endTracker = (endPoint, event_uuid, visitor_uuid) => {
|
439
|
-
if (event_uuid && visitor_uuid) {
|
440
|
-
const body = {
|
441
|
-
event_uuid,
|
442
|
-
visitor_uuid
|
443
|
-
};
|
444
|
-
const headers = { type: "application/json" };
|
445
|
-
const blob = new Blob([JSON.stringify(body)], headers);
|
446
|
-
navigator.sendBeacon(createRequest(endPoint, "end"), blob);
|
447
|
-
}
|
448
|
-
};
|
449
|
-
var endTrackerVisibilityState = (endPoint) => {
|
450
|
-
document.addEventListener("visibilitychange", async () => {
|
451
|
-
if (document.visibilityState === "hidden") {
|
452
|
-
endTracker(endPoint, window["event_uuid"], window["visitor_uuid"]);
|
453
|
-
}
|
454
|
-
if (document.visibilityState === "visible") {
|
455
|
-
const response = await startTracker(endPoint, "", "", "", window["attributes"]);
|
456
|
-
window["event_uuid"] = response?.event_uuid;
|
457
|
-
}
|
458
|
-
});
|
459
|
-
window.addEventListener(
|
460
|
-
"pagehide",
|
461
|
-
(event) => {
|
462
|
-
if (event.persisted) {
|
463
|
-
endTracker(endPoint, window["event_uuid"], window["visitor_uuid"]);
|
464
|
-
}
|
465
|
-
},
|
466
|
-
false
|
467
|
-
);
|
468
|
-
};
|
469
|
-
|
470
|
-
// src/AnalyticsNext/handle.tsx
|
471
22
|
var AnalyticsHandle = ({ router, attributes, children }) => {
|
472
23
|
const AnalyticsStore = React.useContext(AnalyticsContext);
|
473
24
|
const endPoint = process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL;
|
@@ -524,8 +75,8 @@ var handle_default = AnalyticsHandle;
|
|
524
75
|
|
525
76
|
// src/AnalyticsNext/index.tsx
|
526
77
|
import dynamic from "next/dynamic";
|
527
|
-
var ConsentComponent = dynamic(() => import("./Consent-
|
528
|
-
var ConsentComponentCustom = dynamic(() => import("./ConsentCustom-
|
78
|
+
var ConsentComponent = dynamic(() => import("./Consent-BZPDMZRF.js"), { ssr: false });
|
79
|
+
var ConsentComponentCustom = dynamic(() => import("./ConsentCustom-JYEILOEZ.js"), { ssr: false });
|
529
80
|
var AnalyticsNext = ({
|
530
81
|
router,
|
531
82
|
attributes,
|
@@ -534,12 +85,15 @@ var AnalyticsNext = ({
|
|
534
85
|
isLoggedApp,
|
535
86
|
children
|
536
87
|
}) => {
|
537
|
-
const [layout, setLayout] = useState2(process.env.NEXT_PUBLIC_CONSENT_LAYOUT);
|
88
|
+
const [layout, setLayout] = useState2(process.env.NEXT_PUBLIC_CONSENT_LAYOUT ?? "simple-web-2");
|
538
89
|
const [gtagId, setGtagId] = useState2(process.env.NEXT_PUBLIC_ANALYTICS_GTAG_ID);
|
539
90
|
const [gtmId, setGtmId] = useState2(process.env.NEXT_PUBLIC_ANALYTICS_GTM_ID);
|
540
91
|
useEffect2(() => {
|
541
92
|
const init = async () => {
|
542
|
-
const data = await getConsentTemplate(
|
93
|
+
const data = await getConsentTemplate(
|
94
|
+
process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL,
|
95
|
+
window.location.host
|
96
|
+
);
|
543
97
|
setLayout(data?.data?.template ?? process.env.NEXT_PUBLIC_CONSENT_LAYOUT);
|
544
98
|
setGtagId(data?.data?.gtag_id ?? process.env.NEXT_PUBLIC_ANALYTICS_GTAG_ID);
|
545
99
|
setGtmId(data?.data?.gtm_id ?? process.env.NEXT_PUBLIC_ANALYTICS_GTM_ID);
|
@@ -587,8 +141,8 @@ var AnalyticsHandle2 = ({ location, history, children }) => {
|
|
587
141
|
const referer = location.pathname ? location.pathname : "";
|
588
142
|
window["referer"] = referer;
|
589
143
|
const responseStart = await startTracker(endPoint, "", referer);
|
590
|
-
responseStart
|
591
|
-
responseStart
|
144
|
+
responseStart?.event_uuid && AnalyticsStore.setEventID(responseStart.event_uuid);
|
145
|
+
responseStart?.visitor_uuid && AnalyticsStore.setUUID(responseStart.visitor_uuid);
|
592
146
|
} else {
|
593
147
|
endTracker(endPoint, window["event_uuid"], AnalyticsStore.visitor_uuid);
|
594
148
|
}
|
@@ -613,15 +167,18 @@ var AnalyticsHandle2 = ({ location, history, children }) => {
|
|
613
167
|
var handle_default2 = AnalyticsHandle2;
|
614
168
|
|
615
169
|
// src/AnalyticsReact/index.tsx
|
616
|
-
var ConsentComponent2 = React4.lazy(() => import("./Consent-
|
617
|
-
var ConsentComponentCustom2 = React4.lazy(() => import("./ConsentCustom-
|
170
|
+
var ConsentComponent2 = React4.lazy(() => import("./Consent-BZPDMZRF.js"));
|
171
|
+
var ConsentComponentCustom2 = React4.lazy(() => import("./ConsentCustom-JYEILOEZ.js"));
|
618
172
|
var AnalyticsReact = ({ location, history, oldLayout = false, children }) => {
|
619
|
-
const [layout, setLayout] = useState3(process.env.REACT_APP_CONSENT_LAYOUT);
|
173
|
+
const [layout, setLayout] = useState3(process.env.REACT_APP_CONSENT_LAYOUT ?? "simple-web-2");
|
620
174
|
const [gtagId, setGtagId] = useState3(process.env.REACT_APP_ANALYTICS_GTAG_ID);
|
621
175
|
const [gtmId, setGtmId] = useState3(process.env.REACT_APP_ANALYTICS_GTM_ID);
|
622
176
|
useEffect4(() => {
|
623
177
|
const init = async () => {
|
624
|
-
const data = await getConsentTemplate(
|
178
|
+
const data = await getConsentTemplate(
|
179
|
+
process.env.REACT_APP_ENDPOINT_ANALYTICS_URL,
|
180
|
+
window.location.host
|
181
|
+
);
|
625
182
|
setLayout(data?.data?.template ?? process.env.REACT_APP_CONSENT_LAYOUT);
|
626
183
|
setGtagId(data?.data?.gtag_id ?? process.env.REACT_APP_ANALYTICS_GTAG_ID);
|
627
184
|
setGtmId(data?.data?.gtm_id ?? process.env.REACT_APP_ANALYTICS_GTM_ID);
|
@@ -650,10 +207,97 @@ var AnalyticsReact = ({ location, history, oldLayout = false, children }) => {
|
|
650
207
|
))));
|
651
208
|
};
|
652
209
|
var AnalyticsReact_default = AnalyticsReact;
|
210
|
+
|
211
|
+
// src/Components/PaymentConsent.tsx
|
212
|
+
import React5, { useEffect as useEffect5 } from "react";
|
213
|
+
import { Button } from "react-bootstrap";
|
214
|
+
var PaymentConsent = ({ show = false, handleClose }) => {
|
215
|
+
const { t } = useTranslation();
|
216
|
+
const handleConsent = () => {
|
217
|
+
sessionStorage.setItem("aesirx-analytics-payment", "true");
|
218
|
+
window?.funcAfterPaymentConsent && window.funcAfterPaymentConsent();
|
219
|
+
handleClose();
|
220
|
+
};
|
221
|
+
useEffect5(() => {
|
222
|
+
if (sessionStorage.getItem("aesirx-analytics-payment") === "true") {
|
223
|
+
window.funcAfterPaymentConsent && window.funcAfterPaymentConsent();
|
224
|
+
}
|
225
|
+
}, []);
|
226
|
+
return /* @__PURE__ */ React5.createElement("div", { className: "aesirxconsent" }, /* @__PURE__ */ React5.createElement(
|
227
|
+
"div",
|
228
|
+
{
|
229
|
+
tabIndex: -1,
|
230
|
+
className: `toast-container position-fixed m-md-3 ${show ? "top-50 start-50 translate-middle" : "bottom-0 end-0 opacity-0"}`
|
231
|
+
},
|
232
|
+
/* @__PURE__ */ React5.createElement("div", { className: `toast payment-consent ${show ? "show" : ""} custom` }, /* @__PURE__ */ React5.createElement("div", { className: "toast-body p-0 shadow mx-3 mx-md-0" }, /* @__PURE__ */ React5.createElement("div", { className: "bg-white" }, /* @__PURE__ */ React5.createElement(
|
233
|
+
"div",
|
234
|
+
{
|
235
|
+
className: `d-flex rounded-top align-items-center justify-content-between p-2 p-lg-3 fw-medium flex-wrap py-2 py-lg-3 px-4 header-consent-bg`,
|
236
|
+
style: {
|
237
|
+
borderBottom: "1px solid #DEDEDE"
|
238
|
+
}
|
239
|
+
},
|
240
|
+
/* @__PURE__ */ React5.createElement("div", { className: "text-primary text-nowrap" }, t("txt_tracking_data_privacy")),
|
241
|
+
/* @__PURE__ */ React5.createElement("div", { className: "d-flex align-items-center fs-14 text-primary" }, /* @__PURE__ */ React5.createElement(
|
242
|
+
"a",
|
243
|
+
{
|
244
|
+
href: "https://shield.aesirx.io/",
|
245
|
+
rel: "noreferrer",
|
246
|
+
target: "_blank",
|
247
|
+
className: "minimize-shield-wrapper position-relative text-decoration-none"
|
248
|
+
},
|
249
|
+
/* @__PURE__ */ React5.createElement(
|
250
|
+
"img",
|
251
|
+
{
|
252
|
+
className: "cover-img position-absolute h-100 w-100 object-fit-cover z-1",
|
253
|
+
src: bg_default
|
254
|
+
}
|
255
|
+
),
|
256
|
+
/* @__PURE__ */ React5.createElement("div", { className: "minimize-shield position-relative z-2 py-2" }, /* @__PURE__ */ React5.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }), t("txt_shield_of_privacy"))
|
257
|
+
))
|
258
|
+
), /* @__PURE__ */ React5.createElement("div", { className: "p-4 pt-3 pb-0 bg-white" }, /* @__PURE__ */ React5.createElement("p", { className: "fw-semibold lh-160 text-primary mb-2" }, t("txt_payment_notice")), /* @__PURE__ */ React5.createElement("div", { className: "text-primary lh-160" }, t("txt_payment_1"), /* @__PURE__ */ React5.createElement("br", null), /* @__PURE__ */ React5.createElement("br", null), /* @__PURE__ */ React5.createElement(
|
259
|
+
"div",
|
260
|
+
{
|
261
|
+
dangerouslySetInnerHTML: {
|
262
|
+
__html: t("txt_payment_2", {
|
263
|
+
interpolation: { escapeValue: false }
|
264
|
+
})
|
265
|
+
}
|
266
|
+
}
|
267
|
+
), /* @__PURE__ */ React5.createElement("br", null), t("txt_payment_3"), /* @__PURE__ */ React5.createElement("br", null), /* @__PURE__ */ React5.createElement("br", null), /* @__PURE__ */ React5.createElement(
|
268
|
+
"div",
|
269
|
+
{
|
270
|
+
dangerouslySetInnerHTML: {
|
271
|
+
__html: t("txt_payment_4", {
|
272
|
+
interpolation: { escapeValue: false }
|
273
|
+
})
|
274
|
+
}
|
275
|
+
}
|
276
|
+
))), /* @__PURE__ */ React5.createElement("div", { className: "rounded-bottom position-relative overflow-hidden text-white bg-white" }, /* @__PURE__ */ React5.createElement("div", { className: "position-relative pt-2 pt-lg-3 p-3" }, /* @__PURE__ */ React5.createElement("div", { className: "d-flex align-items-center justify-content-between flex-wrap" }, /* @__PURE__ */ React5.createElement(
|
277
|
+
Button,
|
278
|
+
{
|
279
|
+
onClick: handleClose,
|
280
|
+
variant: "outline-success",
|
281
|
+
className: "border-2 fs-7 fw-bold text-primary rounded-pill py-13px px-5rem"
|
282
|
+
},
|
283
|
+
t("txt_reject_consent")
|
284
|
+
), /* @__PURE__ */ React5.createElement(
|
285
|
+
Button,
|
286
|
+
{
|
287
|
+
onClick: handleConsent,
|
288
|
+
variant: "outline-success",
|
289
|
+
className: "border-2 fs-7 fw-bold text-primary rounded-pill py-13px px-5rem"
|
290
|
+
},
|
291
|
+
t("txt_yes_i_consent")
|
292
|
+
)))))))
|
293
|
+
));
|
294
|
+
};
|
295
|
+
var PaymentConsent_default = PaymentConsent;
|
653
296
|
export {
|
654
297
|
AnalyticsContext,
|
655
298
|
AnalyticsNext_default as AnalyticsNext,
|
656
299
|
AnalyticsReact_default as AnalyticsReact,
|
300
|
+
PaymentConsent_default as PaymentConsent,
|
657
301
|
fingerprint_default as getFingerprint,
|
658
302
|
trackEvent
|
659
303
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "aesirx-analytics",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.13",
|
4
4
|
"license": "GPL-3.0-only",
|
5
5
|
"author": "AesirX",
|
6
6
|
"repository": "https://gitlab.redweb.dk/aesirx/analytics",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"@concordium/web-sdk": "^7.0.4-rc.3",
|
15
15
|
"@web3modal/ethereum": "^2.7.0",
|
16
16
|
"@web3modal/react": "^2.7.0",
|
17
|
-
"aesirx-sso": "^1.4.
|
17
|
+
"aesirx-sso": "^1.4.13",
|
18
18
|
"axios": "^1.6.0",
|
19
19
|
"bootstrap": "^5.3.2",
|
20
20
|
"bowser": "^2.11.0",
|
@@ -66,7 +66,7 @@
|
|
66
66
|
"@babel/preset-env": "^7.24.5",
|
67
67
|
"@babel/preset-typescript": "^7.23.0",
|
68
68
|
"@jest/globals": "^29.7.0",
|
69
|
-
"@types/jest": "^29.5.
|
69
|
+
"@types/jest": "^29.5.12",
|
70
70
|
"@types/murmurhash-js": "^1.0.3",
|
71
71
|
"@types/node": "^20.8.0",
|
72
72
|
"@types/react": "^18.3.1",
|
@@ -80,7 +80,7 @@
|
|
80
80
|
"esbuild-scss-modules-plugin": "^1.1.1",
|
81
81
|
"eslint": "^8.48.0",
|
82
82
|
"eslint-plugin-react": "^7.33.2",
|
83
|
-
"jest": "^29.
|
83
|
+
"jest": "^29.7.0",
|
84
84
|
"jest-environment-jsdom": "^29.4.3",
|
85
85
|
"node-fetch": "^3.3.1",
|
86
86
|
"prettier": "^3.0.3",
|