ouisys-engine 3.0.15 → 3.0.17

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.
@@ -70,7 +70,8 @@ var _default = function _default(window, country, page) {
70
70
 
71
71
  if (!window.pac_analytics) {
72
72
  var rockmanId = (0, _v.default)().replace(/-/g, '');
73
- var campaignId = parseInt((0, _queryString2.default)(window.location.search, 'cid')) || 2;
73
+ var campaignId = parseInt((0, _queryString2.default)(window.location.search, 'cid'), 10) || 2; // eslint-disable-next-line no-param-reassign
74
+
74
75
  window.pac_analytics = {
75
76
  visitor: {
76
77
  rockmanId: rockmanId,
@@ -80,7 +81,7 @@ var _default = function _default(window, country, page) {
80
81
  page: page,
81
82
  xaid: (0, _queryString2.default)(window.location.search, 'xaid'),
82
83
  cid: campaignId,
83
- offer: parseInt((0, _queryString2.default)(window.location.search, 'offer')) || 1 // default to 1 offer id
84
+ offer: parseInt((0, _queryString2.default)(window.location.search, 'offer'), 10) || 1 // default to 1 offer id
84
85
 
85
86
  },
86
87
  startTime: new Date().valueOf(),
@@ -21,7 +21,7 @@ require("core-js/modules/es.string.match.js");
21
21
  require("core-js/modules/es.array.concat.js");
22
22
 
23
23
  var _default = function _default(url, paramName) {
24
- var name = paramName.replace(/[\[\]]/g, '\\$&');
24
+ var name = paramName.replace(/[\]]/g, '\\$&');
25
25
  var regex = new RegExp("[?&]".concat(name, "(=([^&#]*)|&|#|$)"), 'i');
26
26
  var results = regex.exec(url);
27
27
  if (!results) return null;
@@ -35,15 +35,16 @@ function updateUrlParameter(uri, key, value) {
35
35
  // remove the hash part before operating on the uri
36
36
  var i = uri.indexOf('#');
37
37
  var hash = i === -1 ? '' : uri.substr(i);
38
- uri = i === -1 ? uri : uri.substr(0, i);
38
+ var newUri = uri;
39
+ newUri = i === -1 ? newUri : newUri.substr(0, i);
39
40
  var re = new RegExp("([?&])".concat(key, "=.*?(&|$)"), 'i');
40
- var separator = uri.indexOf('?') !== -1 ? '&' : '?';
41
+ var separator = newUri.indexOf('?') !== -1 ? '&' : '?';
41
42
 
42
- if (uri.match(re)) {
43
- uri = uri.replace(re, "$1".concat(key, "=").concat(value, "$2"));
43
+ if (newUri.match(re)) {
44
+ newUri = newUri.replace(re, "$1".concat(key, "=").concat(value, "$2"));
44
45
  } else {
45
- uri = "".concat(uri + separator + key, "=").concat(value);
46
+ newUri = "".concat(newUri + separator + key, "=").concat(value);
46
47
  }
47
48
 
48
- return uri + hash; // finally append the hash as well
49
+ return newUri + hash; // finally append the hash as well
49
50
  }
@@ -48,7 +48,7 @@ export declare type IStrategy = {
48
48
  country: string;
49
49
  strategyConfigs: StrategyConfig;
50
50
  };
51
- export declare type IStrategyNames = 'pin' | 'mo' | 'mo-redir' | 'click2sms' | 'one-click' | 'ussd' | 'tpay-he' | 'tallyman-one-click' | 'pin-mo-ask-operator' | 'pin-mo-ask-mobile-number' | 'pin-one-click-ask-operator' | 'pin-one-click-detect-operator-by-ip' | 'one-click-mo-pin-detect-operator-by-ip-or-msisdn' | 'pin-click2sms-ask-operator' | 'mo-redir-one-click-detect-operator-by-ip' | 'pin-mo-redir-ask-mobile-number' | 'pin-click2sms-ask-mobile-number' | 'mo-one-click-detect-operator-by-ip' | 'click2sms-one-click-detect-operator-by-ip' | 'pin-header-enrichment' | 'pin-msisdn-fowarding-pin-header-enrichment' | 'he-pin-mo-redir-header-enrichment' | 'he-pin-one-click-header-enrichment' | 'he-pin-one-click-ask-operator' | 'click2sms-one-click-ask-operator' | 'pin-mo-detect-operator-by-ip' | 'he-mo-redir-one-click-header-enrichment' | 'pin-combo-ask-mobile-number';
51
+ export declare type IStrategyNames = 'pin' | 'mo' | 'mo-redir' | 'click2sms' | 'one-click' | 'ussd' | 'tpay-he' | 'tallyman-one-click' | 'pin-mo-ask-operator' | 'pin-mo-ask-mobile-number' | 'pin-one-click-ask-operator' | 'pin-one-click-detect-operator-by-ip' | 'one-click-mo-pin-detect-operator-by-ip-or-msisdn' | 'pin-click2sms-ask-operator' | 'mo-redir-one-click-detect-operator-by-ip' | 'pin-mo-redir-ask-mobile-number' | 'pin-click2sms-ask-mobile-number' | 'mo-one-click-detect-operator-by-ip' | 'click2sms-one-click-detect-operator-by-ip' | 'pin-header-enrichment' | 'pin-msisdn-fowarding-pin-header-enrichment' | 'he-pin-mo-redir-header-enrichment' | 'he-pin-one-click-header-enrichment' | 'he-pin-one-click-ask-operator' | 'click2sms-one-click-ask-operator' | 'pin-mo-detect-operator-by-ip' | 'he-mo-redir-one-click-header-enrichment' | 'pin-combo-ask-mobile-number' | 'header-enrichment-script';
52
52
  export interface IHash {
53
53
  [key: string]: string;
54
54
  }
@@ -114,6 +114,8 @@ export declare type IIdentfyFlowByOperatorNextAction = 'submitMSISDNAction' | 'l
114
114
  export declare type IIdentfyFlowByIPOperatorNextAction = 'getRedirectUrlAction' | 'submitMSISDNAction';
115
115
  export declare type IIdenyifyFlowByMsisdnSumbitNextData = {
116
116
  nextAction: IIdentfyFlowByMsisdnNextAction;
117
+ msisdn?: string;
118
+ operator?: string;
117
119
  };
118
120
  export declare type IIdenyifyFlowByMsisdnPayload = {
119
121
  type: 'IDENTIFY_FLOW_BY_MSISDN';
@@ -228,3 +230,9 @@ export interface IMockFlowParams<T> {
228
230
  'mock-flow': IMockFlows;
229
231
  'current-state': T;
230
232
  }
233
+ export interface IScriptHeaderEnrichmentSuccess extends CustomEvent {
234
+ detail: {
235
+ msisdn: string;
236
+ operator_code: string;
237
+ };
238
+ }
@@ -79,6 +79,8 @@ var _detect_operator_by_ip = _interopRequireDefault(require("./strategies/detect
79
79
 
80
80
  var _header_enrichment = _interopRequireDefault(require("./strategies/header_enrichment"));
81
81
 
82
+ var _injectHeaderEnrichmentScript = _interopRequireDefault(require("./strategies/injectHeaderEnrichmentScript"));
83
+
82
84
  var _utils2 = require("./utils");
83
85
 
84
86
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -177,12 +179,12 @@ function identifyStrategy() {
177
179
  }
178
180
 
179
181
  dispatch(mockStrategyStateByUrlParam());
180
- _context.next = 32;
182
+ _context.next = 31;
181
183
  break;
182
184
 
183
185
  case 7:
184
186
  _context.t0 = strategy;
185
- _context.next = _context.t0 === 'pin-mo-ask-operator' ? 10 : _context.t0 === 'pin-mo-redir-ask-mobile-number' ? 11 : _context.t0 === 'pin-mo-ask-mobile-number' ? 11 : _context.t0 === 'pin-combo-ask-mobile-number' ? 11 : _context.t0 === 'pin-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'one-click-mo-pin-detect-operator-by-ip-or-msisdn' ? 12 : _context.t0 === 'mo-redir-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'mo-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'click2sms-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'pin-mo-detect-operator-by-ip' ? 12 : _context.t0 === 'pin-click2sms-ask-operator' ? 13 : _context.t0 === 'he-pin-one-click-ask-operator' ? 13 : _context.t0 === 'click2sms-one-click-ask-operator' ? 13 : _context.t0 === 'pin-one-click-ask-operator' ? 13 : _context.t0 === 'pin-header-enrichment' ? 14 : _context.t0 === 'he-pin-mo-redir-header-enrichment' ? 14 : _context.t0 === 'he-pin-one-click-header-enrichment' ? 14 : _context.t0 === 'he-mo-redir-one-click-header-enrichment' ? 14 : _context.t0 === 'pin' ? 15 : _context.t0 === 'mo' ? 17 : _context.t0 === 'mo-redir' ? 19 : _context.t0 === 'one-click' ? 21 : _context.t0 === 'tallyman-one-click' ? 23 : _context.t0 === 'click2sms' ? 25 : _context.t0 === 'ussd' ? 27 : _context.t0 === 'tpay-he' ? 29 : 31;
187
+ _context.next = _context.t0 === 'pin-mo-ask-operator' ? 10 : _context.t0 === 'pin-mo-redir-ask-mobile-number' ? 11 : _context.t0 === 'pin-mo-ask-mobile-number' ? 11 : _context.t0 === 'pin-combo-ask-mobile-number' ? 11 : _context.t0 === 'pin-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'one-click-mo-pin-detect-operator-by-ip-or-msisdn' ? 12 : _context.t0 === 'mo-redir-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'mo-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'click2sms-one-click-detect-operator-by-ip' ? 12 : _context.t0 === 'pin-mo-detect-operator-by-ip' ? 12 : _context.t0 === 'pin-click2sms-ask-operator' ? 13 : _context.t0 === 'he-pin-one-click-ask-operator' ? 13 : _context.t0 === 'click2sms-one-click-ask-operator' ? 13 : _context.t0 === 'pin-one-click-ask-operator' ? 13 : _context.t0 === 'pin-header-enrichment' ? 14 : _context.t0 === 'he-pin-mo-redir-header-enrichment' ? 14 : _context.t0 === 'he-pin-one-click-header-enrichment' ? 14 : _context.t0 === 'he-mo-redir-one-click-header-enrichment' ? 14 : _context.t0 === 'header-enrichment-script' ? 15 : _context.t0 === 'pin' ? 16 : _context.t0 === 'mo' ? 18 : _context.t0 === 'mo-redir' ? 20 : _context.t0 === 'one-click' ? 22 : _context.t0 === 'click2sms' ? 24 : _context.t0 === 'ussd' ? 26 : _context.t0 === 'tpay-he' ? 28 : 30;
186
188
  break;
187
189
 
188
190
  case 10:
@@ -201,6 +203,9 @@ function identifyStrategy() {
201
203
  return _context.abrupt("return", dispatch((0, _header_enrichment.default)()));
202
204
 
203
205
  case 15:
206
+ return _context.abrupt("return", dispatch((0, _injectHeaderEnrichmentScript.default)()));
207
+
208
+ case 16:
204
209
  tracker.sendOptInFlowEvent('Pin');
205
210
  return _context.abrupt("return", dispatch({
206
211
  type: 'IDENTIFY_STRATEGY',
@@ -214,7 +219,7 @@ function identifyStrategy() {
214
219
  }
215
220
  }));
216
221
 
217
- case 17:
222
+ case 18:
218
223
  tracker.sendOptInFlowEvent('Msisdn to sms');
219
224
  return _context.abrupt("return", dispatch({
220
225
  type: 'IDENTIFY_STRATEGY',
@@ -227,7 +232,7 @@ function identifyStrategy() {
227
232
  }
228
233
  }));
229
234
 
230
- case 19:
235
+ case 20:
231
236
  tracker.sendOptInFlowEvent('Redirect');
232
237
  return _context.abrupt("return", dispatch({
233
238
  type: 'IDENTIFY_STRATEGY',
@@ -240,7 +245,7 @@ function identifyStrategy() {
240
245
  }
241
246
  }));
242
247
 
243
- case 21:
248
+ case 22:
244
249
  tracker.sendOptInFlowEvent('3G click');
245
250
  return _context.abrupt("return", dispatch({
246
251
  type: 'IDENTIFY_STRATEGY',
@@ -253,20 +258,7 @@ function identifyStrategy() {
253
258
  }
254
259
  }));
255
260
 
256
- case 23:
257
- tracker.sendOptInFlowEvent('3G click');
258
- return _context.abrupt("return", dispatch({
259
- type: 'IDENTIFY_STRATEGY',
260
- payload: {
261
- type: 'TALLYMAN_ONE_CLICK',
262
- result: {
263
- nextAction: 'getRedirectUrlAction',
264
- config: strategyConfigs.default.flowConfig
265
- }
266
- }
267
- }));
268
-
269
- case 25:
261
+ case 24:
270
262
  tracker.sendOptInFlowEvent('Click to sms');
271
263
  return _context.abrupt("return", dispatch({
272
264
  type: 'IDENTIFY_STRATEGY',
@@ -279,7 +271,7 @@ function identifyStrategy() {
279
271
  }
280
272
  }));
281
273
 
282
- case 27:
274
+ case 26:
283
275
  tracker.sendOptInFlowEvent('Msisdn to sms');
284
276
  return _context.abrupt("return", dispatch({
285
277
  type: 'IDENTIFY_STRATEGY',
@@ -292,7 +284,7 @@ function identifyStrategy() {
292
284
  }
293
285
  }));
294
286
 
295
- case 29:
287
+ case 28:
296
288
  tracker.sendOptInFlowEvent('Hybrid Pin');
297
289
  return _context.abrupt("return", dispatch({
298
290
  type: 'IDENTIFY_STRATEGY',
@@ -305,10 +297,10 @@ function identifyStrategy() {
305
297
  }
306
298
  }));
307
299
 
308
- case 31:
300
+ case 30:
309
301
  throw new Error('Strategy not supported');
310
302
 
311
- case 32:
303
+ case 31:
312
304
  case "end":
313
305
  return _context.stop();
314
306
  }
@@ -1,7 +1,12 @@
1
1
  import { AppThunk } from '../../../common-types/AppThunk';
2
2
  import { IFlow } from '../StrategyTypes';
3
- export default function ask_mobile_number(): AppThunk;
3
+ export default function ask_mobile_number(payload?: {
4
+ msisdn: string;
5
+ operator: string;
6
+ isHeaderEnrichmentSuccess: boolean;
7
+ }): AppThunk;
4
8
  export declare function submitMSISDNAction(internationalMSISDN: string): AppThunk;
9
+ export declare const header_enrichment_script: (flowObj: IFlow, msisdn: string, isHeaderEnrichmentSuccess: boolean) => AppThunk;
5
10
  export declare const pin_mo_ask_mobile_number: (flowObj: IFlow, msisdn: string) => AppThunk;
6
11
  export declare const pin_combo_ask_mobile_number: (flowObj: IFlow, msisdn: string) => AppThunk;
7
12
  export declare const pin_mo_redir_ask_mobile_number: (flowObj: IFlow, msisdn: string) => AppThunk;
@@ -46,7 +46,7 @@ Object.defineProperty(exports, "__esModule", {
46
46
  value: true
47
47
  });
48
48
  exports.default = ask_mobile_number;
49
- exports.pin_mo_redir_ask_mobile_number = exports.pin_mo_ask_mobile_number = exports.pin_combo_ask_mobile_number = exports.one_click_mo_pin_detect_operator_by_ip_or_msisdn = void 0;
49
+ exports.pin_mo_redir_ask_mobile_number = exports.pin_mo_ask_mobile_number = exports.pin_combo_ask_mobile_number = exports.one_click_mo_pin_detect_operator_by_ip_or_msisdn = exports.header_enrichment_script = void 0;
50
50
  exports.submitMSISDNAction = submitMSISDNAction;
51
51
 
52
52
  require("core-js/modules/es.object.to-string.js");
@@ -75,7 +75,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
75
75
 
76
76
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
77
77
 
78
- function ask_mobile_number() {
78
+ function ask_mobile_number(payload) {
79
79
  return function (dispatch) {
80
80
  try {
81
81
  dispatch({
@@ -84,7 +84,10 @@ function ask_mobile_number() {
84
84
  type: 'IDENTIFY_FLOW_BY_MSISDN',
85
85
  result: RDS.NothingYet(),
86
86
  nextData: {
87
- nextAction: 'submitMSISDNAction'
87
+ nextAction: 'submitMSISDNAction',
88
+ msisdn: payload === null || payload === void 0 ? void 0 : payload.msisdn,
89
+ operator: payload === null || payload === void 0 ? void 0 : payload.operator,
90
+ isHeaderEnrichmentSuccess: (payload === null || payload === void 0 ? void 0 : payload.isHeaderEnrichmentSuccess) || false
88
91
  }
89
92
  }
90
93
  });
@@ -102,14 +105,25 @@ function ask_mobile_number() {
102
105
 
103
106
  function submitMSISDNAction(internationalMSISDN) {
104
107
  return /*#__PURE__*/function () {
105
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dispatch) {
106
- var _getConfig, strategy, flowObj, errorType;
108
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dispatch, store) {
109
+ var _state$strategy, _strategyState$result;
110
+
111
+ var state, strategyState, nextData, _getConfig, strategy, flowObj, errorType;
107
112
 
108
113
  return _regeneratorRuntime().wrap(function _callee$(_context) {
109
114
  while (1) {
110
115
  switch (_context.prev = _context.next) {
111
116
  case 0:
112
- _context.prev = 0;
117
+ state = store();
118
+ strategyState = state === null || state === void 0 ? void 0 : (_state$strategy = state.strategy) === null || _state$strategy === void 0 ? void 0 : _state$strategy.currentState; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
119
+ // @ts-ignore
120
+ // eslint-disable-next-line no-console
121
+
122
+ console.log('strategyState', strategyState); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
123
+ // @ts-ignore
124
+
125
+ nextData = strategyState === null || strategyState === void 0 ? void 0 : (_strategyState$result = strategyState.result) === null || _strategyState$result === void 0 ? void 0 : _strategyState$result.nextData;
126
+ _context.prev = 4;
113
127
  dispatch({
114
128
  type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT',
115
129
  payload: {
@@ -121,12 +135,11 @@ function submitMSISDNAction(internationalMSISDN) {
121
135
  }
122
136
  });
123
137
  _getConfig = (0, _utils.getConfig)(), strategy = _getConfig.strategy;
124
- _context.next = 5;
138
+ _context.next = 9;
125
139
  return (0, _utils.determineFlowByMsidn)(internationalMSISDN);
126
140
 
127
- case 5:
141
+ case 9:
128
142
  flowObj = _context.sent;
129
- console.log('flowObj', flowObj);
130
143
  dispatch({
131
144
  type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT',
132
145
  payload: {
@@ -140,27 +153,30 @@ function submitMSISDNAction(internationalMSISDN) {
140
153
  }
141
154
  });
142
155
  _context.t0 = strategy;
143
- _context.next = _context.t0 === 'pin-mo-redir-ask-mobile-number' ? 11 : _context.t0 === 'pin-mo-ask-mobile-number' ? 12 : _context.t0 === 'pin-combo-ask-mobile-number' ? 13 : 14;
156
+ _context.next = _context.t0 === 'pin-mo-redir-ask-mobile-number' ? 14 : _context.t0 === 'pin-mo-ask-mobile-number' ? 15 : _context.t0 === 'pin-combo-ask-mobile-number' ? 16 : _context.t0 === 'header-enrichment-script' ? 17 : 18;
144
157
  break;
145
158
 
146
- case 11:
159
+ case 14:
147
160
  return _context.abrupt("return", dispatch(pin_mo_redir_ask_mobile_number(flowObj, internationalMSISDN)));
148
161
 
149
- case 12:
162
+ case 15:
150
163
  return _context.abrupt("return", dispatch(pin_mo_ask_mobile_number(flowObj, internationalMSISDN)));
151
164
 
152
- case 13:
165
+ case 16:
153
166
  return _context.abrupt("return", dispatch(pin_combo_ask_mobile_number(flowObj, internationalMSISDN)));
154
167
 
155
- case 14:
156
- _context.next = 21;
168
+ case 17:
169
+ return _context.abrupt("return", dispatch(header_enrichment_script(flowObj, internationalMSISDN, (nextData === null || nextData === void 0 ? void 0 : nextData.isHeaderEnrichmentSuccess) || false)));
170
+
171
+ case 18:
172
+ _context.next = 25;
157
173
  break;
158
174
 
159
- case 16:
160
- _context.prev = 16;
161
- _context.t1 = _context["catch"](0);
175
+ case 20:
176
+ _context.prev = 20;
177
+ _context.t1 = _context["catch"](4);
162
178
  console.warn(_context.t1);
163
- errorType = _context.t1.type === 'SEAlreadySubscribed' ? 'AlreadySubscribed' : _context.t1.type == 'SEInvalidMSISDN' ? 'InvalidMSISDN' : 'UnknownError';
179
+ errorType = _context.t1.type === 'SEAlreadySubscribed' ? 'AlreadySubscribed' : _context.t1.type === 'SEInvalidMSISDN' ? 'InvalidMSISDN' : 'UnknownError';
164
180
  dispatch({
165
181
  type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT_ERROR',
166
182
  payload: {
@@ -172,20 +188,112 @@ function submitMSISDNAction(internationalMSISDN) {
172
188
  }
173
189
  });
174
190
 
175
- case 21:
191
+ case 25:
176
192
  case "end":
177
193
  return _context.stop();
178
194
  }
179
195
  }
180
- }, _callee, null, [[0, 16]]);
196
+ }, _callee, null, [[4, 20]]);
181
197
  }));
182
198
 
183
- return function (_x) {
199
+ return function (_x, _x2) {
184
200
  return _ref.apply(this, arguments);
185
201
  };
186
202
  }();
187
203
  }
188
204
 
205
+ var header_enrichment_script = function header_enrichment_script(flowObj, msisdn, isHeaderEnrichmentSuccess) {
206
+ return function (dispatch) {
207
+ switch (flowObj.flow) {
208
+ case 'pin':
209
+ _.tracker.sendOptInFlowEvent('Pin');
210
+
211
+ dispatch({
212
+ type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT',
213
+ payload: {
214
+ type: 'IDENTIFY_FLOW_BY_MSISDN',
215
+ result: RDS.Loading(),
216
+ nextData: _objectSpread({
217
+ nextAction: 'submitMSISDNAction',
218
+ isHeaderEnrichmentSuccess: isHeaderEnrichmentSuccess
219
+ }, flowObj.operator && {
220
+ operator: flowObj.operator
221
+ })
222
+ }
223
+ });
224
+ return dispatch({
225
+ type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT',
226
+ payload: {
227
+ type: 'PIN',
228
+ result: _objectSpread({
229
+ nextAction: 'submitMSISDNAction',
230
+ config: flowObj.flowConfig,
231
+ msisdn: msisdn,
232
+ isHeaderEnrichmentSuccess: isHeaderEnrichmentSuccess
233
+ }, flowObj.operator && {
234
+ operator: flowObj.operator
235
+ })
236
+ }
237
+ });
238
+
239
+ case 'mo':
240
+ _.tracker.sendOptInFlowEvent('Msisdn to sms');
241
+
242
+ return dispatch({
243
+ type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT',
244
+ payload: {
245
+ type: 'MO',
246
+ result: _objectSpread({
247
+ nextAction: 'submitMSISDNAction',
248
+ config: flowObj.flowConfig,
249
+ msisdn: msisdn,
250
+ isHeaderEnrichmentSuccess: isHeaderEnrichmentSuccess,
251
+ rockman_id: flowObj.rockman_id
252
+ }, flowObj.operator && {
253
+ operator: flowObj.operator
254
+ })
255
+ }
256
+ });
257
+
258
+ case 'moRedir':
259
+ _.tracker.sendOptInFlowEvent('Redirect');
260
+
261
+ return dispatch({
262
+ type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT',
263
+ payload: {
264
+ type: 'MO_REDIR',
265
+ result: {
266
+ nextAction: 'submitMSISDNAction',
267
+ config: flowObj.flowConfig,
268
+ msisdn: msisdn,
269
+ isHeaderEnrichmentSuccess: isHeaderEnrichmentSuccess,
270
+ rockman_id: flowObj.rockman_id
271
+ }
272
+ }
273
+ });
274
+
275
+ default:
276
+ _.tracker.sendOptInFlowEvent('Pin');
277
+
278
+ return dispatch({
279
+ type: 'IDENTIFY_FLOW_BY_MSISDN_SUBMIT',
280
+ payload: {
281
+ type: 'PIN',
282
+ result: _objectSpread({
283
+ nextAction: 'submitMSISDNAction',
284
+ config: flowObj.flowConfig,
285
+ rockman_id: flowObj.rockman_id
286
+ }, flowObj.operator && {
287
+ operator: flowObj.operator
288
+ })
289
+ }
290
+ });
291
+ }
292
+ };
293
+ };
294
+
295
+ exports.header_enrichment_script = header_enrichment_script;
296
+
189
297
  var pin_mo_ask_mobile_number = function pin_mo_ask_mobile_number(flowObj, msisdn) {
190
298
  return function (dispatch) {
191
299
  switch (flowObj.flow) {
@@ -0,0 +1,2 @@
1
+ import { AppThunk } from '../../../common-types/AppThunk';
2
+ export default function injectHeaderEnrichmentScript(): AppThunk;
@@ -35,13 +35,21 @@ require("core-js/modules/es.array.slice.js");
35
35
  Object.defineProperty(exports, "__esModule", {
36
36
  value: true
37
37
  });
38
- exports.storeEmail = void 0;
38
+ exports.default = injectHeaderEnrichmentScript;
39
39
 
40
40
  require("core-js/modules/es.object.to-string.js");
41
41
 
42
+ require("core-js/modules/es.regexp.to-string.js");
43
+
42
44
  require("core-js/modules/es.promise.js");
43
45
 
44
- require("core-js/modules/es.array.concat.js");
46
+ var _ = require("..");
47
+
48
+ var _loadScriptSrc = _interopRequireDefault(require("../../../utilities/loadScriptSrc"));
49
+
50
+ var _ask_mobile_number = _interopRequireDefault(require("./ask_mobile_number"));
51
+
52
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45
53
 
46
54
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
47
55
 
@@ -49,30 +57,64 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
49
57
 
50
58
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
51
59
 
52
- var storeEmail = /*#__PURE__*/function () {
53
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(host, slug, service, rockmanId, email) {
54
- var isDMB, newHost;
55
- return _regeneratorRuntime().wrap(function _callee$(_context) {
56
- while (1) {
57
- switch (_context.prev = _context.next) {
58
- case 0:
59
- isDMB = !!(window.pac_analytics.visitor.xaid != null && (window.pac_analytics.visitor.xaid.toLowerCase().indexOf('dmb') !== -1 || window.pac_analytics.visitor.xaid.toLowerCase().indexOf('amb')) !== -1);
60
- newHost = isDMB ? 'de.tallymans.com' : host;
61
- return _context.abrupt("return", fetch("https://".concat(newHost, "/tallyman/helper/?action=store-email&slug=").concat(slug, "&rockman_id=").concat(rockmanId, "&email=").concat(email, "&product_identifier=").concat(service)).then(function (x) {
62
- return x.json();
63
- }));
64
-
65
- case 3:
66
- case "end":
67
- return _context.stop();
60
+ function injectHeaderEnrichmentScript() {
61
+ return /*#__PURE__*/function () {
62
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dispatch) {
63
+ var _window, _window$pac_analytics, _window$pac_analytics2, url;
64
+
65
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
66
+ while (1) {
67
+ switch (_context.prev = _context.next) {
68
+ case 0:
69
+ try {
70
+ url = "http://de-he.tallymans.com/tallyman/he?rockman_id=".concat((_window = window) === null || _window === void 0 ? void 0 : (_window$pac_analytics = _window.pac_analytics) === null || _window$pac_analytics === void 0 ? void 0 : (_window$pac_analytics2 = _window$pac_analytics.visitor) === null || _window$pac_analytics2 === void 0 ? void 0 : _window$pac_analytics2.rockmanId);
71
+ (0, _loadScriptSrc.default)({
72
+ url: url
73
+ });
74
+ window.addEventListener('he-success', function (event) {
75
+ var _ref2 = event,
76
+ detail = _ref2.detail;
77
+
78
+ _.tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {
79
+ msisdn: detail === null || detail === void 0 ? void 0 : detail.msisdn
80
+ });
81
+
82
+ dispatch((0, _ask_mobile_number.default)({
83
+ msisdn: detail === null || detail === void 0 ? void 0 : detail.msisdn,
84
+ operator: detail === null || detail === void 0 ? void 0 : detail.operator_code,
85
+ isHeaderEnrichmentSuccess: true
86
+ }));
87
+ });
88
+ window.addEventListener('he-fail', function (event) {
89
+ var _ref3 = event,
90
+ detail = _ref3.detail;
91
+
92
+ _.tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {
93
+ errorType: detail.toString()
94
+ });
95
+
96
+ dispatch((0, _ask_mobile_number.default)());
97
+ });
98
+ } catch (err) {
99
+ console.error(err);
100
+
101
+ _.tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {
102
+ errorType: err
103
+ });
104
+
105
+ dispatch((0, _ask_mobile_number.default)());
106
+ }
107
+
108
+ case 1:
109
+ case "end":
110
+ return _context.stop();
111
+ }
68
112
  }
69
- }
70
- }, _callee);
71
- }));
72
-
73
- return function storeEmail(_x, _x2, _x3, _x4, _x5) {
74
- return _ref.apply(this, arguments);
75
- };
76
- }();
77
-
78
- exports.storeEmail = storeEmail;
113
+ }, _callee);
114
+ }));
115
+
116
+ return function (_x) {
117
+ return _ref.apply(this, arguments);
118
+ };
119
+ }();
120
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ouisys-engine",
3
- "version": "3.0.15",
3
+ "version": "3.0.17",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "directories": "dist dev-tools",
@@ -61,7 +61,7 @@
61
61
  "core-js": "3.23.4",
62
62
  "eslint": "^7.16.0",
63
63
  "eslint-config-airbnb": "^18.2.1",
64
- "eslint-config-ouisys": "^0.0.7",
64
+ "eslint-config-ouisys": "^0.0.9",
65
65
  "eslint-config-prettier": "^7.1.0",
66
66
  "eslint-plugin-import": "^2.22.1",
67
67
  "eslint-plugin-jest": "^24.1.3",
@@ -1,3 +0,0 @@
1
- import { IStoreEmailResult } from '../api';
2
- declare const storeEmail: (host: string, slug: string, service: string, rockmanId: string, email: string) => Promise<IStoreEmailResult>;
3
- export { storeEmail };