@legalplace/wizardx-core 2.5.3 → 2.6.1

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,28 @@
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.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.6.0...@legalplace/wizardx-core@2.6.1) (2021-12-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix Ab tests tracking api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([9942e36](https://git.legalplace.eu/legalplace/monorepo/commits/9942e36e798195188a172384ce41bba7d967ac54))
12
+
13
+
14
+
15
+
16
+
17
+ # [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)
18
+
19
+
20
+ ### Features
21
+
22
+ * tracking X-AbTests cookie api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([b300234](https://git.legalplace.eu/legalplace/monorepo/commits/b30023402ab5a487e74ba297f5b4c7c988f479c2))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [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
29
 
8
30
  **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,21 @@ class _EventsTracking {
39
39
  }
40
40
  : {};
41
41
  }
42
+ getXAbTests() {
43
+ const xAbTests = cookie.get("X-AbTests");
44
+ if (typeof xAbTests === "object") {
45
+ const xAbTestsFlattened = {};
46
+ Object.keys(xAbTests).forEach((abTestName) => {
47
+ xAbTestsFlattened[`X-AbTests[${abTestName}]`] = xAbTests[abTestName];
48
+ });
49
+ return xAbTestsFlattened;
50
+ }
51
+ return typeof xAbTests === "string" && xAbTests.trim().length > 0
52
+ ? {
53
+ "X-AbTests": xAbTests,
54
+ }
55
+ : {};
56
+ }
42
57
  executeQueue() {
43
58
  for (let i = 0; i < this.queue.length; i += 1) {
44
59
  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.1",
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": "3a47c81e0b3dc87345e047d84b0649de398c140b"
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,26 @@ class _EventsTracking {
70
71
  : {};
71
72
  }
72
73
 
74
+ private getXAbTests(): Record<string, string> {
75
+ const xAbTests = cookie.get("X-AbTests");
76
+
77
+ if (typeof xAbTests === "object") {
78
+ const xAbTestsFlattened: Record<string, string> = {};
79
+
80
+ Object.keys(xAbTests).forEach((abTestName) => {
81
+ xAbTestsFlattened[`X-AbTests[${abTestName}]`] = xAbTests[abTestName];
82
+ });
83
+
84
+ return xAbTestsFlattened;
85
+ }
86
+
87
+ return typeof xAbTests === "string" && xAbTests.trim().length > 0
88
+ ? {
89
+ "X-AbTests": xAbTests,
90
+ }
91
+ : {};
92
+ }
93
+
73
94
  /**
74
95
  * Executes events tracking queue
75
96
  */