@maxzima/wa-communicator 1.0.55 → 1.0.56
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/.prettierrc.js +8 -7
- package/dist/engine/AccountTracker/Enums/AccountTrackerEnum.d.ts +0 -6
- package/dist/engine/AccountTracker/Enums/AccountTrackerEnum.js +0 -8
- package/dist/engine/AccountTracker/Public/AccountTracker.d.ts +1 -2
- package/dist/engine/AccountTracker/Public/AccountTracker.js +1 -10
- package/dist/engine/AccountTracker/Types/TAccountTracker.d.ts +1 -5
- package/dist/engine/AccountTracker/Types/TAccountTracker.js +1 -1
- package/dist/engine/Communicator/Constants/Communicator.d.ts +1 -1
- package/dist/engine/Communicator/Constants/Communicator.js +1 -1
- package/dist/engine/Communicator/Public/Communicator.d.ts +1 -1
- package/dist/engine/Communicator/Public/Communicator.js +9 -10
- package/dist/engine/Communicator/Utils/registrationMetaData.d.ts +1 -1
- package/dist/engine/Communicator/Utils/registrationMetaData.js +1 -1
- package/dist/engine/index.d.ts +2 -2
- package/dist/engine/index.js +2 -2
- package/package.json +1 -1
- package/src/engine/AccountTracker/Enums/AccountTrackerEnum.ts +0 -8
- package/src/engine/AccountTracker/Public/AccountTracker.ts +7 -26
- package/src/engine/AccountTracker/Types/TAccountTracker.ts +8 -16
- package/src/engine/Communicator/Constants/Communicator.ts +1 -3
- package/src/engine/Communicator/Public/Communicator.ts +34 -38
- package/src/engine/Communicator/Types/TCommunicator.ts +6 -6
- package/src/engine/Communicator/Utils/registrationMetaData.ts +2 -2
- package/src/engine/index.ts +2 -2
- package/test/accountTracker.spec.ts +5 -14
- package/test/communicator.spec.ts +10 -14
- package/test/testunits/accountTracker/events.ts +5 -14
package/.prettierrc.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
'semi': true,
|
|
5
|
-
'singleQuote': true,
|
|
6
4
|
'arrowParens': 'always',
|
|
7
|
-
'printWidth': 180,
|
|
8
|
-
'bracketSpacing': false,
|
|
9
|
-
'endOfLine': 'lf',
|
|
10
5
|
'bracketSameLine': false,
|
|
6
|
+
'bracketSpacing': true,
|
|
7
|
+
'endOfLine': 'lf',
|
|
8
|
+
'printWidth': 180,
|
|
11
9
|
'proseWrap': 'preserve',
|
|
10
|
+
'quoteProps': 'consistent',
|
|
12
11
|
'requirePragma': false,
|
|
12
|
+
'semi': true,
|
|
13
|
+
'singleQuote': true,
|
|
13
14
|
'tabWidth': 2,
|
|
14
|
-
'trailingComma': '
|
|
15
|
-
'useTabs': false
|
|
15
|
+
'trailingComma': 'all',
|
|
16
|
+
'useTabs': false,
|
|
16
17
|
}
|
|
@@ -11,11 +11,3 @@ export var GTMEventParamsEnum;
|
|
|
11
11
|
GTMEventParamsEnum["GCL_ID"] = "gcl_id";
|
|
12
12
|
GTMEventParamsEnum["USER_ID"] = "user_id";
|
|
13
13
|
})(GTMEventParamsEnum || (GTMEventParamsEnum = {}));
|
|
14
|
-
export var LintrkActionTypeEnum;
|
|
15
|
-
(function (LintrkActionTypeEnum) {
|
|
16
|
-
LintrkActionTypeEnum["TRACK"] = "track";
|
|
17
|
-
})(LintrkActionTypeEnum || (LintrkActionTypeEnum = {}));
|
|
18
|
-
export var LintrkEventIdEnum;
|
|
19
|
-
(function (LintrkEventIdEnum) {
|
|
20
|
-
LintrkEventIdEnum[LintrkEventIdEnum["REGISTRATION"] = 8612308] = "REGISTRATION";
|
|
21
|
-
})(LintrkEventIdEnum || (LintrkEventIdEnum = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TAccountTrackerEventParams, TAccountTrackerProps } from
|
|
1
|
+
import type { TAccountTrackerEventParams, TAccountTrackerProps } from './../Types/TAccountTracker';
|
|
2
2
|
export declare class AccountTracker {
|
|
3
3
|
private props;
|
|
4
4
|
constructor(props: TAccountTrackerProps);
|
|
@@ -6,5 +6,4 @@ export declare class AccountTracker {
|
|
|
6
6
|
sendVerifyPhoneSuccessEvent(eventParams: TAccountTrackerEventParams): void;
|
|
7
7
|
sendVerifyEmailSuccessEvent(eventParams: TAccountTrackerEventParams): void;
|
|
8
8
|
private sendGtmEvent;
|
|
9
|
-
private sendLinkedInEvent;
|
|
10
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GTMEventEnum
|
|
1
|
+
import { GTMEventEnum } from './../Enums/AccountTrackerEnum';
|
|
2
2
|
export class AccountTracker {
|
|
3
3
|
constructor(props) {
|
|
4
4
|
this.sendGtmEvent = (event, eventParams) => {
|
|
@@ -8,19 +8,10 @@ export class AccountTracker {
|
|
|
8
8
|
const paramsForCurrentEvent = (eventParams[event] || {});
|
|
9
9
|
this.props.gtmDataLayer.push(Object.assign({ event }, paramsForCurrentEvent));
|
|
10
10
|
};
|
|
11
|
-
this.sendLinkedInEvent = (id) => {
|
|
12
|
-
if (typeof this.props.lintrk === 'undefined') {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
this.props.lintrk(LintrkActionTypeEnum.TRACK, {
|
|
16
|
-
conversation_id: id,
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
11
|
this.props = props;
|
|
20
12
|
}
|
|
21
13
|
sendRegistrationSuccessEvent(eventParams) {
|
|
22
14
|
this.sendGtmEvent(GTMEventEnum.SIGN_UP_ONLINE, eventParams.gtm);
|
|
23
|
-
this.sendLinkedInEvent(LintrkEventIdEnum.REGISTRATION);
|
|
24
15
|
}
|
|
25
16
|
sendVerifyPhoneSuccessEvent(eventParams) {
|
|
26
17
|
this.sendGtmEvent(GTMEventEnum.VERIFY_PHONE_ONLINE, eventParams.gtm);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { GTMEventEnum, GTMEventParamsEnum
|
|
2
|
-
export type TLintrkOptions = {
|
|
3
|
-
conversation_id: LintrkEventIdEnum;
|
|
4
|
-
};
|
|
1
|
+
import { GTMEventEnum, GTMEventParamsEnum } from './../Enums/AccountTrackerEnum';
|
|
5
2
|
export type TAccountTrackerProps = {
|
|
6
3
|
gtmDataLayer?: object[];
|
|
7
|
-
lintrk?: (action: LintrkActionTypeEnum, options: TLintrkOptions) => void;
|
|
8
4
|
};
|
|
9
5
|
export type TAccountTrackerEventParams = {
|
|
10
6
|
gtm: TAccountTrackerGtmEventParamsMapping;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { GTMEventEnum, GTMEventParamsEnum
|
|
1
|
+
import { GTMEventEnum, GTMEventParamsEnum } from './../Enums/AccountTrackerEnum';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
declare const CommunicatorDefaultRequestData: TDefaultRequestData;
|
|
2
|
-
export { CommunicatorDefaultRequestData
|
|
2
|
+
export { CommunicatorDefaultRequestData };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TCreateSessionRequestData, TEmailUpdateRequestData,
|
|
1
|
+
import type { TCreateSessionRequestData, TEmailUpdateRequestData, TGetAssignedProductsRequestData, TGetCurrentUserProfileRequestData, TGetRestrictedCountriesData, TProfileAssignRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSetupSSERequestData, TSignInByAppRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TStorageRequestData, TVerifyChallengeRequestData } from '@root/types';
|
|
2
2
|
export declare class Communicator {
|
|
3
3
|
private props;
|
|
4
4
|
private sseAuth;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { CommunicatorDefaultRequestData } from
|
|
3
|
-
import { jsonParse } from
|
|
4
|
-
import { CommunicatorAuthAPIEndpointEnum, CommunicatorFAPIEndpointEnum } from
|
|
5
|
-
import { prepareMetadata } from
|
|
2
|
+
import { CommunicatorDefaultRequestData } from './../Constants/Communicator';
|
|
3
|
+
import { jsonParse } from './../Utils/jsonParseSafe';
|
|
4
|
+
import { CommunicatorAuthAPIEndpointEnum, CommunicatorFAPIEndpointEnum } from './../Enums/CommunicatorEnum';
|
|
5
|
+
import { prepareMetadata } from './../Utils/registrationMetaData';
|
|
6
6
|
export class Communicator {
|
|
7
7
|
constructor(props) {
|
|
8
8
|
this.getHeaders = (token) => {
|
|
9
9
|
let headers = CommunicatorDefaultRequestData.FETCH_HEADERS_INIT;
|
|
10
10
|
if (token) {
|
|
11
|
-
headers = Object.assign(Object.assign({}, headers), {
|
|
11
|
+
headers = Object.assign(Object.assign({}, headers), { Authorization: `Bearer ${token}` });
|
|
12
12
|
}
|
|
13
13
|
return headers;
|
|
14
14
|
};
|
|
@@ -122,7 +122,7 @@ export class Communicator {
|
|
|
122
122
|
if (this.props.env !== 'prod') {
|
|
123
123
|
console.log('sse open', event);
|
|
124
124
|
}
|
|
125
|
-
if (typeof data.onOpen ===
|
|
125
|
+
if (typeof data.onOpen === 'function') {
|
|
126
126
|
data.onOpen();
|
|
127
127
|
}
|
|
128
128
|
});
|
|
@@ -131,7 +131,7 @@ export class Communicator {
|
|
|
131
131
|
if (this.props.env !== 'prod') {
|
|
132
132
|
console.log('sse message', event, responseData);
|
|
133
133
|
}
|
|
134
|
-
if (typeof data.onMessage ===
|
|
134
|
+
if (typeof data.onMessage === 'function') {
|
|
135
135
|
data.onMessage(responseData);
|
|
136
136
|
}
|
|
137
137
|
});
|
|
@@ -140,7 +140,7 @@ export class Communicator {
|
|
|
140
140
|
if (this.props.env !== 'prod') {
|
|
141
141
|
console.log('sse error', event, responseData);
|
|
142
142
|
}
|
|
143
|
-
if (typeof data.onError ===
|
|
143
|
+
if (typeof data.onError === 'function') {
|
|
144
144
|
data.onError();
|
|
145
145
|
}
|
|
146
146
|
this.closeSSEAuth();
|
|
@@ -272,8 +272,7 @@ export class Communicator {
|
|
|
272
272
|
method: requestInitProps.method,
|
|
273
273
|
body: requestInitProps.body,
|
|
274
274
|
headers: requestInitProps.headers,
|
|
275
|
-
})
|
|
276
|
-
.then((response) => {
|
|
275
|
+
}).then((response) => {
|
|
277
276
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
278
277
|
let data = {};
|
|
279
278
|
try {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { TRegistrationMetadata, TRegistrationRequestBodySourceMetadata } from
|
|
1
|
+
import type { TRegistrationMetadata, TRegistrationRequestBodySourceMetadata } from '@root/types';
|
|
2
2
|
export declare function prepareMetadata(obj: TRegistrationMetadata): TRegistrationRequestBodySourceMetadata[];
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './AccountTracker';
|
|
2
|
+
export * from './Communicator';
|
package/dist/engine/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './AccountTracker';
|
|
2
|
+
export * from './Communicator';
|
package/package.json
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { GTMEventEnum
|
|
2
|
-
import type {
|
|
3
|
-
TAccountTrackerEventParams,
|
|
4
|
-
TAccountTrackerGtmEventParams,
|
|
5
|
-
TAccountTrackerGtmEventParamsMapping,
|
|
6
|
-
TAccountTrackerProps
|
|
7
|
-
} from "./../Types/TAccountTracker";
|
|
1
|
+
import { GTMEventEnum } from './../Enums/AccountTrackerEnum';
|
|
2
|
+
import type { TAccountTrackerEventParams, TAccountTrackerGtmEventParams, TAccountTrackerGtmEventParamsMapping, TAccountTrackerProps } from './../Types/TAccountTracker';
|
|
8
3
|
|
|
9
4
|
export class AccountTracker {
|
|
10
5
|
private props: TAccountTrackerProps;
|
|
@@ -13,23 +8,19 @@ export class AccountTracker {
|
|
|
13
8
|
this.props = props;
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
public sendRegistrationSuccessEvent
|
|
11
|
+
public sendRegistrationSuccessEvent(eventParams: TAccountTrackerEventParams) {
|
|
17
12
|
this.sendGtmEvent(GTMEventEnum.SIGN_UP_ONLINE, eventParams.gtm);
|
|
18
|
-
this.sendLinkedInEvent(LintrkEventIdEnum.REGISTRATION);
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
public sendVerifyPhoneSuccessEvent
|
|
15
|
+
public sendVerifyPhoneSuccessEvent(eventParams: TAccountTrackerEventParams) {
|
|
22
16
|
this.sendGtmEvent(GTMEventEnum.VERIFY_PHONE_ONLINE, eventParams.gtm);
|
|
23
17
|
}
|
|
24
18
|
|
|
25
|
-
public sendVerifyEmailSuccessEvent
|
|
19
|
+
public sendVerifyEmailSuccessEvent(eventParams: TAccountTrackerEventParams) {
|
|
26
20
|
this.sendGtmEvent(GTMEventEnum.VERIFY_EMAIL_ONLINE, eventParams.gtm);
|
|
27
21
|
}
|
|
28
22
|
|
|
29
|
-
private sendGtmEvent = (
|
|
30
|
-
event: GTMEventEnum,
|
|
31
|
-
eventParams: TAccountTrackerGtmEventParamsMapping
|
|
32
|
-
) => {
|
|
23
|
+
private sendGtmEvent = (event: GTMEventEnum, eventParams: TAccountTrackerGtmEventParamsMapping) => {
|
|
33
24
|
if (!Array.isArray(this.props.gtmDataLayer)) {
|
|
34
25
|
return;
|
|
35
26
|
}
|
|
@@ -38,17 +29,7 @@ export class AccountTracker {
|
|
|
38
29
|
|
|
39
30
|
this.props.gtmDataLayer.push({
|
|
40
31
|
event,
|
|
41
|
-
...paramsForCurrentEvent
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
private sendLinkedInEvent = (id: LintrkEventIdEnum) => {
|
|
46
|
-
if (typeof this.props.lintrk === 'undefined') {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
this.props.lintrk(LintrkActionTypeEnum.TRACK, {
|
|
51
|
-
conversation_id: id,
|
|
32
|
+
...paramsForCurrentEvent,
|
|
52
33
|
});
|
|
53
34
|
};
|
|
54
35
|
}
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GTMEventEnum, GTMEventParamsEnum,
|
|
3
|
-
LintrkActionTypeEnum,
|
|
4
|
-
LintrkEventIdEnum
|
|
5
|
-
} from "./../Enums/AccountTrackerEnum";
|
|
6
|
-
|
|
7
|
-
export type TLintrkOptions = {
|
|
8
|
-
conversation_id: LintrkEventIdEnum;
|
|
9
|
-
}
|
|
1
|
+
import { GTMEventEnum, GTMEventParamsEnum } from './../Enums/AccountTrackerEnum';
|
|
10
2
|
|
|
11
3
|
export type TAccountTrackerProps = {
|
|
12
4
|
gtmDataLayer?: object[];
|
|
13
|
-
|
|
14
|
-
}
|
|
5
|
+
};
|
|
15
6
|
|
|
16
7
|
export type TAccountTrackerEventParams = {
|
|
17
8
|
gtm: TAccountTrackerGtmEventParamsMapping;
|
|
18
|
-
}
|
|
9
|
+
};
|
|
19
10
|
|
|
20
11
|
export type TAccountTrackerGtmEventParamsMapping = {
|
|
21
12
|
[event in GTMEventEnum]?: TAccountTrackerGtmEventParams;
|
|
22
13
|
};
|
|
23
14
|
|
|
24
|
-
export type TAccountTrackerGtmEventParams =
|
|
15
|
+
export type TAccountTrackerGtmEventParams =
|
|
16
|
+
| TAccountTrackerGtmSignUpOnlineEventParams
|
|
25
17
|
| TAccountTrackerGtmVerifyPhoneOnlineEventParams
|
|
26
18
|
| TAccountTrackerGtmVerifyEmailOnlineEventParams;
|
|
27
19
|
|
|
@@ -30,12 +22,12 @@ export type TAccountTrackerGtmSignUpOnlineEventParams = {
|
|
|
30
22
|
[GTMEventParamsEnum.PHONE]: string;
|
|
31
23
|
[GTMEventParamsEnum.GCL_ID]: string;
|
|
32
24
|
[GTMEventParamsEnum.USER_ID]: string;
|
|
33
|
-
}
|
|
25
|
+
};
|
|
34
26
|
|
|
35
27
|
export type TAccountTrackerGtmVerifyPhoneOnlineEventParams = {
|
|
36
28
|
[GTMEventParamsEnum.GCL_ID]: string;
|
|
37
|
-
}
|
|
29
|
+
};
|
|
38
30
|
|
|
39
31
|
export type TAccountTrackerGtmVerifyEmailOnlineEventParams = {
|
|
40
32
|
[GTMEventParamsEnum.GCL_ID]: string;
|
|
41
|
-
}
|
|
33
|
+
};
|
|
@@ -3,35 +3,32 @@ import type {
|
|
|
3
3
|
TAccountMeta,
|
|
4
4
|
TCreateSessionRequestData,
|
|
5
5
|
TEmailUpdateRequestData,
|
|
6
|
+
TGetAssignedProductsRequestData,
|
|
6
7
|
TGetCurrentUserProfileRequestData,
|
|
8
|
+
TGetRestrictedCountriesData,
|
|
9
|
+
TProfileAssignRequestData,
|
|
7
10
|
TRegistrationRequestData,
|
|
8
11
|
TRequestProps,
|
|
9
12
|
TRequestQueryParams,
|
|
10
13
|
TResponse,
|
|
11
14
|
TSetupChallengeRequestData,
|
|
15
|
+
TSetupSSERequestData,
|
|
16
|
+
TSignInAppRequestBody,
|
|
17
|
+
TSignInByAppRequestData,
|
|
12
18
|
TSignInByMobileRequestData,
|
|
19
|
+
TSignInBySSEResponse,
|
|
13
20
|
TSignInStartRequestBody,
|
|
14
21
|
TSignUpByMobileRequestData,
|
|
15
22
|
TSignUpStartRequestBody,
|
|
23
|
+
TSSEResponseData,
|
|
24
|
+
TStorageRequestData,
|
|
16
25
|
TVerifyChallengeRequestBody,
|
|
17
26
|
TVerifyChallengeRequestData,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
TSignInBySSEResponse,
|
|
24
|
-
TSSEResponseData,
|
|
25
|
-
TGetAssignedProductsRequestData,
|
|
26
|
-
TProfileAssignRequestData,
|
|
27
|
-
} from "@root/types";
|
|
28
|
-
import {CommunicatorDefaultRequestData} from "./../Constants/Communicator";
|
|
29
|
-
import {jsonParse} from "./../Utils/jsonParseSafe";
|
|
30
|
-
import {
|
|
31
|
-
CommunicatorAuthAPIEndpointEnum,
|
|
32
|
-
CommunicatorFAPIEndpointEnum
|
|
33
|
-
} from "./../Enums/CommunicatorEnum";
|
|
34
|
-
import {prepareMetadata} from "./../Utils/registrationMetaData";
|
|
27
|
+
} from '@root/types';
|
|
28
|
+
import { CommunicatorDefaultRequestData } from './../Constants/Communicator';
|
|
29
|
+
import { jsonParse } from './../Utils/jsonParseSafe';
|
|
30
|
+
import { CommunicatorAuthAPIEndpointEnum, CommunicatorFAPIEndpointEnum } from './../Enums/CommunicatorEnum';
|
|
31
|
+
import { prepareMetadata } from './../Utils/registrationMetaData';
|
|
35
32
|
|
|
36
33
|
export class Communicator {
|
|
37
34
|
private props: TCommunicatorProps;
|
|
@@ -130,7 +127,7 @@ export class Communicator {
|
|
|
130
127
|
if (this.props.env !== 'prod') {
|
|
131
128
|
console.log('sse open', event);
|
|
132
129
|
}
|
|
133
|
-
if (typeof data.onOpen ===
|
|
130
|
+
if (typeof data.onOpen === 'function') {
|
|
134
131
|
data.onOpen();
|
|
135
132
|
}
|
|
136
133
|
});
|
|
@@ -140,7 +137,7 @@ export class Communicator {
|
|
|
140
137
|
if (this.props.env !== 'prod') {
|
|
141
138
|
console.log('sse message', event, responseData);
|
|
142
139
|
}
|
|
143
|
-
if (typeof data.onMessage ===
|
|
140
|
+
if (typeof data.onMessage === 'function') {
|
|
144
141
|
data.onMessage(responseData);
|
|
145
142
|
}
|
|
146
143
|
});
|
|
@@ -150,7 +147,7 @@ export class Communicator {
|
|
|
150
147
|
if (this.props.env !== 'prod') {
|
|
151
148
|
console.log('sse error', event, responseData);
|
|
152
149
|
}
|
|
153
|
-
if (typeof data.onError ===
|
|
150
|
+
if (typeof data.onError === 'function') {
|
|
154
151
|
data.onError();
|
|
155
152
|
}
|
|
156
153
|
this.closeSSEAuth();
|
|
@@ -245,7 +242,7 @@ export class Communicator {
|
|
|
245
242
|
const headers = this.getHeaders(data.accessToken);
|
|
246
243
|
const body = JSON.stringify({
|
|
247
244
|
seo_source: data.origin,
|
|
248
|
-
...(data.profileId && { last_profile_id: data.profileId })
|
|
245
|
+
...(data.profileId && { last_profile_id: data.profileId }),
|
|
249
246
|
});
|
|
250
247
|
|
|
251
248
|
return await this.send({
|
|
@@ -263,7 +260,7 @@ export class Communicator {
|
|
|
263
260
|
method: 'GET',
|
|
264
261
|
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.RESTRICTED_COUNTRIES}`,
|
|
265
262
|
headers,
|
|
266
|
-
...(data?.entityType && {queryParams: {entity_type: data.entityType}}),
|
|
263
|
+
...(data?.entityType && { queryParams: { entity_type: data.entityType } }),
|
|
267
264
|
});
|
|
268
265
|
}
|
|
269
266
|
|
|
@@ -298,22 +295,21 @@ export class Communicator {
|
|
|
298
295
|
method: requestInitProps.method,
|
|
299
296
|
body: requestInitProps.body,
|
|
300
297
|
headers: requestInitProps.headers,
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
json: data,
|
|
314
|
-
});
|
|
298
|
+
}).then((response) => {
|
|
299
|
+
return new Promise(async (resolve) => {
|
|
300
|
+
let data = {};
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
data = await response.json();
|
|
304
|
+
} catch (error) {}
|
|
305
|
+
|
|
306
|
+
return resolve({
|
|
307
|
+
status: response.status,
|
|
308
|
+
ok: response.ok,
|
|
309
|
+
json: data,
|
|
315
310
|
});
|
|
316
311
|
});
|
|
312
|
+
});
|
|
317
313
|
}
|
|
318
314
|
|
|
319
315
|
private getHeaders = (token?: string) => {
|
|
@@ -322,7 +318,7 @@ export class Communicator {
|
|
|
322
318
|
if (token) {
|
|
323
319
|
headers = {
|
|
324
320
|
...headers,
|
|
325
|
-
|
|
321
|
+
Authorization: `Bearer ${token}`,
|
|
326
322
|
};
|
|
327
323
|
}
|
|
328
324
|
|
|
@@ -341,7 +337,7 @@ export class Communicator {
|
|
|
341
337
|
};
|
|
342
338
|
};
|
|
343
339
|
|
|
344
|
-
private processingQueryParams = (queryParams: TRequestQueryParams):string => {
|
|
340
|
+
private processingQueryParams = (queryParams: TRequestQueryParams): string => {
|
|
345
341
|
let queryParamsString = '';
|
|
346
342
|
const queryParamsList = Object.entries(queryParams);
|
|
347
343
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
type TDefaultRequestData = {
|
|
2
|
-
IP: string
|
|
3
|
-
LANG: string
|
|
4
|
-
FETCH_HEADERS_INIT: HeadersInit
|
|
5
|
-
AUDIT_SOURCE_TYPE: import('@root/types').TAuditSource
|
|
6
|
-
}
|
|
2
|
+
IP: string;
|
|
3
|
+
LANG: string;
|
|
4
|
+
FETCH_HEADERS_INIT: HeadersInit;
|
|
5
|
+
AUDIT_SOURCE_TYPE: import('@root/types').TAuditSource;
|
|
6
|
+
};
|
|
7
7
|
|
|
8
8
|
type TCommunicatorProps = {
|
|
9
9
|
env?: 'local' | 'dev' | 'prod';
|
|
10
10
|
clientAuthApiBaseUrl: string;
|
|
11
11
|
clientAuthSSEBaseUrl: string;
|
|
12
12
|
clientFAPIBaseUrl: string;
|
|
13
|
-
}
|
|
13
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { registrationMetadataKeys } from
|
|
2
|
-
import type { TRegistrationMetadata, TRegistrationRequestBodySourceMetadata } from
|
|
1
|
+
import { registrationMetadataKeys } from '../Constants/RegistrationMetadata';
|
|
2
|
+
import type { TRegistrationMetadata, TRegistrationRequestBodySourceMetadata } from '@root/types';
|
|
3
3
|
|
|
4
4
|
export function prepareMetadata(obj: TRegistrationMetadata): TRegistrationRequestBodySourceMetadata[] {
|
|
5
5
|
const result: TRegistrationRequestBodySourceMetadata[] = [];
|
package/src/engine/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './AccountTracker';
|
|
2
|
+
export * from './Communicator';
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {AccountTracker} from
|
|
2
|
-
import {registrationSuccessEventParams, registrationSuccessEvents} from
|
|
1
|
+
import { AccountTracker } from '../src';
|
|
2
|
+
import { registrationSuccessEventParams, registrationSuccessEvents } from './testunits/accountTracker/events';
|
|
3
3
|
|
|
4
4
|
const mockGtmDataLayer = [];
|
|
5
|
-
const mockLintrk = jest.fn().mockImplementation();
|
|
6
5
|
|
|
7
6
|
const accountTrackerInitProps = {
|
|
8
7
|
gtmDataLayer: mockGtmDataLayer,
|
|
9
|
-
lintrk: mockLintrk,
|
|
10
8
|
};
|
|
11
9
|
|
|
12
10
|
const accountTracker = new AccountTracker(accountTrackerInitProps);
|
|
@@ -18,23 +16,16 @@ describe('AccountTracker', () => {
|
|
|
18
16
|
|
|
19
17
|
test('sendRegistrationSuccessEvent', () => {
|
|
20
18
|
accountTracker.sendRegistrationSuccessEvent(registrationSuccessEventParams);
|
|
21
|
-
|
|
22
|
-
expect(mockGtmDataLayer[0]).toEqual({...registrationSuccessEvents.gtm.sign_up_online});
|
|
23
|
-
|
|
24
|
-
expect(mockLintrk.mock.calls[0][0]).toBe(registrationSuccessEvents.linkedIn.action);
|
|
25
|
-
expect(mockLintrk.mock.calls[0][1]).toEqual(registrationSuccessEvents.linkedIn.event);
|
|
26
|
-
expect(mockLintrk).toHaveBeenCalled();
|
|
19
|
+
expect(mockGtmDataLayer[0]).toEqual({ ...registrationSuccessEvents.gtm.sign_up_online });
|
|
27
20
|
});
|
|
28
21
|
|
|
29
22
|
test('sendVerifyPhoneSuccessEvent', () => {
|
|
30
23
|
accountTracker.sendVerifyPhoneSuccessEvent(registrationSuccessEventParams);
|
|
31
|
-
|
|
32
|
-
expect(mockGtmDataLayer[1]).toEqual({...registrationSuccessEvents.gtm.verify_phone_online});
|
|
24
|
+
expect(mockGtmDataLayer[1]).toEqual({ ...registrationSuccessEvents.gtm.verify_phone_online });
|
|
33
25
|
});
|
|
34
26
|
|
|
35
27
|
test('sendVerifyEmailSuccessEvent', () => {
|
|
36
28
|
accountTracker.sendVerifyEmailSuccessEvent(registrationSuccessEventParams);
|
|
37
|
-
|
|
38
|
-
expect(mockGtmDataLayer[2]).toEqual({...registrationSuccessEvents.gtm.verify_email_online});
|
|
29
|
+
expect(mockGtmDataLayer[2]).toEqual({ ...registrationSuccessEvents.gtm.verify_email_online });
|
|
39
30
|
});
|
|
40
31
|
});
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import {Communicator} from
|
|
2
|
-
import {
|
|
3
|
-
headerTokenNormal,
|
|
4
|
-
queryParamsMulti,
|
|
5
|
-
queryParamsNormal
|
|
6
|
-
} from "./testunits/communicator/utils";
|
|
1
|
+
import { Communicator } from '../src';
|
|
2
|
+
import { headerTokenNormal, queryParamsMulti, queryParamsNormal } from './testunits/communicator/utils';
|
|
7
3
|
import {
|
|
8
4
|
createSessionData,
|
|
9
5
|
emailUpdateData,
|
|
6
|
+
getAssignedProductsData,
|
|
10
7
|
getCurrentUserProfileData,
|
|
8
|
+
getRestrictedCountriesData,
|
|
9
|
+
profileAssignData,
|
|
11
10
|
registrationData,
|
|
11
|
+
setStorageValuesData,
|
|
12
|
+
setStorageValuesDataWithProfileId,
|
|
12
13
|
setupChallengeData,
|
|
13
|
-
signInData,
|
|
14
14
|
signInByAppData,
|
|
15
|
+
signInData,
|
|
15
16
|
signUpData,
|
|
16
17
|
verifyChallengeData,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
getAssignedProductsData,
|
|
20
|
-
profileAssignData,
|
|
21
|
-
setStorageValuesDataWithProfileId,
|
|
22
|
-
} from "./testunits/communicator/requests";
|
|
23
|
-
import {communicatorTestData} from "./testunits/communicator/general";
|
|
18
|
+
} from './testunits/communicator/requests';
|
|
19
|
+
import { communicatorTestData } from './testunits/communicator/general';
|
|
24
20
|
|
|
25
21
|
const communicator = new Communicator(communicatorTestData.initProps);
|
|
26
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {communicatorTestData} from
|
|
1
|
+
import { communicatorTestData } from '../communicator/general';
|
|
2
2
|
|
|
3
3
|
const registrationSuccessEvents = {
|
|
4
4
|
gtm: {
|
|
@@ -16,12 +16,6 @@ const registrationSuccessEvents = {
|
|
|
16
16
|
verify_email_online: {
|
|
17
17
|
event: 'verify_email_online',
|
|
18
18
|
gcl_id: communicatorTestData.gcId,
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
linkedIn: {
|
|
22
|
-
action: 'track',
|
|
23
|
-
event: {
|
|
24
|
-
conversation_id: 8612308,
|
|
25
19
|
},
|
|
26
20
|
},
|
|
27
21
|
};
|
|
@@ -39,11 +33,8 @@ const registrationSuccessEventParams = {
|
|
|
39
33
|
},
|
|
40
34
|
verify_email_online: {
|
|
41
35
|
gcl_id: communicatorTestData.gcId,
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
registrationSuccessEvents,
|
|
48
|
-
registrationSuccessEventParams,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
49
38
|
};
|
|
39
|
+
|
|
40
|
+
export { registrationSuccessEvents, registrationSuccessEventParams };
|