aesirx-analytics 2.2.5 → 2.2.7

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.
@@ -5,26 +5,28 @@ import {
5
5
  LoadingStatus,
6
6
  TermsComponent,
7
7
  WALLET_CONNECT,
8
- agreeConsents,
9
8
  arrow_default,
10
9
  bg_default,
11
- getConsents,
12
- getMember,
13
- getNonce,
14
- getSignature,
15
- getWalletNonce,
16
10
  getWeb3ID,
17
11
  no_default,
18
12
  privacy_default,
19
- revokeConsents,
20
13
  useConsentStatus_default,
21
- verifySignature,
22
14
  yes_default
23
- } from "./chunk-PHG7RB3K.js";
15
+ } from "./chunk-IMKTWH5I.js";
24
16
  import {
25
17
  AnalyticsContext,
26
- useTranslation
27
- } from "./chunk-JH54YDTD.js";
18
+ agreeConsents,
19
+ getConsents,
20
+ getMember,
21
+ getNonce,
22
+ getSignature,
23
+ getWalletNonce,
24
+ loadGtagScript,
25
+ loadGtmScript,
26
+ revokeConsents,
27
+ useTranslation,
28
+ verifySignature
29
+ } from "./chunk-N36VEWSG.js";
28
30
 
29
31
  // src/Components/ConsentCustom.tsx
30
32
  import React, { useContext, useEffect, useState } from "react";
@@ -56,7 +58,10 @@ var ConsentComponentCustom = ({
56
58
  aesirXEndpoint,
57
59
  networkEnv,
58
60
  loginApp,
59
- isLoggedApp
61
+ isLoggedApp,
62
+ gtagId,
63
+ gtmId,
64
+ layout
60
65
  }) => {
61
66
  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(
62
67
  ConsentComponentCustomApp,
@@ -65,7 +70,10 @@ var ConsentComponentCustom = ({
65
70
  endpoint,
66
71
  aesirXEndpoint,
67
72
  loginApp,
68
- isLoggedApp
73
+ isLoggedApp,
74
+ gtagId,
75
+ gtmId,
76
+ layout
69
77
  }
70
78
  ))));
71
79
  };
@@ -75,6 +83,9 @@ var ConsentComponentCustomApp = (props) => {
75
83
  aesirXEndpoint,
76
84
  loginApp,
77
85
  isLoggedApp,
86
+ gtagId,
87
+ gtmId,
88
+ layout,
78
89
  activeConnectorType,
79
90
  activeConnector,
80
91
  activeConnectorError,
@@ -103,7 +114,7 @@ var ConsentComponentCustomApp = (props) => {
103
114
  handleLevel,
104
115
  showRevoke,
105
116
  handleRevoke
106
- ] = useConsentStatus_default(endpoint, props);
117
+ ] = useConsentStatus_default(endpoint, layout, props);
107
118
  const [consents, setConsents] = useState([1, 2]);
108
119
  const [loading, setLoading] = useState("done");
109
120
  const [loadingCheckAccount, setLoadingCheckAccount] = useState(false);
@@ -168,7 +179,10 @@ var ConsentComponentCustomApp = (props) => {
168
179
  signature,
169
180
  web3ID,
170
181
  jwt,
171
- "metamask"
182
+ "metamask",
183
+ gtagId,
184
+ gtmId,
185
+ layout
172
186
  );
173
187
  sessionStorage.setItem("aesirx-analytics-uuid", uuid);
174
188
  sessionStorage.setItem("aesirx-analytics-allow", "1");
@@ -246,7 +260,20 @@ var ConsentComponentCustomApp = (props) => {
246
260
  level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}"
247
261
  );
248
262
  setLoading("saving");
249
- await agreeConsents(endpoint, level, uuid, consents, account, signature, web3ID, jwt);
263
+ await agreeConsents(
264
+ endpoint,
265
+ level,
266
+ uuid,
267
+ consents,
268
+ account,
269
+ signature,
270
+ web3ID,
271
+ jwt,
272
+ "concordium",
273
+ gtagId,
274
+ gtmId,
275
+ layout
276
+ );
250
277
  sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
