@legalplace/wizardx-core 2.1.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 CHANGED
@@ -3,6 +3,35 @@
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
+
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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * fix config test api[#4377](https://git.legalplace.eu/legalplace/monorepo/issues/4377) ([8de0c2c](https://git.legalplace.eu/legalplace/monorepo/commits/8de0c2c8faadf18c082d372e0b9caf70d3b0d669))
23
+ * fix styled-component issues api[#4377](https://git.legalplace.eu/legalplace/monorepo/issues/4377) ([d21227c](https://git.legalplace.eu/legalplace/monorepo/commits/d21227c278d545a6aba492b5e6b33062e31a52cd))
24
+ * fix type errors api[#4377](https://git.legalplace.eu/legalplace/monorepo/issues/4377) ([c14a871](https://git.legalplace.eu/legalplace/monorepo/commits/c14a8717b53d023f89d09b329d2dff062b4890f0))
25
+
26
+
27
+ ### Features
28
+
29
+ * upgrading wizardx-app to support wizard-params throught props and fixing notFoundUrl api[#4377](https://git.legalplace.eu/legalplace/monorepo/issues/4377) ([72709a3](https://git.legalplace.eu/legalplace/monorepo/commits/72709a374e5037ed5eb743679159459e3b7d5483))
30
+
31
+
32
+
33
+
34
+
6
35
  # [2.1.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.0.0...@legalplace/wizardx-core@2.1.0) (2021-11-04)
7
36
 
8
37
 
package/dist/App.js CHANGED
@@ -73,7 +73,7 @@ class WizardXCore extends React.Component {
73
73
  React.createElement(Route, { path: "/p/:path", component: PluginRoute }),
74
74
  React.createElement(Route, { path: getConfig().router.wizardInstancePath, component: ViewComponent }),
75
75
  React.createElement(Route, { path: getConfig().router.wizardPath, component: ViewComponent }),
76
- React.createElement(Route, { path: getConfig().router.smartscriptRoute ||
76
+ React.createElement(Route, { path: getConfig().router.smartscriptPath ||
77
77
  '/contrats/:permalink/smartscript/:uniqid?', component: SmartScriptComponent }),
78
78
  React.createElement(Redirect, { to: {
79
79
  pathname: getConfig().router.notFoundPath,
@@ -16,12 +16,12 @@ describe('Config loader', () => {
16
16
  router: {
17
17
  wizardPath: '/contrats/:prefix?/:permalink/creer/:page?',
18
18
  wizardInstancePath: '/contrats/:prefix?/:permalink/continuer/:uniqid([0-9a-zA-Z]+)/:page?',
19
- notFoundUrl: '/contrats/conditions-generales-de-vente/creer',
19
+ notFoundPath: '/contrats/conditions-generales-de-vente/creer',
20
20
  appStatesPages: {
21
21
  termsheet: 'resume',
22
22
  email: 'email',
23
23
  },
24
- smartscriptRoute: '/contrats/:permalink/smartscript/:uniqid?',
24
+ smartscriptPath: '/contrats/:permalink/smartscript/:uniqid?',
25
25
  },
26
26
  plugins: {
27
27
  b2c_actions: '1.0.0',
@@ -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];
@@ -14,8 +14,8 @@ const watchEnableSmartScript = (mpi, next, action) => {
14
14
  const { permalink, prefix } = mpi.getState().app.meta;
15
15
  const { uniqid } = mpi.getState().app.instance;
16
16
  const { modelVersion } = new PathReader(mpi.getState());
17
- if (getConfig().router.smartscriptRoute) {
18
- const path = generatePath(getConfig().router.smartscriptRoute, {
17
+ if (getConfig().router.smartscriptPath) {
18
+ const path = generatePath(getConfig().router.smartscriptPath, {
19
19
  permalink,
20
20
  prefix: prefix.trim().length > 0 ? prefix : undefined,
21
21
  uniqid: uniqid.trim().length > 0 ? uniqid : undefined,
@@ -32,10 +32,9 @@ export interface IWizardParams {
32
32
  fixedConfig?: boolean;
33
33
  router: {
34
34
  wizardPath: string;
35
- smartscriptRoute: string;
36
35
  wizardInstancePath: string;
37
- notFoundUrl: string;
38
- notFoundPath?: string;
36
+ notFoundPath: string;
37
+ smartscriptPath: string;
39
38
  appStatesPages?: Record<string, string>;
40
39
  };
41
40
  plugins: Record<string, string>;
@@ -4,12 +4,12 @@ const config = {
4
4
  router: {
5
5
  wizardPath: '/contrats/:prefix?/:permalink/creer/:page?',
6
6
  wizardInstancePath: '/contrats/:prefix?/:permalink/continuer/:uniqid([0-9a-zA-Z]+)/:page?',
7
- notFoundUrl: '/contrats/conditions-generales-de-vente/creer',
7
+ notFoundPath: '/contrats/conditions-generales-de-vente/creer',
8
8
  appStatesPages: {
9
9
  termsheet: 'resume',
10
10
  email: 'email',
11
11
  },
12
- smartscriptRoute: '/contrats/:permalink/smartscript/:uniqid?',
12
+ smartscriptPath: '/contrats/:permalink/smartscript/:uniqid?',
13
13
  },
14
14
  plugins: {
15
15
  b2c_actions: '1.0.0',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -15,11 +15,11 @@
15
15
  "precommit": "test && lint:fix"
16
16
  },
17
17
  "dependencies": {
18
- "@legalplace/lp-events": "^1.8.0",
18
+ "@legalplace/lp-events": "1.9.0",
19
19
  "@legalplace/lplogic": "^2.1.6",
20
20
  "@legalplace/model-healthcheck": "^1.1.5",
21
21
  "@legalplace/referencesparser": "^1.7.0",
22
- "@legalplace/storybook": "1.113.2",
22
+ "@legalplace/storybook": "1.122.2",
23
23
  "@loadable/component": "^5.15.0",
24
24
  "@redux-saga/core": "^1.1.3",
25
25
  "awesome-phonenumber": "^2.62.1",
@@ -46,9 +46,9 @@
46
46
  "xss": "^1.0.9"
47
47
  },
48
48
  "devDependencies": {
49
- "@legalplace/eslint-config": "^2.0.1",
49
+ "@legalplace/eslint-config": "^2.0.2",
50
50
  "@legalplace/models-v3-types": "^3.6.0",
51
- "@legalplace/prettier-config": "^2.0.1",
51
+ "@legalplace/prettier-config": "^2.0.2",
52
52
  "@swc-node/jest": "^1.3.2",
53
53
  "@swc/core": "^1.2.93",
54
54
  "@swc/jest": "^0.2.4",
@@ -84,5 +84,5 @@
84
84
  "*.test.ts",
85
85
  "*.test.tsx"
86
86
  ],
87
- "gitHead": "15f7a2a1b1b7bcbded4da4e19988b1662e5eb757"
87
+ "gitHead": "199c9832aa50d42e719c5008c0206a57dd57c8c4"
88
88
  }
package/src/App.tsx CHANGED
@@ -134,7 +134,7 @@ class WizardXCore extends React.Component<AppProps, { loaded: boolean }> {
134
134
  {/* SmartScript Frame */}
135
135
  <Route
136
136
  path={
137
- getConfig().router.smartscriptRoute ||
137
+ getConfig().router.smartscriptPath ||
138
138
  '/contrats/:permalink/smartscript/:uniqid?'
139
139
  }
140
140
  component={SmartScriptComponent}
@@ -14,12 +14,12 @@ describe('Config loader', () => {
14
14
  wizardPath: '/contrats/:prefix?/:permalink/creer/:page?',
15
15
  wizardInstancePath:
16
16
  '/contrats/:prefix?/:permalink/continuer/:uniqid([0-9a-zA-Z]+)/:page?',
17
- notFoundUrl: '/contrats/conditions-generales-de-vente/creer',
17
+ notFoundPath: '/contrats/conditions-generales-de-vente/creer',
18
18
  appStatesPages: {
19
19
  termsheet: 'resume',
20
20
  email: 'email',
21
21
  },
22
- smartscriptRoute: '/contrats/:permalink/smartscript/:uniqid?',
22
+ smartscriptPath: '/contrats/:permalink/smartscript/:uniqid?',
23
23
  },
24
24
 
25
25
  // Enabled plugins (this should move to the apiEndpoint first response)
@@ -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
  */
@@ -34,9 +34,9 @@ const watchEnableSmartScript = (
34
34
  const { uniqid } = mpi.getState().app.instance;
35
35
  const { modelVersion } = new PathReader(mpi.getState());
36
36
 
37
- if (getConfig().router.smartscriptRoute) {
37
+ if (getConfig().router.smartscriptPath) {
38
38
  // Generating path
39
- const path = generatePath(getConfig().router.smartscriptRoute, {
39
+ const path = generatePath(getConfig().router.smartscriptPath, {
40
40
  permalink,
41
41
  prefix: prefix.trim().length > 0 ? prefix : undefined,
42
42
  uniqid: uniqid.trim().length > 0 ? uniqid : undefined,
@@ -35,10 +35,9 @@ export interface IWizardParams {
35
35
  fixedConfig?: boolean;
36
36
  router: {
37
37
  wizardPath: string;
38
- smartscriptRoute: string;
39
38
  wizardInstancePath: string;
40
- notFoundUrl: string;
41
- notFoundPath?: string;
39
+ notFoundPath: string;
40
+ smartscriptPath: string;
42
41
  appStatesPages?: Record<string, string>;
43
42
  };
44
43
  plugins: Record<string, string>;
@@ -11,12 +11,12 @@ const config: IWizardParams = {
11
11
  wizardPath: '/contrats/:prefix?/:permalink/creer/:page?',
12
12
  wizardInstancePath:
13
13
  '/contrats/:prefix?/:permalink/continuer/:uniqid([0-9a-zA-Z]+)/:page?',
14
- notFoundUrl: '/contrats/conditions-generales-de-vente/creer',
14
+ notFoundPath: '/contrats/conditions-generales-de-vente/creer',
15
15
  appStatesPages: {
16
16
  termsheet: 'resume',
17
17
  email: 'email',
18
18
  },
19
- smartscriptRoute: '/contrats/:permalink/smartscript/:uniqid?',
19
+ smartscriptPath: '/contrats/:permalink/smartscript/:uniqid?',
20
20
  },
21
21
 
22
22
  // Enabled plugins (this should move to the apiEndpoint first response)