ouisys-engine 3.0.2 → 3.0.6

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 (198) hide show
  1. package/.babelrc +4 -8
  2. package/.eslintrc.js +1 -1
  3. package/.nvmrc +1 -1
  4. package/.prettierignore +2 -1
  5. package/README.md +2 -4
  6. package/dist/api/index.d.ts +5 -5
  7. package/dist/api/index.js +76 -76
  8. package/dist/common-types/AppThunk.d.ts +11 -12
  9. package/dist/common-types/IOptInFlowName.d.ts +1 -1
  10. package/dist/common-types/ITracker.js +1 -2
  11. package/dist/common-types/RemoteDataState.d.ts +4 -4
  12. package/dist/common-types/RemoteDataState.js +17 -17
  13. package/dist/flows/click2smsFlow.d.ts +2 -2
  14. package/dist/flows/moFlow.d.ts +2 -2
  15. package/dist/flows/moRedirFlow.d.ts +2 -2
  16. package/dist/flows/oneClickFlow.d.ts +2 -2
  17. package/dist/flows/pinFlow.d.ts +2 -2
  18. package/dist/flows/pinFlow.js +2 -0
  19. package/dist/flows/strategy.d.ts +8 -8
  20. package/dist/flows/ussdFlow.d.ts +2 -2
  21. package/dist/ips/tryGetIPRangeName.d.ts +1 -1
  22. package/dist/ips/tryGetIPRangeName.js +7 -5
  23. package/dist/jest.config.js +1 -1
  24. package/dist/pacman/index.d.ts +2 -2
  25. package/dist/pacman/index.js +41 -41
  26. package/dist/pacman/queryString.js +11 -9
  27. package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +19 -19
  28. package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +1 -1
  29. package/dist/reducers/click2smsFlow/index.d.ts +2 -2
  30. package/dist/reducers/click2smsFlow/index.js +24 -24
  31. package/dist/reducers/click2smsFlow/utils.d.ts +1 -1
  32. package/dist/reducers/click2smsFlow/utils.js +30 -30
  33. package/dist/reducers/moFlow/IMoConstants.d.ts +1 -1
  34. package/dist/reducers/moFlow/MoTypes.d.ts +13 -13
  35. package/dist/reducers/moFlow/index.d.ts +3 -3
  36. package/dist/reducers/moFlow/index.js +27 -27
  37. package/dist/reducers/moFlow/utils.d.ts +1 -2
  38. package/dist/reducers/moFlow/utils.js +28 -26
  39. package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +1 -1
  40. package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +13 -13
  41. package/dist/reducers/moRedirFlow/index.d.ts +3 -3
  42. package/dist/reducers/moRedirFlow/index.js +27 -27
  43. package/dist/reducers/moRedirFlow/utils.d.ts +1 -1
  44. package/dist/reducers/moRedirFlow/utils.js +17 -17
  45. package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +1 -1
  46. package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +10 -10
  47. package/dist/reducers/oneClickFlow/index.d.ts +3 -3
  48. package/dist/reducers/oneClickFlow/index.js +75 -68
  49. package/dist/reducers/oneClickFlow/utils.d.ts +2 -2
  50. package/dist/reducers/oneClickFlow/utils.js +70 -69
  51. package/dist/reducers/pinFlow/IPinConstants.d.ts +1 -1
  52. package/dist/reducers/pinFlow/PinTypes.d.ts +23 -23
  53. package/dist/reducers/pinFlow/index.d.ts +3 -3
  54. package/dist/reducers/pinFlow/index.js +76 -76
  55. package/dist/reducers/pinFlow/utils.d.ts +1 -1
  56. package/dist/reducers/pinFlow/utils.js +61 -65
  57. package/dist/reducers/strategy/IStategyActionContants.d.ts +1 -1
  58. package/dist/reducers/strategy/StrategyTypes.d.ts +56 -56
  59. package/dist/reducers/strategy/index.d.ts +2 -2
  60. package/dist/reducers/strategy/index.js +99 -99
  61. package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +3 -2
  62. package/dist/reducers/strategy/strategies/ask_mobile_number.js +132 -74
  63. package/dist/reducers/strategy/strategies/ask_operator.d.ts +2 -2
  64. package/dist/reducers/strategy/strategies/ask_operator.js +64 -68
  65. package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +2 -2
  66. package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +97 -97
  67. package/dist/reducers/strategy/strategies/header_enrichment.d.ts +2 -2
  68. package/dist/reducers/strategy/strategies/header_enrichment.js +116 -120
  69. package/dist/reducers/strategy/utils.d.ts +3 -3
  70. package/dist/reducers/strategy/utils.js +115 -111
  71. package/dist/reducers/ussdFlow/IUssdConstants.d.ts +1 -1
  72. package/dist/reducers/ussdFlow/UssdTypes.d.ts +13 -13
  73. package/dist/reducers/ussdFlow/index.d.ts +3 -3
  74. package/dist/reducers/ussdFlow/index.js +27 -27
  75. package/dist/reducers/ussdFlow/utils.d.ts +1 -2
  76. package/dist/reducers/ussdFlow/utils.js +19 -17
  77. package/dist/store/index.d.ts +8 -8
  78. package/dist/store/index.js +87 -83
  79. package/dist/store/reducers.d.ts +7 -7
  80. package/dist/store/reducers.js +4 -4
  81. package/dist/utilities/handleSubmitNumber.d.ts +7 -3
  82. package/dist/utilities/handleSubmitNumber.js +15 -18
  83. package/dist/utilities/index.d.ts +1 -1
  84. package/dist/utilities/index.js +13 -11
  85. package/dist/utilities/loadScriptInnerHtml.js +0 -1
  86. package/index.html +21 -28
  87. package/package.json +23 -15
  88. package/setupJest.js +1 -1
  89. package/tsconfig.json +2 -2
  90. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  91. package/.idea/modules.xml +0 -8
  92. package/.idea/ouisys-engine.iml +0 -12
  93. package/.idea/vcs.xml +0 -6
  94. package/.vscode/settings.json +0 -6
  95. package/dist/api/click2sms.js +0 -357
  96. package/dist/api/mo.js +0 -274
  97. package/dist/api/moRedir.js +0 -186
  98. package/dist/api/oneClick.js +0 -366
  99. package/dist/api/pin.js +0 -493
  100. package/dist/api/strategies.js +0 -704
  101. package/dist/api/ussd.js +0 -1
  102. package/dist/app/store.js +0 -35
  103. package/dist/features/strategies/categories/askMobileNumber.js +0 -395
  104. package/dist/features/strategies/categories/askOperator.js +0 -311
  105. package/dist/features/strategies/categories/detectOperatorByIp.js +0 -606
  106. package/dist/features/strategies/categories/headerEnrichment.js +0 -670
  107. package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +0 -12
  108. package/dist/features/strategies/categories/typings/identifySliceTypes.js +0 -22
  109. package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +0 -22
  110. package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +0 -21
  111. package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +0 -13
  112. package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +0 -13
  113. package/dist/features/strategies/click2smsFlowSlice.js +0 -172
  114. package/dist/features/strategies/identifySlice.js +0 -455
  115. package/dist/features/strategies/moFlowSlice.js +0 -196
  116. package/dist/features/strategies/moRedirFlowSlice.js +0 -190
  117. package/dist/features/strategies/oneClickFlowSlice.js +0 -277
  118. package/dist/features/strategies/pinFlowSlice.js +0 -313
  119. package/dist/features/strategies/ussdFlowSlice.js +0 -1
  120. package/dist/flows/tpayHeFlow.d.ts +0 -7
  121. package/dist/flows/tpayHeFlow.js +0 -23
  122. package/dist/mockServer/browser.js +0 -48
  123. package/dist/mockServer/handlers.js +0 -22
  124. package/dist/mockServer/server.js +0 -48
  125. package/dist/reducers/tpayHeFlow/ITpayHeConstants.d.ts +0 -2
  126. package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
  127. package/dist/reducers/tpayHeFlow/TpayHeTypes.d.ts +0 -114
  128. package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
  129. package/dist/reducers/tpayHeFlow/index.d.ts +0 -7
  130. package/dist/reducers/tpayHeFlow/index.js +0 -331
  131. package/dist/reducers/tpayHeFlow/utils.d.ts +0 -20
  132. package/dist/reducers/tpayHeFlow/utils.js +0 -510
  133. package/dist/test/setup.js +0 -24
  134. package/dist/test/test-utils.js +0 -51
  135. package/mockData/config.json +0 -28
  136. package/prettier.config.js +0 -7
  137. package/src/@types/react-tracker.d.ts +0 -16
  138. package/src/@types/redux-cli-logger.d.ts +0 -1
  139. package/src/@types/tiny-async-pool.d.ts +0 -3
  140. package/src/@types/window.d.ts +0 -74
  141. package/src/api/index.ts +0 -225
  142. package/src/common-types/AppThunk.ts +0 -19
  143. package/src/common-types/Either.ts +0 -3
  144. package/src/common-types/IError.ts +0 -5
  145. package/src/common-types/IOptInFlowName.ts +0 -1
  146. package/src/common-types/ITracker.ts +0 -10
  147. package/src/common-types/IVisitor.ts +0 -16
  148. package/src/common-types/RemoteDataState.ts +0 -88
  149. package/src/flows/click2smsFlow.ts +0 -18
  150. package/src/flows/moFlow.ts +0 -20
  151. package/src/flows/moRedirFlow.ts +0 -20
  152. package/src/flows/oneClickFlow.ts +0 -20
  153. package/src/flows/pinFlow.ts +0 -25
  154. package/src/flows/strategy.ts +0 -51
  155. package/src/flows/ussdFlow.ts +0 -20
  156. package/src/index.ts +0 -3
  157. package/src/ips/tryGetIPRangeName.ts +0 -22
  158. package/src/jest.config.js +0 -194
  159. package/src/pacman/index.ts +0 -71
  160. package/src/pacman/queryString.ts +0 -24
  161. package/src/reducers/click2smsFlow/Click2smsTypes.ts +0 -93
  162. package/src/reducers/click2smsFlow/IClick2smsConstants.ts +0 -4
  163. package/src/reducers/click2smsFlow/index.ts +0 -105
  164. package/src/reducers/click2smsFlow/utils.ts +0 -126
  165. package/src/reducers/moFlow/IMoConstants.ts +0 -7
  166. package/src/reducers/moFlow/MoTypes.ts +0 -125
  167. package/src/reducers/moFlow/index.ts +0 -150
  168. package/src/reducers/moFlow/utils.ts +0 -135
  169. package/src/reducers/moRedirFlow/IMoRedirConstants.ts +0 -7
  170. package/src/reducers/moRedirFlow/MoRedirTypes.ts +0 -99
  171. package/src/reducers/moRedirFlow/index.ts +0 -137
  172. package/src/reducers/moRedirFlow/utils.ts +0 -78
  173. package/src/reducers/oneClickFlow/IOneClickConstants.ts +0 -3
  174. package/src/reducers/oneClickFlow/OneClickTypes.ts +0 -108
  175. package/src/reducers/oneClickFlow/index.ts +0 -268
  176. package/src/reducers/oneClickFlow/utils.ts +0 -217
  177. package/src/reducers/pinFlow/IPinConstants.ts +0 -9
  178. package/src/reducers/pinFlow/PinTypes.ts +0 -190
  179. package/src/reducers/pinFlow/index.ts +0 -331
  180. package/src/reducers/pinFlow/utils.ts +0 -232
  181. package/src/reducers/strategy/IStategyActionContants.ts +0 -17
  182. package/src/reducers/strategy/StrategyTypes.ts +0 -375
  183. package/src/reducers/strategy/index.ts +0 -321
  184. package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -316
  185. package/src/reducers/strategy/strategies/ask_operator.ts +0 -195
  186. package/src/reducers/strategy/strategies/detect_operator_by_ip.ts +0 -414
  187. package/src/reducers/strategy/strategies/header_enrichment.ts +0 -489
  188. package/src/reducers/strategy/utils.ts +0 -357
  189. package/src/reducers/ussdFlow/IUssdConstants.ts +0 -7
  190. package/src/reducers/ussdFlow/UssdTypes.ts +0 -112
  191. package/src/reducers/ussdFlow/index.ts +0 -146
  192. package/src/reducers/ussdFlow/utils.ts +0 -88
  193. package/src/store/index.ts +0 -150
  194. package/src/store/reducers.ts +0 -37
  195. package/src/utilities/handleSubmitNumber.ts +0 -65
  196. package/src/utilities/index.ts +0 -114
  197. package/src/utilities/loadScriptInnerHtml.ts +0 -14
  198. package/src/utilities/loadScriptSrc.ts +0 -26
