aesirx-analytics 2.2.15 → 2.2.16

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
@@ -313,4 +313,146 @@ REACT_APP_CONSENT_LAYOUT=default
313
313
  add this environment variable to `.env`
314
314
  ```
315
315
  NEXT_PUBLIC_CONSENT_LAYOUT=default
316
+ ```
317
+
318
+ ## Opt-in Consent
319
+
320
+ #### Usage in SSR site:
321
+ ```
322
+ <script>
323
+ window.optInConsentData = `[
324
+ {
325
+ "title":"payment",
326
+ "content":"<div>YOUR_CONTENT_INPUT_HERE</div>"
327
+ }
328
+ ]`
329
+ </script>
330
+ ```
331
+
332
+ (We also provive option `replaceAnalyticsConsent` to replace Analytics Consent with Opt-in Consent)
333
+ ```
334
+ <script>
335
+ window.optInConsentData = `[
336
+ {
337
+ "title":"payment",
338
+ "content":"<div>YOUR_CONTENT_INPUT_HERE</div>",
339
+ "replaceAnalyticsConsent": "true"
340
+ }
341
+ ]`
342
+ </script>
343
+ ```
344
+
345
+ #### In ReactJS:
346
+ ```
347
+ const OptInConsent = React.lazy(
348
+ () => import('./OptInConsent').then(module => ({ default: module.OptInConsent }))
349
+ );
350
+ const ConsentComponent = () => {
351
+ const [showModal, setShowModal] = useState(false);
352
+ const handleOpen = () => {
353
+ setShowModal(true);
354
+ };
355
+ const handleConsent = () => {
356
+ setShowModal(false);
357
+ };
358
+ const handleReject = () => {
359
+ setShowModal(false);
360
+ };
361
+ return (
362
+ <>
363
+ <OptInConsent
364
+ optInConsentData={[
365
+ {
366
+ title: 'payment',
367
+ content: `<div>YOUR_CONTENT_INPUT_HERE</div>`,
368
+ show: showModal,
369
+ handleConsent: handleConsent,
370
+ handleReject: handleReject
371
+ },
372
+ ]}
373
+ />
374
+ </>
375
+ );
376
+ };
377
+ ```
378
+ (We also provive option `replaceAnalyticsConsent` to replace Analytics Consent with Opt-in Consent)
379
+ To use this in ReactJS please add `isOptInReplaceAnalytics` to our provider first
380
+ ```
381
+ <AnalyticsReact location={location} history={history} isOptInReplaceAnalytics={true}>
382
+ {children}
383
+ </AnalyticsReact>
384
+ ```
385
+ ```
386
+ <OptInConsent
387
+ optInConsentData={[
388
+ {
389
+ title: 'payment',
390
+ content: `<div>YOUR_CONTENT_INPUT_HERE</div>`,
391
+ show: showModal,
392
+ handleConsent: handleConsent,
393
+ handleReject: handleReject,
394
+ replaceAnalyticsConsent: "true"
395
+ },
396
+ ]}
397
+ />
398
+ ```
399
+ #### In NextJS:
400
+ ```
401
+ import dynamic from "next/dynamic";
402
+ const OptInConsent = dynamic(
403
+ () => import("aesirx-analytics").then((module) => module.OptInConsent),
404
+ {
405
+ loading: () => <div>Loading...</div>,
406
+ ssr: false,
407
+ }
408
+ );
409
+
410
+ const ConsentComponent = () => {
411
+ const [showModal, setShowModal] = useState(false);
412
+ const handleOpen = () => {
413
+ setShowModal(true);
414
+ };
415
+ const handleConsent = () => {
416
+ setShowModal(false);
417
+ };
418
+ const handleReject = () => {
419
+ setShowModal(false);
420
+ };
421
+ return (
422
+ <>
423
+ <OptInConsent
424
+ optInConsentData={[
425
+ {
426
+ title: 'payment',
427
+ content: `<div>YOUR_CONTENT_INPUT_HERE</div>`,
428
+ show: showModal,
429
+ handleConsent: handleConsent,
430
+ handleReject: handleReject
431
+ },
432
+ ]}
433
+ />
434
+ </>
435
+ );
436
+ };
437
+ ```
438
+ (We also provive option `replaceAnalyticsConsent` to replace Analytics Consent with Opt-in Consent)
439
+ To use this in NextJS please add `isOptInReplaceAnalytics` to our provider first
440
+ ```
441
+ <AnalyticsNext router={useRouter()} isOptInReplaceAnalytics={true}>
442
+ <[YOUR-COMPONENT]/>
443
+ </AnalyticsNext>
444
+ ```
445
+ ```
446
+ <OptInConsent
447
+ optInConsentData={[
448
+ {
449
+ title: 'payment',
450
+ content: `<div>YOUR_CONTENT_INPUT_HERE</div>`,
451
+ show: showModal,
452
+ handleConsent: handleConsent,
453
+ handleReject: handleReject,
454
+ replaceAnalyticsConsent: "true"
455
+ },
456
+ ]}
457
+ />
316
458
  ```
