aesirx-analytics 2.2.20 → 2.2.21

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/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  endTracker,
3
3
  endTrackerVisibilityState,
4
- fingerprint_default,
5
4
  startTracker,
6
5
  trackEvent
7
- } from "./chunk-UJTYOAT7.js";
6
+ } from "./chunk-YOHHSMUP.js";
8
7
  import {
9
8
  AnalyticsContext,
10
9
  AnalyticsContextProvider_default,
11
10
  bg_default,
11
+ fingerprint_default,
12
12
  getConsentTemplate,
13
13
  no_default,
14
14
  privacy_default,
15
15
  useTranslation
16
- } from "./chunk-HGACFQLI.js";
16
+ } from "./chunk-NTEWP6UQ.js";
17
17
 
18
18
  // src/AnalyticsNext/index.tsx
19
19
  import React2, { useEffect as useEffect2, useState as useState2 } from "react";
@@ -76,8 +76,8 @@ var handle_default = AnalyticsHandle;
76
76
 
77
77
  // src/AnalyticsNext/index.tsx
78
78
  import dynamic from "next/dynamic";
79
- var ConsentComponent = dynamic(() => import("./Consent-4SM7WZEN.js"), { ssr: false });
80
- var ConsentComponentCustom = dynamic(() => import("./ConsentCustom-MHFD6YO3.js"), { ssr: false });
79
+ var ConsentComponent = dynamic(() => import("./Consent-OHFGKDZJ.js"), { ssr: false });
80
+ var ConsentComponentCustom = dynamic(() => import("./ConsentCustom-UTTNESFI.js"), { ssr: false });
81
81
  var AnalyticsNext = ({
82
82
  router,
83
83
  attributes,
@@ -180,8 +180,8 @@ var AnalyticsHandle2 = ({ location, history, children }) => {
180
180
  var handle_default2 = AnalyticsHandle2;
181
181
 
182
182
  // src/AnalyticsReact/index.tsx
183
- var ConsentComponent2 = React4.lazy(() => import("./Consent-4SM7WZEN.js"));
184
- var ConsentComponentCustom2 = React4.lazy(() => import("./ConsentCustom-MHFD6YO3.js"));
183
+ var ConsentComponent2 = React4.lazy(() => import("./Consent-OHFGKDZJ.js"));
184
+ var ConsentComponentCustom2 = React4.lazy(() => import("./ConsentCustom-UTTNESFI.js"));
185
185
  var AnalyticsReact = ({
186
186
  location,
187
187
  history,
@@ -241,6 +241,7 @@ var AnalyticsReact_default = AnalyticsReact;
241
241
  // src/Components/OptInConsent.tsx
242
242
  import React5, { useEffect as useEffect5, useState as useState4 } from "react";
243
243
  import { Button, Form } from "react-bootstrap";
244
+ var endpoint = window["aesirx1stparty"] ? window["aesirx1stparty"] : process?.env?.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL ? process?.env?.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL : process?.env?.REACT_APP_ENDPOINT_ANALYTICS_URL ? process?.env?.REACT_APP_ENDPOINT_ANALYTICS_URL : "";
244
245
  var OptInConsent = ({
245
246
  optInConsentData = window?.optInConsentData ? JSON.parse(window?.optInConsentData) : []
246
247
  }) => {
@@ -277,7 +278,8 @@ var OptInConsent = ({
277
278
  "img",
278
279
  {
279
280
  className: "cover-img position-absolute h-100 w-100 object-fit-cover",
280
- src: bg_default
281
+ src: bg_default,
282
+ alt: "Background Image"
281
283
  }
282
284
  ), /* @__PURE__ */ React5.createElement(
283
285
  "div",
@@ -287,8 +289,8 @@ var OptInConsent = ({
287
289
  setShowExpandRevoke(true);
288
290
  }
289
291
  },
290
- /* @__PURE__ */ React5.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
291
- t("txt_shield_of_privacy")
292
+ /* @__PURE__ */ React5.createElement("img", { src: privacy_default, alt: "SoP Icon" }),
293
+ window?.aesirx_analytics_translate?.txt_shield_of_privacy ?? t("txt_shield_of_privacy")
292
294
  )),
293
295
  showExpandRevoke && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
294
296
  "div",
@@ -298,7 +300,7 @@ var OptInConsent = ({
298
300
  borderBottom: "1px solid #DEDEDE"
299
301
  }
300
302
  },
301
- /* @__PURE__ */ React5.createElement("div", { className: "text-primary text-nowrap" }, t("txt_tracking_data_privacy")),
303
+ /* @__PURE__ */ React5.createElement("div", { className: "text-primary text-nowrap" }, window?.aesirx_analytics_translate?.txt_tracking_data_privacy ?? t("txt_tracking_data_privacy")),
302
304
  /* @__PURE__ */ React5.createElement("div", { className: "d-flex align-items-center fs-14 text-primary" }, /* @__PURE__ */ React5.createElement(
303
305
  "a",
304
306
  {
@@ -311,10 +313,11 @@ var OptInConsent = ({
311
313
  "img",
312
314
  {
313
315
  className: "cover-img position-absolute h-100 w-100 object-fit-cover z-1",
314
- src: bg_default
316
+ src: bg_default,
317
+ alt: "Background Image"
315
318
  }
316
319
  ),
317
- /* @__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"))
320
+ /* @__PURE__ */ React5.createElement("div", { className: "minimize-shield position-relative z-2 py-2" }, /* @__PURE__ */ React5.createElement("img", { src: privacy_default, alt: "SoP Icon" }), window?.aesirx_analytics_translate?.txt_shield_of_privacy ?? t("txt_shield_of_privacy"))
318
321
  ))
319
322
  ), /* @__PURE__ */ React5.createElement(
320
323
  "div",
@@ -324,8 +327,8 @@ var OptInConsent = ({
324
327
  setShowExpandRevoke(false);
325
328
  }
326
329
  },
327
- /* @__PURE__ */ React5.createElement("img", { src: no_default })
328
- ), /* @__PURE__ */ React5.createElement("div", { className: "p-3 bg-white" }, t("txt_you_can_revoke")), /* @__PURE__ */ React5.createElement(Form, { className: "mb-0 w-100 bg-white px-3" }, optInRevokes?.map((item, key) => {
330
+ /* @__PURE__ */ React5.createElement("img", { src: no_default, alt: "No Icon" })
331
+ ), /* @__PURE__ */ React5.createElement("div", { className: "p-3 bg-white" }, window?.aesirx_analytics_translate?.txt_you_can_revoke ?? t("txt_you_can_revoke")), /* @__PURE__ */ React5.createElement(Form, { className: "mb-0 w-100 bg-white px-3" }, optInRevokes?.map((item, key) => {
329
332
  return /* @__PURE__ */ React5.createElement(
330
333
  Form.Check,
331
334
  {
@@ -333,7 +336,7 @@ var OptInConsent = ({
333
336
  id: `option-revoke-${item}`,
334
337
  checked: revokeConsentOption === item,
335
338
  type: "checkbox",
336
- label: item === "aesirx-analytics-optin-default" ? t("txt_revoke_opt_in") : t("txt_revoke_opt_in") + " " + item?.replace("aesirx-analytics-optin-", ""),
339
+ label: item === "aesirx-analytics-optin-default" ? window?.aesirx_analytics_translate?.txt_revoke_opt_in ?? t("txt_revoke_opt_in") : window?.aesirx_analytics_translate?.txt_revoke_opt_in ?? t("txt_revoke_opt_in") + " " + item?.replace("aesirx-analytics-optin-", ""),
337
340
  value: item,
338
341
  onChange: ({ target: { value } }) => {
339
342
  setRevokeConsentOption(value);
@@ -348,7 +351,7 @@ var OptInConsent = ({
348
351
  target: "_blank",
349
352
  rel: "noreferrer"
350
353
  },
351
- t("txt_manage_consent")
354
+ window?.aesirx_analytics_translate?.txt_manage_consent ?? t("txt_manage_consent")
352
355
  ), /* @__PURE__ */ React5.createElement(
353
356
  Button,
354
357
  {
@@ -366,7 +369,7 @@ var OptInConsent = ({
366
369
  },
367
370
  className: "d-flex align-items-center justify-content-center w-100 w-lg-35 revoke-btn fs-14 rounded-pill py-2 py-lg-3"
368
371
  },
369
- t("txt_revoke_consent")
372
+ window?.aesirx_analytics_translate?.txt_revoke_consent ?? t("txt_revoke_consent")
370
373
  ))))))
371
374
  ))
372
375
  )
@@ -390,6 +393,12 @@ var OptIntConsentDetail = ({ optIn, setShowRevoke }) => {
390
393
  optIn?.handleConsent && optIn?.handleConsent();
391
394
  window?.funcAfterOptInConsent && window.funcAfterOptInConsent();
392
395
  window?.optInConsentData && document.querySelector(`.opt-in-consent.${optIn?.title}`).classList.remove("show");
396
+ const hostUrl = endpoint ? endpoint : "";
397
+ const root = hostUrl ? hostUrl.replace(/\/$/, "") : "";
398
+ root && trackEvent(root, "", {
399
+ event_name: "Opt-in consent",
400
+ event_type: "opt-in-consent"
401
+ });
393
402
  };
394
403
  const handleClose = () => {
395
404
  setShow(false);
@@ -441,7 +450,8 @@ var OptIntConsentDetail = ({ optIn, setShowRevoke }) => {
441
450
  "img",
442
451
  {
443
452
  className: "cover-img position-absolute h-100 w-100 object-fit-cover",
444
- src: bg_default
453
+ src: bg_default,
454
+ alt: "Background Image"
445
455
  }
446
456
  ), /* @__PURE__ */ React5.createElement(
447
457
  "div",
@@ -453,8 +463,8 @@ var OptIntConsentDetail = ({ optIn, setShowRevoke }) => {
453
463
  sessionStorage.removeItem("aesirx-analytics-rejected");
454
464
  }
455
465
  },
456
- /* @__PURE__ */ React5.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
457
- t("txt_shield_of_privacy")
466
+ /* @__PURE__ */ React5.createElement("img", { src: privacy_default, alt: "SoP Icon" }),
467
+ window?.aesirx_analytics_translate?.txt_shield_of_privacy ?? t("txt_shield_of_privacy")
458
468
  ))) : /* @__PURE__ */ React5.createElement("div", { className: "bg-white" }, /* @__PURE__ */ React5.createElement(
459
469
  "div",
460
470
  {
@@ -463,7 +473,7 @@ var OptIntConsentDetail = ({ optIn, setShowRevoke }) => {
463
473
  borderBottom: "1px solid #DEDEDE"
464
474
  }
465
475
  },
466
- /* @__PURE__ */ React5.createElement("div", { className: "text-primary text-nowrap" }, t("txt_tracking_data_privacy")),
476
+ /* @__PURE__ */ React5.createElement("div", { className: "text-primary text-nowrap" }, window?.aesirx_analytics_translate?.txt_tracking_data_privacy ?? t("txt_tracking_data_privacy")),
467
477
  /* @__PURE__ */ React5.createElement("div", { className: "d-flex align-items-center fs-14 text-primary" }, /* @__PURE__ */ React5.createElement(
468
478
  "a",
469
479
  {
@@ -476,10 +486,11 @@ var OptIntConsentDetail = ({ optIn, setShowRevoke }) => {
476
486
  "img",
477
487
  {
478
488
  className: "cover-img position-absolute h-100 w-100 object-fit-cover z-1",
479
- src: bg_default
489
+ src: bg_default,
490
+ alt: "Background Image"
480
491
  }
481
492
  ),
482
- /* @__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"))
493
+ /* @__PURE__ */ React5.createElement("div", { className: "minimize-shield position-relative z-2 py-2" }, /* @__PURE__ */ React5.createElement("img", { src: privacy_default, alt: "SoP Icon" }), window?.aesirx_analytics_translate?.txt_shield_of_privacy ?? t("txt_shield_of_privacy"))
483
494
  ))
484
495
  ), /* @__PURE__ */ React5.createElement("div", { className: "p-4 pt-3 pb-0 bg-white" }, /* @__PURE__ */ React5.createElement(
485
496
  "div",
@@ -495,7 +506,7 @@ var OptIntConsentDetail = ({ optIn, setShowRevoke }) => {
495
506
  variant: "outline-success",
496
507
  className: "border-2 fs-7 fw-bold text-primary rounded-pill"
497
508
  },
498
- t("txt_reject_consent")
509
+ window?.aesirx_analytics_translate?.txt_reject_consent ?? t("txt_reject_consent")
499
510
  ), /* @__PURE__ */ React5.createElement(
500
511
  Button,
501
512
  {
@@ -503,7 +514,7 @@ var OptIntConsentDetail = ({ optIn, setShowRevoke }) => {
503
514
  variant: "outline-success",
504
515
  className: "border-2 fs-7 fw-bold text-primary rounded-pill"
505
516
  },
506
- t("txt_yes_i_consent")
517
+ window?.aesirx_analytics_translate?.txt_yes_i_consent ?? t("txt_yes_i_consent")
507
518
  ))))))
508
519
  )
509
520
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aesirx-analytics",
3
- "version": "2.2.20",
3
+ "version": "2.2.21",
4
4
  "license": "GPL-3.0-only",
5
5
  "author": "AesirX",
6
6
  "repository": "https://gitlab.redweb.dk/aesirx/analytics",
@@ -1,464 +0,0 @@
1
- // src/lib/envHelper.ts
2
- var getHashKey = () => {
3
- let value = null;
4
- try {
5
- if (typeof process.env != "undefined") {
6
- 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;
7
- } else {
8
- console.warn(`react-secure-storage : process is not defined! Just a warning!`);
9
- }
10
- } catch (ex) {
11
- return null;
12
- }
13
- return value;
14
- };
15
- var getStoragePrefix = () => {
16
- let value = null;
17
- try {
18
- if (typeof process.env != "undefined") {
19
- 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;
20
- } else {
21
- console.warn(`react-secure-storage : process is not defined! Just a warning!`);
22
- }
23
- } catch (ex) {
24
- return null;
25
- }
26
- return value;
27
- };
28
- var getDisabledKeys = () => {
29
- let value = null;
30
- try {
31
- if (typeof process.env != "undefined") {
32
- 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;
33
- } else {
34
- console.warn(`react-secure-storage : process is not defined! Just a warning!`);
35
- }
36
- } catch (ex) {
37
- return null;
38
- }
39
- return value;
40
- };
41
- var envHelper = {
42
- getHashKey,
43
- getStoragePrefix,
44
- getDisabledKeys
45
- };
46
- var envHelper_default = envHelper;
47
-
48
- // src/lib/fingerpint.lib.ts
49
- import murmurhash3_32_gc from "murmurhash-js/murmurhash3_gc";
50
-
51
- // src/lib/utils.ts
52
- var FINGERPRINT_KEYS = {
53
- USERAGENT: "UserAgent",
54
- SCREEN_PRINT: "ScreenPrint",
55
- PLUGINS: "Plugins",
56
- FONTS: "Fonts",
57
- LOCAL_STORAGE: "LocalStorage",
58
- SESSION_STORAGE: "SessionStorage",
59
- TIMEZONE: "TimeZone",
60
- LANGUAGE: "Language",
61
- SYSTEM_LANGUAGE: "SystemLanguage",
62
- COOKIE: "Cookie",
63
- CANVAS: "Canvas",
64
- HOSTNAME: "Hostname"
65
- };
66
- var getDisabledKeys2 = () => {
67
- const DISABLED_KEYS = envHelper_default.getDisabledKeys() || "";
68
- if (DISABLED_KEYS === "")
69
- return [];
70
- const allOptions = [
71
- FINGERPRINT_KEYS.USERAGENT,
72
- FINGERPRINT_KEYS.SCREEN_PRINT,
73
- FINGERPRINT_KEYS.PLUGINS,
74
- FINGERPRINT_KEYS.FONTS,
75
- FINGERPRINT_KEYS.LOCAL_STORAGE,
76
- FINGERPRINT_KEYS.SESSION_STORAGE,
77
- FINGERPRINT_KEYS.TIMEZONE,
78
- FINGERPRINT_KEYS.LANGUAGE,
79
- FINGERPRINT_KEYS.SYSTEM_LANGUAGE,
80
- FINGERPRINT_KEYS.COOKIE,
81
- FINGERPRINT_KEYS.CANVAS,
82
- FINGERPRINT_KEYS.HOSTNAME
83
- ];
84
- const response = [];
85
- DISABLED_KEYS.split("|").forEach((key) => {
86
- if (key === "") {
87
- console.log("test");
88
- } else if (allOptions.includes(key))
89
- response.push(key);
90
- else
91
- console.warn(
92
- `react-secure-storage : ${key} is not present in the available disabled keys options! Please go through the documentation`
93
- );
94
- });
95
- return response;
96
- };
97
-
98
- // src/lib/fingerpint.lib.ts
99
- var ClientJS = class {
100
- //
101
- // MAIN METHODS
102
- //
103
- // Get Fingerprint. Return a 32-bit integer representing the browsers fingerprint.
104
- getFingerprint() {
105
- const bar = "|";
106
- const disabledKeys = getDisabledKeys2();
107
- let key = "";
108
- if (!disabledKeys.includes(FINGERPRINT_KEYS.USERAGENT)) {
109
- key += navigator.userAgent + bar;
110
- }
111
- if (!disabledKeys.includes(FINGERPRINT_KEYS.HOSTNAME)) {
112
- key += window.location.hostname + bar;
113
- }
114
- if (!disabledKeys.includes(FINGERPRINT_KEYS.SCREEN_PRINT)) {
115
- key += this.getScreenPrint() + bar;
116
- }
117
- if (!disabledKeys.includes(FINGERPRINT_KEYS.PLUGINS)) {
118
- key += this.getPlugins() + bar;
119
- }
120
- if (!disabledKeys.includes(FINGERPRINT_KEYS.FONTS)) {
121
- key += this.getFonts() + bar;
122
- }
123
- if (!disabledKeys.includes(FINGERPRINT_KEYS.LOCAL_STORAGE)) {
124
- key += this.isLocalStorage() + bar;
125
- }
126
- if (!disabledKeys.includes(FINGERPRINT_KEYS.SESSION_STORAGE)) {
127
- key += this.isSessionStorage() + bar;
128
- }
129
- if (!disabledKeys.includes(FINGERPRINT_KEYS.TIMEZONE)) {
130
- key += this.getTimeZone() + bar;
131
- }
132
- if (!disabledKeys.includes(FINGERPRINT_KEYS.LANGUAGE)) {
133
- key += this.getLanguage() + bar;
134
- }
135
- if (!disabledKeys.includes(FINGERPRINT_KEYS.SYSTEM_LANGUAGE)) {
136
- key += this.getSystemLanguage() + bar;
137
- }
138
- if (!disabledKeys.includes(FINGERPRINT_KEYS.COOKIE)) {
139
- key += this.isCookie() + bar;
140
- }
141
- if (!disabledKeys.includes(FINGERPRINT_KEYS.CANVAS)) {
142
- key += this.getCanvasPrint();
143
- }
144
- if (key.endsWith(bar))
145
- key = key.substring(0, key.length - 1);
146
- const seed = 256;
147
- return murmurhash3_32_gc(key, seed);
148
- }
149
- //
150
- // SCREEN METHODS
151
- //
152
- // Get Screen Print. Return a string containing screen information.
153
- getScreenPrint() {
154
- return "Color Depth: " + this.getColorDepth() + ", Device XDPI: " + this.getDeviceXDPI() + ", Device YDPI: " + this.getDeviceYDPI();
155
- }
156
- // Get Color Depth. Return a string containing the color depth.
157
- getColorDepth() {
158
- return window.screen.colorDepth;
159
- }
160
- // Get Current Resolution. Return a string containing the current resolution.
161
- getCurrentResolution() {
162
- return window.screen.width + "x" + window.screen.height;
163
- }
164
- // Get Available Resolution. Return a string containing the available resolution.
165
- getAvailableResolution() {
166
- return window.screen.availWidth + "x" + window.screen.availHeight;
167
- }
168
- // Get Device XPDI. Return a string containing the device XPDI.
169
- getDeviceXDPI() {
170
- return "";
171
- }
172
- // Get Device YDPI. Return a string containing the device YDPI.
173
- getDeviceYDPI() {
174
- return "";
175
- }
176
- //
177
- // PLUGIN METHODS
178
- //
179
- // Get Plugins. Return a string containing a list of installed plugins.
180
- getPlugins() {
181
- let pluginsList = "";
182
- for (let i = 0; i < navigator.plugins.length; i++) {
183
- if (i === navigator.plugins.length - 1) {
184
- pluginsList += navigator.plugins[i].name;
185
- } else {
186
- pluginsList += navigator.plugins[i].name + ", ";
187
- }
188
- }
189
- return pluginsList;
190
- }
191
- //
192
- // FONT METHODS
193
- //
194
- // Get Fonts. Return a string containing a list of installed fonts.
195
- getFonts() {
196
- const fontString = "";
197
- return fontString;
198
- }
199
- //
200
- // STORAGE METHODS
201
- //
202
- // Is Local Storage. Check if local storage is enabled.
203
- isLocalStorage() {
204
- try {
205
- return !!localStorage;
206
- } catch (e) {
207
- return true;
208
- }
209
- }
210
- // Is Session Storage. Check if session storage is enabled.
211
- isSessionStorage() {
212
- try {
213
- return !!sessionStorage;
214
- } catch (e) {
215
- return true;
216
- }
217
- }
218
- // Is Cookie. Check if cookies are enabled.
219
- isCookie() {
220
- return navigator.cookieEnabled;
221
- }
222
- //
223
- // TIME METHODS
224
- //
225
- // Get Time Zone. Return a string containing the time zone.
226
- getTimeZone() {
227
- const rightNow = /* @__PURE__ */ new Date();
228
- let myNumber, formattedNumber, result;
229
- myNumber = String(-(rightNow.getTimezoneOffset() / 60));
230
- if (myNumber < 0) {
231
- myNumber = myNumber * -1;
232
- formattedNumber = ("0" + myNumber).slice(-2);
233
- result = "-" + formattedNumber;
234
- } else {
235
- formattedNumber = ("0" + myNumber).slice(-2);
236
- result = "+" + formattedNumber;
237
- }
238
- return result;
239
- }
240
- //
241
- // LANGUAGE METHODS
242
- //
243
- // Get Language. Return a string containing the user language.
244
- getLanguage() {
245
- return navigator.language;
246
- }
247
- // Get System Language. Return a string containing the system language.
248
- getSystemLanguage() {
249
- return navigator.language || window.navigator.language;
250
- }
251
- // Get Canvas Print. Return a string containing the canvas URI data.
252
- getCanvasPrint() {
253
- const canvas = document.createElement("canvas");
254
- let ctx;
255
- try {
256
- ctx = canvas.getContext("2d");
257
- } catch (e) {
258
- return "";
259
- }
260
- const txt = "ClientJS,org <canvas> 1.0";
261
- ctx.textBaseline = "top";
262
- ctx.font = "14px 'Arial'";
263
- ctx.textBaseline = "alphabetic";
264
- ctx.fillStyle = "#f60";
265
- ctx.fillRect(125, 1, 62, 20);
266
- ctx.fillStyle = "#069";
267
- ctx.fillText(txt, 2, 15);
268
- ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
269
- ctx.fillText(txt, 4, 17);
270
- return canvas.toDataURL();
271
- }
272
- };
273
- var clientJS = new ClientJS();
274
- var fingerpint_lib_default = clientJS;
275
-
276
- // src/lib/fingerprint.ts
277
- var HASH_KEY = "E86E2612010258B35137";
278
- var getFingerprint = () => {
279
- const HASH_KEY_CUSTOM = envHelper_default.getHashKey() || HASH_KEY;
280
- if (typeof window === "undefined")
281
- return HASH_KEY_CUSTOM;
282
- return fingerpint_lib_default.getFingerprint() + HASH_KEY_CUSTOM;
283
- };
284
- var fingerprint_default = getFingerprint;
285
-
286
- // src/utils/services.ts
287
- var cache;
288
- var assign = (a, b) => {
289
- Object.keys(b).forEach((key) => {
290
- if (b[key] !== void 0)
291
- a[key] = b[key];
292
- });
293
- return a;
294
- };
295
- var trackerService = async (endpoint, payload) => {
296
- const fetchData = await fetch(endpoint, {
297
- method: "POST",
298
- body: JSON.stringify(payload),
299
- headers: assign({ "Content-Type": "application/json" }, { ["x-tracker-cache"]: cache })
300
- });
301
- const response = await fetchData.json();
302
- if (response.error) {
303
- throw response.error;
304
- } else {
305
- return response;
306
- }
307
- };
308
-
309
- // src/utils/index.ts
310
- import Bowser from "bowser";
311
- var createRequest = (endpoint, task) => {
312
- return `${endpoint}/visitor/v1/${task}`;
313
- };
314
- var createRequestV2 = (endpoint, task) => {
315
- return `${endpoint}/visitor/v2/${task}`;
316
- };
317
- var rememberFlow = (endpoint, flow) => {
318
- return `${endpoint}/remember_flow/${flow}`;
319
- };
320
- var startTracker = async (endpoint, url, referer, user_agent, attributesVisit) => {
321
- const allow = sessionStorage.getItem("aesirx-analytics-allow");
322
- const reject = sessionStorage.getItem("aesirx-analytics-rejected");
323
- if (allow === "0" || reject === "true") {
324
- return null;
325
- }
326
- const { location, document: document2 } = window;
327
- const { pathname, search, origin } = location;
328
- url = `${origin}${pathname}${search}`;
329
- 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"] : "";
330
- user_agent = window.navigator.userAgent;
331
- const browser = Bowser.parse(window.navigator.userAgent);
332
- const browser_name = browser?.browser?.name;
333
- const browser_version = browser?.browser?.version ?? "0";
334
- const lang = window.navigator["userLanguage"] || window.navigator.language;
335
- const device = browser?.platform?.model ?? browser?.platform?.type;
336
- const queryString = window.location.search;
337
- const urlParams = new URLSearchParams(queryString);
338
- const ip = "";
339
- try {
340
- const fingerprint = fingerprint_default();
341
- const attributes = [];
342
- for (const key of urlParams.keys()) {
343
- if (key.startsWith("utm_")) {
344
- urlParams.get(key) && attributes.push({ name: key, value: urlParams.get(key) });
345
- }
346
- }
347
- if (attributesVisit?.length) {
348
- attributesVisit?.forEach((element) => {
349
- element?.name && attributes.push({ name: element?.name, value: element?.value });
350
- });
351
- }
352
- const responseStart = await trackerService(createRequestV2(endpoint, "start"), {
353
- fingerprint,
354
- url: url?.replace(/^(https?:\/\/)?(www\.)?/, "$1"),
355
- ...referer && (referer !== url || document2.referrer) && {
356
- referer: referer !== url ? referer?.replace(/^(https?:\/\/)?(www\.)?/, "$1") : document2.referrer?.replace(/^(https?:\/\/)?(www\.)?/, "$1")
357
- },
358
- user_agent,
359
- ip,
360
- browser_name,
361
- browser_version,
362
- lang,
363
- device: device?.includes("iPhone") ? "mobile" : device?.includes("iPad") ? "tablet" : device,
364
- ...attributes?.length && {
365
- event_name: "visit",
366
- event_type: "action",
367
- attributes
368
- }
369
- });
370
- if (window["aesirxTrackEcommerce"] === "true" && sessionStorage.getItem("aesirx-analytics-flow") !== (await responseStart)?.flow_uuid) {
371
- sessionStorage.setItem("aesirx-analytics-flow", (await responseStart)?.flow_uuid);
372
- try {
373
- await trackerService(
374
- rememberFlow(window.location.origin, (await responseStart)?.flow_uuid),
375
- {}
376
- );
377
- } catch (error) {
378
- console.log("Remember Flow Error", error);
379
- }
380
- }
381
- return responseStart;
382
- } catch (error) {
383
- console.error("Analytics Error: ", error);
384
- }
385
- };
386
- var trackEvent = async (endpoint, referer, data) => {
387
- const allow = sessionStorage.getItem("aesirx-analytics-allow");
388
- const reject = sessionStorage.getItem("aesirx-analytics-rejected");
389
- if (allow === "0" || reject === "true") {
390
- return null;
391
- }
392
- const { location, document: document2 } = window;
393
- 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"] : "";
394
- const url = location.protocol + "//" + location.host + location.pathname;
395
- const user_agent = window.navigator.userAgent;
396
- const browser = Bowser.parse(window.navigator.userAgent);
397
- const browser_name = browser?.browser?.name;
398
- const browser_version = browser?.browser?.version ?? "0";
399
- const lang = window.navigator["userLanguage"] || window.navigator.language;
400
- const device = browser?.platform?.model ?? browser?.platform?.type;
401
- const ip = "";
402
- const fingerprint = fingerprint_default();
403
- const headers = { type: "application/json" };
404
- const blobData = new Blob(
405
- [
406
- JSON.stringify({
407
- fingerprint,
408
- url: url?.replace(/^(https?:\/\/)?(www\.)?/, "$1"),
409
- ...referer !== "/" && referer && {
410
- referer: referer?.replace(/^(https?:\/\/)?(www\.)?/, "$1")
411
- },
412
- user_agent,
413
- ip,
414
- browser_name,
415
- browser_version,
416
- lang,
417
- device: device?.includes("iPhone") ? "mobile" : device?.includes("iPad") ? "tablet" : device,
418
- ...data
419
- })
420
- ],
421
- headers
422
- );
423
- const responseStart = navigator.sendBeacon(createRequestV2(endpoint, "start"), blobData);
424
- return responseStart;
425
- };
426
- var endTracker = (endPoint, event_uuid, visitor_uuid) => {
427
- if (event_uuid && visitor_uuid) {
428
- const body = {
429
- event_uuid,
430
- visitor_uuid
431
- };
432
- const headers = { type: "application/json" };
433
- const blob = new Blob([JSON.stringify(body)], headers);
434
- navigator.sendBeacon(createRequest(endPoint, "end"), blob);
435
- }
436
- };
437
- var endTrackerVisibilityState = (endPoint) => {
438
- document.addEventListener("visibilitychange", async () => {
439
- if (document.visibilityState === "hidden") {
440
- endTracker(endPoint, window["event_uuid"], window["visitor_uuid"]);
441
- }
442
- if (document.visibilityState === "visible") {
443
- const response = await startTracker(endPoint, "", "", "", window["attributes"]);
444
- window["event_uuid"] = response?.event_uuid;
445
- }
446
- });
447
- window.addEventListener(
448
- "pagehide",
449
- (event) => {
450
- if (event.persisted) {
451
- endTracker(endPoint, window["event_uuid"], window["visitor_uuid"]);
452
- }
453
- },
454
- false
455
- );
456
- };
457
-
458
- export {
459
- fingerprint_default,
460
- startTracker,
461
- trackEvent,
462
- endTracker,
463
- endTrackerVisibilityState
464
- };