aesirx-analytics 2.1.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -144,6 +144,7 @@ function warn() {
144
144
  }
145
145
  if (typeof args[0] === "string")
146
146
  args[0] = `react-i18next:: ${args[0]}`;
147
+ console.warn(...args);
147
148
  }
148
149
  }
149
150
  var alreadyWarned = {};
@@ -473,7 +474,7 @@ var common_default2 = {
473
474
  txt_revoke_consent: "Revoke Consent",
474
475
  txt_yes_i_consent: "Yes, I consent",
475
476
  txt_reject_consent: "Reject Consent",
476
- txt_please_connect: "Please connect your Concordium wallet",
477
+ txt_please_connect: "Please connect your Web3 wallet",
477
478
  txt_please_sign: "Please sign the message on your wallet twice and wait for it to be saved.",
478
479
  txt_saving: "Saving...",
479
480
  txt_please_connect_your_wallet: "Please connect to your wallet",
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AnalyticsContext,
3
3
  AnalyticsContextProvider_default
4
- } from "./chunk-OGDZQCIU.js";
4
+ } from "./chunk-ZYCOHH2R.js";
5
5
 
6
6
  // src/AnalyticsNext/index.tsx
7
7
  import React2 from "react";
@@ -41,6 +41,9 @@ var createRequest = (endpoint, task) => {
41
41
  var createRequestV2 = (endpoint, task) => {
42
42
  return `${endpoint}/visitor/v2/${task}`;
43
43
  };
44
+ var rememberFlow = (endpoint, flow) => {
45
+ return `${endpoint}/remember_flow/${flow}`;
46
+ };
44
47
  var startTracker = async (endpoint, url, referer, user_agent) => {
45
48
  const allow = sessionStorage.getItem("aesirx-analytics-allow");
46
49
  if (allow === "0") {
@@ -72,8 +75,8 @@ var startTracker = async (endpoint, url, referer, user_agent) => {
72
75
  return await trackerService(createRequestV2(endpoint, "start"), {
73
76
  fingerprint,
74
77
  url,
75
- ...referer && referer !== url && {
76
- referer
78
+ ...referer && (referer !== url || document2.referrer) && {
79
+ referer: referer !== url ? referer : document2.referrer
77
80
  },
78
81
  user_agent,
79
82
  ip,
@@ -88,8 +91,16 @@ var startTracker = async (endpoint, url, referer, user_agent) => {
88
91
  }
89
92
  });
90
93
  });
94
+ if (window["aesirxTrackEcommerce"] === "true" && sessionStorage.getItem("aesirx-analytics-flow") !== (await responseStart)?.flow_uuid) {
95
+ sessionStorage.setItem("aesirx-analytics-flow", (await responseStart)?.flow_uuid);
96
+ await trackerService(
97
+ rememberFlow(window.location.origin, (await responseStart)?.flow_uuid),
98
+ {}
99
+ );
100
+ }
91
101
  return responseStart;
92
102
  } catch (error) {
103
+ console.error("Analytics Error: ", error);
93
104
  }
94
105
  };
95
106
  var trackEvent = async (endpoint, referer, data) => {
@@ -108,26 +119,30 @@ var trackEvent = async (endpoint, referer, data) => {
108
119
  const device = browser?.platform?.model ?? browser?.platform?.type;
109
120
  const ip = "";
110
121
  const fpPromise = FingerprintJS.load({ monitoring: false });
111
- const body = fpPromise.then((fp) => fp.get()).then(async (result) => {
122
+ const responseStart = fpPromise.then((fp) => fp.get()).then(async (result) => {
112
123
  const fingerprint = result.visitorId;
113
- return {
114
- fingerprint,
115
- url,
116
- ...referer !== "/" && referer && {
117
- referer
118
- },
119
- user_agent,
120
- ip,
121
- browser_name,
122
- browser_version,
123
- lang,
124
- device,
125
- ...data
126
- };
124
+ const headers = { type: "application/json" };
125
+ const blobData = new Blob(
126
+ [
127
+ JSON.stringify({
128
+ fingerprint,
129
+ url,
130
+ ...referer !== "/" && referer && {
131
+ referer
132
+ },
133
+ user_agent,
134
+ ip,
135
+ browser_name,
136
+ browser_version,
137
+ lang,
138
+ device,
139
+ ...data
140
+ })
141
+ ],
142
+ headers
143
+ );
144
+ return navigator.sendBeacon(createRequestV2(endpoint, "start"), blobData);
127
145
  });
128
- const headers = { type: "application/json" };
129
- const blob = new Blob([JSON.stringify(body)], headers);
130
- const responseStart = navigator.sendBeacon(createRequestV2(endpoint, "start"), blob);
131
146
  return responseStart;
132
147
  };
133
148
  var endTracker = (endPoint, event_uuid, visitor_uuid) => {
@@ -180,6 +195,7 @@ var AnalyticsHandle = ({ router, children }) => {
180
195
  useEffect(() => {
181
196
  const init = async () => {
182
197
  if (!AnalyticsStore.visitor_uuid) {
198
+ setPrevRoute(router.asPath);
183
199
  await handleStartTracker(router.asPath);
184
200
  }
185
201
  };
@@ -217,9 +233,15 @@ var handle_default = AnalyticsHandle;
217
233
 
218
234
  // src/AnalyticsNext/index.tsx
219
235
  import dynamic from "next/dynamic";
220
- var ConsentComponent = dynamic(() => import("./Consent-MKSHHJAP.js"), { ssr: false });
236
+ var ConsentComponent = dynamic(() => import("./Consent-3FMR7JQE.js"), { ssr: false });
221
237
  var AnalyticsNext = ({ router, children }) => {
222
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(AnalyticsContextProvider_default, null, /* @__PURE__ */ React2.createElement(handle_default, { router }, children, process.env.NEXT_PUBLIC_DISABLE_ANALYTICS_CONSENT !== "true" && /* @__PURE__ */ React2.createElement(ConsentComponent, { endpoint: process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL }))));
238
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(AnalyticsContextProvider_default, null, /* @__PURE__ */ React2.createElement(handle_default, { router }, children, process.env.NEXT_PUBLIC_DISABLE_ANALYTICS_CONSENT !== "true" && /* @__PURE__ */ React2.createElement(
239
+ ConsentComponent,
240
+ {
241
+ endpoint: process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL,
242
+ aesirXEndpoint: process.env.NEXT_PUBLIC_ENDPOINT_URL ?? "https://api.aesirx.io"
243
+ }
244
+ ))));
223
245
  };
224
246
  var AnalyticsNext_default = AnalyticsNext;
225
247
 
@@ -263,9 +285,15 @@ var AnalyticsHandle2 = ({ location, history, children }) => {
263
285
  var handle_default2 = AnalyticsHandle2;
264
286
 
265
287
  // src/AnalyticsReact/index.tsx
266
- var ConsentComponent2 = React4.lazy(() => import("./Consent-MKSHHJAP.js"));
288
+ var ConsentComponent2 = React4.lazy(() => import("./Consent-3FMR7JQE.js"));
267
289
  var AnalyticsReact = ({ location, history, children }) => {
268
- return /* @__PURE__ */ React4.createElement(AnalyticsContextProvider_default, null, /* @__PURE__ */ React4.createElement(handle_default2, { location, history }, children, process.env.REACT_APP_DISABLE_ANALYTICS_CONSENT !== "true" && /* @__PURE__ */ React4.createElement(Suspense, { fallback: /* @__PURE__ */ React4.createElement(React4.Fragment, null) }, /* @__PURE__ */ React4.createElement(ConsentComponent2, { endpoint: process.env.REACT_APP_ENDPOINT_ANALYTICS_URL }))));
290
+ return /* @__PURE__ */ React4.createElement(AnalyticsContextProvider_default, null, /* @__PURE__ */ React4.createElement(handle_default2, { location, history }, children, process.env.REACT_APP_DISABLE_ANALYTICS_CONSENT !== "true" && /* @__PURE__ */ React4.createElement(Suspense, { fallback: /* @__PURE__ */ React4.createElement(React4.Fragment, null) }, /* @__PURE__ */ React4.createElement(
291
+ ConsentComponent2,
292
+ {
293
+ endpoint: process.env.REACT_APP_ENDPOINT_ANALYTICS_URL,
294
+ aesirXEndpoint: process.env.REACT_APP_ENDPOINT_URL ?? "https://api.aesirx.io"
295
+ }
296
+ ))));
269
297
  };
270
298
  var AnalyticsReact_default = AnalyticsReact;
271
299
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aesirx-analytics",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "license": "GPL-3.0-only",
5
5
  "author": "AesirX",
6
6
  "repository": "https://gitlab.redweb.dk/aesirx/analytics",
@@ -12,32 +12,36 @@
12
12
  "@concordium/browser-wallet-api-helpers": "^2",
13
13
  "@concordium/react-components": "^0.3.0",
14
14
  "@concordium/web-sdk": "^6",
15
- "@fingerprintjs/fingerprintjs": "^4.0.1",
16
- "aesirx-sso": "^1.2.1",
15
+ "@fingerprintjs/fingerprintjs": "3.4.2",
16
+ "@web3modal/ethereum": "^2.7.0",
17
+ "@web3modal/react": "^2.7.0",
18
+ "aesirx-sso": "^1.4.1",
17
19
  "axios": "^1.4.0",
18
- "bootstrap": "^5.3.0",
20
+ "bootstrap": "^5.3.2",
19
21
  "bowser": "^2.11.0",
20
22
  "buffer": "^6.0.3",
23
+ "ethers": "^6.6.5",
21
24
  "i18next": "^23.4.4",
22
25
  "i18next-browser-languagedetector": "^7.1.0",
23
- "next": "^13.4.19",
26
+ "next": "^13.5.4",
24
27
  "query-string": "^7.1.1",
25
28
  "react": "^18.2.0",
26
29
  "react-bootstrap": "^2.8.0",
27
30
  "react-content-loader": "^6.2.1",
28
31
  "react-device-detect": "^2.2.3",
29
32
  "react-dom": "18",
30
- "react-toastify": "^9.1.3"
33
+ "react-toastify": "^9.1.3",
34
+ "wagmi": "^1.3.2"
31
35
  },
32
36
  "scripts": {
33
- "dev": "tsup --watch --onSuccess 'yalc push --changed --no-scripts'",
37
+ "dev": "NODE_ENV=development tsup --watch",
34
38
  "build": "tsup",
35
39
  "lint": "eslint --fix \"src/**/\"",
36
40
  "lint:check": "eslint \"src/**/\"",
37
41
  "lint:nowarns": "eslint --quiet \"src/**/\"",
38
42
  "prepublishOnly": "yarn run build",
39
- "format:check": "prettier --check 'src/**/*.{js,jsx,ts,tsx}'",
40
- "format:write": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'",
43
+ "format:check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx}\"",
44
+ "format:write": "prettier --write \"./src/**/*.{js,jsx,ts,tsx}\"",
41
45
  "test": "jest"
42
46
  },
43
47
  "eslintConfig": {
@@ -60,10 +64,10 @@
60
64
  },
61
65
  "devDependencies": {
62
66
  "@babel/preset-env": "^7.21.5",
63
- "@babel/preset-typescript": "^7.21.5",
64
- "@jest/globals": "^29.6.4",
67
+ "@babel/preset-typescript": "^7.23.0",
68
+ "@jest/globals": "^29.7.0",
65
69
  "@types/jest": "^29.5.0",
66
- "@types/node": "^20.1.4",
70
+ "@types/node": "^20.8.0",
67
71
  "@types/react": "^18.2.21",
68
72
  "@types/react-dom": "^18.2.4",
69
73
  "@typescript-eslint/eslint-plugin": "^5.57.0",
@@ -71,7 +75,7 @@
71
75
  "@walletconnect/types": "^2.10.0",
72
76
  "dotenv": "^16.0.3",
73
77
  "esbuild-plugin-inline-image": "^0.0.9",
74
- "esbuild-sass-plugin": "^2.10.0",
78
+ "esbuild-sass-plugin": "^2.15.0",
75
79
  "esbuild-scss-modules-plugin": "^1.1.1",
76
80
  "eslint": "^8.48.0",
77
81
  "eslint-plugin-react": "^7.31.10",
@@ -86,5 +90,8 @@
86
90
  },
87
91
  "files": [
88
92
  "dist"
89
- ]
93
+ ],
94
+ "resolutions": {
95
+ "postcss": "^8"
96
+ }
90
97
  }