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 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-AJMXPNA2.js";
14
+ } from "./chunk-7GRKFZZL.js";
23
15
  import {
24
16
  AnalyticsContext,
25
- useTranslation
26
- } from "./chunk-FKCTTU52.js";
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,13 +49,39 @@ 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 = ({ endpoint, aesirXEndpoint, networkEnv }) => {
51
- 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(ConsentComponentApp, { ...props, endpoint, aesirXEndpoint }))));
52
+ var ConsentComponent = ({
53
+ endpoint,
54
+ aesirXEndpoint,
55
+ networkEnv,
56
+ loginApp,
57
+ isLoggedApp,
58
+ gtagId,
59
+ gtmId,
60
+ layout
61
+ }) => {
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(
63
+ ConsentComponentApp,
64
+ {
65
+ ...props,
66
+ endpoint,
67
+ aesirXEndpoint,
68
+ loginApp,
69
+ isLoggedApp,
70
+ gtagId,
71
+ gtmId,
72
+ layout
73
+ }
74
+ ))));
52
75
  };
53
76
  var ConsentComponentApp = (props) => {
54
77
  const {
55
78
  endpoint,
56
79
  aesirXEndpoint,
80
+ loginApp,
81
+ isLoggedApp,
82
+ gtagId,
83
+ gtmId,
84
+ layout,
57
85
  activeConnectorType,
58
86
  activeConnector,
59
87
  activeConnectorError,
@@ -82,7 +110,7 @@ var ConsentComponentApp = (props) => {
82
110
  handleLevel,
83
111
  showRevoke,
84
112
  handleRevoke
85
- ] = useConsentStatus_default(endpoint, props);
113
+ ] = useConsentStatus_default(endpoint, layout, props);
86
114
  const [consents, setConsents] = useState([1, 2]);
87
115
  const [loading, setLoading] = useState("done");
88
116
  const [loadingCheckAccount, setLoadingCheckAccount] = useState(false);
@@ -144,7 +172,10 @@ var ConsentComponentApp = (props) => {
144
172
  signature,
145
173
  web3ID,
146
174
  jwt,
147
- "metamask"
175
+ "metamask",
176
+ gtagId,
177
+ gtmId,
178
+ layout
148
179
  );
149
180
  sessionStorage.setItem("aesirx-analytics-uuid", uuid);
150
181
  sessionStorage.setItem("aesirx-analytics-allow", "1");
@@ -197,6 +228,7 @@ var ConsentComponentApp = (props) => {
197
228
  );
198
229
  sessionStorage.setItem("aesirx-analytics-jwt", data?.jwt);
199
230
  jwt = data?.jwt;
231
+ loginApp && !isLoggedApp && loginApp(data);
200
232
  setLoadingCheckAccount(false);
201
233
  }
202
234
  } else {
@@ -221,7 +253,20 @@ var ConsentComponentApp = (props) => {
221
253
  level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}"
222
254
  );
223
255
  setLoading("saving");
224
- await agreeConsents(endpoint, level, uuid, consents, account, signature, web3ID, jwt);
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
+ );
225
270
  sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
226
271
  } else if (connector) {
227
272
  if (level === 3) {
@@ -243,9 +288,35 @@ var ConsentComponentApp = (props) => {
243
288
  consents.forEach(async (consent) => {
244
289
  const existConsent = consentList.find((item) => item?.consent === consent);
245
290
  if (!existConsent) {
246
- await agreeConsents(endpoint, 1, uuid, consent);
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
+ );
247
305
  } else if (!!existConsent?.consent_uuid && existConsent?.expiration && new Date(existConsent.expiration) < /* @__PURE__ */ new Date()) {
248
- await agreeConsents(endpoint, 1, uuid, consent);
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
+ );
249
320
  }
250
321
  });
251
322
  }
@@ -303,7 +374,11 @@ var ConsentComponentApp = (props) => {
303
374
  account,
304
375
  signature,
305
376
  null,
306
- response?.jwt
377
+ response?.jwt,
378
+ "concordium",
379
+ gtagId,
380
+ gtmId,
381
+ layout
307
382
  );
308
383
  setShow(false);
309
384
  handleRevoke(true, level);
@@ -342,12 +417,26 @@ var ConsentComponentApp = (props) => {
342
417
  }
343
418
  setConsentTier4(response);
344
419
  } else {
345
- await agreeConsents(endpoint, level, uuid, consents, null, null, null, response?.jwt);
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
+ );
346
434
  setShow(false);
347
435
  handleRevoke(true, level);
348
436
  setLoading("done");
349
437
  }
350
438
  }
439
+ loginApp && !isLoggedApp && loginApp(response);
351
440
  } catch (error) {
352
441
  console.log(error);
353
442
  setShow(false);
@@ -450,6 +539,32 @@ var ConsentComponentApp = (props) => {
450
539
  const element = document.querySelector(selector);
451
540
  element.click();
452
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
+ };
453
568
  useEffect(() => {
454
569
  if (activeConnectorError) {
455
570
  toast.error(activeConnectorError);
@@ -460,6 +575,7 @@ var ConsentComponentApp = (props) => {
460
575
  setShowBackdrop(false);
461
576
  setShowExpandConsent(false);
462
577
  }
578
+ (gtagId || gtmId) && loadConsentDefault(gtagId, gtmId);
463
579
  }, []);
464
580
  console.log("level", uuid, level, web3ID, account, loading);
465
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(
@@ -567,7 +683,7 @@ var ConsentComponentApp = (props) => {
567
683
  },
568
684
  /* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
569
685
  t("txt_shield_of_privacy")
570
- ))) : /* @__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(
571
687
  Form.Check,
572
688
  {
573
689
  checked: consents.includes(1),