251
278
  } else if (connector) {
252
279
  if (level === 3) {
@@ -268,9 +295,35 @@ var ConsentComponentCustomApp = (props) => {
268
295
  consents.forEach(async (consent) => {
269
296
  const existConsent = consentList.find((item) => item?.consent === consent);
270
297
  if (!existConsent) {
271
- await agreeConsents(endpoint, 1, uuid, consent);
298
+ await agreeConsents(
299
+ endpoint,
300
+ 1,
301
+ uuid,
302
+ consent,
303
+ null,
304
+ null,
305
+ null,
306
+ null,
307
+ null,
308
+ gtagId,
309
+ gtmId,
310
+ layout
311
+ );
272
312
  } else if (!!existConsent?.consent_uuid && existConsent?.expiration && new Date(existConsent.expiration) < /* @__PURE__ */ new Date()) {
273
- await agreeConsents(endpoint, 1, uuid, consent);
313
+ await agreeConsents(
314
+ endpoint,
315
+ 1,
316
+ uuid,
317
+ consent,
318
+ null,
319
+ null,
320
+ null,
321
+ null,
322
+ null,
323
+ gtagId,
324
+ gtmId,
325
+ layout
326
+ );
274
327
  }
275
328
  });
276
329
  }
@@ -328,7 +381,11 @@ var ConsentComponentCustomApp = (props) => {
328
381
  account,
329
382
  signature,
330
383
  null,
331
- response?.jwt
384
+ response?.jwt,
385
+ "concordium",
386
+ gtagId,
387
+ gtmId,
388
+ layout
332
389
  );
333
390
  setShow(false);
334
391
  handleRevoke(true, level);
@@ -367,7 +424,20 @@ var ConsentComponentCustomApp = (props) => {
367
424
  }
368
425
  setConsentTier4(response);
369
426
  } else {
370
- await agreeConsents(endpoint, level, uuid, consents, null, null, null, response?.jwt);
427
+ await agreeConsents(
428
+ endpoint,
429
+ level,
430
+ uuid,
431
+ consents,
432
+ null,
433
+ null,
434
+ null,
435
+ response?.jwt,
436
+ "concordium",
437
+ gtagId,
438
+ gtmId,
439
+ layout
440
+ );
371
441
  setShow(false);
372
442
  handleRevoke(true, level);
373
443
  setLoading("done");
@@ -489,6 +559,7 @@ var ConsentComponentCustomApp = (props) => {
489
559
  if (sessionStorage.getItem("aesirx-analytics-revoke") && sessionStorage.getItem("aesirx-analytics-revoke") !== "0") {
490
560
  window.funcAfterConsent && window.funcAfterConsent();
491
561
  }
562
+ (gtagId || gtmId) && loadConsentDefault(gtagId, gtmId);
492
563
  }, []);
493
564
  console.log("level", uuid, level, web3ID, account, loading);
494
565
  const ConsentLevelUprade = ({
@@ -519,6 +590,32 @@ var ConsentComponentCustomApp = (props) => {
519
590
  ))) : /* @__PURE__ */ React.createElement(React.Fragment, null)
520
591
  );
521
592
  };
