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.
@@ -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-AJMXPNA2.js";
15
+ } from "./chunk-7GRKFZZL.js";
24
16
  import {
25
17
  AnalyticsContext,
26
- useTranslation
27
- } from "./chunk-FKCTTU52.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";
@@ -51,13 +53,27 @@ import {
51
53
  } from "@concordium/react-components";
52
54
  import { OsTypes, isDesktop, isMobile, osName } from "react-device-detect";
53
55
  import { useAccount, useSignMessage } from "wagmi";
54
- var ConsentComponentCustom = ({ endpoint, aesirXEndpoint, networkEnv }) => {
56
+ var ConsentComponentCustom = ({
57
+ endpoint,
58
+ aesirXEndpoint,
59
+ networkEnv,
60
+ loginApp,
61
+ isLoggedApp,
62
+ gtagId,
63
+ gtmId,
64
+ layout
65
+ }) => {
55
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(
56
67
  ConsentComponentCustomApp,
57
68
  {
58
69
  ...props,
59
70
  endpoint,
60
- aesirXEndpoint
71
+ aesirXEndpoint,
72
+ loginApp,
73
+ isLoggedApp,
74
+ gtagId,
75
+ gtmId,
76
+ layout
61
77
  }
62
78
  ))));
63
79
  };
@@ -65,6 +81,11 @@ var ConsentComponentCustomApp = (props) => {
65
81
  const {
66
82
  endpoint,
67
83
  aesirXEndpoint,
84
+ loginApp,
85
+ isLoggedApp,
86
+ gtagId,
87
+ gtmId,
88
+ layout,
68
89
  activeConnectorType,
69
90
  activeConnector,
70
91
  activeConnectorError,
@@ -93,7 +114,7 @@ var ConsentComponentCustomApp = (props) => {
93
114
  handleLevel,
94
115
  showRevoke,
95
116
  handleRevoke
96
- ] = useConsentStatus_default(endpoint, props);
117
+ ] = useConsentStatus_default(endpoint, layout, props);
97
118
  const [consents, setConsents] = useState([1, 2]);
98
119
  const [loading, setLoading] = useState("done");
99
120
  const [loadingCheckAccount, setLoadingCheckAccount] = useState(false);
@@ -158,7 +179,10 @@ var ConsentComponentCustomApp = (props) => {
158
179
  signature,
159
180
  web3ID,
160
181
  jwt,
161
- "metamask"
182
+ "metamask",
183
+ gtagId,
184
+ gtmId,
185
+ layout
162
186
  );
163
187
  sessionStorage.setItem("aesirx-analytics-uuid", uuid);
164
188
  sessionStorage.setItem("aesirx-analytics-allow", "1");
@@ -211,6 +235,7 @@ var ConsentComponentCustomApp = (props) => {
211
235
  );
212
236
  sessionStorage.setItem("aesirx-analytics-jwt", data?.jwt);
213
237
  jwt = data?.jwt;
238
+ loginApp && !isLoggedApp && loginApp(data);
214
239
  setLoadingCheckAccount(false);
215
240
  }
216
241
  } else {
@@ -235,7 +260,20 @@ var ConsentComponentCustomApp = (props) => {
235
260
  level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}"
236
261
  );
237
262
  setLoading("saving");
238
- 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
+ );
239
277
  sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
240
278
  } else if (connector) {
241
279
  if (level === 3) {
@@ -257,9 +295,35 @@ var ConsentComponentCustomApp = (props) => {
257
295
  consents.forEach(async (consent) => {
258
296
  const existConsent = consentList.find((item) => item?.consent === consent);
259
297
  if (!existConsent) {
260
- 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
+ );
261
312
  } else if (!!existConsent?.consent_uuid && existConsent?.expiration && new Date(existConsent.expiration) < /* @__PURE__ */ new Date()) {
262
- 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
+ );
263
327
  }
264
328
  });
265
329
  }
@@ -317,7 +381,11 @@ var ConsentComponentCustomApp = (props) => {
317
381
  account,
318
382
  signature,
319
383
  null,
320
- response?.jwt
384
+ response?.jwt,
385
+ "concordium",
386
+ gtagId,
387
+ gtmId,
388
+ layout
321
389
  );
322
390
  setShow(false);
323
391
  handleRevoke(true, level);
@@ -356,12 +424,26 @@ var ConsentComponentCustomApp = (props) => {
356
424
  }
357
425
  setConsentTier4(response);
358
426
  } else {
359
- 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
+ );
360
441
  setShow(false);
361
442
  handleRevoke(true, level);
362
443
  setLoading("done");
363
444
  }
364
445
  }