@@ -6,9 +6,8 @@ import {
6
6
  TermsComponent,
7
7
  WALLET_CONNECT,
8
8
  getWeb3ID,
9
- no_default,
10
9
  useConsentStatus_default
11
- } from "./chunk-YM52A2TI.js";
10
+ } from "./chunk-7VGQDRF4.js";
12
11
  import {
13
12
  AnalyticsContext,
14
13
  agreeConsents,
@@ -20,11 +19,12 @@ import {
20
19
  getWalletNonce,
21
20
  loadGtagScript,
22
21
  loadGtmScript,
22
+ no_default,
23
23
  privacy_default,
24
24
  revokeConsents,
25
25
  useTranslation,
26
26
  verifySignature
27
- } from "./chunk-SBBLINO2.js";
27
+ } from "./chunk-EQQ4ASJH.js";
28
28
 
29
29
  // src/Components/Consent.tsx
30
30
  import React, { Suspense, useContext, useEffect, useState } from "react";
@@ -161,7 +161,7 @@ var ConsentComponentApp = (props) => {
161
161
  const nonce = await getNonce(
162
162
  endpoint,
163
163
  address,
164
- "Give consent Tier 4:{nonce} {domain} {time}",
164
+ "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
165
165
  "metamask"
166
166
  );
167
167
  signMessage({ message: `${nonce}` });
@@ -254,7 +254,7 @@ var ConsentComponentApp = (props) => {
254
254
  endpoint,
255
255
  account,
256
256
  connection,
257
- level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}"
257
+ level === 3 ? "Decentralized Consent:{nonce} {domain} {time}" : "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}"
258
258
  );
259
259
  setLoading("saving");
