aesirx-analytics 2.2.4 → 2.2.6
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 +38 -0
- package/dist/{Consent-J6XDJB65.js → Consent-U7ESRVW5.js} +137 -21
- package/dist/{ConsentCustom-6YFZO4ZJ.js → ConsentCustom-CSPWI25K.js} +205 -86
- package/dist/analytics.js +152 -123
- package/dist/{chunk-AJMXPNA2.js → chunk-7GRKFZZL.js} +159 -309
- package/dist/{chunk-FKCTTU52.js → chunk-N36VEWSG.js} +268 -4
- package/dist/index.d.ts +7 -3
- package/dist/index.js +82 -24
- package/package.json +6 -6
@@ -381,7 +381,7 @@ import { createElement as createElement4 } from "react";
|
|
381
381
|
import { useContext as useContext3 } from "react";
|
382
382
|
|
383
383
|
// src/utils/AnalyticsContextProvider.tsx
|
384
|
-
import React3, { useState as useState2 } from "react";
|
384
|
+
import React3, { useRef as useRef2, useState as useState2 } from "react";
|
385
385
|
|
386
386
|
// src/translations/dk/common.json
|
387
387
|
var common_default = {
|
@@ -1093,11 +1093,13 @@ var AnalyticsContext = React3.createContext({
|
|
1093
1093
|
event_uuid: void 0,
|
1094
1094
|
visitor_uuid: void 0,
|
1095
1095
|
setEventID: void 0,
|
1096
|
-
setUUID: void 0
|
1096
|
+
setUUID: void 0,
|
1097
|
+
ref: void 0
|
1097
1098
|
});
|
1098
1099
|
var AnalyticsContextProvider = ({ children }) => {
|
1099
1100
|
const [eventID, setEventID] = useState2();
|
1100
1101
|
const [UUID, setUUID] = useState2();
|
1102
|
+
const ref = useRef2();
|
1101
1103
|
return /* @__PURE__ */ React3.createElement(
|
1102
1104
|
AnalyticsContext.Provider,
|
1103
1105
|
{
|
@@ -1105,7 +1107,8 @@ var AnalyticsContextProvider = ({ children }) => {
|
|
1105
1107
|
event_uuid: eventID,
|
1106
1108
|
visitor_uuid: UUID,
|
1107
1109
|
setEventID,
|
1108
|
-
setUUID
|
1110
|
+
setUUID,
|
1111
|
+
ref
|
1109
1112
|
}
|
1110
1113
|
},
|
1111
1114
|
/* @__PURE__ */ React3.createElement(AesirXI18nextProvider, { appLanguages }, children)
|
@@ -1113,10 +1116,271 @@ var AnalyticsContextProvider = ({ children }) => {
|
|
1113
1116
|
};
|
1114
1117
|
var AnalyticsContextProvider_default = AnalyticsContextProvider;
|
1115
1118
|
|
1119
|
+
// src/utils/consent.ts
|
1120
|
+
import { stringMessage } from "@concordium/react-components";
|
1121
|
+
import axios from "axios";
|
1122
|
+
var agreeConsents = async (endpoint, level, uuid, consent, wallet, signature, web3id, jwt, network = "concordium", gtagId, gtmId, layout) => {
|
1123
|
+
const url = `${endpoint}/consent/v1/level${level}/${uuid}`;
|
1124
|
+
const urlV2 = `${endpoint}/consent/v2/level${level}/${uuid}`;
|
1125
|
+
if (sessionStorage.getItem("consentGranted") !== "true") {
|
1126
|
+
gtagId && consentModeGrant(true, gtagId, layout);
|
1127
|
+
gtmId && consentModeGrant(false, gtmId, layout);
|
1128
|
+
}
|
1129
|
+
try {
|
1130
|
+
switch (level) {
|
1131
|
+
case 1:
|
1132
|
+
await axios.post(`${url}/${consent}`);
|
1133
|
+
break;
|
1134
|
+
case 2:
|
1135
|
+
await axios.post(
|
1136
|
+
`${url}`,
|
1137
|
+
{ consent: [1, 2] },
|
1138
|
+
{
|
1139
|
+
headers: {
|
1140
|
+
"Content-Type": "application/json",
|
1141
|
+
Authorization: "Bearer " + jwt
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
);
|
1145
|
+
break;
|
1146
|
+
case 3:
|
1147
|
+
await axios.post(`${url}/${network}/${wallet}`, {
|
1148
|
+
signature,
|
1149
|
+
consent
|
1150
|
+
});
|
1151
|
+
break;
|
1152
|
+
case 4:
|
1153
|
+
await axios.post(
|
1154
|
+
`${urlV2}/${network}/${wallet}`,
|
1155
|
+
{
|
1156
|
+
signature,
|
1157
|
+
consent
|
1158
|
+
},
|
1159
|
+
{
|
1160
|
+
headers: {
|
1161
|
+
"Content-Type": "application/json",
|
1162
|
+
Authorization: "Bearer " + jwt
|
1163
|
+
}
|
1164
|
+
}
|
1165
|
+
);
|
1166
|
+
break;
|
1167
|
+
default:
|
1168
|
+
break;
|
1169
|
+
}
|
1170
|
+
} catch (error) {
|
1171
|
+
throw error;
|
1172
|
+
}
|
1173
|
+
};
|
1174
|
+
var consentModeGrant = async (isGtag, id, layout) => {
|
1175
|
+
if (layout !== "advance-consent-mode") {
|
1176
|
+
isGtag ? loadGtagScript(id) : loadGtmScript(id);
|
1177
|
+
}
|
1178
|
+
sessionStorage.setItem("consentGranted", "true");
|
1179
|
+
function gtag(p0, p1, p2) {
|
1180
|
+
dataLayer.push(arguments);
|
1181
|
+
}
|
1182
|
+
gtag("consent", "update", {
|
1183
|
+
ad_user_data: "granted",
|
1184
|
+
ad_personalization: "granted",
|
1185
|
+
ad_storage: "granted",
|
1186
|
+
analytics_storage: "granted"
|
1187
|
+
});
|
1188
|
+
};
|
1189
|
+
var loadGtagScript = (gtagId) => {
|
1190
|
+
const gtagScript = document.createElement("script");
|
1191
|
+
gtagScript.async = true;
|
1192
|
+
gtagScript.src = `https://www.googletagmanager.com/gtag/js?id=${gtagId}`;
|
1193
|
+
const firstScript = document.getElementsByTagName("script")[0];
|
1194
|
+
firstScript.parentNode.insertBefore(gtagScript, firstScript);
|
1195
|
+
};
|
1196
|
+
var loadGtmScript = (gtmId) => {
|
1197
|
+
const gtmScript = document.createElement("script");
|
1198
|
+
gtmScript.async = true;
|
1199
|
+
gtmScript.src = `https://www.googletagmanager.com/gtm.js?id=${gtmId}`;
|
1200
|
+
const firstScript = document.getElementsByTagName("script")[0];
|
1201
|
+
firstScript.parentNode.insertBefore(gtmScript, firstScript);
|
1202
|
+
};
|
1203
|
+
var getConsents = async (endpoint, uuid) => {
|
1204
|
+
try {
|
1205
|
+
const response = (await axios.get(`${endpoint}/visitor/v1/${uuid}`))?.data?.visitor_consents;
|
1206
|
+
return response;
|
1207
|
+
} catch (error) {
|
1208
|
+
throw error;
|
1209
|
+
}
|
1210
|
+
};
|
1211
|
+
var getSignature = async (endpoint, address, provider, text, network = "concordium") => {
|
1212
|
+
try {
|
1213
|
+
const nonce = await getNonce(endpoint, address, text, network);
|
1214
|
+
return getSignedNonce(nonce, address, provider);
|
1215
|
+
} catch (error) {
|
1216
|
+
throw error;
|
1217
|
+
}
|
1218
|
+
};
|
1219
|
+
var getNonce = async (endpoint, address, text, network = "concordium") => {
|
1220
|
+
try {
|
1221
|
+
const nonce = (await axios.post(`${endpoint}/wallet/v1/${network}/${address}/nonce`, { text }))?.data.nonce;
|
1222
|
+
return nonce;
|
1223
|
+
} catch (error) {
|
1224
|
+
throw error;
|
1225
|
+
}
|
1226
|
+
};
|
1227
|
+
var getSignedNonce = async (nonce, address, provider) => {
|
1228
|
+
const signature = await provider.signMessage(address, stringMessage(`${nonce}`));
|
1229
|
+
return Buffer.from(
|
1230
|
+
typeof signature === "object" && signature !== null ? JSON.stringify(signature) : signature,
|
1231
|
+
"utf-8"
|
1232
|
+
).toString("base64");
|
1233
|
+
};
|
1234
|
+
var revokeConsents = async (endpoint, level, uuid, wallet, signature, web3id, jwt, network = "concordium") => {
|
1235
|
+
const url = `${endpoint}/consent/v1/level${level}/revoke/${uuid}`;
|
1236
|
+
const urlV2 = `${endpoint}/consent/v2/level${level}/revoke/${uuid}`;
|
1237
|
+
sessionStorage.setItem("consentGranted", "false");
|
1238
|
+
try {
|
1239
|
+
switch (level) {
|
1240
|
+
case "2":
|
1241
|
+
await axios.put(`${url}`, null, {
|
1242
|
+
headers: {
|
1243
|
+
"Content-Type": "application/json",
|
1244
|
+
Authorization: "Bearer " + jwt
|
1245
|
+
}
|
1246
|
+
});
|
1247
|
+
break;
|
1248
|
+
case "3":
|
1249
|
+
await axios.put(`${url}/${network}/${wallet}`, {
|
1250
|
+
signature
|
1251
|
+
});
|
1252
|
+
break;
|
1253
|
+
case "4":
|
1254
|
+
await axios.put(
|
1255
|
+
`${urlV2}/${network}/${wallet}`,
|
1256
|
+
{
|
1257
|
+
signature
|
1258
|
+
},
|
1259
|
+
{
|
1260
|
+
headers: {
|
1261
|
+
"Content-Type": "application/json",
|
1262
|
+
Authorization: "Bearer " + jwt
|
1263
|
+
}
|
1264
|
+
}
|
1265
|
+
);
|
1266
|
+
break;
|
1267
|
+
default:
|
1268
|
+
break;
|
1269
|
+
}
|
1270
|
+
} catch (error) {
|
1271
|
+
throw error;
|
1272
|
+
}
|
1273
|
+
};
|
1274
|
+
var getMember = async (endpoint, accessToken) => {
|
1275
|
+
try {
|
1276
|
+
const member = await axios.get(
|
1277
|
+
`${endpoint}/index.php?webserviceClient=site&webserviceVersion=1.0.0&option=persona&api=hal&task=getTokenByUser`,
|
1278
|
+
{
|
1279
|
+
headers: {
|
1280
|
+
"Content-Type": "application/json",
|
1281
|
+
Authorization: "Bearer " + accessToken
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
);
|
1285
|
+
if (member?.data?.result?.member_id) {
|
1286
|
+
const data = await axios.get(
|
1287
|
+
`${endpoint}/index.php?webserviceClient=site&webserviceVersion=1.0.0&option=member&api=hal&id=${member?.data?.result?.member_id}`,
|
1288
|
+
{
|
1289
|
+
headers: {
|
1290
|
+
"Content-Type": "application/json",
|
1291
|
+
Authorization: "Bearer " + accessToken
|
1292
|
+
}
|
1293
|
+
}
|
1294
|
+
);
|
1295
|
+
return data?.data;
|
1296
|
+
}
|
1297
|
+
} catch (error) {
|
1298
|
+
console.log("getMember", error);
|
1299
|
+
throw error;
|
1300
|
+
}
|
1301
|
+
};
|
1302
|
+
var getWalletNonce = async (endpoint, wallet, publicAddress) => {
|
1303
|
+
try {
|
1304
|
+
const reqAuthFormData = {
|
1305
|
+
publicAddress,
|
1306
|
+
wallet,
|
1307
|
+
text: `Login with nonce: {}`
|
1308
|
+
};
|
1309
|
+
const config = {
|
1310
|
+
method: "post",
|
1311
|
+
url: `${endpoint}/index.php?webserviceClient=site&webserviceVersion=1.0.0&option=member&task=getWalletNonce&api=hal`,
|
1312
|
+
headers: {
|
1313
|
+
"Content-Type": "application/json"
|
1314
|
+
},
|
1315
|
+
data: reqAuthFormData
|
1316
|
+
};
|
1317
|
+
const { data } = await axios(config);
|
1318
|
+
if (data.result) {
|
1319
|
+
return data.result;
|
1320
|
+
}
|
1321
|
+
throw false;
|
1322
|
+
} catch (error) {
|
1323
|
+
throw error;
|
1324
|
+
}
|
1325
|
+
};
|
1326
|
+
var verifySignature = async (endpoint, wallet, publicAddress, signature) => {
|
1327
|
+
try {
|
1328
|
+
const returnParams = new URLSearchParams(window.location.search)?.get("return");
|
1329
|
+
const reqAuthFormData = {
|
1330
|
+
wallet,
|
1331
|
+
publicAddress,
|
1332
|
+
signature
|
1333
|
+
};
|
1334
|
+
const config = {
|
1335
|
+
method: "post",
|
1336
|
+
url: `${endpoint}/index.php?webserviceClient=site&webserviceVersion=1.0.0&option=member&task=walletLogin&api=hal&return=${returnParams ?? null}`,
|
1337
|
+
headers: {
|
1338
|
+
"Content-Type": "application/json"
|
1339
|
+
},
|
1340
|
+
data: reqAuthFormData
|
1341
|
+
};
|
1342
|
+
const { data } = await axios(config);
|
1343
|
+
if (data?.result) {
|
1344
|
+
return data?.result;
|
1345
|
+
} else {
|
1346
|
+
throw false;
|
1347
|
+
}
|
1348
|
+
} catch (error) {
|
1349
|
+
console.log(error);
|
1350
|
+
throw error;
|
1351
|
+
}
|
1352
|
+
};
|
1353
|
+
var getConsentTemplate = async (domain) => {
|
1354
|
+
try {
|
1355
|
+
const endpointWeb3 = "https://web3id.backend.aesirx.io:8001";
|
1356
|
+
const data = await axios.get(`${endpointWeb3}/datastream/template/${domain}`, {
|
1357
|
+
headers: {
|
1358
|
+
"Content-Type": "application/json"
|
1359
|
+
}
|
1360
|
+
});
|
1361
|
+
if (data) {
|
1362
|
+
return data;
|
1363
|
+
}
|
1364
|
+
} catch (error) {
|
1365
|
+
console.log("error", error);
|
1366
|
+
}
|
1367
|
+
};
|
1368
|
+
|
1116
1369
|
export {
|
1117
1370
|
useTranslation,
|
1118
1371
|
AnalyticsContext,
|
1119
|
-
AnalyticsContextProvider_default
|
1372
|
+
AnalyticsContextProvider_default,
|
1373
|
+
agreeConsents,
|
1374
|
+
loadGtagScript,
|
1375
|
+
loadGtmScript,
|
1376
|
+
getConsents,
|
1377
|
+
getSignature,
|
1378
|
+
getNonce,
|
1379
|
+
revokeConsents,
|
1380
|
+
getMember,
|
1381
|
+
getWalletNonce,
|
1382
|
+
verifySignature,
|
1383
|
+
getConsentTemplate
|
1120
1384
|
};
|
1121
1385
|
/*
|
1122
1386
|
* @copyright Copyright (C) 2022 AesirX. All rights reserved.
|
package/dist/index.d.ts
CHANGED
@@ -4,10 +4,12 @@ import { NextRouter } from 'next/router';
|
|
4
4
|
interface AnalyticsNext {
|
5
5
|
router: NextRouter;
|
6
6
|
attributes: any;
|
7
|
-
|
7
|
+
oldLayout?: boolean;
|
8
|
+
loginApp?: any;
|
9
|
+
isLoggedApp?: boolean;
|
8
10
|
children?: ReactNode;
|
9
11
|
}
|
10
|
-
declare const AnalyticsNext: ({ router, attributes,
|
12
|
+
declare const AnalyticsNext: ({ router, attributes, oldLayout, loginApp, isLoggedApp, children, }: AnalyticsNext) => React.JSX.Element;
|
11
13
|
|
12
14
|
interface AnalyticsReact {
|
13
15
|
location: {
|
@@ -18,8 +20,9 @@ interface AnalyticsReact {
|
|
18
20
|
replace: (_: object) => void;
|
19
21
|
};
|
20
22
|
children?: ReactNode;
|
23
|
+
oldLayout?: boolean;
|
21
24
|
}
|
22
|
-
declare const AnalyticsReact: ({ location, history, children }: AnalyticsReact) => React.JSX.Element;
|
25
|
+
declare const AnalyticsReact: ({ location, history, oldLayout, children }: AnalyticsReact) => React.JSX.Element;
|
23
26
|
|
24
27
|
declare const trackEvent: (endpoint: string, referer?: string, data?: object) => Promise<boolean>;
|
25
28
|
|
@@ -28,6 +31,7 @@ interface AnalyticsContextType {
|
|
28
31
|
visitor_uuid: string;
|
29
32
|
setEventID: Dispatch<SetStateAction<string>>;
|
30
33
|
setUUID: Dispatch<SetStateAction<string>>;
|
34
|
+
ref: any;
|
31
35
|
}
|
32
36
|
declare const AnalyticsContext: React.Context<AnalyticsContextType>;
|
33
37
|
|
package/dist/index.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import {
|
2
2
|
AnalyticsContext,
|
3
|
-
AnalyticsContextProvider_default
|
4
|
-
|
3
|
+
AnalyticsContextProvider_default,
|
4
|
+
getConsentTemplate
|
5
|
+
} from "./chunk-N36VEWSG.js";
|
5
6
|
|
6
7
|
// src/AnalyticsNext/index.tsx
|
7
|
-
import React2 from "react";
|
8
|
+
import React2, { useEffect as useEffect2, useState as useState2 } from "react";
|
8
9
|
|
9
10
|
// src/AnalyticsNext/handle.tsx
|
10
11
|
import React, { useCallback, useEffect, useState } from "react";
|
@@ -381,10 +382,14 @@ var startTracker = async (endpoint, url, referer, user_agent, attributesVisit) =
|
|
381
382
|
});
|
382
383
|
if (window["aesirxTrackEcommerce"] === "true" && sessionStorage.getItem("aesirx-analytics-flow") !== (await responseStart)?.flow_uuid) {
|
383
384
|
sessionStorage.setItem("aesirx-analytics-flow", (await responseStart)?.flow_uuid);
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
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
|
+
}
|
388
393
|
}
|
389
394
|
return responseStart;
|
390
395
|
} catch (error) {
|
@@ -518,36 +523,64 @@ var handle_default = AnalyticsHandle;
|
|
518
523
|
|
519
524
|
// src/AnalyticsNext/index.tsx
|
520
525
|
import dynamic from "next/dynamic";
|
521
|
-
var ConsentComponent = dynamic(() => import("./Consent-
|
522
|
-
var ConsentComponentCustom = dynamic(() => import("./ConsentCustom-
|
523
|
-
var AnalyticsNext = ({
|
524
|
-
|
525
|
-
|
526
|
+
var ConsentComponent = dynamic(() => import("./Consent-U7ESRVW5.js"), { ssr: false });
|
527
|
+
var ConsentComponentCustom = dynamic(() => import("./ConsentCustom-CSPWI25K.js"), { ssr: false });
|
528
|
+
var AnalyticsNext = ({
|
529
|
+
router,
|
530
|
+
attributes,
|
531
|
+
oldLayout = false,
|
532
|
+
loginApp,
|
533
|
+
isLoggedApp,
|
534
|
+
children
|
535
|
+
}) => {
|
536
|
+
const [layout, setLayout] = useState2(process.env.NEXT_PUBLIC_CONSENT_LAYOUT);
|
537
|
+
const [gtagId, setGtagId] = useState2(process.env.NEXT_PUBLIC_ANALYTICS_GTAG_ID);
|
538
|
+
const [gtmId, setGtmId] = useState2(process.env.NEXT_PUBLIC_ANALYTICS_GTM_ID);
|
539
|
+
useEffect2(() => {
|
540
|
+
const init = async () => {
|
541
|
+
const data = await getConsentTemplate(window.location.host);
|
542
|
+
setLayout(data?.data?.template ?? process.env.NEXT_PUBLIC_CONSENT_LAYOUT);
|
543
|
+
setGtagId(data?.data?.gtag_id ?? process.env.NEXT_PUBLIC_ANALYTICS_GTAG_ID);
|
544
|
+
setGtmId(data?.data?.gtm_id ?? process.env.NEXT_PUBLIC_ANALYTICS_GTM_ID);
|
545
|
+
};
|
546
|
+
init();
|
547
|
+
}, []);
|
548
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(AnalyticsContextProvider_default, null, /* @__PURE__ */ React2.createElement(handle_default, { router, attributes }, children, process.env.NEXT_PUBLIC_DISABLE_ANALYTICS_CONSENT !== "true" && /* @__PURE__ */ React2.createElement(React2.Fragment, null, oldLayout || layout === "original" ? /* @__PURE__ */ React2.createElement(
|
549
|
+
ConsentComponent,
|
526
550
|
{
|
527
551
|
endpoint: process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL,
|
528
552
|
networkEnv: process.env.NEXT_PUBLIC_CONCORDIUM_NETWORK,
|
529
|
-
aesirXEndpoint: process.env.NEXT_PUBLIC_ENDPOINT_URL ?? "https://api.aesirx.io"
|
553
|
+
aesirXEndpoint: process.env.NEXT_PUBLIC_ENDPOINT_URL ?? "https://api.aesirx.io",
|
554
|
+
loginApp,
|
555
|
+
isLoggedApp,
|
556
|
+
gtagId,
|
557
|
+
gtmId
|
530
558
|
}
|
531
559
|
) : /* @__PURE__ */ React2.createElement(
|
532
|
-
|
560
|
+
ConsentComponentCustom,
|
533
561
|
{
|
534
562
|
endpoint: process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL,
|
535
563
|
networkEnv: process.env.NEXT_PUBLIC_CONCORDIUM_NETWORK,
|
536
|
-
aesirXEndpoint: process.env.NEXT_PUBLIC_ENDPOINT_URL ?? "https://api.aesirx.io"
|
564
|
+
aesirXEndpoint: process.env.NEXT_PUBLIC_ENDPOINT_URL ?? "https://api.aesirx.io",
|
565
|
+
loginApp,
|
566
|
+
isLoggedApp,
|
567
|
+
gtagId,
|
568
|
+
gtmId,
|
569
|
+
layout
|
537
570
|
}
|
538
571
|
)))));
|
539
572
|
};
|
540
573
|
var AnalyticsNext_default = AnalyticsNext;
|
541
574
|
|
542
575
|
// src/AnalyticsReact/index.tsx
|
543
|
-
import React4, { Suspense } from "react";
|
576
|
+
import React4, { Suspense, useEffect as useEffect4, useState as useState3 } from "react";
|
544
577
|
|
545
578
|
// src/AnalyticsReact/handle.tsx
|
546
|
-
import React3, { useEffect as
|
579
|
+
import React3, { useEffect as useEffect3 } from "react";
|
547
580
|
var AnalyticsHandle2 = ({ location, history, children }) => {
|
548
581
|
const AnalyticsStore = React3.useContext(AnalyticsContext);
|
549
582
|
const endPoint = process.env.REACT_APP_ENDPOINT_ANALYTICS_URL;
|
550
|
-
|
583
|
+
useEffect3(() => {
|
551
584
|
const init = async () => {
|
552
585
|
if (!AnalyticsStore.visitor_uuid) {
|
553
586
|
const referer = location.pathname ? location.pathname : "";
|
@@ -561,13 +594,13 @@ var AnalyticsHandle2 = ({ location, history, children }) => {
|
|
561
594
|
};
|
562
595
|
init();
|
563
596
|
}, [location.pathname, history]);
|
564
|
-
|
597
|
+
useEffect3(() => {
|
565
598
|
const init = async () => {
|
566
599
|
endTrackerVisibilityState(endPoint);
|
567
600
|
};
|
568
601
|
init();
|
569
602
|
}, []);
|
570
|
-
|
603
|
+
useEffect3(() => {
|
571
604
|
const init = async () => {
|
572
605
|
window["event_uuid"] = AnalyticsStore.event_uuid;
|
573
606
|
window["visitor_uuid"] = AnalyticsStore.visitor_uuid;
|
@@ -579,14 +612,39 @@ var AnalyticsHandle2 = ({ location, history, children }) => {
|
|
579
612
|
var handle_default2 = AnalyticsHandle2;
|
580
613
|
|
581
614
|
// src/AnalyticsReact/index.tsx
|
582
|
-
var ConsentComponent2 = React4.lazy(() => import("./Consent-
|
583
|
-
var
|
584
|
-
|
615
|
+
var ConsentComponent2 = React4.lazy(() => import("./Consent-U7ESRVW5.js"));
|
616
|
+
var ConsentComponentCustom2 = React4.lazy(() => import("./ConsentCustom-CSPWI25K.js"));
|
617
|
+
var AnalyticsReact = ({ location, history, oldLayout = false, children }) => {
|
618
|
+
const [layout, setLayout] = useState3(process.env.REACT_APP_CONSENT_LAYOUT);
|
619
|
+
const [gtagId, setGtagId] = useState3(process.env.REACT_APP_ANALYTICS_GTAG_ID);
|
620
|
+
const [gtmId, setGtmId] = useState3(process.env.REACT_APP_ANALYTICS_GTM_ID);
|
621
|
+
useEffect4(() => {
|
622
|
+
const init = async () => {
|
623
|
+
const data = await getConsentTemplate(window.location.host);
|
624
|
+
setLayout(data?.data?.template ?? process.env.REACT_APP_CONSENT_LAYOUT);
|
625
|
+
setGtagId(data?.data?.gtag_id ?? process.env.REACT_APP_ANALYTICS_GTAG_ID);
|
626
|
+
setGtmId(data?.data?.gtm_id ?? process.env.REACT_APP_ANALYTICS_GTM_ID);
|
627
|
+
};
|
628
|
+
init();
|
629
|
+
}, []);
|
630
|
+
return /* @__PURE__ */ React4.createElement(AnalyticsContextProvider_default, null, /* @__PURE__ */ React4.createElement(handle_default2, { location, history }, children, process.env.REACT_APP_DISABLE_ANALYTICS_CONSENT !== "true" && /* @__PURE__ */ React4.createElement(Suspense, { fallback: /* @__PURE__ */ React4.createElement(React4.Fragment, null) }, oldLayout || layout === "original" ? /* @__PURE__ */ React4.createElement(
|
585
631
|
ConsentComponent2,
|
586
632
|
{
|
587
633
|
endpoint: process.env.REACT_APP_ENDPOINT_ANALYTICS_URL,
|
588
634
|
networkEnv: process.env.REACT_APP_CONCORDIUM_NETWORK,
|
589
|
-
aesirXEndpoint: process.env.REACT_APP_ENDPOINT_URL ?? "https://api.aesirx.io"
|
635
|
+
aesirXEndpoint: process.env.REACT_APP_ENDPOINT_URL ?? "https://api.aesirx.io",
|
636
|
+
gtagId,
|
637
|
+
gtmId
|
638
|
+
}
|
639
|
+
) : /* @__PURE__ */ React4.createElement(
|
640
|
+
ConsentComponentCustom2,
|
641
|
+
{
|
642
|
+
endpoint: process.env.REACT_APP_ENDPOINT_ANALYTICS_URL,
|
643
|
+
networkEnv: process.env.REACT_APP_CONCORDIUM_NETWORK,
|
644
|
+
aesirXEndpoint: process.env.REACT_APP_ENDPOINT_URL ?? "https://api.aesirx.io",
|
645
|
+
gtagId,
|
646
|
+
gtmId,
|
647
|
+
layout
|
590
648
|
}
|
591
649
|
))));
|
592
650
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "aesirx-analytics",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.6",
|
4
4
|
"license": "GPL-3.0-only",
|
5
5
|
"author": "AesirX",
|
6
6
|
"repository": "https://gitlab.redweb.dk/aesirx/analytics",
|
@@ -21,13 +21,13 @@
|
|
21
21
|
"buffer": "^6.0.3",
|
22
22
|
"ethers": "^6.6.5",
|
23
23
|
"i18next": "^23.6.0",
|
24
|
-
"i18next-browser-languagedetector": "^7.1
|
24
|
+
"i18next-browser-languagedetector": "^7.2.1",
|
25
25
|
"murmurhash-js": "^1.0.0",
|
26
26
|
"next": "^14.1.0",
|
27
27
|
"query-string": "^7.1.1",
|
28
|
-
"react": "^18.
|
28
|
+
"react": "^18.3.1",
|
29
29
|
"react-bootstrap": "^2.8.0",
|
30
|
-
"react-content-loader": "^
|
30
|
+
"react-content-loader": "^7.0.0",
|
31
31
|
"react-device-detect": "^2.2.3",
|
32
32
|
"react-dom": "18",
|
33
33
|
"react-toastify": "^9.1.3",
|
@@ -63,13 +63,13 @@
|
|
63
63
|
]
|
64
64
|
},
|
65
65
|
"devDependencies": {
|
66
|
-
"@babel/preset-env": "^7.
|
66
|
+
"@babel/preset-env": "^7.24.5",
|
67
67
|
"@babel/preset-typescript": "^7.23.0",
|
68
68
|
"@jest/globals": "^29.7.0",
|
69
69
|
"@types/jest": "^29.5.0",
|
70
70
|
"@types/murmurhash-js": "^1.0.3",
|
71
71
|
"@types/node": "^20.8.0",
|
72
|
-
"@types/react": "^18.
|
72
|
+
"@types/react": "^18.3.1",
|
73
73
|
"@types/react-dom": "^18.2.14",
|
74
74
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
75
75
|
"@typescript-eslint/parser": "^5.57.0",
|