593
+ const loadConsentDefault = (gtagId2, gtmId2) => {
594
+ window.dataLayer = window.dataLayer || [];
595
+ function gtag(p0, p1, p2) {
596
+ dataLayer.push(arguments);
597
+ }
598
+ gtag("consent", "default", {
599
+ ad_user_data: "denied",
600
+ ad_personalization: "denied",
601
+ ad_storage: "denied",
602
+ analytics_storage: "denied",
603
+ wait_for_update: 500
604
+ });
605
+ if (gtagId2) {
606
+ gtag("js", /* @__PURE__ */ new Date());
607
+ gtag("config", `${gtagId2}`);
608
+ }
609
+ if (gtmId2) {
610
+ dataLayer.push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), event: "gtm.js" });
611
+ }
612
+ if (layout === "advance-consent-mode") {
613
+ gtagId2 && loadGtagScript(gtagId2);
614
+ gtmId2 && loadGtmScript(gtmId2);
615
+ gtag("set", "url_passthrough", true);
616
+ gtag("set", "ads_data_redaction", true);
617
+ }
618
+ };
522
619
  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(
523
620
  "div",
524
621
  {
@@ -631,7 +728,7 @@ var ConsentComponentCustomApp = (props) => {
631
728
  },
632
729
  /* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
633
730
  t("txt_shield_of_privacy")
634
- ))) : /* @__PURE__ */ React.createElement("div", { className: "bg-white" }, level ? /* @__PURE__ */ React.createElement(React.Fragment, null, upgradeLayout ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "bg-white rounded p-3 w-100" }, loading === "done" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", { className: "mb-2 mb-lg-3" }, t("txt_upgrade_consent_text")), /* @__PURE__ */ React.createElement("p", { className: "fw-semibold text-dark" }, t("txt_your_current_level")), /* @__PURE__ */ React.createElement(
731
+ ))) : /* @__PURE__ */ React.createElement("div", { className: "bg-white" }, level ? /* @__PURE__ */ React.createElement(React.Fragment, null, upgradeLayout ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "bg-white rounded p-3 w-auto" }, loading === "done" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", { className: "mb-2 mb-lg-3" }, t("txt_upgrade_consent_text")), /* @__PURE__ */ React.createElement("p", { className: "fw-semibold text-dark" }, t("txt_your_current_level")), /* @__PURE__ */ React.createElement(
635
732
  ConsentLevelUprade,
636
733
  {
637
734
  level,
@@ -657,7 +754,7 @@ var ConsentComponentCustomApp = (props) => {
657
754
  className: `ms-1 ${upgradeShowDetail ? "revert" : ""}`
658
755
  }
659
756
  )
660
- )), /* @__PURE__ */ React.createElement(Form, null, level !== 1 && /* @__PURE__ */ React.createElement(
757
+ )), /* @__PURE__ */ React.createElement(Form, null, level !== 1 && layout !== "advance-consent-mode" && /* @__PURE__ */ React.createElement(
661
758
  ConsentLevelUprade,
662
759
  {
663
760
  level: 1,
@@ -722,76 +819,85 @@ var ConsentComponentCustomApp = (props) => {
722
819
  className: "d-flex align-items-center justify-content-center fs-14 w-100 w-lg-30 me-3 rounded-pill py-3 text-white"
723
820
  },
724
821
  t("txt_change_consent")
725
- ))) : /* @__PURE__ */ React.createElement(React.Fragment, null))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TermsComponent, { level, handleLevel, isCustom: true }, /* @__PURE__ */ React.createElement(Form, { className: "mb-0 w-100" }, /* @__PURE__ */ React.createElement(
726
- Form.Check,
727
- {
728
- checked: consents.includes(1),
729
- type: "switch",
730
- label: "Personal data share consent.",
731
- value: 1,
732
- onChange: handleChange,
733
- className: "d-none"
734
- }
735
- ), /* @__PURE__ */ React.createElement(
736
- Form.Check,
737
- {
738
- checked: consents.includes(2),
739
- type: "switch",
740
- label: "Personal data cross site share consent.",
741
- value: 2,
742
- onChange: handleChange,
743
- className: "d-none"
744
- }
745
- ), /* @__PURE__ */ React.createElement("div", { className: "d-flex w-100 flex-wrap flex-lg-nowrap" }, loading === "done" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
746
- Button,
747
- {
748
- variant: "outline-success",
749
- onClick: () => {
750
- setUpgradeLayout(true);
751
- },
752
- className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-2 py-lg-3 text-dark"
753
- },
754
- t("txt_change_consent")
755
- ), " ", /* @__PURE__ */ React.createElement(
756
- Button,
757
- {
758
- variant: "outline-success",
759
- onClick: handleNotAllow,
760
- className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-2 py-lg-3 text-dark"
761
- },
762
- t("txt_reject_consent")
763
- ), /* @__PURE__ */ React.createElement(
764
- "div",
822
+ ))) : /* @__PURE__ */ React.createElement(React.Fragment, null))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
823
+ TermsComponent,
765
824
  {
766
- className: `ssoBtnWrapper w-100 me-3 bg-success rounded-pill ${level === 2 || level === 4 && !account && !address ? "" : "d-none"}`
825
+ level,
826
+ handleLevel,
827
+ isCustom: true,
828
+ layout
767
829
  },