260
260
  await agreeConsents(
@@ -277,7 +277,7 @@ var ConsentComponentApp = (props) => {
277
277
  const nonce = await getNonce(
278
278
  endpoint,
279
279
  address,
280
- level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}",
280
+ level === 3 ? "Decentralized Consent:{nonce} {domain} {time}" : "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
281
281
  "metamask"
282
282
  );
283
283
  signMessage({ message: `${nonce}` });
@@ -368,7 +368,7 @@ var ConsentComponentApp = (props) => {
368
368
  endpoint,
369
369
  account,
370
370
  connection,
371
- "Give consent Tier 4:{nonce} {domain} {time}"
371
+ "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}"
372
372
  );
373
373
  await agreeConsents(
374
374
  endpoint,
@@ -392,7 +392,7 @@ var ConsentComponentApp = (props) => {
392
392
  const nonce = await getNonce(
393
393
  endpoint,
394
394
  address,
395
- "Give consent Tier 4:{nonce} {domain} {time}",
395
+ "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
396
396
  "metamask"
397
397
  );
398
398
  signMessage({ message: `${nonce}` });
@@ -10,9 +10,8 @@ import {
10
10
  WALLET_CONNECT,
11
11
  check_circle_default,
12
12
  getWeb3ID,
13
- no_default,
14
13
  useConsentStatus_default
15
- } from "./chunk-YM52A2TI.js";
14
+ } from "./chunk-7VGQDRF4.js";
16
15
  import {
17
16
  AnalyticsContext,
18
17
  agreeConsents,
@@ -24,11 +23,12 @@ import {
24
23
  getWalletNonce,
25
24
  loadGtagScript,
26
25
  loadGtmScript,
26
+ no_default,
27
27
  privacy_default,
28
28
  revokeConsents,
29
29
  useTranslation,
30
30
  verifySignature
31
- } from "./chunk-SBBLINO2.js";
31
+ } from "./chunk-EQQ4ASJH.js";
32
32
 
33
33
  // src/Components/ConsentCustom.tsx
34
34
  import React, { Suspense, useContext, useEffect, useState } from "react";
@@ -71,9 +71,10 @@ var ConsentComponentCustom = ({
71
71
  isLoggedApp,
72
72
  gtagId,
73
73
  gtmId,
74
- layout
74
+ layout,
75
+ isOptInReplaceAnalytics
75
76
  }) => {
76
- return /* @__PURE__ */ React.createElement(WithWalletConnector, { network: networkEnv === "testnet" ? TESTNET : MAINNET }, (props) => /* @__PURE__ */ React.createElement(
77
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, !isOptInReplaceAnalytics ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(WithWalletConnector, { network: networkEnv === "testnet" ? TESTNET : MAINNET }, (props) => /* @__PURE__ */ React.createElement(
77
78
  ConsentComponentCustomWrapper,
78
79
  {
79
80
  ...props,
@@ -85,7 +86,7 @@ var ConsentComponentCustom = ({
85
86
  gtmId,
86
87
  layout
87
88
  }
88
- ));
89
+ ))) : /* @__PURE__ */ React.createElement(React.Fragment, null));
89
90
  };
90
91
  var ConsentComponentCustomWrapper = (props) => {
91
92
  const [
@@ -215,7 +216,7 @@ var ConsentComponentCustomApp = (props) => {
215
216
  const nonce = await getNonce(
216
217
  endpoint,
217
218
  address,
218
- "Give consent Tier 4:{nonce} {domain} {time}",
219
+ "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
219
220
  "metamask"
220
221
  );
221
222
  signMessage({ message: `${nonce}` });
@@ -308,7 +309,7 @@ var ConsentComponentCustomApp = (props) => {
308
309
  endpoint,
309
310
  account,
310
311
  connection,
311
- level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}"
312
+ level === 3 ? "Decentralized Consent:{nonce} {domain} {time}" : "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}"
312
313
  );
313
314
  setLoading("saving");
314
315
  await agreeConsents(
@@ -332,7 +333,7 @@ var ConsentComponentCustomApp = (props) => {
332
333
  const nonce = await getNonce(
333
334
  endpoint,
334
335
  address,
335
- level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}",
336
+ level === 3 ? "Decentralized Consent:{nonce} {domain} {time}" : "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
336
337
  "metamask"
337
338
  );
338
339
  signMessage({ message: `${nonce}` });
@@ -425,7 +426,7 @@ var ConsentComponentCustomApp = (props) => {
425
426
  endpoint,
426
427
  account,
427
428
  connection,
428
- "Give consent Tier 4:{nonce} {domain} {time}"
429
+ "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}"
429
430
  );
430
431
  await agreeConsents(
431
432
  endpoint,
@@ -450,7 +451,7 @@ var ConsentComponentCustomApp = (props) => {
450
451
  const nonce = await getNonce(
451
452
  endpoint,
452
453
  address,
453
- "Give consent Tier 4:{nonce} {domain} {time}",
454
+ "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
454
455
  "metamask"
455
456
  );
456
457
  signMessage({ message: `${nonce}` });
@@ -510,17 +511,17 @@ var ConsentComponentCustomApp = (props) => {
510
511
  toast.error(error?.response?.data?.error ?? error.message);
511
512
  }
512
513
  };
513
- const handleNotAllow = () => {
514
+ const handleNotAllow = async () => {
514
515
  sessionStorage.setItem("aesirx-analytics-uuid", uuid);
515
- sessionStorage.setItem("aesirx-analytics-rejected", "true");
516
516
  setShowExpandConsent(false);
517
517
  setShowBackdrop(false);
518
518
  const hostUrl = endpoint ? endpoint : "";
519
519
  const root = hostUrl ? hostUrl.replace(/\/$/, "") : "";
520
- trackEvent(root, "", {
520
+ await trackEvent(root, "", {
521
521
  event_name: "Reject consent",
522
522
  event_type: "reject-consent"
523
523
  });
524
+ sessionStorage.setItem("aesirx-analytics-rejected", "true");
524
525
  window.funcAfterReject && window.funcAfterReject();
525
526
  };
526
527
  const handleRevokeBtn = async () => {
@@ -692,9 +693,8 @@ var ConsentComponentCustomApp = (props) => {
692
693
  gtag("set", "ads_data_redaction", true);
693
694
  }
694
695
  };
695
- const paymentRevoke = sessionStorage.getItem("aesirx-analytics-payment");
696
- const advisorRevoke = sessionStorage.getItem("aesirx-analytics-advisor");
697
- console.log("loading", loading);
696
+ const paymentRevoke = sessionStorage.getItem("aesirx-analytics-opt-payment");
697
+ const optInRevokes = Object.keys(sessionStorage).filter((key) => key.startsWith("aesirx-analytics-optin")).map((key) => key);
698
698
  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(
699
699
  "div",
700
700
  {
@@ -767,31 +767,7 @@ var ConsentComponentCustomApp = (props) => {
767
767
  }
768
768
  },
769
769
  /* @__PURE__ */ React.createElement("img", { src: no_default })
770
- ), /* @__PURE__ */ React.createElement("div", { className: "p-3 bg-white" }, paymentRevoke ? t("txt_you_can_revoke_on_the_site") : t("txt_you_can_revoke")), /* @__PURE__ */ React.createElement(Form, { className: "mb-0 w-100 bg-white px-3" }, paymentRevoke ? /* @__PURE__ */ React.createElement(
771
- Form.Check,
772
- {
773
- id: `option-revoke-payment`,
774
- checked: revokeConsentOption === "payment",
775
- type: "checkbox",
776
- label: t("txt_revoke_opt_in"),
777
- value: "payment",
778
- onChange: ({ target: { value } }) => {
779
- setRevokeConsentOption(value);
780
- }
781
- }
782
- ) : /* @__PURE__ */ React.createElement(React.Fragment, null), advisorRevoke ? /* @__PURE__ */ React.createElement(
783
- Form.Check,
784
- {
785
- id: `option-revoke-advisor`,
786
- checked: revokeConsentOption === "advisor",
787
- type: "checkbox",
788
- label: t("txt_revoke_opt_in_advisor"),
789
- value: "advisor",
790
- onChange: ({ target: { value } }) => {
791
- setRevokeConsentOption(value);
792
- }
793
- }
794
- ) : /* @__PURE__ */ React.createElement(React.Fragment, null), /* @__PURE__ */ React.createElement(
770
+ ), /* @__PURE__ */ React.createElement("div", { className: "p-3 bg-white" }, paymentRevoke ? t("txt_you_can_revoke_on_the_site") : t("txt_you_can_revoke")), /* @__PURE__ */ React.createElement(Form, { className: "mb-0 w-100 bg-white px-3" }, /* @__PURE__ */ React.createElement(
795
771
  Form.Check,
796
772
  {
797
773
  id: `option-revoke-consent`,
@@ -803,7 +779,22 @@ var ConsentComponentCustomApp = (props) => {
803
779
  setRevokeConsentOption(value);
804
780
  }
805
781
  }
806
- )), /* @__PURE__ */ React.createElement("div", { className: "rounded-bottom position-relative overflow-hidden bg-white" }, /* @__PURE__ */ React.createElement("div", { className: "position-relative p-3" }, /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center flex-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center w-100 justify-content-end" }, /* @__PURE__ */ React.createElement(
782
+ ), optInRevokes?.map((item, key) => {
783
+ return /* @__PURE__ */ React.createElement(
784
+ Form.Check,
785
+ {
786
+ key,
787
+ id: `option-revoke-${item}`,
788
+ checked: revokeConsentOption === item,
789
+ type: "checkbox",
790
+ label: item === "aesirx-analytics-optin-default" ? t("txt_revoke_opt_in") : item === "aesirx-analytics-optin-payment" ? t("txt_revoke_opt_in_payment") : item === "aesirx-analytics-optin-advisor" ? t("txt_revoke_opt_in_advisor") : t("txt_revoke_opt_in") + " " + item?.replace("aesirx-analytics-optin-", ""),
791
+ value: item,
792
+ onChange: ({ target: { value } }) => {
793
+ setRevokeConsentOption(value);
794
+ }
795
+ }
796
+ );
797
+ })), /* @__PURE__ */ React.createElement("div", { className: "rounded-bottom position-relative overflow-hidden bg-white" }, /* @__PURE__ */ React.createElement("div", { className: "position-relative p-3" }, /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center flex-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center w-100 justify-content-end" }, /* @__PURE__ */ React.createElement(
807
798
  "a",
808
799
  {
809
800
  className: "manage-consent fs-14 btn btn-outline-success rounded-pill py-2 py-lg-3 d-flex align-items-center justify-content-center w-100 w-lg-35",
@@ -817,27 +808,20 @@ var ConsentComponentCustomApp = (props) => {
817
808
  {
818
809
  variant: "outline-success",
819
810
  onClick: async () => {
820
- if (revokeConsentOption === "payment") {
821
- sessionStorage.removeItem("aesirx-analytics-payment");
822
- setShowExpandRevoke(false);
823
- setRevokeConsentOption("consent");
824
- setTimeout(() => {
825
- window.location.reload();
826
- }, 1e3);
827
- } else if (revokeConsentOption === "advisor") {
828
- sessionStorage.removeItem("aesirx-analytics-advisor");
829
- setShowExpandRevoke(false);
830
- setRevokeConsentOption("consent");
831
- setTimeout(() => {
832
- window.location.reload();
833
- }, 1e3);
834
- } else {
811
+ if (revokeConsentOption === "consent") {
835
812
  await handleRevokeBtn();
836
813
  if (level > 1) {
837
814
  setTimeout(() => {
838
815
  window.location.reload();
839
816
  }, 1e3);
840
817
  }
818
+ } else {
819
+ sessionStorage.removeItem(revokeConsentOption);
820
+ setShowExpandRevoke(false);
821
+ setRevokeConsentOption("consent");
822
+ setTimeout(() => {
823
+ window.location.reload();
824
+ }, 1e3);
841
825
  }
842
826
  },
843
827
  className: "d-flex align-items-center justify-content-center w-100 w-lg-35 revoke-btn fs-14 rounded-pill py-2 py-lg-3"