ouisys-engine 3.0.3 → 3.0.7

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 +38 -38
  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 +2 -2
  62. package/dist/reducers/strategy/strategies/ask_mobile_number.js +78 -78
  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 -219
  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 -376
  183. package/src/reducers/strategy/index.ts +0 -322
  184. package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -366
  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,489 +0,0 @@
1
- import * as RDS from "../../../common-types/RemoteDataState";
2
-
3
- import { determineFlowByOperator, getConfig, determineFlowByOperatorFromIp, identifyUser } from "../utils";
4
- import { AppThunk } from "../../../common-types/AppThunk";
5
- import {
6
- IFlow
7
- } from "../StrategyTypes";
8
- import { tracker } from "..";
9
- import tryGetIPRangeName from "../../../ips/tryGetIPRangeName";
10
-
11
- export default function identify_user():AppThunk {
12
- return (dispatch)=>{
13
- try{
14
- dispatch({
15
- type:"HE_IDENTIFY",
16
- payload:{
17
- type:"HE_IDENTIFY",
18
- result:RDS.Loading()
19
- }
20
- });
21
-
22
- const { strategy, strategyConfigs } = getConfig();
23
- const defaultFlow = strategyConfigs.default
24
-
25
- switch (strategy) {
26
- case "pin-header-enrichment":
27
- return dispatch(pin_header_enrichment(defaultFlow))
28
- case "he-pin-mo-redir-header-enrichment":
29
- return dispatch(he_pin_mo_redir_header_enrichment(defaultFlow))
30
- case "he-pin-one-click-header-enrichment":
31
- return dispatch(he_pin_one_click_header_enrichment(defaultFlow))
32
- case "he-mo-redir-one-click-header-enrichment":
33
- return dispatch(he_mo_redir_one_click_header_enrichment(defaultFlow))
34
-
35
- }
36
- }catch(err){
37
- dispatch({
38
- type:"HE_IDENTIFY",
39
- payload:{
40
- type:"HE_IDENTIFY",
41
- result:RDS.Failure(err)
42
- }
43
- });
44
- }
45
- }
46
- }
47
-
48
-
49
-
50
- export const pin_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
51
- return async(dispatch)=>{
52
- try{
53
- let ipRangeName = await tryGetIPRangeName(window.pac_analytics.visitor);
54
- console.log("ipRangeName", ipRangeName)
55
- if (ipRangeName == null) {
56
-
57
- tracker.sendOptInFlowEvent("Pin")
58
- return dispatch({
59
- type:"IDENTIFY_FLOW_BY_HE",
60
- payload:{
61
- type:"PIN",
62
- result: {
63
- nextAction:"submitMSISDNAction",
64
- config:defaultFlow.flowConfig,
65
- }
66
- }
67
- });
68
- }
69
- const heResult = await identifyUser();
70
- const flowObj = defaultFlow
71
- if(heResult.msisdn !== undefined && heResult.msisdn !== ""){
72
- const msisdn = heResult.msisdn;
73
- const operator = heResult.operator;
74
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
75
-
76
- tracker.sendOptInFlowEvent("Hybrid Pin")
77
- return dispatch({
78
- type:"IDENTIFY_FLOW_BY_HE",
79
- payload:{
80
- type:"PIN",
81
- result: {
82
- nextAction:"submitMSISDNAction",
83
- config:flowObj.flowConfig,
84
- msisdn,
85
- rockman_id:flowObj.rockman_id,
86
- isHeaderEnrichmentSuccess:true
87
- }
88
- }
89
- });
90
- }else{
91
- tracker.sendOptInFlowEvent("Pin")
92
- return dispatch({
93
- type:"IDENTIFY_FLOW_BY_HE",
94
- payload:{
95
- type:"PIN",
96
- result: {
97
- nextAction:"submitMSISDNAction",
98
- config:flowObj.flowConfig,
99
- }
100
- }
101
- });
102
- }
103
- }catch(err){
104
- console.warn(err)
105
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
106
- tracker.sendOptInFlowEvent("Pin")
107
-
108
- dispatch({
109
- type:"IDENTIFY_FLOW_BY_HE",
110
- payload:{
111
- type:"PIN",
112
- result: {
113
- nextAction:"submitMSISDNAction",
114
- config:defaultFlow.flowConfig,
115
- }
116
- }
117
- });
118
- }
119
- }
120
- }
121
-
122
- export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
123
- return async(dispatch)=>{
124
-
125
- const switchState = ({flowObj,msisdn,operator, subscription_url, redirect_url}:{
126
- flowObj:IFlow,
127
- msisdn?:string,
128
- operator?:string,
129
- subscription_url?:string,
130
- redirect_url?:string,
131
- })=>{
132
- const isHeaderEnrichmentSuccess = (msisdn !== undefined && msisdn !== "") ? true : false;
133
-
134
- switch (flowObj.flow) {
135
- case "oneClick":
136
-
137
- tracker.sendOptInFlowEvent("3G click")
138
- return dispatch({
139
- type:"IDENTIFY_FLOW_BY_HE",
140
- payload:{
141
- type:"ONE_CLICK",
142
- result: {
143
- nextAction:"getRedirectUrlAction",
144
- config:flowObj.flowConfig,
145
- operator:flowObj.operator,
146
- subscription_url:subscription_url || null,
147
- redirect_url:redirect_url || null
148
- }
149
- }
150
- });
151
- case "pin":
152
- if(isHeaderEnrichmentSuccess == true){
153
- tracker.sendOptInFlowEvent("Hybrid Pin")
154
- }else{
155
- tracker.sendOptInFlowEvent("Pin")
156
- }
157
- return dispatch({
158
- type:"IDENTIFY_FLOW_BY_HE",
159
- payload:{
160
- type:"PIN",
161
- result: {
162
- nextAction:"submitMSISDNAction",
163
- config:flowObj.flowConfig,
164
- msisdn,
165
- rockman_id:flowObj.rockman_id,
166
- operator,
167
- isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess
168
- }
169
- }
170
- });
171
- default:
172
- tracker.sendOptInFlowEvent("Pin")
173
- return dispatch({
174
- type:"IDENTIFY_FLOW_BY_HE",
175
- payload:{
176
- type:"PIN",
177
- result: {
178
- nextAction:"submitMSISDNAction",
179
- config:defaultFlow.flowConfig,
180
- rockman_id:defaultFlow.rockman_id
181
- }
182
- }
183
- });
184
- }
185
- }
186
- let ipRangeName = await tryGetIPRangeName(window.pac_analytics.visitor);
187
-
188
- if (ipRangeName == null) {
189
- tracker.sendOptInFlowEvent("Pin")
190
- return dispatch({
191
- type:"IDENTIFY_FLOW_BY_HE",
192
- payload:{
193
- type:"PIN",
194
- result: {
195
- nextAction:"submitMSISDNAction",
196
- config:defaultFlow.flowConfig,
197
- rockman_id:defaultFlow.rockman_id
198
- }
199
- }
200
- });
201
- }
202
-
203
- try{
204
-
205
- const flowObj = determineFlowByOperator(ipRangeName.toUpperCase());
206
- if(flowObj.flow == "oneClick"){
207
- const heResult = await identifyUser({operator:ipRangeName});
208
-
209
- const {msisdn, subscription_url, redirect_url} = heResult;
210
-
211
- const operator = heResult.operator ? heResult.operator.toUpperCase() : ipRangeName.toUpperCase()
212
- if(msisdn && msisdn !== ""){
213
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
214
- const flowObj = determineFlowByOperator(operator);
215
- switchState({flowObj, msisdn, operator, subscription_url, redirect_url})
216
- }else{
217
- const flowObj = determineFlowByOperator(operator);
218
- switchState({flowObj, redirect_url, subscription_url, operator})
219
- }
220
- }else{
221
- tracker.sendOptInFlowEvent("Pin")
222
- return dispatch({
223
- type:"IDENTIFY_FLOW_BY_HE",
224
- payload:{
225
- type:"PIN",
226
- result: {
227
- nextAction:"submitMSISDNAction",
228
- config:defaultFlow.flowConfig,
229
- rockman_id:defaultFlow.rockman_id
230
- }
231
- }
232
- });
233
- }
234
-
235
- }catch(err){
236
- console.warn(err)
237
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
238
- tracker.sendOptInFlowEvent("Pin")
239
- dispatch({
240
- type:"IDENTIFY_FLOW_BY_HE",
241
- payload:{
242
- type:"PIN",
243
- result: {
244
- nextAction:"submitMSISDNAction",
245
- config:defaultFlow.flowConfig,
246
- }
247
- }
248
- });
249
- }
250
- }
251
- }
252
-
253
-
254
- export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
255
- return async(dispatch)=>{
256
-
257
- const switchState = ({flowObj,msisdn,operator, subscription_url, redirect_url}:{
258
- flowObj:IFlow,
259
- msisdn?:string,
260
- operator?:string,
261
- subscription_url?:string,
262
- redirect_url?:string,
263
- })=>{
264
- const isHeaderEnrichmentSuccess = (msisdn !== undefined && msisdn !== "") ? true : false;
265
-
266
- switch (flowObj.flow) {
267
- case "oneClick":
268
-
269
- tracker.sendOptInFlowEvent("3G click")
270
- return dispatch({
271
- type:"IDENTIFY_FLOW_BY_HE",
272
- payload:{
273
- type:"ONE_CLICK",
274
- result: {
275
- nextAction:"getRedirectUrlAction",
276
- config:flowObj.flowConfig,
277
- operator:flowObj.operator,
278
- subscription_url:subscription_url || null,
279
- redirect_url:redirect_url || null
280
- }
281
- }
282
- });
283
- case "moRedir":
284
- tracker.sendOptInFlowEvent("Redirect")
285
- return dispatch({
286
- type:"IDENTIFY_FLOW_BY_HE",
287
- payload:{
288
- type:"MO_REDIR",
289
- result: {
290
- nextAction:"submitMSISDNAction",
291
- config:flowObj.flowConfig,
292
- msisdn,
293
- rockman_id:flowObj.rockman_id,
294
- operator,
295
- isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess
296
- }
297
- }
298
- });
299
- default:
300
- tracker.sendOptInFlowEvent("Redirect")
301
- return dispatch({
302
- type:"IDENTIFY_FLOW_BY_HE",
303
- payload:{
304
- type:"MO_REDIR",
305
- result: {
306
- nextAction:"submitMSISDNAction",
307
- config:defaultFlow.flowConfig,
308
- rockman_id:defaultFlow.rockman_id
309
- }
310
- }
311
- });
312
- }
313
- }
314
- let ipRangeName = await tryGetIPRangeName(window.pac_analytics.visitor);
315
-
316
- if (ipRangeName == null) {
317
- tracker.sendOptInFlowEvent("Redirect")
318
- return dispatch({
319
- type:"IDENTIFY_FLOW_BY_HE",
320
- payload:{
321
- type:"MO_REDIR",
322
- result: {
323
- nextAction:"submitMSISDNAction",
324
- config:defaultFlow.flowConfig,
325
- rockman_id:defaultFlow.rockman_id
326
- }
327
- }
328
- });
329
- }
330
-
331
- try{
332
-
333
- const flowObj = determineFlowByOperator(ipRangeName.toUpperCase());
334
- if(flowObj.flow == "oneClick"){
335
- const heResult = await identifyUser({operator:ipRangeName});
336
-
337
- const {msisdn, subscription_url, redirect_url} = heResult;
338
-
339
- const operator = heResult.operator ? heResult.operator.toUpperCase() : ipRangeName.toUpperCase()
340
- if(msisdn && msisdn !== ""){
341
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
342
- const flowObj = determineFlowByOperator(operator);
343
- switchState({flowObj, msisdn, operator, subscription_url, redirect_url})
344
- }else{
345
- const flowObj = determineFlowByOperator(operator);
346
- switchState({flowObj, redirect_url, subscription_url, operator})
347
- }
348
- }else{
349
- tracker.sendOptInFlowEvent("Redirect")
350
- return dispatch({
351
- type:"IDENTIFY_FLOW_BY_HE",
352
- payload:{
353
- type:"MO_REDIR",
354
- result: {
355
- nextAction:"submitMSISDNAction",
356
- config:defaultFlow.flowConfig,
357
- rockman_id:defaultFlow.rockman_id
358
- }
359
- }
360
- });
361
- }
362
-
363
- }catch(err){
364
- console.warn(err)
365
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
366
- tracker.sendOptInFlowEvent("Redirect")
367
- dispatch({
368
- type:"IDENTIFY_FLOW_BY_HE",
369
- payload:{
370
- type:"MO_REDIR",
371
- result: {
372
- nextAction:"submitMSISDNAction",
373
- config:defaultFlow.flowConfig,
374
- }
375
- }
376
- });
377
- }
378
- }
379
- }
380
-
381
- export const he_pin_mo_redir_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
382
- return async(dispatch)=>{
383
-
384
- const switchState = (flowObj:IFlow,msisdn?:string,operator?:string)=>{
385
-
386
- const isHeaderEnrichmentSuccess = (msisdn !== undefined && msisdn !== "") ? true : false;
387
- switch (flowObj.flow) {
388
- case "moRedir":
389
- tracker.sendOptInFlowEvent("Redirect")
390
-
391
- return dispatch({
392
- type:"IDENTIFY_FLOW_BY_HE",
393
- payload:{
394
- type:"MO_REDIR",
395
- result: {
396
- nextAction:"submitMSISDNAction",
397
- config:flowObj.flowConfig,
398
- msisdn,
399
- rockman_id:flowObj.rockman_id,
400
- operator,
401
- isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess
402
- }
403
- }
404
- });
405
- case "pin":
406
- if(isHeaderEnrichmentSuccess == true){
407
- tracker.sendOptInFlowEvent("Hybrid Pin")
408
- }else{
409
- tracker.sendOptInFlowEvent("Pin")
410
- }
411
- return dispatch({
412
- type:"IDENTIFY_FLOW_BY_HE",
413
- payload:{
414
- type:"PIN",
415
- result: {
416
- nextAction:"submitMSISDNAction",
417
- config:flowObj.flowConfig,
418
- msisdn,
419
- rockman_id:flowObj.rockman_id,
420
- operator,
421
- isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess
422
- }
423
- }
424
- });
425
- default:
426
- tracker.sendOptInFlowEvent("Pin")
427
- return dispatch({
428
- type:"IDENTIFY_FLOW_BY_HE",
429
- payload:{
430
- type:"PIN",
431
- result: {
432
- nextAction:"submitMSISDNAction",
433
- config:defaultFlow.flowConfig,
434
- rockman_id:defaultFlow.rockman_id
435
- }
436
- }
437
- });
438
- }
439
- }
440
- try{
441
-
442
- const heResult = await identifyUser();
443
- if(heResult.msisdn !== undefined && heResult.msisdn !== ""){
444
-
445
- const msisdn = heResult.msisdn;
446
- const operator = heResult.operator;
447
-
448
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
449
-
450
- if(!!operator && operator !== ""){
451
- const flowObj = determineFlowByOperator(operator);
452
- switchState(flowObj, msisdn, operator)
453
- }else{
454
-
455
- const flowObj = await determineFlowByOperatorFromIp()
456
- switchState(flowObj,msisdn)
457
- }
458
- }else{
459
- const flowObj = await determineFlowByOperatorFromIp()
460
- switchState(flowObj)
461
- }
462
- }catch(err){
463
- console.warn(err)
464
- tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
465
-
466
- try{
467
- const flowObj = await determineFlowByOperatorFromIp()
468
- switchState(flowObj)
469
- }catch(e){
470
- console.warn(e)
471
- tracker.sendOptInFlowEvent("Pin")
472
-
473
- dispatch({
474
- type:"IDENTIFY_FLOW_BY_HE",
475
- payload:{
476
- type:"PIN",
477
- result: {
478
- nextAction:"submitMSISDNAction",
479
- config:defaultFlow.flowConfig,
480
- }
481
- }
482
- });
483
- }
484
- }
485
- }
486
- }
487
-
488
-
489
-