@maxzima/wa-communicator 1.0.36 → 1.0.38

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.
@@ -1,10 +1,14 @@
1
1
  declare const enum GTMEventEnum {
2
- SIGN_UP = "sign_up"
2
+ SIGN_UP = "sign_up",
3
+ SIGN_UP_ONLINE = "sign_up_online"
3
4
  }
4
5
  declare const enum GTMEventParamsEnum {
5
6
  GCLID = "gclid",
6
7
  PHONE = "phone",
7
- EMAIL = "email"
8
+ EMAIL = "email",
9
+ ORIGIN = "origin",
10
+ SEND_TO = "send_to",
11
+ GCL_ID = "gcl_id"
8
12
  }
9
13
  declare const enum LintrkActionTypeEnum {
10
14
  TRACK = "track"
@@ -23,6 +23,7 @@ export class AccountTracker {
23
23
  }
24
24
  sendRegistrationSuccessEvent(eventParams) {
25
25
  this.sendGtmEvent("sign_up", eventParams.gtm);
26
+ this.sendGtmEvent("sign_up_online", eventParams.gtm);
26
27
  this.sendLinkedInEvent(8612308);
27
28
  }
28
29
  }
@@ -11,9 +11,14 @@ declare type TAccountTrackerEventParams = {
11
11
  declare type TAccountTrackerGtmEventParamsMapping = {
12
12
  [event in GTMEventEnum]: TAccountTrackerGtmEventParams;
13
13
  };
14
- declare type TAccountTrackerGtmEventParams = TAccountTrackerGtmSignUpEventParams;
14
+ declare type TAccountTrackerGtmEventParams = TAccountTrackerGtmSignUpEventParams | TAccountTrackerGtmSignUpOnlineEventParams;
15
15
  declare type TAccountTrackerGtmSignUpEventParams = {
16
16
  [GTMEventParamsEnum.GCLID]: string;
17
17
  [GTMEventParamsEnum.EMAIL]: string;
18
18
  [GTMEventParamsEnum.PHONE]: string;
19
19
  };
20
+ declare type TAccountTrackerGtmSignUpOnlineEventParams = {
21
+ [GTMEventParamsEnum.ORIGIN]: string;
22
+ [GTMEventParamsEnum.SEND_TO]: string;
23
+ [GTMEventParamsEnum.GCL_ID]: string;
24
+ };
@@ -3,7 +3,9 @@ declare const enum CommunicatorFAPIEndpointEnum {
3
3
  USER = "user",
4
4
  REGISTRATION = "clients/registration",
5
5
  STORAGE = "storage",
6
- RESTRICTED_COUNTRIES = "access-control/restricted-countries"
6
+ RESTRICTED_COUNTRIES = "access-control/restricted-countries",
7
+ ASSIGNED_PRODUCTS = "assigned-products",
8
+ PROFILE_ASSIGN = "users/profiles"
7
9
  }
8
10
  declare const enum CommunicatorAuthAPIEndpointEnum {
9
11
  SIGN_IN = "sign-in",
@@ -1,4 +1,4 @@
1
- import { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData, TStorageRequestData, TGetRestrictedCountriesData, TSetupSSERequestData, TSignInByAppRequestData } from "@root/types";
1
+ import { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData, TStorageRequestData, TGetRestrictedCountriesData, TSetupSSERequestData, TSignInByAppRequestData, TGetAssignedProductsRequestData, TProfileAssignRequestData } from "@root/types";
2
2
  export declare class Communicator {
3
3
  private props;
4
4
  private sseAuth;
@@ -16,6 +16,8 @@ export declare class Communicator {
16
16
  registration(data: TRegistrationRequestData): Promise<TResponse>;
17
17
  setStorageValues(data: TStorageRequestData): Promise<TResponse>;
18
18
  getRestrictedCountries(data?: TGetRestrictedCountriesData): Promise<TResponse>;
19
+ getAssignedProducts(data: TGetAssignedProductsRequestData): Promise<TResponse>;
20
+ profileAssign(data: TProfileAssignRequestData): Promise<TResponse>;
19
21
  private send;
20
22
  private getHeaders;
21
23
  private getMeta;
@@ -242,6 +242,26 @@ export class Communicator {
242
242
  return yield this.send(Object.assign({ method: 'GET', url: `${this.props.clientFAPIBaseUrl}${"access-control/restricted-countries"}`, headers }, ((data === null || data === void 0 ? void 0 : data.entityType) && { queryParams: { entity_type: data.entityType } })));
243
243
  });
244
244
  }
245
+ getAssignedProducts(data) {
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ const headers = this.getHeaders(data.accessToken);
248
+ return yield this.send({
249
+ method: 'GET',
250
+ url: `${this.props.clientFAPIBaseUrl}${"assigned-products"}`,
251
+ headers,
252
+ });
253
+ });
254
+ }
255
+ profileAssign(data) {
256
+ return __awaiter(this, void 0, void 0, function* () {
257
+ const headers = this.getHeaders(data.accessToken);
258
+ return yield this.send({
259
+ method: 'POST',
260
+ url: `${this.props.clientFAPIBaseUrl}${"users/profiles"}/${data.profileId}/assign`,
261
+ headers,
262
+ });
263
+ });
264
+ }
245
265
  send(requestInitProps) {
246
266
  return __awaiter(this, void 0, void 0, function* () {
247
267
  let url = requestInitProps.url;
@@ -170,4 +170,38 @@ declare type TStorageRequestData = {
170
170
  declare type TGetRestrictedCountriesData = {
171
171
  entityType?: import('@root/enums').CountryTypeEnum;
172
172
  };
173
- export { TRegistrationRequestBodySourceDeviceType, TChallenge, TAuditSource, TRequestProps, TRequestQueryParams, TResponse, TSignInStartRequestBody, TSignInAppRequestBody, TAccountMeta, TAccountBrowserData, TSignInByMobileRequestData, TSignInByAppRequestData, TSignInByMobileResponse, TSignInBySSEResponse, TSignUpStartRequestBody, TSignUpByMobileRequestData, TSetupChallengeRequestData, TSetupSSERequestData, TSSEResponseData, TSetupChallengeResponse, TVerifyChallengeRequestBody, TVerifyChallengeRequestData, TVerifyChallengeResponse, TEmailUpdateRequestData, TCreateSessionRequestData, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TStorageRequestData, TGetRestrictedCountriesData, };
173
+ declare type TGetAssignedProductsRequestData = {
174
+ accessToken: string;
175
+ };
176
+ declare type TAssignedProduct = {
177
+ id: string;
178
+ client_id: string;
179
+ name: string;
180
+ pricing_plan_subscription_started_at: string;
181
+ product_type: string;
182
+ is_frozen: boolean;
183
+ code?: string;
184
+ description?: string;
185
+ icon?: string;
186
+ client_name?: string;
187
+ pricing_plan_id?: string;
188
+ currency_code?: string;
189
+ deleted_at?: string | null;
190
+ next_pricing_plan_type?: string;
191
+ pricing_plan_selected_at?: string;
192
+ pricing_plan_type?: string;
193
+ pricing_plan_type_id?: string;
194
+ product_additional_info?: any;
195
+ updated_at?: string;
196
+ };
197
+ declare type TGetAssignedProductsResponse = {
198
+ products: TAssignedProduct[];
199
+ };
200
+ declare type TProfileAssignRequestData = {
201
+ accessToken: string;
202
+ profileId: string;
203
+ };
204
+ declare type TProfileAssignResponse = {
205
+ profile_permission_ids: string[];
206
+ };
207
+ export { TRegistrationRequestBodySourceDeviceType, TChallenge, TAuditSource, TRequestProps, TRequestQueryParams, TResponse, TSignInStartRequestBody, TSignInAppRequestBody, TAccountMeta, TAccountBrowserData, TSignInByMobileRequestData, TSignInByAppRequestData, TSignInByMobileResponse, TSignInBySSEResponse, TSignUpStartRequestBody, TSignUpByMobileRequestData, TSetupChallengeRequestData, TSetupSSERequestData, TSSEResponseData, TSetupChallengeResponse, TVerifyChallengeRequestBody, TVerifyChallengeRequestData, TVerifyChallengeResponse, TEmailUpdateRequestData, TCreateSessionRequestData, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TStorageRequestData, TGetRestrictedCountriesData, TGetAssignedProductsRequestData, TAssignedProduct, TGetAssignedProductsResponse, TProfileAssignRequestData, TProfileAssignResponse, };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.36",
2
+ "version": "1.0.38",
3
3
  "name": "@maxzima/wa-communicator",
4
4
  "description": "",
5
5
  "author": "Noname",
@@ -1,11 +1,15 @@
1
1
  const enum GTMEventEnum {
2
2
  SIGN_UP = 'sign_up',
3
+ SIGN_UP_ONLINE = 'sign_up_online',
3
4
  }
4
5
 
5
6
  const enum GTMEventParamsEnum {
6
7
  GCLID = 'gclid',
7
8
  PHONE = 'phone',
8
9
  EMAIL = 'email',
10
+ ORIGIN = 'origin',
11
+ SEND_TO = 'send_to',
12
+ GCL_ID = 'gcl_id',
9
13
  }
10
14
 
11
15
  const enum LintrkActionTypeEnum {
@@ -7,6 +7,7 @@ export class AccountTracker {
7
7
 
8
8
  public sendRegistrationSuccessEvent (eventParams: TAccountTrackerEventParams) {
9
9
  this.sendGtmEvent(GTMEventEnum.SIGN_UP, eventParams.gtm);
10
+ this.sendGtmEvent(GTMEventEnum.SIGN_UP_ONLINE, eventParams.gtm);
10
11
  this.sendLinkedInEvent(LintrkEventIdEnum.REGISTRATION);
11
12
  }
12
13
 
@@ -15,10 +15,16 @@ type TAccountTrackerGtmEventParamsMapping = {
15
15
  [event in GTMEventEnum]: TAccountTrackerGtmEventParams;
16
16
  };
17
17
 
18
- type TAccountTrackerGtmEventParams = TAccountTrackerGtmSignUpEventParams;
18
+ type TAccountTrackerGtmEventParams = TAccountTrackerGtmSignUpEventParams | TAccountTrackerGtmSignUpOnlineEventParams;
19
19
 
20
20
  type TAccountTrackerGtmSignUpEventParams = {
21
21
  [GTMEventParamsEnum.GCLID]: string;
22
22
  [GTMEventParamsEnum.EMAIL]: string;
23
23
  [GTMEventParamsEnum.PHONE]: string;
24
24
  }
25
+
26
+ type TAccountTrackerGtmSignUpOnlineEventParams = {
27
+ [GTMEventParamsEnum.ORIGIN]: string;
28
+ [GTMEventParamsEnum.SEND_TO]: string;
29
+ [GTMEventParamsEnum.GCL_ID]: string;
30
+ }
@@ -4,6 +4,8 @@ const enum CommunicatorFAPIEndpointEnum {
4
4
  REGISTRATION = 'clients/registration',
5
5
  STORAGE = 'storage',
6
6
  RESTRICTED_COUNTRIES = 'access-control/restricted-countries',
7
+ ASSIGNED_PRODUCTS = 'assigned-products',
8
+ PROFILE_ASSIGN = 'users/profiles',
7
9
  }
8
10
 
9
11
  const enum CommunicatorAuthAPIEndpointEnum {
@@ -22,6 +22,8 @@ import {
22
22
  TSignInByAppRequestData,
23
23
  TSignInBySSEResponse,
24
24
  TSSEResponseData,
25
+ TGetAssignedProductsRequestData,
26
+ TProfileAssignRequestData,
25
27
  } from "@root/types";
26
28
  import {CommunicatorDefaultRequestData} from "./../Constants/Communicator";
27
29
  import {jsonParse} from "./../Utils/jsonParseSafe";
@@ -47,7 +49,7 @@ export class Communicator {
47
49
  mobile: data.phoneNumber,
48
50
  } as TSignInStartRequestBody);
49
51
 
50
- const queryParams = {}
52
+ const queryParams = {};
51
53
  if (data.outOfBandAllowed) {
52
54
  // TODO: temporary
53
55
  queryParams['out_of_band_allowed'] = true;
@@ -115,7 +117,7 @@ export class Communicator {
115
117
  const params: TSignInBySSEResponse = {
116
118
  request_id: data.requestId,
117
119
  mobile: data.phoneNumber,
118
- }
120
+ };
119
121
  const url = `${this.props.clientAuthSSEBaseUrl}${CommunicatorAuthAPIEndpointEnum.SSE_AUTH}`;
120
122
  this.sseAuth = new EventSource(new URL(`${url}?${this.processingQueryParams(params)}`));
121
123
  if (this.sseAuth) {
@@ -258,6 +260,26 @@ export class Communicator {
258
260
  });
259
261
  }
260
262
 
263
+ public async getAssignedProducts(data: TGetAssignedProductsRequestData): Promise<TResponse> {
264
+ const headers = this.getHeaders(data.accessToken);
265
+
266
+ return await this.send({
267
+ method: 'GET',
268
+ url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.ASSIGNED_PRODUCTS}`,
269
+ headers,
270
+ });
271
+ }
272
+
273
+ public async profileAssign(data: TProfileAssignRequestData): Promise<TResponse> {
274
+ const headers = this.getHeaders(data.accessToken);
275
+
276
+ return await this.send({
277
+ method: 'POST',
278
+ url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.PROFILE_ASSIGN}/${data.profileId}/assign`,
279
+ headers,
280
+ });
281
+ }
282
+
261
283
  private async send(requestInitProps: TRequestProps): Promise<TResponse> {
262
284
  let url = requestInitProps.url;
263
285
 
@@ -230,6 +230,49 @@ type TGetRestrictedCountriesData = {
230
230
  }
231
231
  /* endregion getRestrictedCountries */
232
232
 
233
+ /* region getAssignedProducts */
234
+ type TGetAssignedProductsRequestData = {
235
+ accessToken: string;
236
+ }
237
+
238
+ type TAssignedProduct = {
239
+ id: string;
240
+ client_id: string;
241
+ name: string;
242
+ pricing_plan_subscription_started_at: string;
243
+ product_type: string;
244
+ is_frozen: boolean;
245
+ code?: string;
246
+ description?: string;
247
+ icon?: string;
248
+ client_name?: string;
249
+ pricing_plan_id?: string;
250
+ currency_code?: string;
251
+ deleted_at?: string | null;
252
+ next_pricing_plan_type?: string;
253
+ pricing_plan_selected_at?: string;
254
+ pricing_plan_type?: string;
255
+ pricing_plan_type_id?: string;
256
+ product_additional_info?: any;
257
+ updated_at?: string;
258
+ }
259
+
260
+ type TGetAssignedProductsResponse = {
261
+ products: TAssignedProduct[];
262
+ }
263
+ /* endregion getAssignedProducts */
264
+
265
+ /* region profileAssign */
266
+ type TProfileAssignRequestData = {
267
+ accessToken: string;
268
+ profileId: string;
269
+ }
270
+
271
+ type TProfileAssignResponse = {
272
+ profile_permission_ids: string[];
273
+ }
274
+ /* endregion profileAssign */
275
+
233
276
  export {
234
277
  TRegistrationRequestBodySourceDeviceType,
235
278
  TChallenge,
@@ -262,4 +305,9 @@ export {
262
305
  TRegistrationRequestData,
263
306
  TStorageRequestData,
264
307
  TGetRestrictedCountriesData,
308
+ TGetAssignedProductsRequestData,
309
+ TAssignedProduct,
310
+ TGetAssignedProductsResponse,
311
+ TProfileAssignRequestData,
312
+ TProfileAssignResponse,
265
313
  };
@@ -7,6 +7,11 @@ const registrationSuccessEvents = {
7
7
  gclid: communicatorTestData.gcId,
8
8
  email: communicatorTestData.email,
9
9
  phone: communicatorTestData.phoneNumber,
10
+ },
11
+ sign_up_online: {
12
+ event: 'sign_up_online',
13
+ send_to: communicatorTestData.gaId,
14
+ gcl_id: communicatorTestData.gcId,
10
15
  }
11
16
  },
12
17
  linkedIn: {
@@ -23,6 +28,11 @@ const registrationSuccessEventParams = {
23
28
  gclid: communicatorTestData.gcId,
24
29
  email: communicatorTestData.email,
25
30
  phone: communicatorTestData.phoneNumber,
31
+ },
32
+ sign_up_online: {
33
+ origin: communicatorTestData.gtmId,
34
+ send_to: communicatorTestData.ga4Id,
35
+ gcl_id: communicatorTestData.gcId,
26
36
  }
27
37
  }
28
38
  }
@@ -27,6 +27,8 @@ const communicatorTestData = {
27
27
  accessToken: '_accessToken_',
28
28
  hash: '_hash_',
29
29
  gaId: '_gaId_',
30
+ ga4Id: '_ga4Id_',
31
+ gtmId: '_gtmId_',
30
32
  origin: '_origin_',
31
33
  gcId: '_gcId_',
32
34
  utmSource: '_utmSource_',