@legalplace/wizardx-core 2.5.3 → 2.6.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.6.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.5.3...@legalplace/wizardx-core@2.6.0) (2021-12-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * tracking X-AbTests cookie api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([b300234](https://git.legalplace.eu/legalplace/monorepo/commits/b30023402ab5a487e74ba297f5b4c7c988f479c2))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.5.3](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.5.2...@legalplace/wizardx-core@2.5.3) (2021-12-08)
7
18
 
8
19
  **Note:** Version bump only for package @legalplace/wizardx-core
@@ -8,6 +8,7 @@ declare class _EventsTracking {
8
8
  trigger(name: string): void;
9
9
  private init;
10
10
  private getXSource;
11
+ private getXAbTests;
11
12
  private executeQueue;
12
13
  private queueTimeout;
13
14
  trackMix(eventName: string, eventProps?: EventsPropsType, doNotPushToQueue?: boolean): boolean;
@@ -28,7 +28,7 @@ class _EventsTracking {
28
28
  }
29
29
  init() {
30
30
  this.initiated = true;
31
- this.register(Object.assign({ "WizardX Build Commit": process.env.REACT_APP_COMMIT || "Unkown build commit", Environement: Globals.appEnv, "Powered By": "WizardX" }, this.getXSource()));
31
+ this.register(Object.assign(Object.assign({ "WizardX Build Commit": process.env.REACT_APP_COMMIT || "Unkown build commit", Environement: Globals.appEnv, "Powered By": "WizardX" }, this.getXSource()), this.getXAbTests()));
32
32
  this.trigger("wizardx");
33
33
  }
34
34
  getXSource() {
@@ -39,6 +39,25 @@ class _EventsTracking {
39
39
  }
40
40
  : {};
41
41
  }
42
+ getXAbTests() {
43
+ const xAbTests = cookie.get("X-AbTests");
44
+ try {
45
+ const xAbTestsObject = JSON.parse(xAbTests);
46
+ const xAbTestsFlattened = {};
47
+ Object.keys(xAbTestsObject).forEach((abTestName) => {
48
+ xAbTestsFlattened[`X-AbTests[${abTestName}]`] =
49
+ xAbTestsObject[abTestName];
50
+ });
51
+ return xAbTestsObject;
52
+ }
53
+ catch (e) {
54
+ return typeof xAbTests === "string" && xAbTests.trim().length > 0
55
+ ? {
56
+ "X-AbTests": xAbTests,
57
+ }
58
+ : {};
59
+ }
60
+ }
42
61
  executeQueue() {
43
62
  for (let i = 0; i < this.queue.length; i += 1) {
44
63
  const currentEvent = this.queue[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "2.5.3",
3
+ "version": "2.6.0",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "exports": {
@@ -92,5 +92,5 @@
92
92
  "*.test.ts",
93
93
  "*.test.tsx"
94
94
  ],
95
- "gitHead": "a478cb2dce721dcd5f1b70f9c1b2f1b007e71c1a"
95
+ "gitHead": "ed1fddfc65363d82140964988ced16a13ab0df00"
96
96
  }
@@ -56,6 +56,7 @@ class _EventsTracking {
56
56
  Environement: Globals.appEnv,
57
57
  "Powered By": "WizardX",
58
58
  ...this.getXSource(),
59
+ ...this.getXAbTests(),
59
60
  });
60
61
  this.trigger("wizardx");
61
62
  }
@@ -70,6 +71,28 @@ class _EventsTracking {
70
71
  : {};
71
72
  }
72
73
 
74
+ private getXAbTests(): Record<string, string> {
75
+ const xAbTests = cookie.get("X-AbTests");
76
+
77
+ try {
78
+ const xAbTestsObject = JSON.parse(xAbTests);
79
+ const xAbTestsFlattened: Record<string, string> = {};
80
+
81
+ Object.keys(xAbTestsObject).forEach((abTestName) => {
82
+ xAbTestsFlattened[`X-AbTests[${abTestName}]`] =
83
+ xAbTestsObject[abTestName];
84
+ });
85
+
86
+ return xAbTestsObject;
87
+ } catch (e) {
88
+ return typeof xAbTests === "string" && xAbTests.trim().length > 0
89
+ ? {
90
+ "X-AbTests": xAbTests,
91
+ }
92
+ : {};
93
+ }
94
+ }
95
+
73
96
  /**
74
97
  * Executes events tracking queue
75
98
  */