@legalplace/wizardx-core 2.10.0 → 2.11.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,31 @@
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.11.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.10.1...@legalplace/wizardx-core@2.11.0) (2022-04-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * use getUserInfo from lp-events ([02b2012](https://git.legalplace.eu/legalplace/monorepo/commits/02b201209e5b6b6e2c2aa9aa4ee1bb7562949db3)), closes [api#5171](https://git.legalplace.eu/legalplace/monorepo/issues/5171)
12
+
13
+
14
+ ### Features
15
+
16
+ * adding userInfos to all funnelGA datalayer events ([973ff37](https://git.legalplace.eu/legalplace/monorepo/commits/973ff37ffe15d7b3d262c3250be36c8d09915fcb)), closes [api#5171](https://git.legalplace.eu/legalplace/monorepo/issues/5171)
17
+ * update version lp-events ([1214891](https://git.legalplace.eu/legalplace/monorepo/commits/1214891d08f2033ac24850ee80760c059b5cce13)), closes [api#5171](https://git.legalplace.eu/legalplace/monorepo/issues/5171)
18
+
19
+
20
+
21
+
22
+
23
+ ## [2.10.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.10.0...@legalplace/wizardx-core@2.10.1) (2022-04-14)
24
+
25
+ **Note:** Version bump only for package @legalplace/wizardx-core
26
+
27
+
28
+
29
+
30
+
6
31
  # [2.10.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.9.0...@legalplace/wizardx-core@2.10.0) (2022-04-11)
7
32
 
8
33
 
package/dist/Globals.d.ts CHANGED
@@ -3,11 +3,6 @@ declare global {
3
3
  dataLayer: any;
4
4
  google_trackConversion: (...args: any[]) => any;
5
5
  uetq: any;
6
- fbq: (...args: any[]) => any;
7
- mixpanel: any;
8
- sendinblue: any;
9
- ga: any;
10
- hj: any;
11
6
  wizardxLoadAfterLcp: ({
12
7
  src: string;
13
8
  } | Function)[];
@@ -13,7 +13,6 @@ import PropTypes from "prop-types";
13
13
  import { getConfig } from "./config";
14
14
  import { getStore } from "./redux/store";
15
15
  import { getHistory } from "./redux/routerHistory";
16
- import { EventsTracking } from "./libs/EventsTracking";
17
16
  import Globals from "./Globals";
18
17
  import { INIT_PLUGINS } from "./redux/constants/app";
19
18
  let globalAnchors = {};
@@ -78,7 +77,7 @@ const loadPluginFiles = (pluginsList) => __awaiter(void 0, void 0, void 0, funct
78
77
  const anchors = pluginModule.default;
79
78
  const { loader } = pluginModule;
80
79
  if (loader !== undefined) {
81
- loader(getStore().dispatch, getHistory(), getConfig(), EventsTracking);
80
+ loader(getStore().dispatch, getHistory(), getConfig());
82
81
  }
83
82
  Object.keys(anchors).forEach((anchor) => {
84
83
  if (anchor === "replace") {
@@ -1,5 +1,4 @@
1
1
  export * from "./OvcConverter";
2
- export * from "./EventsTracking";
3
2
  export * from "./InputsInitiator";
4
3
  export * from "./PathReader";
5
4
  export * from "./SectionValidity";
@@ -1,5 +1,4 @@
1
1
  export * from "./OvcConverter";
2
- export * from "./EventsTracking";
3
2
  export * from "./InputsInitiator";
4
3
  export * from "./PathReader";
5
4
  export * from "./SectionValidity";
@@ -1,5 +1,5 @@
1
1
  import { call, put, takeLatest } from "redux-saga/effects";
2
- import { getContractFunnelGAEvent } from "@legalplace/lp-events";
2
+ import { getContractFunnelGAEvent, getUserInfos } from "@legalplace/lp-events";
3
3
  import { getConfig } from "../../config";
4
4
  import { selectPermalink, selectInstanceUniqid, selectDocumentTitle, selectAvailableAppStates, selectDocumentModelVersion, } from "../selectors/app";
5
5
  import { selectInputs } from "../selectors/inputs";
@@ -9,6 +9,7 @@ import { updateAvailableAppStatesAction, initInstanceAction, goNextPageAction, }
9
9
  import { OvcConverter } from "../../libs/OvcConverter";
10
10
  import { setUserEmailSucceeded } from "../actions/sagas/user";
11
11
  import { EMAIL_REGEX } from "../../constants/emailValidation";
12
+ import { selectUserStatus, selectUserEmail } from "../selectors/user";
12
13
  const canalHeaders = {
13
14
  "lp-referrer": window.document.referrer,
14
15
  "lp-origin": window.location.href,
@@ -74,13 +75,17 @@ function* setUserEmailDecorator(action) {
74
75
  }
75
76
  }
76
77
  try {
77
- if (redirectTo && redirectTo.includes("generation"))
78
+ if (redirectTo === null || redirectTo === void 0 ? void 0 : redirectTo.includes("generation")) {
79
+ const userStatus = selectUserStatus();
80
+ const userEmail = selectUserEmail();
78
81
  window.dataLayer.push(getContractFunnelGAEvent({
79
82
  currentStep: 1,
80
83
  contractName: selectDocumentTitle(),
81
84
  sectionTitle: "Choississez votre pack",
82
85
  pageAction: "Confirmation avant paiement 1 | 2",
86
+ user: getUserInfos({ userStatus, userEmail }),
83
87
  }));
88
+ }
84
89
  }
85
90
  catch (error) {
86
91
  console.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@appnest/masonry-layout": "^2.0.8",
23
23
  "@cryptography/sha1": "^0.2.0",
24
- "@legalplace/lp-events": "1.9.0",
24
+ "@legalplace/lp-events": "1.13.0",
25
25
  "@legalplace/lplogic": "^2.1.6",
26
26
  "@legalplace/model-healthcheck": "^1.1.5",
27
27
  "@legalplace/referencesparser": "1.7.0",
@@ -92,5 +92,5 @@
92
92
  "*.test.ts",
93
93
  "*.test.tsx"
94
94
  ],
95
- "gitHead": "edcdffc91089957236baed872a7dd42e826f0067"
95
+ "gitHead": "91c2fbffa238edebf2874a844920628bebebd006"
96
96
  }
@@ -1,22 +0,0 @@
1
- export declare type EventsPropsType = Record<string, string | number | boolean | Record<string, string | number | boolean>>;
2
- declare class _EventsTracking {
3
- private initiated;
4
- private queue;
5
- private queueTimer;
6
- track(eventName: string, eventProps?: EventsPropsType): void;
7
- register(props: EventsPropsType): void;
8
- trigger(name: string): void;
9
- private init;
10
- private getXSource;
11
- private getXAbTests;
12
- private executeQueue;
13
- private queueTimeout;
14
- trackMix(eventName: string, eventProps?: EventsPropsType, doNotPushToQueue?: boolean): boolean;
15
- private trackFB;
16
- private trackGA;
17
- private registerMix;
18
- private registerFB;
19
- private triggerHj;
20
- }
21
- export declare const EventsTracking: _EventsTracking;
22
- export {};
@@ -1,177 +0,0 @@
1
- import Cookies from "universal-cookie";
2
- import Globals from "../Globals";
3
- const cookie = new Cookies();
4
- class _EventsTracking {
5
- constructor() {
6
- this.initiated = false;
7
- this.queue = [];
8
- this.queueTimer = null;
9
- }
10
- track(eventName, eventProps) {
11
- if (!this.initiated)
12
- this.init();
13
- this.trackMix(eventName, Object.assign({}, eventProps));
14
- this.trackFB(eventName, Object.assign({}, eventProps));
15
- this.trackGA(eventName, Object.assign({}, eventProps));
16
- }
17
- register(props) {
18
- if (!this.initiated)
19
- this.init();
20
- this.registerMix(props);
21
- this.registerFB(props);
22
- }
23
- trigger(name) {
24
- if (!this.initiated)
25
- this.init();
26
- this.triggerHj(name);
27
- }
28
- init() {
29
- this.initiated = true;
30
- 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()));
31
- this.trigger("wizardx");
32
- }
33
- getXSource() {
34
- const xSource = cookie.get("X-Source");
35
- return typeof xSource === "string" && xSource.trim().length > 0
36
- ? {
37
- "X-Source": xSource,
38
- }
39
- : {};
40
- }
41
- getXAbTests() {
42
- const xAbTests = cookie.get("X-AbTests");
43
- if (typeof xAbTests === "object") {
44
- const xAbTestsFlattened = {};
45
- Object.keys(xAbTests).forEach((abTestName) => {
46
- xAbTestsFlattened[`X-AbTests[${abTestName}]`] = xAbTests[abTestName];
47
- });
48
- return xAbTestsFlattened;
49
- }
50
- return typeof xAbTests === "string" && xAbTests.trim().length > 0
51
- ? {
52
- "X-AbTests": xAbTests,
53
- }
54
- : {};
55
- }
56
- executeQueue() {
57
- for (let i = 0; i < this.queue.length; i += 1) {
58
- const currentEvent = this.queue[i];
59
- const args = [];
60
- const [fnName] = currentEvent;
61
- if (currentEvent.length > 1) {
62
- for (let x = 0; x < currentEvent[1].length; x += 1)
63
- args.push(currentEvent[1][x]);
64
- args.push(true);
65
- let fn;
66
- switch (fnName) {
67
- case "trackMix":
68
- fn = this.trackMix.bind(this);
69
- break;
70
- case "trackFB":
71
- fn = this.trackFB.bind(this);
72
- break;
73
- case "trackGA":
74
- fn = this.trackGA.bind(this);
75
- break;
76
- case "registerMix":
77
- fn = this.registerMix.bind(this);
78
- break;
79
- case "registerFB":
80
- fn = this.registerFB.bind(this);
81
- break;
82
- case "triggerHj":
83
- fn = this.triggerHj.bind(this);
84
- break;
85
- default:
86
- throw new Error(`Unkown function "${fnName}" found on events tracking queue`);
87
- }
88
- const result = fn(...args);
89
- if (result === true) {
90
- this.queue.splice(i, 1);
91
- }
92
- }
93
- }
94
- }
95
- queueTimeout() {
96
- if (this.queueTimer !== null)
97
- clearTimeout(this.queueTimer);
98
- this.queueTimer = setTimeout(() => {
99
- this.executeQueue();
100
- }, 50);
101
- }
102
- trackMix(eventName, eventProps, doNotPushToQueue = false) {
103
- if (!this.initiated)
104
- this.init();
105
- if (typeof window.mixpanel !== "undefined") {
106
- if (this.queue.length > 0 && !doNotPushToQueue)
107
- this.executeQueue();
108
- window.mixpanel.track(eventName, eventProps);
109
- return true;
110
- }
111
- if (doNotPushToQueue === false)
112
- this.queue.push(["trackMix", [eventName, eventProps]]);
113
- this.queueTimeout();
114
- return false;
115
- }
116
- trackFB(eventName, eventProps, doNotPushToQueue = false) {
117
- if (typeof window.fbq !== "undefined") {
118
- if (this.queue.length > 0 && !doNotPushToQueue)
119
- this.executeQueue();
120
- window.fbq("trackCustom", eventName, eventProps);
121
- return true;
122
- }
123
- if (doNotPushToQueue === false)
124
- this.queue.push(["trackFB", [eventName, eventProps]]);
125
- this.queueTimeout();
126
- return false;
127
- }
128
- trackGA(eventName, eventProps, doNotPushToQueue = false) {
129
- if (typeof window.ga !== "undefined") {
130
- if (this.queue.length > 0 && !doNotPushToQueue)
131
- this.executeQueue();
132
- window.ga("send", "event", "lpTracking", "track", eventName, 1, eventProps);
133
- return true;
134
- }
135
- if (doNotPushToQueue === false)
136
- this.queue.push(["trackGA", [eventName, eventProps]]);
137
- this.queueTimeout();
138
- return false;
139
- }
140
- registerMix(props, doNotPushToQueue = false) {
141
- if (typeof window.mixpanel !== "undefined") {
142
- if (this.queue.length > 0 && !doNotPushToQueue)
143
- this.executeQueue();
144
- window.mixpanel.register(props);
145
- return true;
146
- }
147
- if (doNotPushToQueue === false)
148
- this.queue.push(["registerMix", [props]]);
149
- this.queueTimeout();
150
- return false;
151
- }
152
- registerFB(props, doNotPushToQueue = false) {
153
- if (typeof window.fbq !== "undefined") {
154
- if (this.queue.length > 0 && !doNotPushToQueue)
155
- this.executeQueue();
156
- window.fbq("trackCustom", "GeneralProps", props);
157
- return true;
158
- }
159
- if (doNotPushToQueue === false)
160
- this.queue.push(["registerFB", [props]]);
161
- this.queueTimeout();
162
- return false;
163
- }
164
- triggerHj(name, doNotPushToQueue = false) {
165
- if (typeof window.hj !== "undefined") {
166
- if (this.queue.length > 0 && !doNotPushToQueue)
167
- this.executeQueue();
168
- window.hj("trigger", name);
169
- return true;
170
- }
171
- if (doNotPushToQueue === false)
172
- this.queue.push(["triggerHj", [name]]);
173
- this.queueTimeout();
174
- return false;
175
- }
176
- }
177
- export const EventsTracking = new _EventsTracking();