@legalplace/wizardx-core 2.2.0 → 2.3.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 +11 -0
- package/dist/libs/EventsTracking.d.ts +1 -0
- package/dist/libs/EventsTracking.js +11 -5
- package/package.json +2 -2
- package/src/libs/EventsTracking.ts +14 -0
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.3.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.2.0...@legalplace/wizardx-core@2.3.0) (2021-11-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* tracking X-Source cookie api[#4377](https://git.legalplace.eu/legalplace/monorepo/issues/4377) ([0b52550](https://git.legalplace.eu/legalplace/monorepo/commits/0b52550632daa141ab241183a9cf2169e8d5fb08))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.2.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0...@legalplace/wizardx-core@2.2.0) (2021-11-10)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -7,6 +7,7 @@ declare class _EventsTracking {
|
|
|
7
7
|
register(props: EventsPropsType): void;
|
|
8
8
|
trigger(name: string): void;
|
|
9
9
|
private init;
|
|
10
|
+
private getXSource;
|
|
10
11
|
private executeQueue;
|
|
11
12
|
private queueTimeout;
|
|
12
13
|
trackMix(eventName: string, eventProps?: EventsPropsType, doNotPushToQueue?: boolean): boolean;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import Cookies from 'universal-cookie';
|
|
1
2
|
import Globals from '../Globals';
|
|
3
|
+
const cookie = new Cookies();
|
|
2
4
|
class _EventsTracking {
|
|
3
5
|
constructor() {
|
|
4
6
|
this.initiated = false;
|
|
@@ -26,13 +28,17 @@ class _EventsTracking {
|
|
|
26
28
|
}
|
|
27
29
|
init() {
|
|
28
30
|
this.initiated = true;
|
|
29
|
-
this.register({
|
|
30
|
-
'WizardX Build Commit': process.env.REACT_APP_COMMIT || 'Unkown build commit',
|
|
31
|
-
Environement: Globals.env,
|
|
32
|
-
'Powered By': 'WizardX',
|
|
33
|
-
});
|
|
31
|
+
this.register(Object.assign({ 'WizardX Build Commit': process.env.REACT_APP_COMMIT || 'Unkown build commit', Environement: Globals.env, 'Powered By': 'WizardX' }, this.getXSource()));
|
|
34
32
|
this.trigger('wizardx');
|
|
35
33
|
}
|
|
34
|
+
getXSource() {
|
|
35
|
+
const xSource = cookie.get('X-Source');
|
|
36
|
+
return typeof xSource === 'string' && xSource.trim().length > 0
|
|
37
|
+
? {
|
|
38
|
+
'X-Source': xSource,
|
|
39
|
+
}
|
|
40
|
+
: {};
|
|
41
|
+
}
|
|
36
42
|
executeQueue() {
|
|
37
43
|
for (let i = 0; i < this.queue.length; i += 1) {
|
|
38
44
|
const currentEvent = this.queue[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"*.test.ts",
|
|
85
85
|
"*.test.tsx"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "199c9832aa50d42e719c5008c0206a57dd57c8c4"
|
|
88
88
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Cookies from 'universal-cookie';
|
|
1
2
|
import Globals from '../Globals';
|
|
2
3
|
|
|
3
4
|
export type EventsPropsType = Record<
|
|
@@ -5,6 +6,8 @@ export type EventsPropsType = Record<
|
|
|
5
6
|
string | number | boolean | Record<string, string | number | boolean>
|
|
6
7
|
>;
|
|
7
8
|
|
|
9
|
+
const cookie = new Cookies();
|
|
10
|
+
|
|
8
11
|
class _EventsTracking {
|
|
9
12
|
private initiated = false;
|
|
10
13
|
|
|
@@ -52,10 +55,21 @@ class _EventsTracking {
|
|
|
52
55
|
process.env.REACT_APP_COMMIT || 'Unkown build commit',
|
|
53
56
|
Environement: Globals.env,
|
|
54
57
|
'Powered By': 'WizardX',
|
|
58
|
+
...this.getXSource(),
|
|
55
59
|
});
|
|
56
60
|
this.trigger('wizardx');
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
private getXSource(): Record<string, string> {
|
|
64
|
+
const xSource = cookie.get('X-Source');
|
|
65
|
+
|
|
66
|
+
return typeof xSource === 'string' && xSource.trim().length > 0
|
|
67
|
+
? {
|
|
68
|
+
'X-Source': xSource,
|
|
69
|
+
}
|
|
70
|
+
: {};
|
|
71
|
+
}
|
|
72
|
+
|
|
59
73
|
/**
|
|
60
74
|
* Executes events tracking queue
|
|
61
75
|
*/
|