ouisys-engine 2.1.18 → 2.1.22

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.
Files changed (55) hide show
  1. package/dist/api/click2sms.js +357 -0
  2. package/dist/api/index.d.ts +1 -1
  3. package/dist/api/index.js +27 -27
  4. package/dist/api/mo.js +274 -0
  5. package/dist/api/moRedir.js +186 -0
  6. package/dist/api/oneClick.js +366 -0
  7. package/dist/api/pin.js +493 -0
  8. package/dist/api/strategies.js +704 -0
  9. package/dist/api/ussd.js +1 -0
  10. package/dist/app/store.js +35 -0
  11. package/dist/features/strategies/categories/askMobileNumber.js +395 -0
  12. package/dist/features/strategies/categories/askOperator.js +311 -0
  13. package/dist/features/strategies/categories/detectOperatorByIp.js +606 -0
  14. package/dist/features/strategies/categories/headerEnrichment.js +670 -0
  15. package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +12 -0
  16. package/dist/features/strategies/categories/typings/identifySliceTypes.js +22 -0
  17. package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +22 -0
  18. package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +21 -0
  19. package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +13 -0
  20. package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +13 -0
  21. package/dist/features/strategies/click2smsFlowSlice.js +172 -0
  22. package/dist/features/strategies/identifySlice.js +455 -0
  23. package/dist/features/strategies/moFlowSlice.js +196 -0
  24. package/dist/features/strategies/moRedirFlowSlice.js +190 -0
  25. package/dist/features/strategies/oneClickFlowSlice.js +277 -0
  26. package/dist/features/strategies/pinFlowSlice.js +313 -0
  27. package/dist/features/strategies/ussdFlowSlice.js +1 -0
  28. package/dist/ips/tryGetIPRangeName.js +14 -13
  29. package/dist/mockServer/browser.js +48 -0
  30. package/dist/mockServer/handlers.js +22 -0
  31. package/dist/mockServer/server.js +48 -0
  32. package/dist/pacman/index.js +0 -1
  33. package/dist/reducers/click2smsFlow/utils.js +1 -3
  34. package/dist/reducers/oneClickFlow/utils.js +8 -7
  35. package/dist/reducers/pinFlow/utils.js +65 -34
  36. package/dist/reducers/strategy/strategies/header_enrichment.js +31 -25
  37. package/dist/reducers/strategy/utils.js +11 -12
  38. package/dist/reducers/tpayHeFlow/utils.js +1 -1
  39. package/dist/test/test-utils.js +51 -0
  40. package/package.json +1 -1
  41. package/src/@types/window.d.ts +3 -0
  42. package/src/api/index.ts +7 -7
  43. package/src/ips/tryGetIPRangeName.ts +3 -2
  44. package/src/pacman/index.ts +1 -1
  45. package/src/reducers/click2smsFlow/utils.ts +0 -3
  46. package/src/reducers/oneClickFlow/utils.ts +3 -2
  47. package/src/reducers/pinFlow/utils.ts +34 -4
  48. package/src/reducers/strategy/strategies/header_enrichment.ts +14 -11
  49. package/src/reducers/strategy/utils.ts +1 -2
  50. package/src/reducers/tpayHeFlow/utils.ts +1 -1
  51. package/dist/reducers/strategy/__tests__/strategy.spec.d.ts +0 -1
  52. package/dist/reducers/strategy/__tests__/strategy.spec.js +0 -33
  53. package/dist/test/renderWithRouterAndUserMock.d.ts +0 -21
  54. package/dist/test/renderWithRouterAndUserMock.js +0 -40
  55. package/dist/test/setup.d.ts +0 -1
