ouisys-engine 4.7.0-alpha.1 → 4.7.0-alpha.11
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.
- package/dist/RemoteDataState-lcf8PfJd.js +2 -0
- package/dist/{RemoteDataState-CwHLI23e.js.map → RemoteDataState-lcf8PfJd.js.map} +1 -1
- package/dist/bupperizeCountry-CEtt0MKz.js +2 -0
- package/dist/bupperizeCountry-CEtt0MKz.js.map +1 -0
- package/dist/checkSubscriptionByRockmanIdOnly-BwR1un1L.js +2 -0
- package/dist/{checkSubscriptionByRockmanIdOnly-C89Ph9cV.js.map → checkSubscriptionByRockmanIdOnly-BwR1un1L.js.map} +1 -1
- package/dist/checkSubscriptionHander.js +1 -52
- package/dist/checkSubscriptionHander.js.map +1 -1
- package/dist/click2smsFlow.js +1 -245
- package/dist/click2smsFlow.js.map +1 -1
- package/dist/creditCardFlow.js +1 -247
- package/dist/creditCardFlow.js.map +1 -1
- package/dist/getConfig.js +1 -13
- package/dist/getConfig.js.map +1 -1
- package/dist/handleClickChainFlow.js +1 -31
- package/dist/handleClickChainFlow.js.map +1 -1
- package/dist/handleSubmitNumber.js +1 -64
- package/dist/handleSubmitNumber.js.map +1 -1
- package/dist/helpers-xPhGBX-B.js +2 -0
- package/dist/helpers-xPhGBX-B.js.map +1 -0
- package/dist/loadScriptInnerHtml-BzQm-AFb.js +2 -0
- package/dist/loadScriptInnerHtml-BzQm-AFb.js.map +1 -0
- package/dist/loadScriptSrc-Da4autZd.js +2 -0
- package/dist/loadScriptSrc-Da4autZd.js.map +1 -0
- package/dist/moFlow.js +1 -274
- package/dist/moFlow.js.map +1 -1
- package/dist/moRedirFlow.js +1 -224
- package/dist/moRedirFlow.js.map +1 -1
- package/dist/oneClickFlow.js +1 -463
- package/dist/oneClickFlow.js.map +1 -1
- package/dist/pinFlow.js +1 -696
- package/dist/pinFlow.js.map +1 -1
- package/dist/searchToObject.js +1 -18
- package/dist/searchToObject.js.map +1 -1
- package/dist/storeMsisdn-Cjq8_qYH.js +2 -0
- package/dist/{storeMsisdn-ChiBh8mI.js.map → storeMsisdn-Cjq8_qYH.js.map} +1 -1
- package/dist/strategy.js +1 -49
- package/dist/strategy.js.map +1 -1
- package/dist/strategySlice-Dw14E22-.js +2 -0
- package/dist/strategySlice-Dw14E22-.js.map +1 -0
- package/dist/tracker-DaaILhEr.js +2 -0
- package/dist/tracker-DaaILhEr.js.map +1 -0
- package/dist/tracker.js +1 -4
- package/dist/tracker.js.map +1 -1
- package/dist/tryGetIPRangeName-QW-9NgzE.js +2 -0
- package/dist/tryGetIPRangeName-QW-9NgzE.js.map +1 -0
- package/dist/types/{OneClickTypes-DF0jodl-.d.ts → OneClickTypes-DjOesaHp.d.ts} +1 -1
- package/dist/types/{StrategyTypes-BEIYqoJV.d.ts → StrategyTypes-CbOgk0N4.d.ts} +3 -2
- package/dist/types/click2smsFlow.d.ts +3 -3
- package/dist/types/handleSubmitNumber.d.ts +3 -3
- package/dist/types/oneClickFlow.d.ts +2 -2
- package/dist/types/strategy.d.ts +12 -4
- package/dist/ussdFlow.js +1 -210
- package/dist/ussdFlow.js.map +1 -1
- package/package.json +6 -6
- package/dist/RemoteDataState-CwHLI23e.js +0 -75
- package/dist/bupperizeCountry-CCDIOHP6.js +0 -4
- package/dist/bupperizeCountry-CCDIOHP6.js.map +0 -1
- package/dist/checkSubscriptionByRockmanIdOnly-C89Ph9cV.js +0 -27
- package/dist/helpers-J_h-ZgxH.js +0 -29
- package/dist/helpers-J_h-ZgxH.js.map +0 -1
- package/dist/loadScriptInnerHtml-DPcoY467.js +0 -26
- package/dist/loadScriptInnerHtml-DPcoY467.js.map +0 -1
- package/dist/storeMsisdn-ChiBh8mI.js +0 -58
- package/dist/strategySlice-bF74rxDK.js +0 -842
- package/dist/strategySlice-bF74rxDK.js.map +0 -1
- package/dist/tracker-B_zsMRN2.js +0 -79
- package/dist/tracker-B_zsMRN2.js.map +0 -1
- package/dist/tryGetIPRangeName-C69HEG5W.js +0 -42
- package/dist/tryGetIPRangeName-C69HEG5W.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategySlice-Dw14E22-.js","sources":["../src/sharedFlowTypes/StrategyTypes.ts","../src/flows/strategy/api.ts","../src/flows/strategy/main.ts","../src/flows/strategy/strategies/askMobileNumber.ts","../src/flows/strategy/strategies/askOperator.ts","../src/flows/strategy/strategies/detectOperatorByIp.ts","../src/flows/strategy/strategies/injectHeaderEnrichmentScript.ts","../src/flows/strategy/strategySlice.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable camelcase */\nimport * as RDS from '../common-types/RemoteDataState';\nimport { Click2smsFlowState } from './Click2smsTypes';\nimport { CreditCardFlowState } from './CreditCardTypes';\nimport { MoRedirFlowState } from './MoRedirTypes';\nimport { MoFlowState } from './MoTypes';\nimport { OneClickFlowState } from './OneClickTypes';\nimport { PinFlowState } from './PinTypes';\nimport { UssdFlowState } from './UssdTypes';\n\nexport type IIdentifyResult = {\n operator: string;\n flow?: string;\n success: boolean;\n rockman_id?: string;\n message?: string;\n};\n\nexport type ConfigDetails = {\n host: string;\n slug: string;\n country: string;\n device?: 'smart' | 'feature';\n queryString?: Array<[string, string]>;\n automaticallySubmitAllOperators?: boolean;\n operators?: string[];\n service: string;\n offer?: string;\n};\n\nexport type IConfig = {\n offer?: string;\n slug?: string;\n country?: string;\n host?: string;\n device?: 'smart' | 'feature';\n automaticallySubmitAllOperators?: boolean;\n operators?: string[];\n service?: string;\n serviceId?: string;\n queryString?: any;\n apiAction?: any;\n};\n\nexport type ISupportedFlows = 'pin' | 'mo' | 'oneClick' | 'click2sms' | 'moRedir' | 'ussd' | 'creditCard';\nexport type IFlow = {\n flow: ISupportedFlows;\n flowOnWifi?: ISupportedFlows;\n operator?: string;\n flowConfig: ConfigDetails;\n default?: IFlow;\n rockman_id?: string;\n};\n\nexport type StrategyConfig = {\n operators: {\n [key: string]: IFlow;\n };\n default: IFlow;\n isUseMsisdnPrefix?: boolean;\n};\n// export type IStrategy = IPinStrategy | IMoStrategy;\n\nexport type IStrategy = {\n strategy: IStrategyNames;\n country: string;\n strategyConfigs: StrategyConfig;\n};\n\nexport type IStrategyNames =\n | 'pin'\n | 'mo'\n | 'mo-redir'\n | 'click2sms'\n | 'one-click'\n | 'ussd'\n | 'tpay-he'\n | 'credit-card'\n | 'tallyman-one-click'\n | 'pin-mo-ask-operator'\n | 'pin-mo-ask-mobile-number'\n | 'pin-one-click-ask-operator'\n | 'pin-one-click-detect-operator-by-ip'\n | 'one-click-mo-pin-detect-operator-by-ip-or-msisdn'\n | 'pin-click2sms-ask-operator'\n | 'mo-redir-one-click-detect-operator-by-ip'\n | 'pin-mo-redir-ask-mobile-number'\n | 'pin-click2sms-ask-mobile-number'\n | 'mo-one-click-detect-operator-by-ip'\n | 'click2sms-one-click-detect-operator-by-ip'\n | 'pin-header-enrichment'\n | 'pin-msisdn-fowarding-pin-header-enrichment'\n | 'he-pin-mo-redir-header-enrichment'\n | 'he-pin-one-click-header-enrichment'\n | 'he-pin-one-click-ask-operator'\n | 'click2sms-one-click-ask-operator'\n | 'pin-mo-detect-operator-by-ip'\n | 'he-mo-redir-one-click-header-enrichment'\n | 'pin-combo-ask-mobile-number'\n | 'header-enrichment-script'\n | 'mo-redir-mo-click2sms-one-click-detect-operator-by-ip-or-msisdn'\n | 'pin-mo-mo-redir-ask-mobile-number';\n\nexport interface IHash {\n [key: string]: string;\n}\n\nexport type IDENTIFYMSISDNEntryErrorTypes = 'AlreadySubscribed' | 'UnknownError' | 'InvalidMSISDN';\n\nexport type IDENTIFYMSISDNEntryFailure = {\n errorType: IDENTIFYMSISDNEntryErrorTypes;\n error: unknown;\n};\n\nexport type IdentifyFlowOptionsResult = {\n config: IConfig;\n nextAction?: unknown;\n msisdn?: string;\n operator?: string;\n subscription_url?: string;\n redirect_url?: string;\n rockman_id?: string;\n isHeaderEnrichmentSuccess?: boolean;\n autoRedirect?: boolean;\n isUseMsisdnPrefix?: boolean;\n};\n\nexport type IDENTIFYMSISDNEntrySuccess = {};\nexport type OPERATORSelectFailure = {};\nexport type OPERATORSelectSuccess = IdentifyFlowOptionsResult;\n\nexport type IDETECTYOPERATOBYIPFailure = {};\nexport type IDETECTYOPERATOBYIPSuccess = IdentifyFlowOptionsResult;\n\nexport type IDENTIFY_OPERATOR_MSISDNEntrySuccess = IdentifyFlowOptionsResult;\n\nexport type IDENTIFY_FLOW_HESuccess = IdentifyFlowOptionsResult;\n\nexport type OPERATORSelectFlowIdentifyFailure = {};\nexport type OPERATORSelectFlowIdentifySuccess = {\n operators: Array<string>;\n msisdn?: string;\n nextAction: 'selectOperator';\n};\nexport type IDENTIFYFailure = {};\n\nexport type IDENTIFYSuccess = {};\n\nexport type IOperatorSelectFlowIdentifyPayload = {\n type: 'IDENTIFY_FLOW_BY_OPERATOR_SELECT';\n result: RDS.RemoteDataState<OPERATORSelectFlowIdentifyFailure, OPERATORSelectFlowIdentifySuccess>;\n};\n\n// export type IIdentifyByIPPayload= {\n// type:\"IDENTIFY_FLOW_BY_IP\"\n// result: RDS.RemoteDataState<IDENTIFYBYIPFailure, IDENTIFYBYIPSuccess>;\n// }\n\nexport type IDetectOperatorByIpPayload = {\n type: 'DETECT_OPERATOR_BY_IP';\n result: RDS.RemoteDataState<IDETECTYOPERATOBYIPFailure, IDETECTYOPERATOBYIPSuccess>;\n};\n\nexport enum PossibleTypes {\n IDENTIFY_STRATEGY = 'IDENTIFY_STRATEGY',\n IDENTIFY_FLOW_BY_MSISDN = 'IDENTIFY_FLOW_BY_MSISDN',\n IDENTIFY_FLOW_BY_OPERATOR_SELECT = 'IDENTIFY_FLOW_BY_OPERATOR_SELECT',\n PIN = 'PIN',\n MO = 'MO',\n MO_REDIR = 'MO_REDIR',\n ONE_CLICK = 'ONE_CLICK',\n CLICK2SMS = 'CLICK2SMS',\n USSD = 'USSD',\n TPAY_HE = 'TPAY_HE',\n CREDIT_CARD = 'CREDIT_CARD'\n}\n\nexport type IOperatorSelectPayload = {\n type: PossibleTypes;\n result: OPERATORSelectSuccess;\n};\n\nexport type ISubmitMsisdnPayload = {\n type: PossibleTypes;\n result: IDENTIFY_OPERATOR_MSISDNEntrySuccess;\n};\n\nexport type IIdentifyFlowByIpOperatorPayload = {\n type: PossibleTypes;\n result: IDENTIFY_OPERATOR_MSISDNEntrySuccess;\n};\n\nexport type IIdentifyFlowByHePayload = {\n type: PossibleTypes;\n result: IDENTIFY_FLOW_HESuccess;\n};\n\nexport type IIdentfyFlowByMsisdnNextAction = 'submitMSISDNAction' | 'loadOc2sms';\nexport type IIdentfyFlowByOperatorNextAction = 'submitMSISDNAction' | 'loadOc2sms';\nexport type IIdentfyFlowByIPOperatorNextAction = 'getRedirectUrlAction' | 'submitMSISDNAction';\n\nexport type IIdenyifyFlowByMsisdnSumbitNextData = {\n nextAction: IIdentfyFlowByMsisdnNextAction;\n msisdn?: string;\n operator?: string;\n};\n\nexport type IIdenyifyFlowByMsisdnPayload = {\n type: 'IDENTIFY_FLOW_BY_MSISDN';\n result: RDS.RemoteDataState<IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess>;\n data: IIdenyifyFlowByMsisdnSumbitNextData;\n};\n\nexport type IIdenyifyStrategyPayload = {\n type: 'IDENTIFY_FLOW_BY_MSISDN';\n result: RDS.RemoteDataState<IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess>;\n data: IIdenyifyFlowByMsisdnSumbitNextData;\n};\n\nexport type IStrategyCurrentState =\n | {\n type: 'IDENTIFY_STRATEGY';\n result: RDS.RemoteDataState<IDENTIFYFailure, IDENTIFYSuccess>;\n }\n | {\n type: 'IDENTIFY_FLOW_BY_OPERATOR_SELECT';\n result: OPERATORSelectFlowIdentifySuccess;\n }\n | {\n type: 'DETECT_OPERATOR_BY_IP';\n result: RDS.RemoteDataState<IDETECTYOPERATOBYIPFailure, IDETECTYOPERATOBYIPSuccess>;\n }\n | {\n type: 'HE_IDENTIFY';\n result: RDS.RemoteDataState<IDENTIFYFailure, IDENTIFYSuccess>;\n }\n | {\n type: 'OPERATOR_SELECT';\n result: RDS.RemoteDataState<OPERATORSelectFailure, OPERATORSelectSuccess>;\n config: IConfig;\n }\n | {\n type: 'IDENTIFY_FLOW_BY_MSISDN';\n result: RDS.RemoteDataState<IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess>;\n nextData: IIdenyifyFlowByMsisdnSumbitNextData;\n }\n | {\n type: 'PIN';\n result: IdentifyFlowOptionsResult;\n }\n | {\n type: 'MO';\n result: IdentifyFlowOptionsResult;\n }\n | {\n type: 'USSD';\n result: IdentifyFlowOptionsResult;\n }\n | {\n type: 'MO_REDIR';\n result: IdentifyFlowOptionsResult;\n }\n | {\n type: 'ONE_CLICK';\n result: IdentifyFlowOptionsResult;\n }\n | {\n type: 'CLICK2SMS';\n result: IdentifyFlowOptionsResult;\n }\n | {\n type: 'TPAY_HE';\n result: IdentifyFlowOptionsResult;\n }\n | {\n type: 'CREDIT_CARD';\n result: IdentifyFlowOptionsResult;\n };\n\nexport type IStrategyIDentifyUserResult =\n | {\n success: 'true';\n rockman_id: string;\n msisdn: string;\n operator?: string;\n subscription_url?: string;\n redirect_url?: string;\n 'redirect-back'?: string;\n 'msisdn-alias'?: string;\n }\n | {\n success: 'false';\n rockman_id: string;\n message: string;\n 'redirect-back'?: string;\n };\n\nexport type IMockFlows = 'pin' | 'mo' | 'oneclick' | 'click2sms' | 'moredir' | 'ussd' | 'tpay' | 'creditcard';\n\nexport interface IMockFlowParams<T> {\n 'mock-flow': IMockFlows;\n 'current-state': T;\n 'show-pin-entry': '1' | '0';\n 'show-thank-you': '1' | '0';\n operator: string;\n msisdn?: string;\n 'subscription-url'?: string;\n}\n\nexport interface IScriptHeaderEnrichmentSuccess extends CustomEvent {\n detail: {\n msisdn: string;\n operator_code: string;\n };\n}\n\nexport interface ExtraStrategyData {\n isHeaderEnrichmentSuccess?: boolean;\n config?: ConfigDetails;\n msisdn?: string;\n rockman_id?: string;\n operator?: string;\n subscription_url?: string;\n redirect_url?: string;\n operators?: string[];\n}\nexport interface StrategyState {\n currentState: StrategyCurrentState;\n}\n\nexport interface StrategyCurrentState {\n type: PossibleTypes;\n result: RDS.RemoteDataState<any, any>;\n data?: ExtraStrategyData;\n}\n\nexport type IMockPinFlowStates = 'msisdn-state' | 'pin-state' | 'completed-state' | 'msisdn-failure-state';\n\nexport interface RootState {\n strategy?: StrategyState;\n pinFlow?: PinFlowState;\n moFlow?: MoFlowState;\n moRedirFlow?: MoRedirFlowState;\n click2smsFlow?: Click2smsFlowState;\n oneClickFlow?: OneClickFlowState;\n ussdFlow?: UssdFlowState;\n creditCardFlow?: CreditCardFlowState;\n}\n","import { IIdentifyResult, IStrategyIDentifyUserResult } from '../../sharedFlowTypes/StrategyTypes';\nimport { bupperizeCountry } from '../../utilities/bupperizeCountry';\n\nconst fetchJsonp: <T>({ window, _url }: { window: Window; _url: string }) => Promise<T> = ({\n window,\n _url\n}: {\n window: Window;\n _url: string;\n}) => {\n let url = _url;\n const ouisys_callback_function = `ouisys_callback_function${Math.floor(Math.random() * 10000)}`;\n return new Promise((resolve, reject) => {\n (window as any)[ouisys_callback_function] = (arg: any) => {\n resolve(arg);\n };\n\n url += url.indexOf('?') === -1 ? '?' : '&';\n url += `jsonp=${ouisys_callback_function}`;\n const script = document.createElement('script');\n script.src = url;\n script.id = ouisys_callback_function;\n document.body.appendChild(script);\n\n // Caught if got 404/500\n script.onerror = () => {\n reject(new Error(`JSONP request to ${_url} failed`));\n };\n });\n};\nconst identify = async ({\n window,\n slug,\n country,\n msisdn,\n device,\n offer,\n rockmanId\n}: {\n window: Window;\n slug: string;\n country: string;\n msisdn: string;\n device: string;\n offer: string;\n rockmanId: string;\n}): Promise<IIdentifyResult> => {\n const languageCode = window.languageCode ? `&language_code=${window.languageCode}` : '';\n const locationHref = encodeURIComponent(window.location.href);\n\n const host = (window as Window).DEV_BASE_URL || '';\n\n const params = {\n action: 'identify',\n slug,\n country,\n msisdn,\n device,\n offerId: offer,\n rockman_id: rockmanId,\n page: locationHref,\n language_code: languageCode\n };\n\n const urlParams = new URLSearchParams(params).toString();\n const url = `${host}/tallyman/v1/?${urlParams}`;\n\n const response = await fetch(url);\n return response.json();\n};\n\nconst identifyUserGetSubscriptionUrl = async ({\n window,\n country,\n slug,\n device,\n offer,\n rockmanId,\n extraParamsQs = '',\n search = ''\n}: {\n window: Window;\n country: string;\n slug: string;\n device: string;\n offer: string;\n rockmanId: string;\n extraParamsQs?: string;\n search?: string;\n}): Promise<IStrategyIDentifyUserResult> => {\n const xaid = window.pac_analytics.visitor.xaid || '';\n const locationHref = encodeURIComponent(window.location.href);\n const pixelUrl = encodeURIComponent(\n `http://${window.location.host}/pixels?xcid=${window.location.pathname.replace(\n '/',\n ''\n )}&xaid=${xaid}&country=${bupperizeCountry(country)}`\n );\n\n const params = {\n action: 'identify-user',\n country: bupperizeCountry(country),\n slug,\n device,\n offerId: offer,\n page: locationHref,\n pixel_url: pixelUrl,\n rockman_id: rockmanId,\n extraParamsQs,\n search\n };\n\n const urlParams = new URLSearchParams(params).toString();\n const host = window.DEV_BASE_URL || '';\n const url = `${host}/tallyman/v1/?${urlParams}`;\n\n const response = await fetchJsonp<IStrategyIDentifyUserResult>({\n window,\n _url: url\n });\n return response;\n};\n\nexport { identify, identifyUserGetSubscriptionUrl };\n","import { IError } from '../../common-types/IError';\nimport { IStrategy } from '../../common-types/Strategy';\nimport tryGetIPRangeName from '../../ips/tryGetIPRangeName';\nimport { IConfig, IFlow, IIdentifyResult } from '../../sharedFlowTypes/StrategyTypes';\nimport { identify } from './api';\n\nexport async function determineFlowByMsidn({\n window,\n internationalMSISDN,\n configs\n}: {\n window: Window;\n internationalMSISDN: string;\n configs: IStrategy;\n}): Promise<IFlow> {\n if (!internationalMSISDN) {\n const submissionError = new Error(`Error in submitMSISDN() identify action`) as IError;\n submissionError.type = 'SEInvalidMSISDN';\n throw submissionError;\n }\n const msisdn = internationalMSISDN.match(/\\d+/gi)?.join('') || ''; // tallyman API expects international msisdn without unknown special character\n const defaultFlowConfig = configs?.strategyConfigs?.default;\n const config = defaultFlowConfig.flowConfig;\n const operatorsConfig = configs?.strategyConfigs?.operators;\n\n const indentifyFlow = async (): Promise<IIdentifyResult> => {\n const { slug, country, device } = config;\n const { rockmanId } = window.pac_analytics.visitor;\n const { offer } = window.pac_analytics.visitor;\n const flowOperatorResult: IIdentifyResult = await identify({\n window,\n slug,\n country,\n msisdn,\n device,\n offer,\n rockmanId\n });\n return flowOperatorResult;\n };\n const theResult = await indentifyFlow();\n\n const flow = operatorsConfig[theResult.operator] ? operatorsConfig[theResult.operator] : null;\n const cannotDetect =\n theResult.success === false && theResult.message === 'Operator could not be found for the given MSISDN';\n const hlrError =\n theResult.success === false && theResult.message?.indexOf('HLR did not find the operator for given MSISDN') !== -1;\n\n if (cannotDetect || hlrError) {\n const submissionError = new Error(`Error in submitMSISDN() identify action`) as IError & { msisdn: string };\n submissionError.type = 'FlowDetectFailed';\n submissionError.msisdn = msisdn;\n throw submissionError;\n } else if (flow !== null) {\n const flowObj = { operator: theResult.operator, default: defaultFlowConfig, ...flow };\n // @ts-ignore\n return flowObj;\n } else if (flow === null) {\n const flowObj = { operator: theResult.operator, ...defaultFlowConfig };\n // @ts-ignore\n return flowObj;\n } else {\n const submissionError = new Error(`Error in submitMSISDN() identify action`) as IError;\n submissionError.type = 'SEInvalidMSISDN';\n throw submissionError;\n }\n}\n\nexport function determineFlowByOperator({ configs, operator }: { configs: IStrategy; operator: string }): IFlow {\n const defaultFlowConfig = configs?.strategyConfigs?.default;\n const operatorsConfig = configs?.strategyConfigs?.operators;\n\n const flowObj = {\n operator: operator?.toUpperCase(),\n default: defaultFlowConfig,\n ...operatorsConfig[operator?.toUpperCase()]\n };\n // @ts-ignore\n return flowObj;\n}\n\nexport async function determineFlowByOperatorFromIp({\n window,\n configs\n}: {\n window: Window;\n configs: IStrategy;\n}): Promise<IFlow> {\n const operator = await tryGetIPRangeName(window.pac_analytics.visitor);\n const flowObj = determineFlowByOperator({\n configs,\n operator: operator ? operator.toUpperCase() : ''\n });\n return flowObj;\n}\n\nexport function getOperators({ configs }: { configs: IStrategy }): Array<string> {\n const operatorsConfig = configs?.strategyConfigs?.operators;\n const operators = Object.keys(operatorsConfig);\n return operators;\n}\n\nexport const subscribe: (_url: string) => Promise<string> = async (_url: string) =>\n // const result:ISubscribeResult = await fetch(url + \"&operator=kw_viva\").then((x)=>x.json())\n\n // if(false === result.success){\n // const subscribeError = new Error(`Error in subscribe() one-click-subscribe action:\\n${result.message}`) as IError & {type:string;}\n // subscribeError['type'] = \"SubscriptionError\";\n // throw subscribeError\n // }else{\n '/product';\n// }\n\nexport function mockConfig({ configs, flow }: { configs: IStrategy; flow: string }): IConfig {\n const defaultFlowConfig = configs?.strategyConfigs?.default;\n const operatorsConfig = configs?.strategyConfigs?.operators;\n const opArr = Object.keys(operatorsConfig);\n const r = opArr.filter((o) => operatorsConfig[o].flow === flow);\n const operator = r[0];\n const flowObj = { offer: '1', operator, default: defaultFlowConfig, ...operatorsConfig[operator] };\n\n return flowObj;\n}\n\n// export const mockedPinFlow: StrategyState = {\n// currentState: {\n// type: PossibleTypes.PIN,\n// result: RDS.NothingYet(),\n// data: {\n// config: mockConfig('pin')\n// }\n// }\n// };\n\n// export const mockedMoFlow: StrategyState = {\n// currentState: {\n// type: PossibleTypes.MO,\n// result: RDS.NothingYet(),\n// data: {\n// config: mockConfig('mo')\n// }\n// }\n// };\n\n// export const mockedUssdFlow: StrategyState = {\n// currentState: {\n// type: PossibleTypes.USSD,\n// result: RDS.NothingYet(),\n// data: {\n// config: mockConfig('ussd')\n// }\n// }\n// };\n\n// export const mockedMoRdirFlow: StrategyState = {\n// currentState: {\n// type: PossibleTypes.MO_REDIR,\n// result: RDS.NothingYet(),\n// data: {\n// config: mockConfig('moRedir')\n// }\n// }\n// };\n\n// export const mockedClick2smsFlow: StrategyState = {\n// currentState: {\n// type: PossibleTypes.CLICK2SMS,\n// result: RDS.NothingYet(),\n// data: {\n// config: mockConfig('click2sms')\n// }\n// }\n// };\n\n// export const mockedOneClickFlow: StrategyState = {\n// currentState: {\n// type: PossibleTypes.ONE_CLICK,\n// result: RDS.NothingYet(),\n// data: {\n// config: mockConfig('oneClick')\n// }\n// }\n// };\n\n// export const mockedCreditCardFlow: StrategyState = {\n// currentState: {\n// type: PossibleTypes.CREDIT_CARD,\n// result: RDS.NothingYet(),\n// data: {\n// config: mockConfig('creditCard')\n// }\n// }\n// };\n// export const mockedMOFlow : State = { type: \"MO\", result:moFlow(mockTracker, mockConfig(\"mo\"))}\n// export const mockedOneClickFlow : State = { type: \"ONECLICK\", result:oneClickFlow(mockTracker, mockConfig(\"oneClick\"), {\"testextraparams\":\"1\"})}\n// export const mockedClick2smsFlow : State = { type: \"CLICK2SMS\", result:click2smsFlow(mockTracker, mockConfig(\"click2sms\"))}\n// export const mockedMORedirFlow : State = { type: \"MOREDIR\", result:moRedirFlow(mockTracker, mockConfig(\"moRedir\"))}\n","import { createAsyncThunk } from '@reduxjs/toolkit';\nimport * as RDS from '../../../common-types/RemoteDataState';\nimport { getConfig } from '../../../utilities/getConfig';\nimport { tracker } from '../../../utilities/tracker';\n\nimport {\n IDENTIFYMSISDNEntryErrorTypes,\n IFlow,\n PossibleTypes,\n StrategyCurrentState\n} from '../../../sharedFlowTypes/StrategyTypes';\nimport { determineFlowByMsidn } from '../main';\n\nexport const askMobileNumber = (): StrategyCurrentState => ({\n type: PossibleTypes.IDENTIFY_FLOW_BY_MSISDN,\n result: RDS.NothingYet()\n});\n\nexport const submitMSISDNAction = createAsyncThunk(\n 'strategy/submitMSISDNAction',\n async (\n {\n window,\n msisdn\n }: {\n window: Window;\n msisdn: string;\n isHeSuccess?: boolean;\n },\n { rejectWithValue }\n ) => {\n try {\n const configs = getConfig();\n const { strategy } = configs;\n const flowObj = await determineFlowByMsidn({ window, internationalMSISDN: msisdn, configs });\n\n switch (strategy) {\n case 'pin-mo-redir-ask-mobile-number':\n return pinMoRedirAskMobileNumber(flowObj, msisdn);\n case 'pin-mo-ask-mobile-number':\n return pinMoAskMobileNumber(flowObj, msisdn);\n case 'pin-combo-ask-mobile-number':\n return pinComboAskMobileNumber(flowObj, msisdn);\n case 'mo-redir-mo-click2sms-one-click-detect-operator-by-ip-or-msisdn':\n return moRedirMoClick2smsOneClickDetectOperatorByIpOrMsisdn(flowObj, msisdn);\n case 'pin-mo-mo-redir-ask-mobile-number':\n return pinMoMoRedirAskMobileNumber(flowObj, msisdn);\n case 'pin-click2sms-ask-mobile-number':\n return pinClick2smsAskMobileNumber(flowObj, msisdn);\n default:\n return rejectWithValue('Unknown strategy');\n }\n } catch (ex) {\n let errorType: IDENTIFYMSISDNEntryErrorTypes;\n switch (ex.type) {\n case 'SEAlreadySubscribed':\n errorType = 'AlreadySubscribed';\n break;\n case 'SEInvalidMSISDN':\n errorType = 'InvalidMSISDN';\n break;\n default:\n errorType = 'UnknownError';\n }\n return rejectWithValue({\n errorType,\n error: ex,\n productUrl: ex.productUrl\n });\n }\n }\n);\n\nexport const headerEnrichmentScript = (flowObj: IFlow, msisdn: string, isHeaderEnrichmentSuccess: boolean) => {\n switch (flowObj.flow) {\n case 'pin':\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn,\n isHeaderEnrichmentSuccess,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n\n case 'mo':\n tracker.sendOptInFlowEvent('Msisdn to sms');\n return {\n type: PossibleTypes.MO,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn,\n isHeaderEnrichmentSuccess,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n\n case 'moRedir':\n tracker.sendOptInFlowEvent('Redirect');\n return {\n type: PossibleTypes.MO_REDIR,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn,\n isHeaderEnrichmentSuccess\n }\n };\n\n default:\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n }\n};\n\nexport const pinMoAskMobileNumber = (flowObj: IFlow, msisdn: string) => {\n switch (flowObj.flow) {\n case 'pin':\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n\n case 'mo':\n tracker.sendOptInFlowEvent('Msisdn to sms');\n return {\n type: PossibleTypes.MO,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n default:\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n }\n};\n\nexport const pinComboAskMobileNumber = (flowObj: IFlow, msisdn: string) => {\n switch (flowObj.flow) {\n case 'pin':\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n default:\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n };\n }\n};\n\nconst pinMoRedirAskMobileNumber = (flowObj: IFlow, msisdn: string): StrategyCurrentState => {\n switch (flowObj.flow) {\n case 'pin':\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n case 'moRedir':\n tracker.sendOptInFlowEvent('Redirect');\n return {\n type: PossibleTypes.MO_REDIR,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig\n }\n };\n default:\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig\n }\n };\n }\n};\n\nconst pinMoMoRedirAskMobileNumber = (flowObj: IFlow, msisdn: string): StrategyCurrentState => {\n switch (flowObj.flow) {\n case 'pin':\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n case 'moRedir':\n tracker.sendOptInFlowEvent('Redirect');\n\n return {\n type: PossibleTypes.MO_REDIR,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n case 'mo':\n tracker.sendOptInFlowEvent('Msisdn to sms');\n return {\n type: PossibleTypes.MO,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n default:\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig\n }\n };\n }\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental\nconst oneClickMoPinDetectOperatorByIpOrMsisdn = (flowObj: IFlow, msisdn: string): StrategyCurrentState => {\n switch (flowObj.flow) {\n case 'oneClick':\n tracker.sendOptInFlowEvent('3G click');\n return {\n type: PossibleTypes.ONE_CLICK,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n\n case 'mo':\n tracker.sendOptInFlowEvent('Msisdn to sms');\n return {\n type: PossibleTypes.MO,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n\n default:\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n rockman_id: flowObj.rockman_id\n }\n };\n }\n};\n\nexport const moRedirMoClick2smsOneClickDetectOperatorByIpOrMsisdn = (\n flowObj: IFlow,\n msisdn: string\n): StrategyCurrentState => {\n switch (flowObj.flowOnWifi) {\n case 'moRedir':\n tracker.sendOptInFlowEvent('Redirect');\n return {\n type: PossibleTypes.MO_REDIR,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n case 'mo':\n tracker.sendOptInFlowEvent('Msisdn to sms');\n return {\n type: PossibleTypes.MO,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n default:\n tracker.sendOptInFlowEvent('Redirect');\n return {\n type: PossibleTypes.MO_REDIR,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n rockman_id: flowObj.rockman_id\n }\n };\n }\n};\nexport const pinClick2smsAskMobileNumber = (flowObj: IFlow, msisdn: string): StrategyCurrentState => {\n switch (flowObj.flow) {\n case 'pin':\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n case 'click2sms':\n tracker.sendOptInFlowEvent('Click to sms');\n return {\n type: PossibleTypes.CLICK2SMS,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n msisdn\n }\n };\n\n default:\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.CLICK2SMS,\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig\n }\n };\n }\n};\n","import { createAsyncThunk } from '@reduxjs/toolkit';\nimport * as RDS from '../../../common-types/RemoteDataState';\n\nimport { PossibleTypes, StrategyCurrentState } from '../../../sharedFlowTypes/StrategyTypes';\nimport { getConfig } from '../../../utilities/getConfig';\nimport { tracker } from '../../../utilities/tracker';\nimport { determineFlowByOperator, getOperators } from '../main';\n\nexport const askOperator = (): StrategyCurrentState => {\n const configs = getConfig();\n const operators = getOperators({ configs });\n return {\n type: PossibleTypes.IDENTIFY_FLOW_BY_OPERATOR_SELECT,\n result: RDS.NothingYet(),\n data: {\n operators\n }\n };\n};\n\nexport const selectOperatorAction = createAsyncThunk(\n 'strategy/selectOperatorAction',\n async (\n {\n operator\n }: {\n operator: string;\n },\n { rejectWithValue }\n ) => {\n try {\n const configs = getConfig();\n\n const flowObj = determineFlowByOperator({\n configs,\n operator\n });\n\n switch (flowObj.flow) {\n case 'pin':\n tracker.sendOptInFlowEvent('Pin');\n return {\n type: PossibleTypes.PIN,\n result: {\n config: flowObj.flowConfig,\n operator\n }\n };\n case 'mo':\n tracker.sendOptInFlowEvent('Msisdn to sms');\n return {\n type: PossibleTypes.MO,\n result: {\n config: flowObj.flowConfig,\n operator\n }\n };\n case 'click2sms':\n tracker.sendOptInFlowEvent('Click to sms');\n return {\n type: PossibleTypes.CLICK2SMS,\n result: {\n config: {\n operators: [operator],\n ...flowObj.flowConfig\n },\n operator\n }\n };\n case 'oneClick':\n tracker.sendOptInFlowEvent('3G click');\n return {\n type: PossibleTypes.ONE_CLICK,\n result: {\n config: flowObj.flowConfig,\n operator,\n autoRedirect: true\n }\n };\n default:\n tracker.sendOptInFlowEvent('Pin');\n\n return {\n type: PossibleTypes.PIN,\n result: RDS.NothingYet()\n };\n }\n } catch (ex) {\n const errorType = 'UnkownError';\n return rejectWithValue({\n errorType,\n error: ex.toString()\n });\n }\n }\n);\n","import * as RDS from '../../../common-types/RemoteDataState';\n\nimport { IOptInFlowName } from '../../../common-types/IOptInFlowName';\nimport { ISupportedFlows, PossibleTypes } from '../../../sharedFlowTypes/StrategyTypes';\nimport { getConfig } from '../../../utilities/getConfig';\nimport { tracker } from '../../../utilities/tracker';\nimport { determineFlowByOperatorFromIp } from '../main';\n\n// @ts-ignore\nconst trackerEventMapping: Record<ISupportedFlows, IOptInFlowName> = {\n mo: 'Msisdn to sms',\n pin: 'Pin',\n oneClick: '3G click',\n moRedir: 'Redirect',\n click2sms: 'Click to sms',\n ussd: 'Msisdn to sms'\n};\n\nconst flowMapping: Record<ISupportedFlows, PossibleTypes> = {\n mo: PossibleTypes.MO,\n pin: PossibleTypes.PIN,\n oneClick: PossibleTypes.ONE_CLICK,\n moRedir: PossibleTypes.MO_REDIR,\n click2sms: PossibleTypes.CLICK2SMS,\n ussd: PossibleTypes.USSD,\n creditCard: PossibleTypes.CREDIT_CARD\n};\nconst detectOperatorByIp = async () => {\n try {\n const configs = getConfig();\n\n const flowObj = await determineFlowByOperatorFromIp({\n window,\n configs\n });\n const getTrackerEventName = (flowType: ISupportedFlows) => trackerEventMapping[flowType];\n\n const flowType = flowObj.flow;\n const event = getTrackerEventName(flowType);\n\n tracker.sendOptInFlowEvent(event);\n\n return {\n type: flowMapping[flowType],\n result: RDS.NothingYet(),\n data: {\n config: flowObj.flowConfig,\n operator: flowObj.operator\n }\n };\n } catch (ex) {\n console.error('SSSSS', ex);\n }\n};\n\nexport { detectOperatorByIp };\n","import { IOptInFlowName } from '../../../common-types/IOptInFlowName';\nimport * as RDS from '../../../common-types/RemoteDataState';\nimport { IConfig, IFlow, IScriptHeaderEnrichmentSuccess, PossibleTypes } from '../../../sharedFlowTypes/StrategyTypes';\nimport { getConfig } from '../../../utilities/getConfig';\nimport loadScriptSrc from '../../../utilities/loadScriptSrc';\nimport { tracker } from '../../../utilities/tracker';\nimport { determineFlowByOperator } from '../main';\n\nconst countryToPhoneCode: Record<string, string> = {\n AE: '971', // United Arab Emirates\n BH: '973', // Bahrain\n CI: '225', // Côte d'Ivoire (Ivory Coast)\n SN: '221', // Senegal\n KW: '965', // Kuwait\n AT: '43', // Austria\n CZ: '420', // Czech Republic\n OM: '968', // Oman\n PK: '92', // Pakistan\n PE: '51' // Peru\n};\n\n/**\n * Creates a response object with the given parameters.\n *\n * @param {string} msisdn - The MSISDN (Mobile Station International Subscriber Directory Number).\n * @param {IConfig} config - The configuration object.\n * @param {string | null} operator - The operator (default: null).\n * @return {object} The response that sets the state.\n */\nconst createResponseObject = (msisdn: string, config: IConfig, operator: string | null = null) => ({\n type: PossibleTypes.IDENTIFY_FLOW_BY_MSISDN,\n result: RDS.NothingYet(),\n data: {\n config,\n msisdn,\n operator\n }\n});\n/**\n * Formats a phone number to E.164 format.\n *\n * @param {string} number - The phone number to format.\n * @param {string} isoCountryCode - The ISO country code of the phone number.\n * @return {string} The formatted phone number in E.164 format.\n */\nfunction formatNumberToE164(number: string, isoCountryCode: string) {\n const phoneCode = countryToPhoneCode[isoCountryCode.toUpperCase()];\n if (!phoneCode) {\n throw new Error(`Phone code not found for country code: ${isoCountryCode}`);\n }\n\n const cleanNumber = number.replace(/\\D/g, '');\n if (!cleanNumber.startsWith(phoneCode)) {\n return `${phoneCode}${cleanNumber}`;\n }\n return `${cleanNumber}`;\n}\n\n/**\n * Injects header enrichment script based on the provided window object.\n *\n * @param {Window} window - The window object containing analytics visitor details.\n * @return {Promise} A promise that resolves based on specific events or timeouts.\n */\nconst injectHeaderEnrichmentScript = async ({ window }: { window: Window }) => {\n const { strategyConfigs } = getConfig();\n const config = strategyConfigs?.default?.flowConfig;\n\n try {\n const gateway = window?.pac_analytics?.visitor?.genericJsLinkResult?.gateway;\n\n const page = window?.pac_analytics?.visitor?.page;\n let heMsisdn = window?.pac_analytics?.visitor?.heMsisdn;\n const country = window?.pac_analytics?.visitor?.country;\n\n if (heMsisdn && country) {\n heMsisdn = formatNumberToE164(heMsisdn, country);\n }\n\n // START ABTEST\n let msisdnDetected = false;\n let timerExpired = false;\n\n const abTestPages = [\n 'ae-fl-infomedia-evina-hetest',\n 'ae-video-beyondvr-he-test',\n 'ae-video-beyondvr-3sec-hetest',\n 'ae-beyondvr-fileready-he-3sec',\n 'ae-video-beyondvr-he-timer',\n 'ae-video-beyondvr-cta-visible'\n ];\n\n const timerId: string | number | NodeJS.Timeout = setTimeout(() => {\n if (msisdnDetected === false) {\n timerExpired = true;\n tracker.customEvent('Flow', 'recede-auto', 'msisdn-detection-failure', {\n errorType: '3 second timer expired'\n });\n\n window.isPrelanderClicked = true;\n\n return {\n type: PossibleTypes.PIN,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n }\n }, 3000);\n\n // END ABTEST\n\n // Normal HE Sript which calls the Tallyman /he API endpoint to detect the msisdn\n // The result of the API call is an event that will be dispatched with the msisdn\n\n if (gateway !== 'tpay' && !heMsisdn) {\n const host = window.DEV_BASE_HE_SCRIPT_URL || '';\n const url = `${host}/tallyman/he?country=${window?.pac_analytics?.visitor?.country}&rockman_id=${window?.pac_analytics?.visitor?.rockmanId}`;\n\n tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-start', { url });\n loadScriptSrc({\n url,\n callBack: () => {\n tracker.customEvent('Flow', 'recede-auto', 'msisdn-detection-failure', {\n errorType: 'Could not load script possible reason is page is https and script is http'\n });\n return createResponseObject(null, config);\n },\n id: 'he-script'\n });\n } else {\n // resolve(createResponseObject(heMsisdn, config));\n }\n\n // End normal HE Script\n\n // Set up a promise for the 'he-success' event\n window.addEventListener('he-success', (event: IScriptHeaderEnrichmentSuccess) => {\n const { detail } = event as IScriptHeaderEnrichmentSuccess;\n let msisdn;\n if (detail.msisdn) {\n heMsisdn = formatNumberToE164(detail.msisdn, country);\n }\n // ABTEST: ae-video-beyondvr-he-test\n if (abTestPages.includes(page)) {\n if (timerExpired === false) {\n msisdnDetected = true;\n clearTimeout(timerId);\n\n tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {\n msisdn\n });\n const flowObj = determineFlowByOperator({\n configs: getConfig(),\n operator: detail?.operator_code\n });\n return headerEnrichmentScript(flowObj, msisdn, true);\n }\n // END ABTEST\n } else {\n tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {\n msisdn,\n operator: detail?.operator_code\n });\n const flowObj = determineFlowByOperator({\n configs: getConfig(),\n operator: detail?.operator_code\n });\n return headerEnrichmentScript(flowObj, msisdn, true);\n }\n return createResponseObject(heMsisdn, config);\n });\n\n // Set up a promise for the 'he-fail' event\n window.addEventListener('he-fail', () => createResponseObject(null, config));\n\n // Promise.race to handle whichever comes first\n // return Promise.race([loadScriptPromise, heSuccessPromise, heFailurePromise, timeoutPromise]);\n } catch (err) {\n console.error('Error in header enrichment:', err);\n return createResponseObject(null, config);\n }\n};\n\nconst headerEnrichmentScript = (flowObj: IFlow, msisdn: string, isHeaderEnrichmentSuccess: boolean) => {\n // eslint-disable-next-line no-console\n console.log('flowObj', flowObj);\n const preparePayload = (type: string) => ({\n type,\n result: {\n config: flowObj.flowConfig,\n msisdn,\n isHeaderEnrichmentSuccess,\n rockman_id: flowObj.rockman_id,\n ...(flowObj.operator && { operator: flowObj.operator })\n }\n });\n\n // Determine the event name and additional data based on flow type\n let eventName: IOptInFlowName = 'Pin'; // default event name\n switch (flowObj.flow) {\n case 'pin':\n eventName = 'Pin';\n break;\n case 'mo':\n eventName = 'Msisdn to sms';\n break;\n case 'moRedir':\n eventName = 'Redirect';\n break;\n default:\n break;\n }\n\n tracker.sendOptInFlowEvent(eventName);\n return preparePayload(flowObj.flow);\n};\n\nexport { injectHeaderEnrichmentScript };\n","import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit';\nimport * as RDS from '../../common-types/RemoteDataState';\nimport { searchToObject } from '../../utilities/searchToObject';\n\nimport {\n IMockFlowParams,\n IMockPinFlowStates,\n PossibleTypes,\n RootState,\n StrategyCurrentState,\n StrategyState\n} from '../../sharedFlowTypes/StrategyTypes';\nimport { getConfig } from '../../utilities/getConfig';\nimport { determineFlowByOperator } from './main';\nimport { askMobileNumber, submitMSISDNAction } from './strategies/askMobileNumber';\nimport { askOperator, selectOperatorAction } from './strategies/askOperator';\n\nimport { detectOperatorByIp } from './strategies/detectOperatorByIp';\nimport { injectHeaderEnrichmentScript } from './strategies/injectHeaderEnrichmentScript';\n\nconst initialState: StrategyState = {\n currentState: {\n type: PossibleTypes.IDENTIFY_STRATEGY,\n result: RDS.NothingYet(),\n data: undefined\n }\n};\n\nconst mockStrategyStateByUrlParam = (): StrategyCurrentState => {\n const search = searchToObject(window) as IMockFlowParams<any>;\n\n if (search['mock-flow'] !== undefined) {\n if (search.operator !== undefined) {\n window.operator = search.operator;\n }\n\n switch (search['mock-flow']) {\n case 'pin':\n return {\n type: PossibleTypes.PIN,\n result: RDS.Success({})\n };\n\n case 'mo':\n return {\n type: PossibleTypes.MO,\n result: RDS.Success({})\n };\n case 'moredir':\n return {\n type: PossibleTypes.MO_REDIR,\n result: RDS.Success({})\n };\n case 'oneclick':\n return {\n type: PossibleTypes.ONE_CLICK,\n result: RDS.Success({}),\n data: {\n subscription_url: search['subscription-url']\n }\n };\n case 'click2sms':\n return {\n type: PossibleTypes.CLICK2SMS,\n result: RDS.Success({})\n };\n case 'ussd':\n return {\n type: PossibleTypes.USSD,\n result: RDS.Success({})\n };\n case 'creditcard':\n return {\n type: PossibleTypes.CREDIT_CARD,\n result: RDS.Success({})\n };\n default:\n throw new Error('(mockStrategyStateByUrlParam) Strategy Mock Flow not supported');\n }\n }\n};\n\n/**\n * Identify Strategy\n * @returns {type: 'strategy/identifyStrategy', payload: {type: PossibleTypes.MO, result: IdentifyFlowOptionsResult}}\n * - Add type\n * - Makes a decision on which strategy to use in order to identify the flow\n * - Strategy could be asking user's phone number, selecting an operator etc\n * - all with the intension of getting the flow and its configuration\n * - Flows are usually tied to an operator in the pages config.json\n * - But they could also be single flows\n *\n */\n\nexport const identifyStrategy = createAsyncThunk('strategy/identifyStrategy', async () => {\n const configs = getConfig();\n const { strategy, strategyConfigs } = configs;\n // const { isUseMsisdnPrefix } = strategyConfigs;\n const search = searchToObject(window) as IMockFlowParams<IMockPinFlowStates>;\n if (search['mock-flow'] !== undefined) {\n return mockStrategyStateByUrlParam();\n }\n if (\n (search['show-pin-entry'] && search['show-pin-entry'] === '1') ||\n (search['show-thank-you'] && search['show-thank-you'] === '1')\n ) {\n const flowObj = determineFlowByOperator({\n configs,\n operator: search.operator\n });\n const strategyResult: StrategyCurrentState = {\n type: PossibleTypes.PIN,\n result: RDS.Success({}),\n data: {\n config: flowObj?.flowConfig || strategyConfigs?.default?.flowConfig\n }\n };\n return strategyResult;\n }\n\n if (strategy.includes('ask-operator')) {\n return askOperator();\n }\n if (strategy.includes('detect-operator-by-ip')) {\n return detectOperatorByIp();\n }\n if (strategy?.includes('ask-mobile-number')) {\n return askMobileNumber();\n }\n\n switch (strategy) {\n case 'header-enrichment-script':\n // eslint-disable-next-line no-return-await\n return injectHeaderEnrichmentScript({\n window\n });\n case 'pin': {\n return {\n type: PossibleTypes.PIN,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n }\n case 'mo':\n return {\n type: PossibleTypes.MO,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n case 'mo-redir':\n return {\n type: PossibleTypes.MO_REDIR,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n case 'one-click':\n return {\n type: PossibleTypes.ONE_CLICK,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n case 'click2sms':\n return {\n type: PossibleTypes.CLICK2SMS,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n case 'ussd':\n return {\n type: PossibleTypes.USSD,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n case 'credit-card':\n return {\n type: PossibleTypes.CREDIT_CARD,\n result: RDS.Success({}),\n data: {\n config: strategyConfigs?.default?.flowConfig\n }\n };\n default:\n throw new Error('Strategy not supported');\n }\n});\n\nexport const setStrategyExtraData = createAsyncThunk(\n 'strategy/setStrategyExtraData',\n async ({ type, data }: { type: PossibleTypes; data: any }) => ({\n type,\n result: RDS.NothingYet(),\n data\n })\n);\n\nexport const strategySlice = createSlice({\n name: 'strategy',\n initialState,\n reducers: {\n // Define synchronous reducers as needed\n },\n extraReducers: (builder) => {\n // @ts-ignore\n builder\n .addCase(identifyStrategy.pending, (state) => {\n state.currentState = {\n type: PossibleTypes.IDENTIFY_STRATEGY,\n result: RDS.Loading()\n };\n })\n // @ts-ignore\n .addCase(identifyStrategy.fulfilled, (state, action: PayloadAction<StrategyCurrentState>) => {\n state.currentState = action.payload;\n })\n .addCase(identifyStrategy.rejected, (state, action) => {\n state.currentState = {\n type: PossibleTypes.IDENTIFY_STRATEGY,\n result: RDS.Failure(action.error.message)\n };\n })\n .addCase(submitMSISDNAction.pending, (state) => {\n state.currentState = {\n type: PossibleTypes.IDENTIFY_FLOW_BY_MSISDN,\n result: RDS.Loading()\n };\n })\n .addCase(submitMSISDNAction.fulfilled, (state, action: PayloadAction<StrategyCurrentState>) => {\n state.currentState = action.payload;\n })\n .addCase(submitMSISDNAction.rejected, (state, action) => {\n state.currentState = {\n type: PossibleTypes.IDENTIFY_FLOW_BY_MSISDN,\n result: RDS.Failure(action.payload)\n };\n })\n .addCase(setStrategyExtraData.fulfilled, (state, action) => {\n state.currentState = action.payload;\n })\n .addCase(selectOperatorAction.pending, (state) => {\n state.currentState = {\n type: PossibleTypes.IDENTIFY_FLOW_BY_OPERATOR_SELECT,\n result: RDS.Loading()\n };\n })\n .addCase(selectOperatorAction.fulfilled, (state, action: PayloadAction<any>) => {\n state.currentState = action.payload;\n })\n .addCase(selectOperatorAction.rejected, (state, action) => {\n state.currentState = {\n type: PossibleTypes.IDENTIFY_FLOW_BY_OPERATOR_SELECT,\n result: RDS.Failure(action.payload)\n };\n });\n }\n});\n\nexport const selectStrategyState = (state: RootState) => state.strategy;\nexport const strategyReducer = strategySlice.reducer;\n"],"names":["PossibleTypes","identify","_a","window","slug","country","msisdn","device","offer","rockmanId","languageCode","concat","locationHref","encodeURIComponent","location","href","host","DEV_BASE_URL","urlParams","URLSearchParams","action","offerId","rockman_id","page","language_code","toString","url","fetch","_b","sent","json","determineFlowByMsidn","internationalMSISDN","configs","submissionError","Error","type","match","join","defaultFlowConfig","_c","strategyConfigs","default","config","flowConfig","operatorsConfig","_d","operators","indentifyFlow","__awaiter","_this","pac_analytics","visitor","theResult","_f","flow","operator","cannotDetect","success","message","hlrError","_e","indexOf","__assign","determineFlowByOperator","toUpperCase","determineFlowByOperatorFromIp","tryGetIPRangeName","submitMSISDNAction","createAsyncThunk","rejectWithValue","getConfig","strategy","flowObj","pinMoRedirAskMobileNumber","pinMoAskMobileNumber","pinComboAskMobileNumber","moRedirMoClick2smsOneClickDetectOperatorByIpOrMsisdn","pinMoMoRedirAskMobileNumber","pinClick2smsAskMobileNumber","errorType","ex_1","error","productUrl","tracker","sendOptInFlowEvent","PIN","result","RDS.NothingYet","data","MO","MO_REDIR","flowOnWifi","CLICK2SMS","askOperator","Object","keys","getOperators","IDENTIFY_FLOW_BY_OPERATOR_SELECT","selectOperatorAction","ONE_CLICK","autoRedirect","ex","trackerEventMapping","mo","pin","oneClick","moRedir","click2sms","ussd","flowMapping","USSD","creditCard","CREDIT_CARD","countryToPhoneCode","AE","BH","CI","SN","KW","AT","CZ","OM","PK","PE","createResponseObject","IDENTIFY_FLOW_BY_MSISDN","formatNumberToE164","number","isoCountryCode","phoneCode","cleanNumber","replace","startsWith","injectHeaderEnrichmentScript","gateway","genericJsLinkResult","page_1","_g","heMsisdn_1","_j","_h","heMsisdn","country_1","_l","_k","msisdnDetected_1","timerExpired_1","abTestPages_1","timerId_1","setTimeout","customEvent","isPrelanderClicked","RDS.Success","DEV_BASE_HE_SCRIPT_URL","_m","_o","_q","_p","loadScriptSrc","callBack","id","addEventListener","event","detail","includes","operator_code","headerEnrichmentScript","clearTimeout","err","console","isHeaderEnrichmentSuccess","log","eventName","initialState","currentState","IDENTIFY_STRATEGY","undefined","mockStrategyStateByUrlParam","search","searchToObject","subscription_url","identifyStrategy","getTrackerEventName","flowType","event_1","setStrategyExtraData","strategyReducer","createSlice","name","reducers","extraReducers","builder","addCase","pending","state","RDS.Loading","fulfilled","payload","rejected","RDS.Failure","reducer"],"mappings":"+bAoKYA,GAAZ,SAAY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,SAACF,EAAO/K,GAC7C+K,EAAMpB,aAAe3J,EAAOkL,OAC9B,IACCL,QAAQ7H,EAAmBmI,UAAU,SAACJ,EAAO/K,GAC5C+K,EAAMpB,aAAe,CACnB3I,KAAMpC,EAAc8H,wBACpBvC,OAAQiH,EAAYpL,EAAOkL,SAE/B,IACCL,QAAQP,EAAqBW,WAAW,SAACF,EAAO/K,GAC/C+K,EAAMpB,aAAe3J,EAAOkL,OAC9B,IACCL,QAAQ9F,EAAqB+F,SAAS,SAACC,GACtCA,EAAMpB,aAAe,CACnB3I,KAAMpC,EAAckG,iCACpBX,OAAQ6G,IAEZ,IACCH,QAAQ9F,EAAqBkG,WAAW,SAACF,EAAO/K,GAC/C+K,EAAMpB,aAAe3J,EAAOkL,OAC9B,IACCL,QAAQ9F,EAAqBoG,UAAU,SAACJ,EAAO/K,GAC9C+K,EAAMpB,aAAe,CACnB3I,KAAMpC,EAAckG,iCACpBX,OAAQiH,EAAYpL,EAAOkL,SAE/B,GACH,IAI0CG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as n}from"tslib";import e from"pacman-client";import{v1 as a}from"uuid";var c=function(n,e){var a=e.replace(/[\]]/g,"\\$&"),c=new RegExp("[?&]".concat(a,"(=([^&#]*)|&|#|$)"),"i").exec(n);return c?c[2]?decodeURIComponent(c[2].replace(/\+/g," ")):"":null};function r(n,e,a){var c=n.indexOf("#"),r=-1===c?"":n.substr(c),t=n;t=-1===c?t:t.substr(0,c);var o=new RegExp("([?&])".concat(e,"=.*?(&|$)"),"i"),i=-1!==t.indexOf("?")?"&":"?";return t=t.match(o)?t.replace(o,"$1".concat(e,"=").concat(a,"$2")):t.endsWith("&")?"".concat(t+e,"=").concat(a):"".concat(t+i+e,"=").concat(a),"".concat(t+r,"&")}var t=function(r,t,o){if(!r)return{advancedInFlow:function(){},advancedInPreFlow:function(){},recedeInFlow:function(){},customEvent:function(){},sendOptInFlowEvent:function(){}};var i=r.pac_analytics?r.pac_analytics.url:c(r.location.search,"pacman-server")||"/analytics";if(!r.pac_analytics){var s=a().replace(/-/g,""),l=parseInt(c(r.location.search,"cid")||"0",10)||2;r.pac_analytics={visitor:{rockmanId:s,impressionNumber:1,country:process.env.country||"",page:process.env.page||"",xaid:c(r.location.search,"xaid")||r.xaid||"",cid:l,offer:c(r.location.search,"offer")||r.offer||"1"},startTime:(new Date).valueOf(),queryString:function(n){return c(r.location.search,n)||""},url:i,userId:s,encCampaignId:c(r.location.search,"xcid")||"",originalUrl:document.location.href}}var u=e.default({rockmanId:r.pac_analytics.visitor.rockmanId,serverUrl:process.env.pacman_server||i,impressionNumber:1,signalInterval:1e3});return n(n({},u.trackerFlowEvents),{sendOptInFlowEvent:u.sendOptInFlowEvent})}("undefined"!=typeof window?window:null);export{c as q,t,r as u};
|
|
2
|
+
//# sourceMappingURL=tracker-DaaILhEr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracker-DaaILhEr.js","sources":["../src/pacman/queryString.ts","../src/pacman/index.ts","../src/utilities/tracker.ts"],"sourcesContent":["export default (url: string, paramName: string) => {\n const name = paramName.replace(/[\\]]/g, '\\\\$&');\n const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`, 'i');\n const results = regex.exec(url);\n if (!results) return null;\n if (!results[2]) return '';\n return decodeURIComponent(results[2].replace(/\\+/g, ' '));\n};\n\nexport function updateUrlParameter(uri: string, key: string, value: string) {\n // remove the hash part before operating on the uri\n const i = uri.indexOf('#');\n const hash = i === -1 ? '' : uri.substr(i);\n let newUri = uri;\n newUri = i === -1 ? newUri : newUri.substr(0, i);\n\n const re = new RegExp(`([?&])${key}=.*?(&|$)`, 'i');\n const separator = newUri.indexOf('?') !== -1 ? '&' : '?';\n if (newUri.match(re)) {\n newUri = newUri.replace(re, `$1${key}=${value}$2`);\n } else {\n newUri = newUri.endsWith('&') ? `${newUri + key}=${value}` : `${newUri + separator + key}=${value}`;\n }\n return `${newUri + hash}&`; // finally append the hash as well\n}\n","import mkPacmanClient from 'pacman-client';\nimport { ITrackerFlowEvents } from 'pacman-client/.build-lib/Pacman/types';\n\nimport { v1 as uuid } from 'uuid';\nimport queryString from './queryString';\n\nexport { queryString };\nexport type { ITrackerFlowEvents as ITracker };\n\nexport default (window: Window, _country?: string, _page?: string): ITrackerFlowEvents => {\n if (!window) {\n return {\n advancedInFlow: () => void 6,\n advancedInPreFlow: () => void 6,\n recedeInFlow: () => void 6,\n customEvent: () => void 6,\n sendOptInFlowEvent: () => void 6\n };\n }\n const url = window.pac_analytics\n ? window.pac_analytics.url\n : queryString(window.location.search, 'pacman-server') || '/analytics';\n\n if (!window.pac_analytics) {\n const rockmanId = uuid().replace(/-/g, '');\n\n const campaignId = parseInt(queryString(window.location.search, 'cid') || '0', 10) || 2;\n window.pac_analytics = {\n visitor: {\n rockmanId,\n impressionNumber: 1, // TODO: get impressionNumber from localStorage\n country: process.env.country || '',\n page: process.env.page || '',\n xaid: queryString(window.location.search, 'xaid') || window.xaid || '',\n cid: campaignId,\n offer: queryString(window.location.search, 'offer') || window.offer || '1' // default to 1 offer id\n },\n startTime: new Date().valueOf(),\n queryString: (key: string) => queryString(window.location.search, key) || '',\n url,\n userId: rockmanId,\n encCampaignId: queryString(window.location.search, 'xcid') || '',\n originalUrl: document.location.href\n };\n }\n // @ts-ignore\n const pacmanClient = mkPacmanClient.default({\n rockmanId: window.pac_analytics.visitor.rockmanId,\n serverUrl: process.env.pacman_server || url,\n impressionNumber: 1,\n signalInterval: 1000 // in milliseconds\n });\n\n return {\n ...pacmanClient.trackerFlowEvents,\n sendOptInFlowEvent: pacmanClient.sendOptInFlowEvent\n };\n};\n","import mkTracker from '../pacman';\n\nexport const tracker = mkTracker(typeof window !== 'undefined' ? window : null);\n"],"names":["queryString","url","paramName","name","replace","results","RegExp","concat","exec","decodeURIComponent","updateUrlParameter","uri","key","value","i","indexOf","hash","substr","newUri","re","separator","match","endsWith","tracker","window","_country","_page","advancedInFlow","advancedInPreFlow","recedeInFlow","customEvent","sendOptInFlowEvent","pac_analytics","location","search","rockmanId","uuid","campaignId","parseInt","visitor","impressionNumber","country","process","env","page","xaid","cid","offer","startTime","Date","valueOf","userId","encCampaignId","originalUrl","document","href","pacmanClient","mkPacmanClient","default","serverUrl","pacman_server","signalInterval","__assign","trackerFlowEvents","mkTracker"],"mappings":"wFAAA,IAAAA,EAAe,SAACC,EAAaC,GAC3B,IAAMC,EAAOD,EAAUE,QAAQ,QAAS,QAElCC,EADQ,IAAIC,OAAO,OAAOC,OAAAJ,EAAuB,qBAAE,KACnCK,KAAKP,GAC3B,OAAKI,EACAA,EAAQ,GACNI,mBAAmBJ,EAAQ,GAAGD,QAAQ,MAAO,MAD5B,GADH,IAGtB,WAEeM,EAAmBC,EAAaC,EAAaC,GAE3D,IAAMC,EAAIH,EAAII,QAAQ,KAChBC,GAAc,IAAPF,EAAW,GAAKH,EAAIM,OAAOH,GACpCI,EAASP,EACbO,GAAgB,IAAPJ,EAAWI,EAASA,EAAOD,OAAO,EAAGH,GAE9C,IAAMK,EAAK,IAAIb,OAAO,SAASC,OAAAK,EAAc,aAAE,KACzCQ,GAAqC,IAAzBF,EAAOH,QAAQ,KAAc,IAAM,IAMrD,OAJEG,EADEA,EAAOG,MAAMF,GACND,EAAOd,QAAQe,EAAI,KAAAZ,OAAKK,EAAG,KAAAL,OAAIM,EAAK,OAEpCK,EAAOI,SAAS,KAAO,GAAGf,OAAAW,EAASN,EAAO,KAAAL,OAAAM,GAAU,GAAGN,OAAAW,EAASE,EAAYR,EAAO,KAAAL,OAAAM,GAEvF,UAAGK,EAASF,EAAO,IAC5B,CCfA,ICPaO,EDOb,SAAgBC,EAAgBC,EAAmBC,GACjD,IAAKF,EACH,MAAO,CACLG,eAAgB,WAAY,EAC5BC,kBAAmB,WAAY,EAC/BC,aAAc,WAAY,EAC1BC,YAAa,WAAY,EACzBC,mBAAoB,WAAY,GAGpC,IAAM9B,EAAMuB,EAAOQ,cACfR,EAAOQ,cAAc/B,IACrBD,EAAYwB,EAAOS,SAASC,OAAQ,kBAAoB,aAE5D,IAAKV,EAAOQ,cAAe,CACzB,IAAMG,EAAYC,IAAOhC,QAAQ,KAAM,IAEjCiC,EAAaC,SAAStC,EAAYwB,EAAOS,SAASC,OAAQ,QAAU,IAAK,KAAO,EACtFV,EAAOQ,cAAgB,CACrBO,QAAS,CACPJ,UAASA,EACTK,iBAAkB,EAClBC,QAASC,QAAQC,IAAIF,SAAW,GAChCG,KAAMF,QAAQC,IAAIC,MAAQ,GAC1BC,KAAM7C,EAAYwB,EAAOS,SAASC,OAAQ,SAAWV,EAAOqB,MAAQ,GACpEC,IAAKT,EACLU,MAAO/C,EAAYwB,EAAOS,SAASC,OAAQ,UAAYV,EAAOuB,OAAS,KAEzEC,WAAW,IAAIC,MAAOC,UACtBlD,YAAa,SAACY,GAAgB,OAAAZ,EAAYwB,EAAOS,SAASC,OAAQtB,IAAQ,EAAE,EAC5EX,IAAGA,EACHkD,OAAQhB,EACRiB,cAAepD,EAAYwB,EAAOS,SAASC,OAAQ,SAAW,GAC9DmB,YAAaC,SAASrB,SAASsB,KAElC,CAED,IAAMC,EAAeC,EAAeC,QAAQ,CAC1CvB,UAAWX,EAAOQ,cAAcO,QAAQJ,UACxCwB,UAAWjB,QAAQC,IAAIiB,eAAiB3D,EACxCuC,iBAAkB,EAClBqB,eAAgB,MAGlB,OACKC,EAAAA,EAAA,CAAA,EAAAN,EAAaO,mBAAiB,CACjChC,mBAAoByB,EAAazB,oBAEpC,CCvDsBiC,CAA4B,oBAAXxC,OAAyBA,OAAS"}
|
package/dist/tracker.js
CHANGED
package/dist/tracker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracker.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tracker.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__awaiter as n,__generator as e}from"tslib";import{q as o}from"./tracker-DaaILhEr.js";function t(t){return n(this,void 0,void 0,(function(){var n,r,i,a,c;return e(this,(function(e){switch(e.label){case 0:if(n=o(window.location.href,"mock-ip")||process.env.mock_ip,console.log("mockip",n),t.ip||"undefined"==typeof window)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),r=window.location.host,i=window.DEV_BASE_URL_IP||r,[4,fetch("https://".concat(i,"/api/v1/ip").concat(n?"?mock-ip=".concat(n):"")).then((function(n){return n.json()}))];case 2:return a=e.sent(),t.ip=a.ip,t.ip_range_name=a.ip_range_name,[2,a.ip_range_name];case 3:return c=e.sent(),console.warn("IP Lookup failed",c),[2,""];case 4:return[3,6];case 5:return[2,t.ip_range_name||""];case 6:return[2]}}))}))}export{t};
|
|
2
|
+
//# sourceMappingURL=tryGetIPRangeName-QW-9NgzE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tryGetIPRangeName-QW-9NgzE.js","sources":["../src/ips/tryGetIPRangeName.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { IVisitor } from '../common-types/IVisitor';\nimport queryString from '../pacman/queryString';\n\n// eslint-disable-next-line consistent-return\nexport default async function tryGetIPRangeName(visitor: IVisitor): Promise<string> {\n const mockip = queryString(window.location.href, 'mock-ip') || process.env.mock_ip;\n // eslint-disable-next-line no-console\n console.log('mockip', mockip);\n if (!visitor.ip && typeof window !== 'undefined') {\n try {\n const { host } = window.location;\n const newHost = window.DEV_BASE_URL_IP || host;\n const res = await fetch(`https://${newHost}/api/v1/ip${mockip ? `?mock-ip=${mockip}` : ''}`).then((x) =>\n x.json()\n );\n // return isIPInRange('37.200.146.28')\n visitor.ip = res.ip;\n visitor.ip_range_name = res.ip_range_name;\n return res.ip_range_name;\n } catch (ex) {\n console.warn('IP Lookup failed', ex);\n return '';\n }\n } else {\n return visitor.ip_range_name || '';\n }\n}\n"],"names":["tryGetIPRangeName","visitor","mockip","queryString","window","location","href","process","env","mock_ip","console","log","ip","host","newHost","DEV_BASE_URL_IP","fetch","concat","then","x","json","res","_a","sent","ip_range_name","warn","ex_1"],"mappings":"6FAK8B,SAAAA,EAAkBC,8GACxCC,EAASC,EAAYC,OAAOC,SAASC,KAAM,YAAcC,QAAQC,IAAIC,QAE3EC,QAAQC,IAAI,SAAUT,GACjBD,EAAQW,IAAwB,oBAAXR,OAAtB,MAA4C,CAAA,EAAA,oBAIhC,6BAFJS,EAAST,OAAOC,cAClBS,EAAUV,OAAOW,iBAAmBF,EACxB,CAAA,EAAAG,MAAM,WAAWC,OAAAH,uBAAoBZ,EAAS,YAAYe,OAAAf,GAAW,KAAMgB,MAAK,SAACC,GACjG,OAAAA,EAAEC,MAAM,YAKV,OANMC,EAAMC,EAEXC,OAEDtB,EAAQW,GAAKS,EAAIT,GACjBX,EAAQuB,cAAgBH,EAAIG,cACrB,CAAA,EAAAH,EAAIG,sBAGX,kBADAd,QAAQe,KAAK,mBAAoBC,GACjC,CAAA,EAAO,uBAGT,KAAA,EAAA,MAAA,CAAA,EAAOzB,EAAQuB,eAAiB,2BAEnC"}
|
|
@@ -19,7 +19,7 @@ declare type IGETREDIRECTURLFailure = {
|
|
|
19
19
|
declare type IGETREDIRECTURLSuccess = {
|
|
20
20
|
redirectUrl: string;
|
|
21
21
|
};
|
|
22
|
-
declare type SubscribeUserErrorTypes = 'SubscriptionError' | 'UnknownError' | 'AlreadySubscribed';
|
|
22
|
+
declare type SubscribeUserErrorTypes = 'SubscriptionError' | 'UnknownError' | 'AlreadySubscribed' | 'UnexpectedState';
|
|
23
23
|
declare type SubscribeSuccess = {
|
|
24
24
|
productUrl: string;
|
|
25
25
|
};
|
|
@@ -2,7 +2,7 @@ import { R as RemoteDataState } from './RemoteDataState-D1aFrz8W.js';
|
|
|
2
2
|
import { C as CreditCardFlowState } from './CreditCardTypes-B-IT-l6I.js';
|
|
3
3
|
import { e as MoRedirFlowState } from './MoRedirTypes-4tEJjT1g.js';
|
|
4
4
|
import { d as MoFlowState } from './MoTypes-D-UK92gs.js';
|
|
5
|
-
import { O as OneClickFlowState } from './OneClickTypes-
|
|
5
|
+
import { O as OneClickFlowState } from './OneClickTypes-DjOesaHp.js';
|
|
6
6
|
import { h as PinFlowState } from './PinTypes-BLJDBZe6.js';
|
|
7
7
|
import { U as UssdFlowState } from './UssdTypes-C7QlIW11.js';
|
|
8
8
|
|
|
@@ -285,6 +285,7 @@ interface IMockFlowParams<T> {
|
|
|
285
285
|
'show-thank-you': '1' | '0';
|
|
286
286
|
operator: string;
|
|
287
287
|
msisdn?: string;
|
|
288
|
+
'subscription-url'?: string;
|
|
288
289
|
}
|
|
289
290
|
interface IScriptHeaderEnrichmentSuccess extends CustomEvent {
|
|
290
291
|
detail: {
|
|
@@ -322,4 +323,4 @@ interface RootState {
|
|
|
322
323
|
creditCardFlow?: CreditCardFlowState;
|
|
323
324
|
}
|
|
324
325
|
|
|
325
|
-
export { type ILoadOc2click2smsPayload as $, type IIdentifyFlowByHePayload as A, type IIdentfyFlowByMsisdnNextAction as B, type ConfigDetails as C, type IIdentfyFlowByOperatorNextAction as D, type IIdentfyFlowByIPOperatorNextAction as E, type IIdenyifyFlowByMsisdnSumbitNextData as F, type IIdenyifyFlowByMsisdnPayload as G, type IIdenyifyStrategyPayload as H, type IDENTIFYMSISDNEntryFailure as I, type IStrategyCurrentState as J, type IStrategyIDentifyUserResult as K, type IMockFlows as L, type IMockFlowParams as M, type IScriptHeaderEnrichmentSuccess as N, type OPERATORSelectFailure as O, PossibleTypes as P, type ExtraStrategyData as Q, type IMockPinFlowStates as R, type StrategyCurrentState as S, type RootState as T, type LOAD_OC2SMSState as U, type Click2smsFlowState as V, type IWithMultiKeywordShortcode as W, type Click2smsFlowCurrentState as X, type MSISDNEntryErrorTypes as Y, type ILOADOC2SMSFailure as Z, type ILOADOC2SMSSuccess as _, type IDENTIFYMSISDNEntrySuccess as a, type IKeywordShortcode as a0, type IClick2smsConfig as a1, type SingleSubmissionResult as a2, type MultiOperatorSubmissionResult as a3, type ICheckSubscriptionResult as a4, type IFetchResult as a5, type
|
|
326
|
+
export { type ILoadOc2click2smsPayload as $, type IIdentifyFlowByHePayload as A, type IIdentfyFlowByMsisdnNextAction as B, type ConfigDetails as C, type IIdentfyFlowByOperatorNextAction as D, type IIdentfyFlowByIPOperatorNextAction as E, type IIdenyifyFlowByMsisdnSumbitNextData as F, type IIdenyifyFlowByMsisdnPayload as G, type IIdenyifyStrategyPayload as H, type IDENTIFYMSISDNEntryFailure as I, type IStrategyCurrentState as J, type IStrategyIDentifyUserResult as K, type IMockFlows as L, type IMockFlowParams as M, type IScriptHeaderEnrichmentSuccess as N, type OPERATORSelectFailure as O, PossibleTypes as P, type ExtraStrategyData as Q, type IMockPinFlowStates as R, type StrategyCurrentState as S, type RootState as T, type LOAD_OC2SMSState as U, type Click2smsFlowState as V, type IWithMultiKeywordShortcode as W, type Click2smsFlowCurrentState as X, type MSISDNEntryErrorTypes as Y, type ILOADOC2SMSFailure as Z, type ILOADOC2SMSSuccess as _, type IDENTIFYMSISDNEntrySuccess as a, type IKeywordShortcode as a0, type IClick2smsConfig as a1, type SingleSubmissionResult as a2, type MultiOperatorSubmissionResult as a3, type ICheckSubscriptionResult as a4, type IFetchResult as a5, type IConfig as b, type StrategyState as c, type IIdentifyResult as d, type ISupportedFlows as e, type IFlow as f, type StrategyConfig as g, type IStrategy as h, type IStrategyNames as i, type IHash as j, type IDENTIFYMSISDNEntryErrorTypes as k, type IdentifyFlowOptionsResult as l, type OPERATORSelectSuccess as m, type IDETECTYOPERATOBYIPFailure as n, type IDETECTYOPERATOBYIPSuccess as o, type IDENTIFY_OPERATOR_MSISDNEntrySuccess as p, type IDENTIFY_FLOW_HESuccess as q, type OPERATORSelectFlowIdentifyFailure as r, type OPERATORSelectFlowIdentifySuccess as s, type IDENTIFYFailure as t, type IDENTIFYSuccess as u, type IOperatorSelectFlowIdentifyPayload as v, type IDetectOperatorByIpPayload as w, type IOperatorSelectPayload as x, type ISubmitMsisdnPayload as y, type IIdentifyFlowByIpOperatorPayload as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as LOAD_OC2SMSState, V as Click2smsFlowState, j as IHash, W as IWithMultiKeywordShortcode, X as Click2smsFlowCurrentState } from './StrategyTypes-
|
|
2
|
-
export { a4 as ICheckSubscriptionResult, a1 as IClick2smsConfig, a5 as IFetchResult, a0 as IKeywordShortcode, Z as ILOADOC2SMSFailure, _ as ILOADOC2SMSSuccess, $ as ILoadOc2click2smsPayload, Y as MSISDNEntryErrorTypes, a3 as MultiOperatorSubmissionResult, a2 as SingleSubmissionResult } from './StrategyTypes-
|
|
1
|
+
import { U as LOAD_OC2SMSState, V as Click2smsFlowState, j as IHash, W as IWithMultiKeywordShortcode, X as Click2smsFlowCurrentState } from './StrategyTypes-CbOgk0N4.js';
|
|
2
|
+
export { a4 as ICheckSubscriptionResult, a1 as IClick2smsConfig, a5 as IFetchResult, a0 as IKeywordShortcode, Z as ILOADOC2SMSFailure, _ as ILOADOC2SMSSuccess, $ as ILoadOc2click2smsPayload, Y as MSISDNEntryErrorTypes, a3 as MultiOperatorSubmissionResult, a2 as SingleSubmissionResult } from './StrategyTypes-CbOgk0N4.js';
|
|
3
3
|
import * as redux from 'redux';
|
|
4
4
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
5
5
|
import * as _reduxjs_toolkit_dist_createAsyncThunk from '@reduxjs/toolkit/dist/createAsyncThunk';
|
|
@@ -8,7 +8,7 @@ import { R as RemoteDataState } from './RemoteDataState-D1aFrz8W.js';
|
|
|
8
8
|
import './CreditCardTypes-B-IT-l6I.js';
|
|
9
9
|
import './MoRedirTypes-4tEJjT1g.js';
|
|
10
10
|
import './MoTypes-D-UK92gs.js';
|
|
11
|
-
import './OneClickTypes-
|
|
11
|
+
import './OneClickTypes-DjOesaHp.js';
|
|
12
12
|
import './PinTypes-BLJDBZe6.js';
|
|
13
13
|
import './UssdTypes-C7QlIW11.js';
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from '@reduxjs/toolkit';
|
|
2
2
|
|
|
3
|
-
declare const handleAutoSubmitMsisdn: ({ msisdnValue, dispatch, submitMSISDNAction, isHeaderEnrichmentSuccess,
|
|
3
|
+
declare const handleAutoSubmitMsisdn: ({ msisdnValue, dispatch, submitMSISDNAction, isHeaderEnrichmentSuccess, isHeaderEnrichmentAutoSubmit }: {
|
|
4
4
|
window: Window;
|
|
5
5
|
msisdnValue: string;
|
|
6
6
|
dispatch: Dispatch;
|
|
@@ -9,10 +9,9 @@ declare const handleAutoSubmitMsisdn: ({ msisdnValue, dispatch, submitMSISDNActi
|
|
|
9
9
|
msisdn: string;
|
|
10
10
|
}) => any;
|
|
11
11
|
isHeaderEnrichmentSuccess: boolean;
|
|
12
|
-
setMsisdnValue: (msisdnValue: string) => void;
|
|
13
12
|
isHeaderEnrichmentAutoSubmit?: boolean;
|
|
14
13
|
}) => void;
|
|
15
|
-
declare const handleFormSubmit: ({ window, isHeaderEnrichmentSuccess,
|
|
14
|
+
declare const handleFormSubmit: ({ window, isHeaderEnrichmentSuccess, onEnd, internationalNumber, isValid }: {
|
|
16
15
|
window: Window;
|
|
17
16
|
isHeaderEnrichmentSuccess: boolean;
|
|
18
17
|
country: string;
|
|
@@ -21,6 +20,7 @@ declare const handleFormSubmit: ({ window, isHeaderEnrichmentSuccess, setInterna
|
|
|
21
20
|
[key: string]: string;
|
|
22
21
|
}) => void;
|
|
23
22
|
internationalNumber: string;
|
|
23
|
+
isValid: boolean;
|
|
24
24
|
}) => void;
|
|
25
25
|
|
|
26
26
|
export { handleAutoSubmitMsisdn, handleFormSubmit };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as OneClickFlowCurrentState, I as IGETREDIRECTURLFailure, b as IGETREDIRECTURLSuccess, S as SubscribeFailure, c as SubscribeSuccess, G as GETREDIRECTUrlState, A as AJAXSUBSCRIBEState, O as OneClickFlowState } from './OneClickTypes-
|
|
2
|
-
export { g as IHEResult, f as IIDentifyUserResult, e as ILinkExtraParams, i as IMockOneClickFlowStates, h as ISubscribeResult, d as SubscribeUserErrorTypes } from './OneClickTypes-
|
|
1
|
+
import { a as OneClickFlowCurrentState, I as IGETREDIRECTURLFailure, b as IGETREDIRECTURLSuccess, S as SubscribeFailure, c as SubscribeSuccess, G as GETREDIRECTUrlState, A as AJAXSUBSCRIBEState, O as OneClickFlowState } from './OneClickTypes-DjOesaHp.js';
|
|
2
|
+
export { g as IHEResult, f as IIDentifyUserResult, e as ILinkExtraParams, i as IMockOneClickFlowStates, h as ISubscribeResult, d as SubscribeUserErrorTypes } from './OneClickTypes-DjOesaHp.js';
|
|
3
3
|
import { useSelector } from 'react-redux';
|
|
4
4
|
import { R as RemoteDataState } from './RemoteDataState-D1aFrz8W.js';
|
|
5
5
|
import * as redux from 'redux';
|
package/dist/types/strategy.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RemoteDataState } from './RemoteDataState-D1aFrz8W.js';
|
|
2
2
|
export { a as RDS } from './RemoteDataState-D1aFrz8W.js';
|
|
3
|
-
import { S as StrategyCurrentState, I as IDENTIFYMSISDNEntryFailure, a as IDENTIFYMSISDNEntrySuccess, P as PossibleTypes, C as ConfigDetails, b as StrategyState } from './StrategyTypes-
|
|
4
|
-
export { Q as ExtraStrategyData,
|
|
3
|
+
import { S as StrategyCurrentState, I as IDENTIFYMSISDNEntryFailure, a as IDENTIFYMSISDNEntrySuccess, P as PossibleTypes, C as ConfigDetails, b as IConfig, c as StrategyState } from './StrategyTypes-CbOgk0N4.js';
|
|
4
|
+
export { Q as ExtraStrategyData, t as IDENTIFYFailure, k as IDENTIFYMSISDNEntryErrorTypes, u as IDENTIFYSuccess, q as IDENTIFY_FLOW_HESuccess, p as IDENTIFY_OPERATOR_MSISDNEntrySuccess, n as IDETECTYOPERATOBYIPFailure, o as IDETECTYOPERATOBYIPSuccess, w as IDetectOperatorByIpPayload, f as IFlow, j as IHash, E as IIdentfyFlowByIPOperatorNextAction, B as IIdentfyFlowByMsisdnNextAction, D as IIdentfyFlowByOperatorNextAction, A as IIdentifyFlowByHePayload, z as IIdentifyFlowByIpOperatorPayload, d as IIdentifyResult, G as IIdenyifyFlowByMsisdnPayload, F as IIdenyifyFlowByMsisdnSumbitNextData, H as IIdenyifyStrategyPayload, M as IMockFlowParams, L as IMockFlows, R as IMockPinFlowStates, v as IOperatorSelectFlowIdentifyPayload, x as IOperatorSelectPayload, N as IScriptHeaderEnrichmentSuccess, h as IStrategy, J as IStrategyCurrentState, K as IStrategyIDentifyUserResult, i as IStrategyNames, y as ISubmitMsisdnPayload, e as ISupportedFlows, l as IdentifyFlowOptionsResult, O as OPERATORSelectFailure, r as OPERATORSelectFlowIdentifyFailure, s as OPERATORSelectFlowIdentifySuccess, m as OPERATORSelectSuccess, T as RootState, g as StrategyConfig } from './StrategyTypes-CbOgk0N4.js';
|
|
5
5
|
import { useSelector } from 'react-redux';
|
|
6
6
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
7
7
|
import * as _reduxjs_toolkit_dist_createAsyncThunk from '@reduxjs/toolkit/dist/createAsyncThunk';
|
|
@@ -9,7 +9,7 @@ import * as redux from 'redux';
|
|
|
9
9
|
import './CreditCardTypes-B-IT-l6I.js';
|
|
10
10
|
import './MoRedirTypes-4tEJjT1g.js';
|
|
11
11
|
import './MoTypes-D-UK92gs.js';
|
|
12
|
-
import './OneClickTypes-
|
|
12
|
+
import './OneClickTypes-DjOesaHp.js';
|
|
13
13
|
import './PinTypes-BLJDBZe6.js';
|
|
14
14
|
import './UssdTypes-C7QlIW11.js';
|
|
15
15
|
|
|
@@ -80,7 +80,15 @@ declare const identifyStrategy: _reduxjs_toolkit.AsyncThunk<StrategyCurrentState
|
|
|
80
80
|
config: ConfigDetails;
|
|
81
81
|
operator: string;
|
|
82
82
|
};
|
|
83
|
+
} | {
|
|
84
|
+
type: PossibleTypes;
|
|
85
|
+
result: RemoteDataState<unknown, unknown>;
|
|
86
|
+
data: {
|
|
87
|
+
config: IConfig;
|
|
88
|
+
msisdn: string;
|
|
89
|
+
operator: string;
|
|
90
|
+
};
|
|
83
91
|
}, void, _reduxjs_toolkit_dist_createAsyncThunk.AsyncThunkConfig>;
|
|
84
92
|
declare const strategyReducer: redux.Reducer<StrategyState, redux.UnknownAction, StrategyState>;
|
|
85
93
|
|
|
86
|
-
export { ConfigDetails, IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess, PossibleTypes, StrategyCurrentState, StrategyState, identifyStrategy, selectOperatorAction, strategy, strategyReducer, submitMSISDNAction, useStrategyState };
|
|
94
|
+
export { ConfigDetails, IConfig, IDENTIFYMSISDNEntryFailure, IDENTIFYMSISDNEntrySuccess, PossibleTypes, StrategyCurrentState, StrategyState, identifyStrategy, selectOperatorAction, strategy, strategyReducer, submitMSISDNAction, useStrategyState };
|
package/dist/ussdFlow.js
CHANGED
|
@@ -1,211 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
3
|
-
import { S as Success, N as NothingYet, L as Loading, F as Failure } from './RemoteDataState-CwHLI23e.js';
|
|
4
|
-
import { checkSubscriptionHander } from './checkSubscriptionHander.js';
|
|
5
|
-
import { s as storeMsisdn } from './storeMsisdn-ChiBh8mI.js';
|
|
6
|
-
import { t as tracker } from './tracker-B_zsMRN2.js';
|
|
7
|
-
import './checkSubscriptionByRockmanIdOnly-C89Ph9cV.js';
|
|
8
|
-
import './helpers-J_h-ZgxH.js';
|
|
9
|
-
import './searchToObject.js';
|
|
10
|
-
import 'pacman-client';
|
|
11
|
-
import 'uuid';
|
|
12
|
-
|
|
13
|
-
var useUssdFlowState = function (useSelector) {
|
|
14
|
-
var currentState = useSelector(function (state) { return state.ussdFlow.currentState; });
|
|
15
|
-
return currentState;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function ussdFlowMatch(_a) {
|
|
19
|
-
var msisdnEntry = _a.msisdnEntry;
|
|
20
|
-
return function (state) {
|
|
21
|
-
switch (state.type) {
|
|
22
|
-
case 'MSISDNEntry':
|
|
23
|
-
return msisdnEntry(state.result);
|
|
24
|
-
default:
|
|
25
|
-
// TODO - this should be an error or something
|
|
26
|
-
return msisdnEntry(state.result);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var ussd = function (window, slug, country, msisdn, device, offer, rockmanId, search, extraParamsQs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
32
|
-
var params, host, url;
|
|
33
|
-
return __generator(this, function (_a) {
|
|
34
|
-
params = new URLSearchParams(__assign({ action: 'ussd', slug: slug, country: country, msisdn: msisdn, device: device, offerId: offer.toString(), rockman_id: rockmanId }, (search && { search: search })));
|
|
35
|
-
if (extraParamsQs) {
|
|
36
|
-
extraParamsQs.split('&').forEach(function (param) {
|
|
37
|
-
var _a = __read(param.split('='), 2), key = _a[0], value = _a[1];
|
|
38
|
-
if (key)
|
|
39
|
-
params.append(key, value);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
host = window.DEV_BASE_URL || '';
|
|
43
|
-
url = "".concat(host, "/tallyman/v1/?").concat(params.toString());
|
|
44
|
-
return [2 /*return*/, fetch(url).then(function (response) { return response.json(); })];
|
|
45
|
-
});
|
|
46
|
-
}); };
|
|
47
|
-
|
|
48
|
-
function submitMSISDN(window, maybeConfig, internationalMSISDN, extraParams) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var config;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
config = __assign({ offer: window.pac_analytics.visitor.offer }, (maybeConfig || {}));
|
|
53
|
-
return [2 /*return*/, submitMSISDNWithConfig(window, config, internationalMSISDN, extraParams)];
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function submitMSISDNWithConfig(window, config, internationalMSISDN, extraParams) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var slug, country, device, offer, search, extraParamsQs, msisdn, rockmanId, result, type, error;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
slug = config.slug, country = config.country, device = config.device, offer = config.offer;
|
|
64
|
-
search = window.location.search.substr(1) || '';
|
|
65
|
-
extraParamsQs = !extraParams
|
|
66
|
-
? ''
|
|
67
|
-
: "&".concat(Object.keys(extraParams)
|
|
68
|
-
.map(function (k) { return "".concat(k, "=").concat(extraParams[k]); })
|
|
69
|
-
.join('&'));
|
|
70
|
-
msisdn = internationalMSISDN.match(/\d+/gi).join('');
|
|
71
|
-
rockmanId = window.pac_analytics.visitor.rockmanId;
|
|
72
|
-
return [4 /*yield*/, ussd(window, slug, country, msisdn, device, offer, rockmanId, search, extraParamsQs)];
|
|
73
|
-
case 1:
|
|
74
|
-
result = _a.sent();
|
|
75
|
-
if (result.success === false) {
|
|
76
|
-
type = result.message === 'ALREADY SUBSCRIBED' ? 'AlreadySubscribed' : 'InvalidMSISDN';
|
|
77
|
-
error = new Error("".concat(type, ":\n").concat(result.message));
|
|
78
|
-
error.type = type;
|
|
79
|
-
console.error(error);
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
return [2 /*return*/, result];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var initialState = {
|
|
91
|
-
currentState: {
|
|
92
|
-
type: 'MSISDNEntry',
|
|
93
|
-
result: NothingYet()
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* submitMSISDNAction
|
|
98
|
-
* @returns {type: ' 'pinFlow/submitMSISDNAction', payload: {type: PossibleTypes, result: MSISDNEntryState}}
|
|
99
|
-
|
|
100
|
-
* Calls ussd api that open ussd prompt on mobile
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
var submitMSISDNAction = createAsyncThunk('ussdFlow/submitMSISDNAction', function (_a, _b) {
|
|
104
|
-
var window = _a.window, msisdn = _a.msisdn, extraParams = _a.extraParams;
|
|
105
|
-
var getState = _b.getState, rejectWithValue = _b.rejectWithValue;
|
|
106
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
-
var state, config, keywordAndShortcode, ex_1, errorType;
|
|
108
|
-
return __generator(this, function (_c) {
|
|
109
|
-
switch (_c.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
state = getState();
|
|
112
|
-
config = state.strategy.currentState.data.config;
|
|
113
|
-
_c.label = 1;
|
|
114
|
-
case 1:
|
|
115
|
-
_c.trys.push([1, 5, , 6]);
|
|
116
|
-
// Start Ussd Api Call
|
|
117
|
-
tracker.advancedInFlow('tallyman.v1-ussd', 'msisdn-submitted', { msisdn: msisdn });
|
|
118
|
-
return [4 /*yield*/, submitMSISDN(window, config, msisdn, extraParams)];
|
|
119
|
-
case 2:
|
|
120
|
-
keywordAndShortcode = _c.sent();
|
|
121
|
-
tracker.advancedInFlow('tallyman.v1-ussd', 'msisdn-submission-success', { msisdn: msisdn });
|
|
122
|
-
if (!(extraParams && extraParams.storeMsisdn && extraParams.storeMsisdn === 'true')) return [3 /*break*/, 4];
|
|
123
|
-
return [4 /*yield*/, storeMsisdn(msisdn)
|
|
124
|
-
.then(function (data) {
|
|
125
|
-
if (data && data.data && data.data.success) {
|
|
126
|
-
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-success');
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-failed');
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
.catch(function (error) {
|
|
133
|
-
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-error', error);
|
|
134
|
-
})];
|
|
135
|
-
case 3:
|
|
136
|
-
_c.sent();
|
|
137
|
-
_c.label = 4;
|
|
138
|
-
case 4:
|
|
139
|
-
// End Store Msisdn
|
|
140
|
-
// Check For Subscription by rockman id and redirect to product url
|
|
141
|
-
checkSubscriptionHander({
|
|
142
|
-
window: window,
|
|
143
|
-
flow: 'tallyman.v1-ussd',
|
|
144
|
-
action: 'sale',
|
|
145
|
-
args: {
|
|
146
|
-
msisdn: msisdn
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
return [2 /*return*/, {
|
|
150
|
-
type: 'MSISDNEntry',
|
|
151
|
-
result: Success(__assign({}, keywordAndShortcode))
|
|
152
|
-
}];
|
|
153
|
-
case 5:
|
|
154
|
-
ex_1 = _c.sent();
|
|
155
|
-
console.warn(ex_1);
|
|
156
|
-
errorType = void 0;
|
|
157
|
-
switch (ex_1.type) {
|
|
158
|
-
case 'AlreadySubscribed':
|
|
159
|
-
errorType = 'AlreadySubscribed';
|
|
160
|
-
break;
|
|
161
|
-
case 'InvalidMSISDN':
|
|
162
|
-
errorType = 'InvalidMSISDN';
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
errorType = 'UnknownError';
|
|
166
|
-
}
|
|
167
|
-
tracker.recedeInFlow('tallyman.v1-ussd', 'msisdn-submission-failure', {
|
|
168
|
-
msisdn: msisdn,
|
|
169
|
-
errorType: errorType || 'UnknownError'
|
|
170
|
-
});
|
|
171
|
-
return [2 /*return*/, rejectWithValue({
|
|
172
|
-
errorType: errorType,
|
|
173
|
-
productUrl: ex_1.productUrl
|
|
174
|
-
})];
|
|
175
|
-
case 6: return [2 /*return*/];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
var ussdFlowSlice = createSlice({
|
|
181
|
-
name: 'ussdFlow',
|
|
182
|
-
initialState: initialState,
|
|
183
|
-
reducers: {
|
|
184
|
-
backToStartAction: function (state) {
|
|
185
|
-
tracker.recedeInFlow('tallyman.v1-ussd', 'ussd-state', 'requested to change phone number');
|
|
186
|
-
// TODO GO BACK TO IDENTIFY BY MSISDN BASED ON STRATEGY
|
|
187
|
-
state.currentState = { type: 'MSISDNEntry', result: NothingYet() };
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
extraReducers: function (builder) {
|
|
191
|
-
builder
|
|
192
|
-
.addCase(submitMSISDNAction.pending, function (state) {
|
|
193
|
-
state.currentState = { type: 'MSISDNEntry', result: Loading() };
|
|
194
|
-
})
|
|
195
|
-
.addCase(submitMSISDNAction.fulfilled, function (state, action) {
|
|
196
|
-
state.currentState = action.payload;
|
|
197
|
-
})
|
|
198
|
-
.addCase(submitMSISDNAction.rejected, function (state, action) {
|
|
199
|
-
state.currentState = {
|
|
200
|
-
type: 'MSISDNEntry',
|
|
201
|
-
result: Failure(action.payload)
|
|
202
|
-
};
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
// Export reducers and actions
|
|
207
|
-
var ussdFlowReducer = ussdFlowSlice.reducer, ussdFlowActions = ussdFlowSlice.actions;
|
|
208
|
-
var backToStartAction = ussdFlowActions.backToStartAction;
|
|
209
|
-
|
|
210
|
-
export { backToStartAction, submitMSISDNAction, useUssdFlowState, ussdFlowMatch, ussdFlowReducer };
|
|
1
|
+
import{__awaiter as t,__generator as r,__assign as e,__read as n}from"tslib";import{createAsyncThunk as s,createSlice as a}from"@reduxjs/toolkit";import{S as o,N as c,L as i,F as u}from"./RemoteDataState-lcf8PfJd.js";import{checkSubscriptionHander as d}from"./checkSubscriptionHander.js";import{searchToObject as l}from"./searchToObject.js";import{s as m}from"./storeMsisdn-Cjq8_qYH.js";import{t as f}from"./tracker-DaaILhEr.js";import"./checkSubscriptionByRockmanIdOnly-BwR1un1L.js";import"./helpers-xPhGBX-B.js";import"pacman-client";import"uuid";var S=function(t){return t((function(t){return t.ussdFlow.currentState}))};function p(t){var r=t.msisdnEntry;return function(t){return t.type,r(t.result)}}var v=function(s,a,o,c,i,u,d,l,m){return t(void 0,void 0,void 0,(function(){var t,f,S;return r(this,(function(r){return t=new URLSearchParams(e({action:"ussd",slug:a,country:o,msisdn:c,device:i,offerId:u.toString(),rockman_id:d},l&&{search:l})),m&&m.split("&").forEach((function(r){var e=n(r.split("="),2),s=e[0],a=e[1];s&&t.append(s,a)})),f=s.DEV_BASE_URL||"",S="".concat(f,"/tallyman/v1/?").concat(t.toString()),[2,fetch(S).then((function(t){return t.json()}))]}))}))};function y(n,s,a,o){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){return t=e({offer:n.pac_analytics.visitor.offer},s||{}),[2,w(n,t,a,o)]}))}))}function w(e,n,s,a){return t(this,void 0,void 0,(function(){var t,o,c,i,u,d,l,m,f,S,p;return r(this,(function(r){switch(r.label){case 0:return t=n.slug,o=n.country,c=n.device,i=n.offer,u=e.location.search.substr(1)||"",d=a?"&".concat(Object.keys(a).map((function(t){return"".concat(t,"=").concat(a[t])})).join("&")):"",l=s.match(/\d+/gi).join(""),m=e.pac_analytics.visitor.rockmanId,[4,v(e,t,o,l,c,i,m,u,d)];case 1:if(!1===(f=r.sent()).success)throw S="ALREADY SUBSCRIBED"===f.message?"AlreadySubscribed":"InvalidMSISDN",(p=new Error("".concat(S,":\n").concat(f.message))).type=S,console.error(p),p;return[2,f]}}))}))}var h={currentState:{type:"MSISDNEntry",result:o({keyword:"TEST OK",shortcode:"777"})}},b={currentState:{type:"MSISDNEntry",result:u({errorType:"InvalidMSISDN",error:"Invalid Mobile Number"})}},I={currentState:{type:"MSISDNEntry",result:c()}},E=function(t){var r=l(t);if(!r["mock-flow"])return I;switch(r["current-state"]){case"msisdn-entry-failure-state":return b;case"msisdn-entry-success-state":return h;default:return console.error("Mock Flow not supported"),I}}(window),k=s("ussdFlow/submitMSISDNAction",(function(n,s){var a=n.window,c=n.msisdn,i=n.extraParams,u=s.getState,l=s.rejectWithValue;return t(void 0,void 0,void 0,(function(){var t,n,s,S,p;return r(this,(function(r){switch(r.label){case 0:t=u(),n=t.strategy.currentState.data.config,r.label=1;case 1:return r.trys.push([1,5,,6]),f.advancedInFlow("tallyman.v1-ussd","msisdn-submitted",{msisdn:c}),[4,y(a,n,c,i)];case 2:return s=r.sent(),f.advancedInFlow("tallyman.v1-ussd","msisdn-submission-success",{msisdn:c}),i&&i.storeMsisdn&&"true"===i.storeMsisdn?[4,m(c).then((function(t){t&&t.data&&t.data.success?f.customEvent("Flow","advance-auto","msisdn-stored-success"):f.customEvent("Flow","advance-auto","msisdn-stored-failed")})).catch((function(t){f.customEvent("Flow","advance-auto","msisdn-stored-error",t)}))]:[3,4];case 3:r.sent(),r.label=4;case 4:return d({window:a,flow:"tallyman.v1-ussd",action:"sale",args:{msisdn:c}}),[2,{type:"MSISDNEntry",result:o(e({},s))}];case 5:switch(S=r.sent(),console.warn(S),p=void 0,S.type){case"AlreadySubscribed":p="AlreadySubscribed";break;case"InvalidMSISDN":p="InvalidMSISDN";break;default:p="UnknownError"}return f.recedeInFlow("tallyman.v1-ussd","msisdn-submission-failure",{msisdn:c,errorType:p||"UnknownError"}),[2,l({errorType:p,productUrl:S.productUrl})];case 6:return[2]}}))}))})),M=a({name:"ussdFlow",initialState:E,reducers:{backToStartAction:function(t){f.recedeInFlow("tallyman.v1-ussd","ussd-state","requested to change phone number"),t.currentState={type:"MSISDNEntry",result:c()}}},extraReducers:function(t){t.addCase(k.pending,(function(t){t.currentState={type:"MSISDNEntry",result:i()}})).addCase(k.fulfilled,(function(t,r){t.currentState=r.payload})).addCase(k.rejected,(function(t,r){t.currentState={type:"MSISDNEntry",result:u(r.payload)}}))}}),D=M.reducer,j=M.actions.backToStartAction;export{j as backToStartAction,k as submitMSISDNAction,S as useUssdFlowState,p as ussdFlowMatch,D as ussdFlowReducer};
|
|
211
2
|
//# sourceMappingURL=ussdFlow.js.map
|