@@ -1,5 +1,5 @@
1
- import * as RDS from "../common-types/RemoteDataState";
2
- import { IGETREDIRECTURLFailure, IGETREDIRECTURLSuccess, IOneClickCurrentState, SubscribeFailure, SubscribeSuccess } from "../reducers/oneClickFlow/OneClickTypes";
1
+ import * as RDS from '../common-types/RemoteDataState';
2
+ import { IGETREDIRECTURLFailure, IGETREDIRECTURLSuccess, IOneClickCurrentState, SubscribeFailure, SubscribeSuccess } from '../reducers/oneClickFlow/OneClickTypes';
3
3
  declare function oneClickFlowMatch<R>({ getRedirectUrl, subscribe }: {
4
4
  getRedirectUrl: (rds: RDS.RemoteDataState<IGETREDIRECTURLFailure, IGETREDIRECTURLSuccess>) => R;
5
5
  subscribe?: (rds: RDS.RemoteDataState<SubscribeFailure, SubscribeSuccess>) => R;
@@ -1,5 +1,5 @@
1
- import * as RDS from "../common-types/RemoteDataState";
2
- import { MSISDNEntryFailure, MSISDNEntrySuccess, PINEntryFailure, PINEntrySuccess, IPinFlowCurrentState, IMsisdnSumbitNextData } from "../reducers/pinFlow/PinTypes";
1
+ import * as RDS from '../common-types/RemoteDataState';
2
+ import { IMsisdnSumbitNextData, IPinFlowCurrentState, MSISDNEntryFailure, MSISDNEntrySuccess, PINEntryFailure, PINEntrySuccess } from '../reducers/pinFlow/PinTypes';
3
3
  declare function pinFlowMatch<R>({ msisdnEntry, pinEntry }: {
4
4
  msisdnEntry: (rds: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>) => R;
5
5
  pinEntry: (rds: RDS.RemoteDataState<PINEntryFailure, PINEntrySuccess>, nextData: IMsisdnSumbitNextData) => R;
@@ -8,7 +8,9 @@ exports.default = void 0;
8
8
  function pinFlowMatch(_ref) {
9
9
  var msisdnEntry = _ref.msisdnEntry,
10
10
  pinEntry = _ref.pinEntry;
11
+ // eslint-disable-next-line consistent-return
11
12
  return function (state) {
13
+ // eslint-disable-next-line default-case
12
14
  switch (state.type) {
13
15
  case 'MSISDNEntry':
14
16
  return msisdnEntry(state.result);
@@ -1,13 +1,13 @@
1
- import * as RDS from "../common-types/RemoteDataState";
2
- import { OPERATORSelectFlowIdentifySuccess, IStrategyCurrentState, IIdenyifyFlowByMsisdnSumbitNextData, IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess, IdentifyFlowOptionsResult } from '../reducers/strategy/StrategyTypes';
1
+ import * as RDS from '../common-types/RemoteDataState';
2
+ import { IdentifyFlowOptionsResult, IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess, IIdenyifyFlowByMsisdnSumbitNextData, IStrategyCurrentState, OPERATORSelectFlowIdentifySuccess } from '../reducers/strategy/StrategyTypes';
3
3
  declare function strategy<R>({ identifyFlowByOperatorSelect, identifyFlowByMsisdn, pinFlow, moFlow, moRedirFlow, oneClickFlow, click2smsFlow, ussdFlow }: {
4
4
  identifyFlowByOperatorSelect: (data: OPERATORSelectFlowIdentifySuccess) => R;
5
5
  identifyFlowByMsisdn: (rds: RDS.RemoteDataState<IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess>, nextData: IIdenyifyFlowByMsisdnSumbitNextData) => R;
6
- pinFlow: (data: IdentifyFlowOptionsResult<"submitMSISDNAction">) => R;
7
- moFlow: (data: IdentifyFlowOptionsResult<"submitMSISDNAction">) => R;
8
- moRedirFlow: (data: IdentifyFlowOptionsResult<"submitMSISDNAction">) => R;
9
- oneClickFlow: (data: IdentifyFlowOptionsResult<"getRedirectUrlAction">) => R;
10
- click2smsFlow: (data: IdentifyFlowOptionsResult<"loadOc2sms">) => R;
11
- ussdFlow: (data: IdentifyFlowOptionsResult<"submitMSISDNAction">) => R;
6
+ pinFlow: (data: IdentifyFlowOptionsResult<'submitMSISDNAction'>) => R;
7
+ moFlow: (data: IdentifyFlowOptionsResult<'submitMSISDNAction'>) => R;
8
+ moRedirFlow: (data: IdentifyFlowOptionsResult<'submitMSISDNAction'>) => R;
9
+ oneClickFlow: (data: IdentifyFlowOptionsResult<'getRedirectUrlAction'>) => R;
10
+ click2smsFlow: (data: IdentifyFlowOptionsResult<'loadOc2sms'>) => R;
11
+ ussdFlow: (data: IdentifyFlowOptionsResult<'submitMSISDNAction'>) => R;
12
12
  }): (state: IStrategyCurrentState) => R;
13
13
  export default strategy;
@@ -1,5 +1,5 @@
1
- import * as RDS from "../common-types/RemoteDataState";
2
- import { IUssdFlowCurrentState, MSISDNEntryFailure, MSISDNEntrySuccess } from "../reducers/ussdFlow/UssdTypes";
1
+ import * as RDS from '../common-types/RemoteDataState';
2
+ import { IUssdFlowCurrentState, MSISDNEntryFailure, MSISDNEntrySuccess } from '../reducers/ussdFlow/UssdTypes';
3
3
  declare function ussdFlowMatch<R>({ msisdnEntry }: {
4
4
  msisdnEntry: (rds: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>) => R;
5
5
  }): (state: IUssdFlowCurrentState) => R;
@@ -1,2 +1,2 @@
1
- import IVisitor from "../common-types/IVisitor";
1
+ import IVisitor from '../common-types/IVisitor';
2
2
  export default function tryGetIPRangeName(visitor: IVisitor): Promise<string>;
@@ -41,6 +41,8 @@ require("core-js/modules/es.object.to-string.js");
41
41
 
42
42
  require("core-js/modules/es.promise.js");
43
43
 
44
+ require("core-js/modules/es.array.concat.js");
45
+
44
46
  var _queryString = _interopRequireDefault(require("../pacman/queryString"));
45
47
 
46
48
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -62,10 +64,10 @@ function _tryGetIPRangeName() {
62
64
  while (1) {
63
65
  switch (_context.prev = _context.next) {
64
66
  case 0:
65
- mockip = (0, _queryString.default)(window.location.href, "mock-ip") || process.env.mock_ip;
66
- console.log("mockip", mockip);
67
+ mockip = (0, _queryString.default)(window.location.href, 'mock-ip') || process.env.mock_ip;
68
+ console.log('mockip', mockip);
67
69
 
68
- if (!(!visitor.ip && typeof window != "undefined")) {
70
+ if (!(!visitor.ip && typeof window !== 'undefined')) {
69
71
  _context.next = 18;
70
72
  break;
71
73
  }
@@ -73,7 +75,7 @@ function _tryGetIPRangeName() {
73
75
  _context.prev = 3;
74
76
  host = window.location.host;
75
77
  _context.next = 7;
76
- return fetch("https://".concat(host, "/api/v1/ip") + (!!mockip ? "?mock-ip=".concat(mockip) : "")).then(function (x) {
78
+ return fetch("https://".concat(host, "/api/v1/ip").concat(mockip ? "?mock-ip=".concat(mockip) : '')).then(function (x) {
77
79
  return x.json();
78
80
  });
79
81
 
@@ -87,7 +89,7 @@ function _tryGetIPRangeName() {
87
89
  case 13:
88
90
  _context.prev = 13;
89
91
  _context.t0 = _context["catch"](3);
90
- console.warn("IP Lookup failed", _context.t0);
92
+ console.warn('IP Lookup failed', _context.t0);
91
93
 
92
94
  case 16:
93
95
  _context.next = 19;
@@ -12,7 +12,7 @@ module.exports = {
12
12
  // cacheDirectory: "/private/var/folders/wr/8ghl3gfx0cldjmd7jhzs8gt80000gn/T/jest_dx",
13
13
 
14
14
  // Automatically clear mock calls and instances between every test
15
- clearMocks: true
15
+ clearMocks: true,
16
16
 
17
17
  // Indicates whether the coverage information should be collected while executing the test
18
18
  // collectCoverage: false,
@@ -1,5 +1,5 @@
1
- import queryString from "./queryString";
2
- import { ITrackerFlowEvents } from "pacman-client/.build-lib/Pacman/types";
1
+ import { ITrackerFlowEvents } from 'pacman-client/.build-lib/Pacman/types';
2
+ import queryString from './queryString';
3
3
  export { queryString };
4
4
  export type { ITrackerFlowEvents as ITracker };
5
5
  declare const _default: (window: Window, country?: string, page?: string) => ITrackerFlowEvents;
@@ -31,11 +31,11 @@ require("core-js/modules/es.string.search.js");
31
31
 
32
32
  require("core-js/modules/es.string.replace.js");
33
33
 
34
- var _queryString2 = _interopRequireDefault(require("./queryString"));
34
+ var _pacmanClient = _interopRequireDefault(require("pacman-client"));
35
35
 
36
36
  var _v = _interopRequireDefault(require("uuid/v1"));
37
37
 
38
- var _pacmanClient = _interopRequireDefault(require("pacman-client"));
38
+ var _queryString2 = _interopRequireDefault(require("./queryString"));
39
39
 
40
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
41
 
@@ -64,46 +64,46 @@ var _default = function _default(window, country, page) {
64
64
  return void 6;
65
65
  }
66
66
  };
67
- } else {
68
- var url = !!window.pac_analytics ? window.pac_analytics.url : (0, _queryString2.default)(window.location.search, "pacman-server") || "/analytics";
69
-
70
- if (!window.pac_analytics) {
71
- var rockmanId = (0, _v.default)().replace(/-/g, "");
72
- var campaignId = parseInt((0, _queryString2.default)(window.location.search, "cid")) || 2;
73
- window.pac_analytics = {
74
- visitor: {
75
- rockmanId: rockmanId,
76
- impressionNumber: 1,
77
- //TODO: get impressionNumber from localStorage
78
- country: country,
79
- page: page,
80
- xaid: (0, _queryString2.default)(window.location.search, "xaid"),
81
- cid: campaignId,
82
- offer: parseInt((0, _queryString2.default)(window.location.search, "offer")) || 1 // default to 1 offer id
83
-
84
- },
85
- startTime: new Date().valueOf(),
86
- queryString: function queryString(key) {
87
- return (0, _queryString2.default)(window.location.search, key);
88
- },
89
- url: url,
90
- userId: rockmanId,
91
- encCampaignId: (0, _queryString2.default)(window.location.search, "xcid"),
92
- originalUrl: document.location.href
93
- };
94
- }
95
-
96
- var pacmanClient = (0, _pacmanClient.default)({
97
- rockmanId: window.pac_analytics.visitor.rockmanId,
98
- serverUrl: process.env.pacman_server,
99
- impressionNumber: 1,
100
- signalInterval: 1000 // in milliseconds
101
-
102
- });
103
- return _objectSpread({
104
- sendOptInFlowEvent: pacmanClient.sendOptInFlowEvent
105
- }, pacmanClient.trackerFlowEvents);
106
67
  }
68
+
69
+ var url = window.pac_analytics ? window.pac_analytics.url : (0, _queryString2.default)(window.location.search, 'pacman-server') || '/analytics';
70
+
71
+ if (!window.pac_analytics) {
72
+ var rockmanId = (0, _v.default)().replace(/-/g, '');
73
+ var campaignId = parseInt((0, _queryString2.default)(window.location.search, 'cid')) || 2;
74
+ window.pac_analytics = {
75
+ visitor: {
76
+ rockmanId: rockmanId,
77
+ impressionNumber: 1,
78
+ // TODO: get impressionNumber from localStorage
79
+ country: country,
80
+ page: page,
81
+ xaid: (0, _queryString2.default)(window.location.search, 'xaid'),
82
+ cid: campaignId,
83
+ offer: parseInt((0, _queryString2.default)(window.location.search, 'offer')) || 1 // default to 1 offer id
84
+
85
+ },
86
+ startTime: new Date().valueOf(),
87
+ queryString: function queryString(key) {
88
+ return (0, _queryString2.default)(window.location.search, key);
89
+ },
90
+ url: url,
91
+ userId: rockmanId,
92
+ encCampaignId: (0, _queryString2.default)(window.location.search, 'xcid'),
93
+ originalUrl: document.location.href
94
+ };
95
+ }
96
+
97
+ var pacmanClient = (0, _pacmanClient.default)({
98
+ rockmanId: window.pac_analytics.visitor.rockmanId,
99
+ serverUrl: process.env.pacman_server,
100
+ impressionNumber: 1,
101
+ signalInterval: 1000 // in milliseconds
102
+
103
+ });
104
+ return _objectSpread({
105
+ sendOptInFlowEvent: pacmanClient.sendOptInFlowEvent
106
+ }, pacmanClient.trackerFlowEvents);
107
107
  };
108
108
 
109
109
  exports.default = _default;
@@ -18,13 +18,15 @@ require("core-js/modules/es.regexp.to-string.js");
18
18
 
19
19
  require("core-js/modules/es.string.match.js");
20
20
 
21
+ require("core-js/modules/es.array.concat.js");
22
+
21
23
  var _default = function _default(url, paramName) {
22
- var name = paramName.replace(/[\[\]]/g, "\\$&");
23
- var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
24
- results = regex.exec(url);
24
+ var name = paramName.replace(/[\[\]]/g, '\\$&');
25
+ var regex = new RegExp("[?&]".concat(name, "(=([^&#]*)|&|#|$)"), 'i');
26
+ var results = regex.exec(url);
25
27
  if (!results) return null;
26
- if (!results[2]) return "";
27
- return decodeURIComponent(results[2].replace(/\+/g, " "));
28
+ if (!results[2]) return '';
29
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
28
30
  };
29
31
 
30
32
  exports.default = _default;
@@ -34,13 +36,13 @@ function updateUrlParameter(uri, key, value) {
34
36
  var i = uri.indexOf('#');
35
37
  var hash = i === -1 ? '' : uri.substr(i);
36
38
  uri = i === -1 ? uri : uri.substr(0, i);
37
- var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
38
- var separator = uri.indexOf('?') !== -1 ? "&" : "?";
39
+ var re = new RegExp("([?&])".concat(key, "=.*?(&|$)"), 'i');
40
+ var separator = uri.indexOf('?') !== -1 ? '&' : '?';
39
41
 
40
42
  if (uri.match(re)) {
41
- uri = uri.replace(re, '$1' + key + "=" + value + '$2');
43
+ uri = uri.replace(re, "$1".concat(key, "=").concat(value, "$2"));
42
44
  } else {
43
- uri = uri + separator + key + "=" + value;
45
+ uri = "".concat(uri + separator + key, "=").concat(value);
44
46
  }
45
47
 
46
48
  return uri + hash; // finally append the hash as well
@@ -1,14 +1,14 @@
1
- import * as RDS from "../../common-types/RemoteDataState";
2
- import { AppThunk } from "../../common-types/AppThunk";
1
+ import { AppThunk } from '../../common-types/AppThunk';
2
+ import * as RDS from '../../common-types/RemoteDataState';
3
3
  export declare type IWithMultiKeywordShortcode = IKeywordShortcode & {
4
4
  type?: string;
5
5
  data?: Array<IKeywordShortcode>;
6
6
  };
7
7
  export declare type IClick2smsFlowCurrentState = {
8
- type: "LOAD_OC2SMS";
8
+ type: 'LOAD_OC2SMS';
9
9
  result: RDS.RemoteDataState<string, IWithMultiKeywordShortcode>;
10
10
  };
11
- export declare type MSISDNEntryErrorTypes = "AlreadySubscribed" | "UnknownError" | "InvalidMSISDN" | "UnexpectedState";
11
+ export declare type MSISDNEntryErrorTypes = 'AlreadySubscribed' | 'UnknownError' | 'InvalidMSISDN' | 'UnexpectedState';
12
12
  export declare type ILOADOC2SMSFailure = {
13
13
  errorType: MSISDNEntryErrorTypes;
14
14
  error: any;
@@ -16,7 +16,7 @@ export declare type ILOADOC2SMSFailure = {
16
16
  };
17
17
  export declare type ILOADOC2SMSSuccess = IKeywordShortcode;
18
18
  export declare type ILoadOc2click2smsPayload = {
19
- type: "LOAD_OC2SMS";
19
+ type: 'LOAD_OC2SMS';
20
20
  payload: RDS.RemoteDataState<string, IWithMultiKeywordShortcode>;
21
21
  };
22
22
  export interface IClick2smsFlowReducerState {
@@ -34,18 +34,18 @@ declare type Config = {
34
34
  automaticallySubmitAllOperators?: boolean;
35
35
  operators?: string[];
36
36
  };
37
- export declare type IConfig = {
38
- tag: "tallyman";
39
- } & Config | {
40
- tag: "keywordAndShortCode";
41
- } & IKeywordShortcode & Config | {
42
- tag: "keyword";
43
- } & Config;
37
+ export declare type IConfig = ({
38
+ tag: 'tallyman';
39
+ } & Config) | ({
40
+ tag: 'keywordAndShortCode';
41
+ } & IKeywordShortcode & Config) | ({
42
+ tag: 'keyword';
43
+ } & Config);
44
44
  export declare type SingleSubmissionResult = IKeywordShortcode & {
45
- type: "SingleSubmissionResult";
45
+ type: 'SingleSubmissionResult';
46
46
  };
47
47
  export declare type MultiOperatorSubmissionResult = {
48
- type: "MultiOperatorSubmissionResult";
48
+ type: 'MultiOperatorSubmissionResult';
49
49
  data: Array<IKeywordShortcode>;
50
50
  };
51
51
  export declare type ICheckSubscriptionResult = {
@@ -59,14 +59,14 @@ export declare type ICheckSubscriptionResult = {
59
59
  rockman_id: string;
60
60
  };
61
61
  export declare type IClick2SmsActions = {
62
- type: "LOAD_OC2SMS";
62
+ type: 'LOAD_OC2SMS';
63
63
  payload: ILoadOc2click2smsPayload;
64
64
  };
65
65
  export declare type IFetchResult = {
66
- "success": boolean;
67
- "uid": string;
68
- "shortcode": string;
69
- "keyword": string;
66
+ success: boolean;
67
+ uid: string;
68
+ shortcode: string;
69
+ keyword: string;
70
70
  displayKeyword: string;
71
71
  message?: string;
72
72
  };
@@ -1,2 +1,2 @@
1
- declare type IClick2smsConstants = "LOAD_OC2SMS";
1
+ declare type IClick2smsConstants = 'LOAD_OC2SMS';
2
2
  export default IClick2smsConstants;
@@ -1,5 +1,5 @@
1
- import { IClick2smsFlowReducerState, IClick2SmsFlowActionMaps, IClick2SmsActions } from "./Click2smsTypes";
2
- import { AppThunk } from "../../common-types/AppThunk";
1
+ import { AppThunk } from '../../common-types/AppThunk';
2
+ import { IClick2SmsActions, IClick2SmsFlowActionMaps, IClick2smsFlowReducerState } from './Click2smsTypes';
3
3
  export declare function loadOc2sms(): AppThunk;
4
4
  export declare const Click2smsFlowActionMaps: IClick2SmsFlowActionMaps;
5
5
  export default function Click2smsFlowReducer(state: IClick2smsFlowReducerState, action: IClick2SmsActions): IClick2smsFlowReducerState;
@@ -79,7 +79,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
79
79
 
80
80
  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); }); }; }
81
81
 
82
- //ACTION CREATORS
82
+ // ACTION CREATORS
83
83
  function loadOc2sms() {
84
84
  return /*#__PURE__*/function () {
85
85
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dispatch, store) {
@@ -90,7 +90,7 @@ function loadOc2sms() {
90
90
  case 0:
91
91
  currentState = store().strategy.currentState;
92
92
 
93
- if (!(currentState.type === "CLICK2SMS")) {
93
+ if (!(currentState.type === 'CLICK2SMS')) {
94
94
  _context.next = 6;
95
95
  break;
96
96
  }
@@ -99,38 +99,38 @@ function loadOc2sms() {
99
99
 
100
100
  try {
101
101
  dispatch({
102
- type: "LOAD_OC2SMS",
102
+ type: 'LOAD_OC2SMS',
103
103
  payload: {
104
- type: "LOAD_OC2SMS",
104
+ type: 'LOAD_OC2SMS',
105
105
  result: RDS.Loading()
106
106
  }
107
- }); //@ts-ignore
107
+ }); // @ts-ignore
108
108
 
109
- if (!!maybeConfig && maybeConfig.tag == "keywordAndShortCode") {
109
+ if (!!maybeConfig && maybeConfig.tag == 'keywordAndShortCode') {
110
110
  dispatch({
111
- type: "LOAD_OC2SMS",
111
+ type: 'LOAD_OC2SMS',
112
112
  payload: {
113
- type: "LOAD_OC2SMS",
113
+ type: 'LOAD_OC2SMS',
114
114
  result: RDS.Success(_objectSpread({
115
- type: "SingleSubmissionResult"
115
+ type: 'SingleSubmissionResult'
116
116
  }, maybeConfig))
117
117
  }
118
- }); //@ts-ignore
119
- } else if (!!maybeConfig && maybeConfig.tag != "keyword" || !maybeConfig) {
120
- //@ts-ignore
118
+ }); // @ts-ignore
119
+ } else if (!!maybeConfig && maybeConfig.tag != 'keyword' || !maybeConfig) {
120
+ // @ts-ignore
121
121
  (0, _utils.default)(window, maybeConfig).then(function (x) {
122
122
  return dispatch({
123
- type: "LOAD_OC2SMS",
123
+ type: 'LOAD_OC2SMS',
124
124
  payload: {
125
- type: "LOAD_OC2SMS",
125
+ type: 'LOAD_OC2SMS',
126
126
  result: RDS.Success(x)
127
127
  }
128
128
  });
129
129
  }).catch(function (e) {
130
130
  return dispatch({
131
- type: "LOAD_OC2SMS",
131
+ type: 'LOAD_OC2SMS',
132
132
  payload: {
133
- type: "LOAD_OC2SMS",
133
+ type: 'LOAD_OC2SMS',
134
134
  result: RDS.Failure(e.toString())
135
135
  }
136
136
  });
@@ -139,9 +139,9 @@ function loadOc2sms() {
139
139
  } catch (ex) {
140
140
  console.warn(ex);
141
141
  dispatch({
142
- type: "LOAD_OC2SMS",
142
+ type: 'LOAD_OC2SMS',
143
143
  payload: {
144
- type: "LOAD_OC2SMS",
144
+ type: 'LOAD_OC2SMS',
145
145
  result: RDS.Failure(ex.toString())
146
146
  }
147
147
  });
@@ -152,13 +152,13 @@ function loadOc2sms() {
152
152
 
153
153
  case 6:
154
154
  dispatch({
155
- type: "LOAD_OC2SMS",
155
+ type: 'LOAD_OC2SMS',
156
156
  payload: {
157
- type: "LOAD_OC2SMS",
158
- result: RDS.Failure("Unexpected state")
157
+ type: 'LOAD_OC2SMS',
158
+ result: RDS.Failure('Unexpected state')
159
159
  }
160
160
  });
161
- throw "Unexpected state";
161
+ throw 'Unexpected state';
162
162
 
163
163
  case 8:
164
164
  case "end":
@@ -176,7 +176,7 @@ function loadOc2sms() {
176
176
 
177
177
  var initialState = {
178
178
  currentState: {
179
- type: "LOAD_OC2SMS",
179
+ type: 'LOAD_OC2SMS',
180
180
  result: RDS.NothingYet()
181
181
  }
182
182
  };
@@ -190,7 +190,7 @@ function Click2smsFlowReducer() {
190
190
  var action = arguments.length > 1 ? arguments[1] : undefined;
191
191
 
192
192
  switch (action.type) {
193
- case "LOAD_OC2SMS":
193
+ case 'LOAD_OC2SMS':
194
194
  return (0, _strategy.genericHandler)(state, action.payload);
195
195
 
196
196
  default:
@@ -1,4 +1,4 @@
1
- import { IConfig, SingleSubmissionResult, MultiOperatorSubmissionResult } from "./Click2smsTypes";
1
+ import { IConfig, MultiOperatorSubmissionResult, SingleSubmissionResult } from './Click2smsTypes';
2
2
  export default function load(window: Window, maybeConfig: IConfig, keyword?: string, shortcode?: string): Promise<SingleSubmissionResult | MultiOperatorSubmissionResult>;
3
3
  export declare function load1(window: Window, maybeConfig: IConfig, keyword?: string, shortcode?: string): Promise<SingleSubmissionResult | MultiOperatorSubmissionResult>;
4
4
  export declare function checkSubscription(window: Window, maybeConfig: IConfig): Promise<string>;
@@ -85,20 +85,20 @@ function _loadOnce() {
85
85
  while (1) {
86
86
  switch (_context.prev = _context.next) {
87
87
  case 0:
88
- if (!(!!maybeConfig && maybeConfig.tag == "keywordAndShortCode")) {
89
- _context.next = 5;
88
+ if (!(!!maybeConfig && maybeConfig.tag == 'keywordAndShortCode')) {
89
+ _context.next = 3;
90
90
  break;
91
91
  }
92
92
 
93
93
  _keyword = maybeConfig.keyword, _shortcode = maybeConfig.shortcode;
94
94
  return _context.abrupt("return", _objectSpread({
95
- type: "SingleSubmissionResult"
95
+ type: 'SingleSubmissionResult'
96
96
  }, {
97
97
  keyword: _keyword,
98
98
  shortcode: _shortcode
99
99
  }));
100
100
 
101
- case 5:
101
+ case 3:
102
102
  offer = window.pac_analytics.visitor.offer;
103
103
  config = _objectSpread({
104
104
  offer: window.pac_analytics.visitor.offer
@@ -106,28 +106,28 @@ function _loadOnce() {
106
106
  host = config.host, country = config.country, slug = config.slug;
107
107
  rockmanId = window.pac_analytics.visitor.rockmanId;
108
108
  search = window.location.search.substr(1) || '';
109
- _context.next = 12;
109
+ _context.next = 10;
110
110
  return window.tallymanApi.oc2sms(host, country, slug, offer, rockmanId, keyword, operator, search);
111
111
 
112
- case 12:
112
+ case 10:
113
113
  result = _context.sent;
114
114
 
115
115
  if (result.success) {
116
- _context.next = 17;
116
+ _context.next = 15;
117
117
  break;
118
118
  }
119
119
 
120
120
  throw result.message;
121
121
 
122
- case 17:
122
+ case 15:
123
123
  return _context.abrupt("return", _objectSpread({
124
- type: "SingleSubmissionResult"
124
+ type: 'SingleSubmissionResult'
125
125
  }, {
126
- keyword: "".concat(keyword || result.displayKeyword).concat(!!result.uid ? ' ' + result.uid : ''),
126
+ keyword: "".concat(keyword || result.displayKeyword).concat(result.uid ? " ".concat(result.uid) : ''),
127
127
  shortcode: result.shortcode
128
128
  }));
129
129
 
130
- case 18:
130
+ case 16:
131
131
  case "end":
132
132
  return _context.stop();
133
133
  }
@@ -231,7 +231,7 @@ function _loadForMultipleOperators() {
231
231
  }
232
232
  });
233
233
  return _context3.abrupt("return", {
234
- type: "MultiOperatorSubmissionResult",
234
+ type: 'MultiOperatorSubmissionResult',
235
235
  data: arrResult
236
236
  });
237
237
 
@@ -255,30 +255,30 @@ function _load() {
255
255
  while (1) {
256
256
  switch (_context4.prev = _context4.next) {
257
257
  case 0:
258
- if (!(!!maybeConfig && maybeConfig.tag == "keywordAndShortCode")) {
259
- _context4.next = 4;
258
+ if (!(!!maybeConfig && maybeConfig.tag == 'keywordAndShortCode')) {
259
+ _context4.next = 2;
260
260
  break;
261
261
  }
262
262
 
263
263
  return _context4.abrupt("return", _objectSpread({
264
- type: "SingleSubmissionResult"
264
+ type: 'SingleSubmissionResult'
265
265
  }, {
266
266
  keyword: maybeConfig.keyword,
267
267
  shortcode: maybeConfig.shortcode
268
268
  }));
269
269
 
270
- case 4:
271
- if (!(!!maybeConfig && maybeConfig.tag == "keyword")) {
272
- _context4.next = 8;
270
+ case 2:
271
+ if (!(!!maybeConfig && maybeConfig.tag == 'keyword')) {
272
+ _context4.next = 4;
273
273
  break;
274
274
  }
275
275
 
276
276
  return _context4.abrupt("return", load1(window, maybeConfig, keyword, shortcode));
277
277
 
278
- case 8:
278
+ case 4:
279
279
  return _context4.abrupt("return", load1(window, maybeConfig, null, null));
280
280
 
281
- case 9:
281
+ case 5:
282
282
  case "end":
283
283
  return _context4.stop();
284
284
  }
@@ -303,18 +303,18 @@ function _load2() {
303
303
  offer: window.pac_analytics.visitor.offer
304
304
  }, maybeConfig);
305
305
 
306
- if (!(true == config.automaticallySubmitAllOperators && !!config.operators && config.operators.length > 0)) {
307
- _context5.next = 5;
306
+ if (!(config.automaticallySubmitAllOperators == true && !!config.operators && config.operators.length > 0)) {
307
+ _context5.next = 3;
308
308
  break;
309
309
  }
310
310
 
311
311
  return _context5.abrupt("return", loadForMultipleOperators(window, maybeConfig, config.operators, keyword, shortcode));
312
312
 
313
- case 5:
313
+ case 3:
314
314
  singleOperator = maybeConfig.operators && maybeConfig.operators.length > 0 ? maybeConfig.operators[0] : null;
315
315
  return _context5.abrupt("return", loadOnce(window, maybeConfig, singleOperator, keyword, shortcode));
316
316
 
317
- case 7:
317
+ case 5:
318
318
  case "end":
319
319
  return _context5.stop();
320
320
  }
@@ -353,20 +353,20 @@ function _checkSubscription() {
353
353
  case 6:
354
354
  checkResult = _context6.sent;
355
355
 
356
- if (!(true === checkResult.success)) {
357
- _context6.next = 12;
356
+ if (!(checkResult.success === true)) {
357
+ _context6.next = 10;
358
358
  break;
359
359
  }
360
360
 
361
361
  window.location.href = checkResult.product_url;
362
362
  return _context6.abrupt("return", checkResult.product_url || null);
363
363
 
364
- case 12:
365
- error = new Error("SubscriptionFailed".concat(":\n", checkResult.message));
366
- error['type'] = "SubscriptionFailed";
364
+ case 10:
365
+ error = new Error('SubscriptionFailed'.concat(":\n", checkResult.message));
366
+ error.type = 'SubscriptionFailed';
367
367
  throw error;
368
368
 
369
- case 15:
369
+ case 13:
370
370
  case "end":
371
371
  return _context6.stop();
372
372
  }
@@ -1,2 +1,2 @@
1
- declare type IMoConstants = "MO_MSISDN_SUBMIT" | "MO_MSISDN_SUBMIT_ERROR" | "MO_BACK_TO_START" | "MOCK_MO_FLOW_STATE";
1
+ declare type IMoConstants = 'MO_MSISDN_SUBMIT' | 'MO_MSISDN_SUBMIT_ERROR' | 'MO_BACK_TO_START' | 'MOCK_MO_FLOW_STATE';
2
2
  export default IMoConstants;