@@ -95,10 +95,11 @@ export const getRedirectUrl = async(window:Window, maybeConfig: IConfig, extraP
95
95
 
96
96
 
97
97
  export const subscribe:(url:string, extraParams?:IHash)=>Promise<string> = async(url:string, extraParams?:IHash)=>{
98
-
98
+ const evinaTid = (typeof window != "undefined" && window.tid) ? window.tid : "";
99
99
  const extraParamsQs = !extraParams ? '' : '&' + Object.keys(extraParams).map(k => `${k}=${extraParams[k]}`).join('&')
100
100
 
101
- const result:ISubscribeResult = await fetch(url + extraParamsQs).then((x)=>x.json())
101
+
102
+ const result:ISubscribeResult = await fetch(`${url}&sam_evina_tid=${evinaTid}${extraParamsQs}`).then((x)=>x.json())
102
103
 
103
104
  if(false === result.success){
104
105
  const subscribeError = new Error(`Error in subscribe() one-click-subscribe action:\n${result.message}`) as {productUrl:string} & IError;
@@ -1,7 +1,7 @@
1
1
  import { IConfig, IHash, SingleMSISDNSubmissionResult, MultiOperatorMSISDNSubmissionResult, IMSISDNSubmissionResult, IPINSubmissionResult, ICheckSubscriptionResult, IPinFlowCurrentState, MSISDNEntryFailure, MSISDNEntrySuccess, PINEntryFailure, PINEntrySuccess, IPinFlowReducerState, IMcpShieldResult } from "./PinTypes";
2
2
  import IError from "../../common-types/IError";
3
3
  import * as RDS from "../../common-types/RemoteDataState";
4
- import { left, loop, right } from "../strategy/utils";
4
+ import { identifyUser, left, loop, right } from "../strategy/utils";
5
5
 
6
6
  const loadScriptInnerHtml = (innerHTML:string)=>{
7
7
  var script = document.createElement('script');
@@ -32,6 +32,7 @@ export async function loadMcpShield(window: Window, config: IConfig): Promise<IM
32
32
  const rockmanId = window.pac_analytics.visitor.rockmanId
33
33
 
34
34
  try{
35
+
35
36
  const mcpShieldResult: IMcpShieldResult = await window.tallymanApi.mcpShield(host, country, slug, device, offer, rockmanId)
36
37
  if(false == mcpShieldResult.success){
37
38
  console.warn(mcpShieldResult.message);
@@ -53,11 +54,34 @@ async function submitMSISDNOnce(window: Window, config: IConfig, internationalMS
53
54
  }
54
55
 
55
56
  const msisdn = internationalMSISDN.match(/\d+/gi).join('') // tallyman API expects international msisdn without any special character
56
- const { slug, country, device, offer, host } = config
57
+ const rockmanId = window.pac_analytics.visitor.rockmanId
58
+
59
+ // HARDCODING This for now if the concerpt works we move this to configs
60
+ const supportedSlugs:{[key:string]:string} = {
61
+ "kuwait-agency-mix-gamezone-puzzle1":"kuwait-agency-mix-gamezone-puzzle1",
62
+ "kuwait-agency-mix-yourspot-riddles":"kuwait-agency-mix-yourspot-riddles"
63
+ }
64
+
65
+ if(config.country.toLowerCase() == "k2" && supportedSlugs[config.slug]){
66
+ const identifiedUser = await window.tallymanApi.identify(config.host, config.slug, config.country, msisdn, config.device, config.offer, rockmanId);
67
+ if(identifiedUser.operator && identifiedUser.operator == "K2_ZAIN"){
68
+ window.hostCountry = "KW";
69
+ window.hostSlug = "kw-mt2-hosted-flow-mobfun";
70
+ config.country = window.hostCountry;
71
+ config.slug = window.hostSlug;
72
+ }
73
+ }
74
+
75
+ const { slug, country, device, offer, host } = config;
76
+
77
+
78
+
79
+
57
80
  const search = (window.location.search.indexOf("redirect-back=1") == -1) ? (window.location.search.substr(1) || '') : ''
58
81
  const extraParamsQs = !extraParams ? '' : '&' + Object.keys(extraParams).map(k => `${k}=${extraParams[k]}`).join('&')
59
- const rockmanId = window.pac_analytics.visitor.rockmanId
60
82
  const uniqid = (uniqidOnLoadResult != "" && country.toLowerCase() == "iq") ? `&mcpUniqid=${uniqidOnLoadResult}` : '';
83
+
84
+
61
85
 
62
86
  const result: IMSISDNSubmissionResult = await window.tallymanApi.triggerPin(host, country, slug, device, offer, msisdn, rockmanId, extraParamsQs, search, uniqid)
63
87
  if (false === result.success) {
@@ -133,6 +157,10 @@ async function submitMSISDNForMultipleOperators(window: Window, config: IConfig,
133
157
 
134
158
  export async function submitPIN(window:Window, pin: string, config:IConfig, extraParams:IHash): Promise<{productUrl:string; isAlreadySubscribed?:boolean;}> {
135
159
 
160
+ if(window.hostCountry && window.hostSlug){
161
+ config.country = window.hostCountry;
162
+ config.slug = window.hostSlug;
163
+ }
136
164
  const { slug, country, device, host } = config;
137
165
  const offer = window.pac_analytics.visitor.offer;
138
166
  const extraParamsQs = !extraParams ? '' : '&' + Object.keys(extraParams).map(k => `${k}=${extraParams[k]}`).join('&')
@@ -143,7 +171,9 @@ export async function submitPIN(window:Window, pin: string, config:IConfig, extr
143
171
  throw emptyPinError
144
172
  }
145
173
  const uniqid = uniqidResult != "" ? `&mcpUniqid=${uniqidResult}` : '';
146
- const pinResult: IPINSubmissionResult = await window.tallymanApi.verifyPin(host, country, slug, device, offer, rockmanId, pin, extraParamsQs, uniqid)
174
+ const evinaTid = (typeof window != "undefined" && window.tid) ? window.tid : "";
175
+
176
+ const pinResult: IPINSubmissionResult = await window.tallymanApi.verifyPin(host, country, slug, device, offer, rockmanId, pin, extraParamsQs, uniqid, evinaTid)
147
177
  if (false === pinResult.success) {
148
178
  const pinError = new Error(`Error in submitMSISDN() verify-pin action:\n${pinResult.message}`) as IError & {type:string}
149
179
  pinError['type'] = "InvalidPIN";
@@ -71,7 +71,8 @@ export const pin_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
71
71
  if(heResult.msisdn !== undefined && heResult.msisdn !== ""){
72
72
  const msisdn = heResult.msisdn;
73
73
  const operator = heResult.operator;
74
- tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-detected',{msisdn})
74
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
75
+
75
76
  tracker.sendOptInFlowEvent("Hybrid Pin")
76
77
  return dispatch({
77
78
  type:"IDENTIFY_FLOW_BY_HE",
@@ -101,7 +102,7 @@ export const pin_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
101
102
  }
102
103
  }catch(err){
103
104
  console.warn(err)
104
- tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-detection-failure', {errorType: err.toString()})
105
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
105
106
  tracker.sendOptInFlowEvent("Pin")
106
107
 
107
108
  dispatch({
@@ -183,9 +184,9 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
183
184
  }
184
185
  }
185
186
  let ipRangeName = await tryGetIPRangeName(window.pac_analytics.visitor);
186
- console.log("IP ipRangeName", ipRangeName);
187
187
 
188
188
  if (ipRangeName == null) {
189
+ tracker.sendOptInFlowEvent("Pin")
189
190
  return dispatch({
190
191
  type:"IDENTIFY_FLOW_BY_HE",
191
192
  payload:{
@@ -209,7 +210,7 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
209
210
 
210
211
  const operator = heResult.operator ? heResult.operator.toUpperCase() : ipRangeName.toUpperCase()
211
212
  if(msisdn && msisdn !== ""){
212
- tracker.advancedInFlow('identify-user', 'msisdn-detected',{msisdn})
213
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
213
214
  const flowObj = determineFlowByOperator(operator);
214
215
  switchState({flowObj, msisdn, operator, subscription_url, redirect_url})
215
216
  }else{
@@ -217,6 +218,7 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
217
218
  switchState({flowObj, redirect_url, subscription_url, operator})
218
219
  }
219
220
  }else{
221
+ tracker.sendOptInFlowEvent("Pin")
220
222
  return dispatch({
221
223
  type:"IDENTIFY_FLOW_BY_HE",
222
224
  payload:{
@@ -232,7 +234,7 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
232
234
 
233
235
  }catch(err){
234
236
  console.warn(err)
235
- tracker.recedeInFlow('identify-user', 'msisdn-detection-failure', {errorType: err.toString()})
237
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
236
238
  tracker.sendOptInFlowEvent("Pin")
237
239
  dispatch({
238
240
  type:"IDENTIFY_FLOW_BY_HE",
@@ -310,9 +312,9 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
310
312
  }
311
313
  }
312
314
  let ipRangeName = await tryGetIPRangeName(window.pac_analytics.visitor);
313
- console.log("IP ipRangeName", ipRangeName);
314
315
 
315
316
  if (ipRangeName == null) {
317
+ tracker.sendOptInFlowEvent("Redirect")
316
318
  return dispatch({
317
319
  type:"IDENTIFY_FLOW_BY_HE",
318
320
  payload:{
@@ -336,7 +338,7 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
336
338
 
337
339
  const operator = heResult.operator ? heResult.operator.toUpperCase() : ipRangeName.toUpperCase()
338
340
  if(msisdn && msisdn !== ""){
339
- tracker.advancedInFlow('identify-user', 'msisdn-detected',{msisdn})
341
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
340
342
  const flowObj = determineFlowByOperator(operator);
341
343
  switchState({flowObj, msisdn, operator, subscription_url, redirect_url})
342
344
  }else{
@@ -344,6 +346,7 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
344
346
  switchState({flowObj, redirect_url, subscription_url, operator})
345
347
  }
346
348
  }else{
349
+ tracker.sendOptInFlowEvent("Redirect")
347
350
  return dispatch({
348
351
  type:"IDENTIFY_FLOW_BY_HE",
349
352
  payload:{
@@ -359,8 +362,8 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
359
362
 
360
363
  }catch(err){
361
364
  console.warn(err)
362
- tracker.recedeInFlow('identify-user', 'msisdn-detection-failure', {errorType: err.toString()})
363
- tracker.sendOptInFlowEvent("Pin")
365
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
366
+ tracker.sendOptInFlowEvent("Redirect")
364
367
  dispatch({
365
368
  type:"IDENTIFY_FLOW_BY_HE",
366
369
  payload:{
@@ -442,7 +445,7 @@ export const he_pin_mo_redir_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
442
445
  const msisdn = heResult.msisdn;
443
446
  const operator = heResult.operator;
444
447
 
445
- tracker.advancedInFlow('identify-user', 'msisdn-detected',{msisdn})
448
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
446
449
 
447
450
  if(!!operator && operator !== ""){
448
451
  const flowObj = determineFlowByOperator(operator);
@@ -458,7 +461,7 @@ export const he_pin_mo_redir_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
458
461
  }
459
462
  }catch(err){
460
463
  console.warn(err)
461
- tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-detection-failure', {errorType: err.toString()})
464
+ tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
462
465
 
463
466
  try{
464
467
  const flowObj = await determineFlowByOperatorFromIp()
@@ -225,7 +225,6 @@ export const identifyUser = async(extraParams?:ILinkExtraParams):
225
225
  return {redirect_url, msisdn:msisdn, operator:operator}
226
226
  }
227
227
  }else{
228
- console.log("newUrl",window.location.href)
229
228
  const newUrl = new URL(window.location.href);
230
229
  const queryString = newUrl.search;
231
230
  const urlParams = new URLSearchParams(queryString);
@@ -237,7 +236,7 @@ export const identifyUser = async(extraParams?:ILinkExtraParams):
237
236
 
238
237
  }
239
238
  }else{
240
- const url = `https://${newHost}/tallyman/v1/?action=identify-user&country=${bupperizeCountry(country)}&slug=${slug}&device=${device}&offerId=${offer}&page=${window.location.href}&pixel_url=${encodeURIComponent(`http://c1.ouisys.com/pixels?xcid=${window.location.pathname.replace("/", "")}&xaid=${window.pac_analytics.visitor.xaid}&country=${bupperizeCountry(country)}`)}&rockman_id=${rockmanId}${extraParamsQs}&${search}`
239
+ const url = `https://${newHost}/tallyman/v1/?action=identify-user&country=${bupperizeCountry(country)}&slug=${slug}&device=${device}&offerId=${offer}&page=${window.location.href}&pixel_url=${encodeURIComponent(`http://${window.location.host}/pixels?xcid=${window.location.pathname.replace("/", "")}&xaid=${window.pac_analytics.visitor.xaid}&country=${bupperizeCountry(country)}`)}&rockman_id=${rockmanId}${extraParamsQs}&${search}`
241
240
 
242
241
  const result = await fetchJsonp<IStrategyIDentifyUserResult>(url);
243
242
  if(false === result.success){
@@ -224,7 +224,7 @@ export const confirmTPay = (window:Window, tpayConfig:ITpayConsentResult, locale
224
224
  if (config["replace_uid"] != undefined && config['replace_uid'] == true) {
225
225
  console.log('sub id ' + subId);
226
226
  productUrl = config['product_full_access'];
227
- fetch(`http://de-mcb-api.sam-media.com/api/v2/validate-access/?domain=${config.domain}&sub_id=${subId}&country=${tpayConfig.country}&gateway=tpay`).then((response:any)=>{
227
+ fetch(`http://de.tallymans.com/api/v2/validate-access/?domain=${config.domain}&sub_id=${subId}&country=${tpayConfig.country}&gateway=tpay`).then((response:any)=>{
228
228
  if (response.payload.token) {
229
229
  productUrl = config['product_url'].replace('<%UID%>', response.payload.token);
230
230
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
4
-
5
- var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
6
-
7
- var _ = require("..");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- var middlewares = [_reduxThunk.default];
12
- var mockStore = (0, _reduxMockStore.default)(middlewares);
13
- var store = mockStore();
14
- describe('identify strategy action', function () {
15
- var expectedResult = [{
16
- "payload": {
17
- "nextData": {
18
- "nextAction": "submitMSISDNAction"
19
- },
20
- "result": {
21
- "type": "NothingYet"
22
- },
23
- "type": "IDENTIFY_FLOW_BY_MSISDN"
24
- },
25
- "type": "IDENTIFY_FLOW_BY_MSISDN"
26
- }];
27
- it('identifies flow as ', function () {
28
- return store //@ts-ignore
29
- .dispatch((0, _.identifyStrategy)()).then(function () {
30
- return expect(store.getActions()).toEqual(expectedResult);
31
- });
32
- });
33
- });
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import { UserConfig } from '../global/interfaces/user';
3
- interface NestedObjectWithStrings {
4
- [key: string]: string | NestedObjectWithStrings;
5
- }
6
- interface TranslationsItem {
7
- translations: {
8
- lang: string;
9
- entries: NestedObjectWithStrings;
10
- };
11
- }
12
- interface Translations {
13
- [key: string]: TranslationsItem;
14
- }
15
- interface UserMock {
16
- USER: {
17
- payload: Partial<UserConfig>;
18
- };
19
- }
20
- export declare const renderWithRouterAndUserMock: (children: React.ReactNode, userApiMock: UserMock, translations: Translations) => void;
21
- export {};
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.renderWithRouterAndUserMock = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _reactRouterDom = require("react-router-dom");
11
-
12
- var _testUtils = require("./test-utils");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- var renderWithRouterAndUserMock = function renderWithRouterAndUserMock(children, userApiMock, translations) {
17
- (0, _testUtils.render)(<_reactRouterDom.MemoryRouter>{children}</_reactRouterDom.MemoryRouter>, {
18
- initialState: {
19
- api: userApiMock,
20
- distributor: {
21
- selectedOutlet: {
22
- eid: 'SEELENAMAR',
23
- salesOrg: '1010',
24
- name: 'Elena Martinez Sweden Bar',
25
- tradeChannel1Desc: 'On-trade',
26
- region: 'Khammuane',
27
- city: 'ນະຄອນຫລວງວຽງຈັນ',
28
- address: 'ວັດຈັນ ຈັນທະບູລີ ',
29
- selected: true
30
- }
31
- },
32
- user: {
33
- isLoggedIn: true
34
- }
35
- },
36
- translations: translations
37
- });
38
- };
39
-
40
- exports.renderWithRouterAndUserMock = renderWithRouterAndUserMock;
@@ -1 +0,0 @@
1
- import 'whatwg-fetch';