446
+ loginApp && !isLoggedApp && loginApp(response);
365
447
  } catch (error) {
366
448
  console.log(error);
367
449
  setShow(false);
@@ -477,6 +559,7 @@ var ConsentComponentCustomApp = (props) => {
477
559
  if (sessionStorage.getItem("aesirx-analytics-revoke") && sessionStorage.getItem("aesirx-analytics-revoke") !== "0") {
478
560
  window.funcAfterConsent && window.funcAfterConsent();
479
561
  }
562
+ (gtagId || gtmId) && loadConsentDefault(gtagId, gtmId);
480
563
  }, []);
481
564
  console.log("level", uuid, level, web3ID, account, loading);
482
565
  const ConsentLevelUprade = ({
@@ -507,6 +590,32 @@ var ConsentComponentCustomApp = (props) => {
507
590
  ))) : /* @__PURE__ */ React.createElement(React.Fragment, null)
508
591
  );
509
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
+ };
510
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(
511
620
  "div",
512
621
  {
@@ -611,6 +720,7 @@ var ConsentComponentCustomApp = (props) => {
611
720
  "div",
612
721
  {
613
722
  className: "minimize-shield",
723
+ ref: analyticsContext?.ref,
614
724
  onClick: () => {
615
725
  setShowExpandConsent(true);
616
726
  sessionStorage.removeItem("aesirx-analytics-rejected");
@@ -618,7 +728,7 @@ var ConsentComponentCustomApp = (props) => {
618
728
  },
619
729
  /* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
620
730
  t("txt_shield_of_privacy")
621
- ))) : /* @__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-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(
622
732
  ConsentLevelUprade,
623
733
  {
624
734
  level,
@@ -644,7 +754,7 @@ var ConsentComponentCustomApp = (props) => {
644
754
  className: `ms-1 ${upgradeShowDetail ? "revert" : ""}`
645
755
  }
646
756
  )
647
- )), /* @__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(
648
758
  ConsentLevelUprade,
649
759
  {
650
760
  level: 1,
@@ -709,76 +819,85 @@ var ConsentComponentCustomApp = (props) => {
709
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"
710
820
  },
711
821
  t("txt_change_consent")
712
- ))) : /* @__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(
713
- Form.Check,
714
- {
715
- checked: consents.includes(1),
716
- type: "switch",
717
- label: "Personal data share consent.",
718
- value: 1,
719
- onChange: handleChange,
720
- className: "d-none"
721
- }
722
- ), /* @__PURE__ */ React.createElement(
723
- Form.Check,
724
- {
725
- checked: consents.includes(2),
726
- type: "switch",
727
- label: "Personal data cross site share consent.",
728
- value: 2,
729
- onChange: handleChange,
730
- className: "d-none"
731
- }
732
- ), /* @__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(
733
- Button,
734
- {
735
- variant: "outline-success",
736
- onClick: () => {
737
- setUpgradeLayout(true);
738
- },
739
- className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-3 text-dark"
740
- },
741
- t("txt_change_consent")
742
- ), " ", /* @__PURE__ */ React.createElement(
743
- Button,
744
- {
745
- variant: "outline-success",
746
- onClick: handleNotAllow,
747
- className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-3 text-dark"
748
- },
749
- t("txt_reject_consent")
750
- ), /* @__PURE__ */ React.createElement(
751
- "div",
822
+ ))) : /* @__PURE__ */ React.createElement(React.Fragment, null))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
823
+ TermsComponent,
752
824
  {
753
- 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
754
829
  },
755
- /* @__PURE__ */ React.createElement(
756
- SSOButton,
830
+ /* @__PURE__ */ React.createElement(Form, { className: "mb-0 w-100" }, /* @__PURE__ */ React.createElement(
831
+ Form.Check,
757
832
  {
758
- className: "btn btn-success text-white d-flex align-items-center justify-content-center loginSSO rounded-pill py-3 w-100",
759
- text: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }), t("txt_yes_i_consent")),
760
- ssoState: "noscopes",
761
- onGetData,
762
- ...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"
763
839
  }
764
- )
765
- ), level === 2 || level === 4 && !account && !address ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement(
766
- Button,
767
- {
768
- variant: "success",
769
- onClick: handleAgree,
770
- className: "w-100 me-3 text-white d-flex align-items-center justify-content-center fs-14 rounded-pill py-3"
771
- },
772
- loadingCheckAccount ? /* @__PURE__ */ React.createElement(
773
- "span",
840
+ ), /* @__PURE__ */ React.createElement(
841
+ Form.Check,
774
842
  {
775
- className: "spinner-border spinner-border-sm me-1",
776
- role: "status",
777
- "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"
778
849
  }
779
- ) : /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }),
780
- t("txt_yes_i_consent")
781
- )) : /* @__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(
782
901
  ContentLoader,
783
902
  {
784
903
  speed: 2,