768
- /* @__PURE__ */ React.createElement(
769
- SSOButton,
830
+ /* @__PURE__ */ React.createElement(Form, { className: "mb-0 w-100" }, /* @__PURE__ */ React.createElement(
831
+ Form.Check,
770
832
  {
771
- className: "btn btn-success text-white d-flex align-items-center justify-content-center loginSSO rounded-pill py-2 py-lg-3 w-100",
772
- text: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }), t("txt_yes_i_consent")),
773
- ssoState: "noscopes",
774
- onGetData,
775
- ...level === 2 ? { noCreateAccount: true } : {}
833
+ checked: consents.includes(1),
834
+ type: "switch",
835
+ label: "Personal data share consent.",
836
+ value: 1,
837
+ onChange: handleChange,
838
+ className: "d-none"
776
839
  }
777
- )
778
- ), level === 2 || level === 4 && !account && !address ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement(
779
- Button,
780
- {
781
- variant: "success",
782
- onClick: handleAgree,
783
- className: "w-100 me-3 text-white d-flex align-items-center justify-content-center fs-14 rounded-pill py-2 py-lg-3"
784
- },
785
- loadingCheckAccount ? /* @__PURE__ */ React.createElement(
786
- "span",
840
+ ), /* @__PURE__ */ React.createElement(
841
+ Form.Check,
787
842
  {
788
- className: "spinner-border spinner-border-sm me-1",
789
- role: "status",
790
- "aria-hidden": "true"
843
+ checked: consents.includes(2),
844
+ type: "switch",
845
+ label: "Personal data cross site share consent.",
846
+ value: 2,
847
+ onChange: handleChange,
848
+ className: "d-none"
791
849
  }
792
- ) : /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }),
793
- t("txt_yes_i_consent")
794
- )) : /* @__PURE__ */ React.createElement(React.Fragment, null)))))) : /* @__PURE__ */ React.createElement("div", { className: "p-4" }, /* @__PURE__ */ React.createElement(
850
+ ), /* @__PURE__ */ React.createElement("div", { className: "d-flex w-100 flex-wrap flex-lg-nowrap" }, loading === "done" ? /* @__PURE__ */ React.createElement(React.Fragment, null, layout === "simple-consent-mode" || layout === "simple-web-2" ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
851
+ Button,
852
+ {
853
+ variant: "outline-success",
854
+ onClick: () => {
855
+ setUpgradeLayout(true);
856
+ },
857
+ className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-2 py-lg-3 text-dark"
858
+ },
859
+ t("txt_change_consent")
860
+ ), " "), /* @__PURE__ */ React.createElement(
861
+ Button,
862
+ {
863
+ variant: "outline-success",
864
+ onClick: handleNotAllow,
865
+ className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-2 py-lg-3 text-dark"
866
+ },
867
+ t("txt_reject_consent")
868
+ ), /* @__PURE__ */ React.createElement(
869
+ "div",
870
+ {
871
+ className: `ssoBtnWrapper w-100 me-3 bg-success rounded-pill ${level === 2 || level === 4 && !account && !address ? "" : "d-none"}`
872
+ },
873
+ /* @__PURE__ */ React.createElement(
874
+ SSOButton,
875
+ {
876
+ className: "btn btn-success text-white d-flex align-items-center justify-content-center loginSSO rounded-pill py-2 py-lg-3 w-100",
877
+ text: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }), t("txt_yes_i_consent")),
878
+ ssoState: "noscopes",
879
+ onGetData,
880
+ ...level === 2 ? { noCreateAccount: true } : {}
881
+ }
882
+ )
883
+ ), level === 2 || level === 4 && !account && !address ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement(
884
+ Button,
885
+ {
886
+ variant: "success",
887
+ onClick: handleAgree,
888
+ className: "w-100 me-3 text-white d-flex align-items-center justify-content-center fs-14 rounded-pill py-2 py-lg-3"
889
+ },
890
+ loadingCheckAccount ? /* @__PURE__ */ React.createElement(
891
+ "span",
892
+ {
893
+ className: "spinner-border spinner-border-sm me-1",
894
+ role: "status",
895
+ "aria-hidden": "true"
896
+ }
897
+ ) : /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }),
898
+ t("txt_yes_i_consent")
899
+ )) : /* @__PURE__ */ React.createElement(React.Fragment, null)))
900
+ ))) : /* @__PURE__ */ React.createElement("div", { className: "p-4" }, /* @__PURE__ */ React.createElement(
795
901
  ContentLoader,
796
902
  {
797
903
  speed: 2,