aesirx-analytics 2.2.5 → 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-ZWVGMKB7.js → Consent-U7ESRVW5.js} +124 -21
- package/dist/{ConsentCustom-P3FMYMS3.js → ConsentCustom-CSPWI25K.js} +192 -86
- package/dist/analytics.js +118 -115
- package/dist/{chunk-PHG7RB3K.js → chunk-7GRKFZZL.js} +125 -298
- package/dist/{chunk-JH54YDTD.js → chunk-N36VEWSG.js} +262 -1
- package/dist/index.js +63 -24
- package/package.json +1 -1
package/README.md
CHANGED
@@ -22,6 +22,7 @@ Follow the instructions in: [https://github.com/aesirxio/analytics-1stparty](htt
|
|
22
22
|
<script>
|
23
23
|
window.aesirx1stparty = "https://example.com"
|
24
24
|
window.aesirxClientID="[REPLACE THIS WITH THE PROVIDED CLIENT_ID]"
|
25
|
+
window.aesirxClientSecret="[REPLACE THIS WITH THE PROVIDED CLIENT_SECRET]"
|
25
26
|
</script>
|
26
27
|
<script async defer src="YOUR_PROJECT_PATH/analytics.js"></script>
|
27
28
|
```
|
@@ -46,9 +47,11 @@ Follow the instructions in: [https://github.com/aesirxio/analytics-1stparty](htt
|
|
46
47
|
```
|
47
48
|
REACT_APP_ENDPOINT_ANALYTICS_URL=https://example.com
|
48
49
|
REACT_APP_SSO_CLIENT_ID=[REPLACE THIS WITH THE PROVIDED CLIENT_ID]
|
50
|
+
REACT_APP_SSO_CLIENT_SECRET=[REPLACE THIS WITH THE PROVIDED CLIENT_SECRET]
|
49
51
|
|
50
52
|
(https://example.com is the link to your 1st party server)
|
51
53
|
`CLIENT_ID` replace this with the provided `CLIENT_ID` from https://dapp.shield.aesirx.io/
|
54
|
+
`CLIENT_SECRET` replace this with the provided `CLIENT_SECRET` fromhttps://dapp.shield.aesirx.io/
|
52
55
|
```
|
53
56
|
|
54
57
|
##### Disable Consent Popup:
|
@@ -87,9 +90,11 @@ export default AnalyticsContainer;
|
|
87
90
|
```
|
88
91
|
NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL=https://example.com
|
89
92
|
NEXT_PUBLIC_SSO_CLIENT_ID=[REPLACE THIS WITH THE PROVIDED CLIENT_ID]
|
93
|
+
NEXT_PUBLIC_SSO_CLIENT_SECRET=[REPLACE THIS WITH THE PROVIDED CLIENT_SECRET]
|
90
94
|
|
91
95
|
(https://example.com is the link to your 1st party server)
|
92
96
|
`CLIENT_ID` replace this with the provided `CLIENT_ID` from https://dapp.shield.aesirx.io/
|
97
|
+
`CLIENT_SECRET` replace this with the provided `CLIENT_SECRET` fromhttps://dapp.shield.aesirx.io/
|
93
98
|
```
|
94
99
|
|
95
100
|
##### Disable Consent Popup:
|
@@ -274,4 +279,37 @@ Please follow below CSS example:
|
|
274
279
|
[data-bs-theme=dark] .aesirxconsent {
|
275
280
|
color: #fff;
|
276
281
|
}
|
282
|
+
```
|
283
|
+
|
284
|
+
|
285
|
+
## Choose template for Consent modal
|
286
|
+
|
287
|
+
There is 5 template for Consent modal
|
288
|
+
1. original
|
289
|
+
2. default (recommend)
|
290
|
+
3. simple-consent-mode
|
291
|
+
1. Support Basic Consent Mode v2
|
292
|
+
4. advance-consent-mode
|
293
|
+
1. Support Advance Consent Mode v2
|
294
|
+
5. simple-web-2
|
295
|
+
|
296
|
+
#### Usage in SSR site:
|
297
|
+
```
|
298
|
+
<script>
|
299
|
+
window.consentLayout = "default"
|
300
|
+
</script>
|
301
|
+
```
|
302
|
+
|
303
|
+
#### In ReactJS:
|
304
|
+
|
305
|
+
add this environment variable to `.env`
|
306
|
+
```
|
307
|
+
REACT_APP_CONSENT_LAYOUT=default
|
308
|
+
```
|
309
|
+
|
310
|
+
#### In NextJS:
|
311
|
+
|
312
|
+
add this environment variable to `.env`
|
313
|
+
```
|
314
|
+
NEXT_PUBLIC_CONSENT_LAYOUT=default
|
277
315
|
```
|
@@ -5,25 +5,27 @@ import {
|
|
5
5
|
LoadingStatus,
|
6
6
|
TermsComponent,
|
7
7
|
WALLET_CONNECT,
|
8
|
-
agreeConsents,
|
9
8
|
bg_default,
|
10
|
-
getConsents,
|
11
|
-
getMember,
|
12
|
-
getNonce,
|
13
|
-
getSignature,
|
14
|
-
getWalletNonce,
|
15
9
|
getWeb3ID,
|
16
10
|
no_default,
|
17
11
|
privacy_default,
|
18
|
-
revokeConsents,
|
19
12
|
useConsentStatus_default,
|
20
|
-
verifySignature,
|
21
13
|
yes_default
|
22
|
-
} from "./chunk-
|
14
|
+
} from "./chunk-7GRKFZZL.js";
|
23
15
|
import {
|
24
16
|
AnalyticsContext,
|
25
|
-
|
26
|
-
|
17
|
+
agreeConsents,
|
18
|
+
getConsents,
|
19
|
+
getMember,
|
20
|
+
getNonce,
|
21
|
+
getSignature,
|
22
|
+
getWalletNonce,
|
23
|
+
loadGtagScript,
|
24
|
+
loadGtmScript,
|
25
|
+
revokeConsents,
|
26
|
+
useTranslation,
|
27
|
+
verifySignature
|
28
|
+
} from "./chunk-N36VEWSG.js";
|
27
29
|
|
28
30
|
// src/Components/Consent.tsx
|
29
31
|
import React, { useContext, useEffect, useState } from "react";
|
@@ -47,7 +49,16 @@ import {
|
|
47
49
|
} from "@concordium/react-components";
|
48
50
|
import { OsTypes, isDesktop, isMobile, osName } from "react-device-detect";
|
49
51
|
import { useAccount, useSignMessage } from "wagmi";
|
50
|
-
var ConsentComponent = ({
|
52
|
+
var ConsentComponent = ({
|
53
|
+
endpoint,
|
54
|
+
aesirXEndpoint,
|
55
|
+
networkEnv,
|
56
|
+
loginApp,
|
57
|
+
isLoggedApp,
|
58
|
+
gtagId,
|
59
|
+
gtmId,
|
60
|
+
layout
|
61
|
+
}) => {
|
51
62
|
return /* @__PURE__ */ React.createElement(WithWalletConnector, { network: networkEnv === "testnet" ? TESTNET : MAINNET }, (props) => /* @__PURE__ */ React.createElement("div", { className: "aesirxconsent" }, /* @__PURE__ */ React.createElement(Ethereum_default, null, /* @__PURE__ */ React.createElement(
|
52
63
|
ConsentComponentApp,
|
53
64
|
{
|
@@ -55,7 +66,10 @@ var ConsentComponent = ({ endpoint, aesirXEndpoint, networkEnv, loginApp, isLogg
|
|
55
66
|
endpoint,
|
56
67
|
aesirXEndpoint,
|
57
68
|
loginApp,
|
58
|
-
isLoggedApp
|
69
|
+
isLoggedApp,
|
70
|
+
gtagId,
|
71
|
+
gtmId,
|
72
|
+
layout
|
59
73
|
}
|
60
74
|
))));
|
61
75
|
};
|
@@ -65,6 +79,9 @@ var ConsentComponentApp = (props) => {
|
|
65
79
|
aesirXEndpoint,
|
66
80
|
loginApp,
|
67
81
|
isLoggedApp,
|
82
|
+
gtagId,
|
83
|
+
gtmId,
|
84
|
+
layout,
|
68
85
|
activeConnectorType,
|
69
86
|
activeConnector,
|
70
87
|
activeConnectorError,
|
@@ -93,7 +110,7 @@ var ConsentComponentApp = (props) => {
|
|
93
110
|
handleLevel,
|
94
111
|
showRevoke,
|
95
112
|
handleRevoke
|
96
|
-
] = useConsentStatus_default(endpoint, props);
|
113
|
+
] = useConsentStatus_default(endpoint, layout, props);
|
97
114
|
const [consents, setConsents] = useState([1, 2]);
|
98
115
|
const [loading, setLoading] = useState("done");
|
99
116
|
const [loadingCheckAccount, setLoadingCheckAccount] = useState(false);
|
@@ -155,7 +172,10 @@ var ConsentComponentApp = (props) => {
|
|
155
172
|
signature,
|
156
173
|
web3ID,
|
157
174
|
jwt,
|
158
|
-
"metamask"
|
175
|
+
"metamask",
|
176
|
+
gtagId,
|
177
|
+
gtmId,
|
178
|
+
layout
|
159
179
|
);
|
160
180
|
sessionStorage.setItem("aesirx-analytics-uuid", uuid);
|
161
181
|
sessionStorage.setItem("aesirx-analytics-allow", "1");
|
@@ -233,7 +253,20 @@ var ConsentComponentApp = (props) => {
|
|
233
253
|
level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}"
|
234
254
|
);
|
235
255
|
setLoading("saving");
|
236
|
-
await agreeConsents(
|
256
|
+
await agreeConsents(
|
257
|
+
endpoint,
|
258
|
+
level,
|
259
|
+
uuid,
|
260
|
+
consents,
|
261
|
+
account,
|
262
|
+
signature,
|
263
|
+
web3ID,
|
264
|
+
jwt,
|
265
|
+
"concordium",
|
266
|
+
gtagId,
|
267
|
+
gtmId,
|
268
|
+
layout
|
269
|
+
);
|
237
270
|
sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
|
238
271
|
} else if (connector) {
|
239
272
|
if (level === 3) {
|
@@ -255,9 +288,35 @@ var ConsentComponentApp = (props) => {
|
|
255
288
|
consents.forEach(async (consent) => {
|
256
289
|
const existConsent = consentList.find((item) => item?.consent === consent);
|
257
290
|
if (!existConsent) {
|
258
|
-
await agreeConsents(
|
291
|
+
await agreeConsents(
|
292
|
+
endpoint,
|
293
|
+
1,
|
294
|
+
uuid,
|
295
|
+
consent,
|
296
|
+
null,
|
297
|
+
null,
|
298
|
+
null,
|
299
|
+
null,
|
300
|
+
"concordium",
|
301
|
+
gtagId,
|
302
|
+
gtmId,
|
303
|
+
layout
|
304
|
+
);
|
259
305
|
} else if (!!existConsent?.consent_uuid && existConsent?.expiration && new Date(existConsent.expiration) < /* @__PURE__ */ new Date()) {
|
260
|
-
await agreeConsents(
|
306
|
+
await agreeConsents(
|
307
|
+
endpoint,
|
308
|
+
1,
|
309
|
+
uuid,
|
310
|
+
consent,
|
311
|
+
null,
|
312
|
+
null,
|
313
|
+
null,
|
314
|
+
null,
|
315
|
+
"concordium",
|
316
|
+
gtagId,
|
317
|
+
gtmId,
|
318
|
+
layout
|
319
|
+
);
|
261
320
|
}
|
262
321
|
});
|
263
322
|
}
|
@@ -315,7 +374,11 @@ var ConsentComponentApp = (props) => {
|
|
315
374
|
account,
|
316
375
|
signature,
|
317
376
|
null,
|
318
|
-
response?.jwt
|
377
|
+
response?.jwt,
|
378
|
+
"concordium",
|
379
|
+
gtagId,
|
380
|
+
gtmId,
|
381
|
+
layout
|
319
382
|
);
|
320
383
|
setShow(false);
|
321
384
|
handleRevoke(true, level);
|
@@ -354,7 +417,20 @@ var ConsentComponentApp = (props) => {
|
|
354
417
|
}
|
355
418
|
setConsentTier4(response);
|
356
419
|
} else {
|
357
|
-
await agreeConsents(
|
420
|
+
await agreeConsents(
|
421
|
+
endpoint,
|
422
|
+
level,
|
423
|
+
uuid,
|
424
|
+
consents,
|
425
|
+
null,
|
426
|
+
null,
|
427
|
+
null,
|
428
|
+
response?.jwt,
|
429
|
+
"concordium",
|
430
|
+
gtagId,
|
431
|
+
gtmId,
|
432
|
+
layout
|
433
|
+
);
|
358
434
|
setShow(false);
|
359
435
|
handleRevoke(true, level);
|
360
436
|
setLoading("done");
|
@@ -463,6 +539,32 @@ var ConsentComponentApp = (props) => {
|
|
463
539
|
const element = document.querySelector(selector);
|
464
540
|
element.click();
|
465
541
|
};
|
542
|
+
const loadConsentDefault = (gtagId2, gtmId2) => {
|
543
|
+
window.dataLayer = window.dataLayer || [];
|
544
|
+
function gtag(p0, p1, p2) {
|
545
|
+
dataLayer.push(arguments);
|
546
|
+
}
|
547
|
+
gtag("consent", "default", {
|
548
|
+
ad_user_data: "denied",
|
549
|
+
ad_personalization: "denied",
|
550
|
+
ad_storage: "denied",
|
551
|
+
analytics_storage: "denied",
|
552
|
+
wait_for_update: 500
|
553
|
+
});
|
554
|
+
if (gtagId2) {
|
555
|
+
gtag("js", /* @__PURE__ */ new Date());
|
556
|
+
gtag("config", `${gtagId2}`);
|
557
|
+
}
|
558
|
+
if (gtmId2) {
|
559
|
+
dataLayer.push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), event: "gtm.js" });
|
560
|
+
}
|
561
|
+
if (layout === "advance-consent-mode") {
|
562
|
+
gtagId2 && loadGtagScript(gtagId2);
|
563
|
+
gtmId2 && loadGtmScript(gtmId2);
|
564
|
+
gtag("set", "url_passthrough", true);
|
565
|
+
gtag("set", "ads_data_redaction", true);
|
566
|
+
}
|
567
|
+
};
|
466
568
|
useEffect(() => {
|
467
569
|
if (activeConnectorError) {
|
468
570
|
toast.error(activeConnectorError);
|
@@ -473,6 +575,7 @@ var ConsentComponentApp = (props) => {
|
|
473
575
|
setShowBackdrop(false);
|
474
576
|
setShowExpandConsent(false);
|
475
577
|
}
|
578
|
+
(gtagId || gtmId) && loadConsentDefault(gtagId, gtmId);
|
476
579
|
}, []);
|
477
580
|
console.log("level", uuid, level, web3ID, account, loading);
|
478
581
|
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(ToastContainer, null), /* @__PURE__ */ React.createElement("div", { className: `offcanvas-backdrop fade ${showBackdrop && show ? "show" : "d-none"}` }), /* @__PURE__ */ React.createElement(
|
@@ -580,7 +683,7 @@ var ConsentComponentApp = (props) => {
|
|
580
683
|
},
|
581
684
|
/* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
|
582
685
|
t("txt_shield_of_privacy")
|
583
|
-
))) : /* @__PURE__ */ React.createElement(React.Fragment, null, level ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TermsComponent, { level, handleLevel }, /* @__PURE__ */ React.createElement(Form, { className: "mb-0" }, /* @__PURE__ */ React.createElement(
|
686
|
+
))) : /* @__PURE__ */ React.createElement(React.Fragment, null, level ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TermsComponent, { level, handleLevel, layout }, /* @__PURE__ */ React.createElement(Form, { className: "mb-0" }, /* @__PURE__ */ React.createElement(
|
584
687
|
Form.Check,
|
585
688
|
{
|
586
689
|
checked: consents.includes(1),
|