@tef-novum/webview-bridge
Advanced tools
Comparing version
# CHANGELOG | ||
## v.2.20.0 - 2021-05-13 | ||
- Add `setTrackingProperty` method. | ||
## v.2.19.0 - 2021-03-19 | ||
@@ -4,0 +8,0 @@ |
@@ -5,9 +5,10 @@ declare type CustomDimensionIdx = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 26; | ||
export declare const CD_EVENT_VALUE: CustomDimensionIdx; | ||
export declare const logEvent: ({ category, action, label, value, ...fieldsObject }: Readonly<{ | ||
[key: string]: any; | ||
declare type TrackingEvent = Readonly<{ | ||
category: string; | ||
action: string; | ||
label?: string | undefined; | ||
value?: number | undefined; | ||
}>) => Promise<void>; | ||
label?: string; | ||
value?: number; | ||
[key: string]: any; | ||
}>; | ||
export declare const logEvent: ({ category, action, label, value, ...fieldsObject }: TrackingEvent) => Promise<void>; | ||
export declare const logTiming: ({ category, variable, value, label, }: Readonly<{ | ||
@@ -20,3 +21,25 @@ category?: string | undefined; | ||
export declare const setScreenName: (screenName: string, fieldsObject?: {} | undefined) => Promise<void>; | ||
export declare const setUserProperty: (name: "obIds" | "paymentModels" | "serviceWorkerStatus" | "isAdmin" | "hasIpComms" | "af_source" | "af_campaign" | "novum_uid_session" | "user_logged" | "currentSubscriptionId" | "currentSubscriptionType" | "currentPaymentModel" | "webviewBrowserVersion" | "activatedRoles" | "appInstanceId" | "experimentflag" | "friendsApps" | "accountLineSelector" | "OneClickDisplayed", value: string) => Promise<void>; | ||
declare const USER_PROPERTY_TO_CUSTOM_DIMENSION: { | ||
obIds: 1; | ||
paymentModels: 2; | ||
serviceWorkerStatus: 3; | ||
isAdmin: 5; | ||
hasIpComms: 6; | ||
af_source: 9; | ||
af_campaign: 10; | ||
novum_uid_session: 11; | ||
user_logged: 12; | ||
currentSubscriptionId: 13; | ||
currentSubscriptionType: 14; | ||
currentPaymentModel: 15; | ||
webviewBrowserVersion: 16; | ||
activatedRoles: 17; | ||
appInstanceId: 18; | ||
experimentflag: 20; | ||
friendsApps: 24; | ||
accountLineSelector: 25; | ||
OneClickDisplayed: 26; | ||
}; | ||
declare type UserPropertyName = keyof typeof USER_PROPERTY_TO_CUSTOM_DIMENSION; | ||
export declare const setUserProperty: (name: UserPropertyName, value: string) => Promise<void>; | ||
export declare const setCustomerHash: (hash: string) => Promise<void>; | ||
@@ -26,2 +49,3 @@ export declare const getCustomerHash: () => Promise<{ | ||
}>; | ||
export declare const setTrackingProperty: (system: 'palitagem' | 'medalia', name: string, value?: string | undefined) => Promise<void>; | ||
export {}; |
@@ -0,1 +1,2 @@ | ||
import { NativeAppResponsePayload } from './post-message'; | ||
export declare const requestContact: ({ filter, }?: { | ||
@@ -14,8 +15,2 @@ filter?: "phone" | "email" | undefined; | ||
}>; | ||
export declare const fetchContactsByPhone: (phoneNumbers: readonly string[]) => Promise<{ | ||
phoneNumber: string; | ||
firstName?: string | undefined; | ||
middleName?: string | undefined; | ||
lastName?: string | undefined; | ||
encodedAvatar?: string | undefined; | ||
}[]>; | ||
export declare const fetchContactsByPhone: (phoneNumbers: ReadonlyArray<string>) => Promise<NativeAppResponsePayload<'FETCH_CONTACTS_DATA'>>; |
export declare const requestSimIcc: () => Promise<string | null>; | ||
export declare const requestSimImsi: () => Promise<string | null>; | ||
export declare const requestDeviceImei: () => Promise<string | null>; | ||
export declare const internalNavigation: (feature: "notification-settings") => Promise<void>; | ||
declare type RoutesAvalaible = 'notification-settings'; | ||
export declare const internalNavigation: (feature: RoutesAvalaible) => Promise<void>; | ||
export declare const dismiss: (onCompletionUrl?: string | undefined) => Promise<void>; | ||
export declare const requestVibration: (type: "error" | "success") => Promise<void>; | ||
export declare const requestVibration: (type: 'error' | 'success') => Promise<void>; | ||
export declare const getDiskSpaceInfo: () => Promise<{ | ||
@@ -14,1 +15,2 @@ availableBytes: number; | ||
}>; | ||
export {}; |
@@ -215,4 +215,10 @@ /** | ||
}; | ||
SET_TRACKING_PROPERTY: { | ||
type: 'SET_TRACKING_PROPERTY'; | ||
id: string; | ||
payload: void; | ||
}; | ||
}; | ||
export declare type NativeAppResponsePayload<Type extends keyof ResponsesFromNativeApp> = ResponsesFromNativeApp[Type]['payload']; | ||
declare type NativeAppRequestPayload<Type extends keyof RequestsFromNativeApp> = RequestsFromNativeApp[Type]['payload']; | ||
/** | ||
@@ -225,7 +231,7 @@ * Returns true if there is a WebView Bridge installed | ||
*/ | ||
export declare const postMessageToNativeApp: <T extends "SIM_ICC" | "IMEI" | "IMSI" | "ATTACH_TO_EMAIL" | "SET_TITLE" | "PAGE_LOADED" | "ALERT" | "MESSAGE" | "CONFIRM" | "CREATE_CALENDAR_EVENT" | "GET_CONTACT_DATA" | "NAVIGATION_BAR" | "SHARE" | "ERROR" | "GET_REMOTE_CONFIG" | "STATUS_REPORT" | "FETCH" | "OS_PERMISSION_STATUS" | "INTERNAL_NAVIGATION" | "DISMISS" | "VIBRATION" | "FETCH_CONTACTS_DATA" | "RENEW_SESSION" | "GET_APP_METADATA" | "SET_CUSTOMER_HASH" | "GET_CUSTOMER_HASH" | "GET_DISK_SPACE_INFO" | "GET_ESIM_INFO">({ type, id, payload }: { | ||
export declare const postMessageToNativeApp: <T extends "SIM_ICC" | "IMEI" | "IMSI" | "ATTACH_TO_EMAIL" | "SET_TITLE" | "PAGE_LOADED" | "ALERT" | "MESSAGE" | "CONFIRM" | "CREATE_CALENDAR_EVENT" | "GET_CONTACT_DATA" | "NAVIGATION_BAR" | "SHARE" | "ERROR" | "GET_REMOTE_CONFIG" | "STATUS_REPORT" | "FETCH" | "OS_PERMISSION_STATUS" | "INTERNAL_NAVIGATION" | "DISMISS" | "VIBRATION" | "FETCH_CONTACTS_DATA" | "RENEW_SESSION" | "GET_APP_METADATA" | "SET_CUSTOMER_HASH" | "GET_CUSTOMER_HASH" | "GET_DISK_SPACE_INFO" | "GET_ESIM_INFO" | "SET_TRACKING_PROPERTY">({ type, id, payload }: { | ||
type: T; | ||
id?: string | undefined; | ||
payload?: Object | undefined; | ||
}, timeout?: number | undefined) => Promise<ResponsesFromNativeApp[T]["payload"]>; | ||
}, timeout?: number | undefined) => Promise<NativeAppResponsePayload<T>>; | ||
export declare type NativeEventHandler = ({ event, }: { | ||
@@ -236,3 +242,3 @@ event: string; | ||
}; | ||
export declare const listenToNativeMessage: <T extends "NATIVE_EVENT" | "SESSION_RENEWED">(type: T, handler: (payload: RequestsFromNativeApp[T]["payload"]) => void | Object | Promise<Object>) => () => void; | ||
export declare const listenToNativeMessage: <T extends "NATIVE_EVENT" | "SESSION_RENEWED">(type: T, handler: (payload: NativeAppRequestPayload<T>) => Object | void | Promise<Object>) => () => void; | ||
export declare const onNativeEvent: (eventHandler: NativeEventHandler) => () => void; | ||
@@ -239,0 +245,0 @@ export declare const onSessionRenewal: (handler: (payload: { |
@@ -0,1 +1,2 @@ | ||
import { NativeAppResponsePayload } from './post-message'; | ||
export declare const attachToEmail: ({ url, subject, fileName, recipient, body, }: { | ||
@@ -31,4 +32,4 @@ url: string; | ||
export declare const reportStatus: ({ feature, status, reason, }: { | ||
feature: "ACCOUNT"; | ||
status: "CRITICAL" | "GOOD" | "BAD"; | ||
feature: 'ACCOUNT'; | ||
status: 'CRITICAL' | 'GOOD' | 'BAD'; | ||
reason: string; | ||
@@ -38,3 +39,3 @@ }) => Promise<void>; | ||
url: string; | ||
method: "GET" | "POST"; | ||
method: 'GET' | 'POST'; | ||
headers: { | ||
@@ -44,10 +45,5 @@ [key: string]: string; | ||
body: string; | ||
}) => Promise<{ | ||
status: number; | ||
headers: { | ||
[key: string]: string; | ||
}; | ||
body: string; | ||
}>; | ||
export declare const checkPermissionStatus: (feature: "notifications", params?: { | ||
}) => Promise<NativeAppResponsePayload<'FETCH'>>; | ||
declare type PermissionsStatus = 'notifications'; | ||
export declare const checkPermissionStatus: (feature: PermissionsStatus, params?: { | ||
[key: string]: string; | ||
@@ -54,0 +50,0 @@ } | undefined) => Promise<boolean>; |
@@ -403,14 +403,14 @@ define(['exports'], function (exports) { 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -417,0 +417,0 @@ |
@@ -405,14 +405,14 @@ 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -419,0 +419,0 @@ |
@@ -404,14 +404,14 @@ var webviewBridge = (function (exports) { | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -418,0 +418,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global.webviewBridge = {})); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.webviewBridge = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -407,14 +407,14 @@ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -421,0 +421,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return"webapp-"+n++},o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(n){return n!==e})},l=function(){return r()||i()},d=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),d=JSON.stringify({type:o,id:i,payload:u});return l?(setTimeout(function(){l(d)}),new Promise(function(e,t){var r=!1,a=function(n){n.id!==i||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+o}),c(a))};s(a),n&&setTimeout(function(){r=!0,c(a),t({code:408,reason:"request timeout"})},n)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}u.forEach(function(e){return e(n)})}});var f=function(e,n){var t=function(t){t.type===e&&Promise.resolve(n(t.payload)).then(function(e){var n=a();n&&n(JSON.stringify({type:t.type,id:t.id,payload:e}))})};return s(t),function(){c(t)}},p=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return l()?d({type:"NAVIGATION_BAR",payload:{title:n,expandedTitle:t,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==n&&"undefined"!=typeof document&&(document.title=n),Promise.resolve())},m=null,y=function(e){return"true"===m.result[e]},v=function(e){return Math.floor(e/1e3)},w=function(){return(w=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};var g,b=["NovumTracker","OBARGTracker"],T=function(e){return b.indexOf(e.get("name"))>=0},E=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?o(window.ga):Promise.resolve()},h={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15,webviewBrowserVersion:16,activatedRoles:17,appInstanceId:18,experimentflag:20,friendsApps:24,accountLineSelector:25,OneClickDisplayed:26};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return d({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return d({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:n}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return d({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:v(n),endTime:v(t),title:o}})},e.dismiss=function(e){return d({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return l()?d({type:"FETCH",payload:{url:n,method:t,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return d({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return d({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return d({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return d({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return d({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.internalNavigation=function(e){return d({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(m)return Promise.resolve(y(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=d({type:"GET_REMOTE_CONFIG"}).then(function(n){return m=n,y(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=l,e.logEvent=function(e){var n=e.category,t=e.action,o=e.label,r=e.value,i=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;o||(o="null_label"),r||(r=0);var u=w({eventCategory:n,eventAction:t,eventLabel:function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}(o),eventValue:r},i);return E({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(u)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:u}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",w(w({},u),{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,o=e.variable,r=e.value,i=e.label;if(!t||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:o,value:r}),Promise.resolve();var a={timingCategory:t,timingVar:o,timingValue:r=Math.round(r),timingLabel:i},u=t;return E({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("NovumTracker.send",w(((t={hitType:"timing",hitCallback:n}).dimension8=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return l()?d({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return l()?d({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(n))},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return l()?d({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyPageLoaded=function(){return d({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return f("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return f("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e){return d({type:"RENEW_SESSION",payload:{accessToken:e||null}}).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return d({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return d({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return d({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return d({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return d({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return d({type:"VIBRATION",payload:{type:e}})},e.setCustomerHash=function(e){return d({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setScreenName=function(e,n){return e?E({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(o){var r=e.startsWith("/")?e:"/"+e;r!==g?(g=r,t(function(){t.getAll().filter(T).forEach(function(e){e.set("page",r),e.send("pageView",w(w({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),E({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var o,r=h[e];return r?(t("NovumTracker.set",((o={})["dimension"+r]=String(n),o)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.setWebViewTitle=function(e){return l()?p({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return d({type:"SHARE",payload:e})},e.updateNavigationBar=p,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return"webapp-"+n++},o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(n){return n!==e})},l=function(){return r()||i()},d=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),d=JSON.stringify({type:o,id:i,payload:u});return l?(setTimeout(function(){l(d)}),new Promise(function(e,t){var r=!1,a=function(n){n.id!==i||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+o}),c(a))};s(a),n&&setTimeout(function(){r=!0,c(a),t({code:408,reason:"request timeout"})},n)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}u.forEach(function(e){return e(n)})}});var f=function(e,n){var t=function(t){t.type===e&&Promise.resolve(n(t.payload)).then(function(e){var n=a();n&&n(JSON.stringify({type:t.type,id:t.id,payload:e}))})};return s(t),function(){c(t)}},p=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return l()?d({type:"NAVIGATION_BAR",payload:{title:n,expandedTitle:t,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==n&&"undefined"!=typeof document&&(document.title=n),Promise.resolve())},m=null,y=function(e){return"true"===m.result[e]},v=function(e){return Math.floor(e/1e3)},w=function(){return(w=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};var g,b=["NovumTracker","OBARGTracker"],T=function(e){return b.indexOf(e.get("name"))>=0},E=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?o(window.ga):Promise.resolve()},h={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15,webviewBrowserVersion:16,activatedRoles:17,appInstanceId:18,experimentflag:20,friendsApps:24,accountLineSelector:25,OneClickDisplayed:26};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return d({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return d({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:n}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return d({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:v(n),endTime:v(t),title:o}})},e.dismiss=function(e){return d({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return l()?d({type:"FETCH",payload:{url:n,method:t,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return d({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return d({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return d({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return d({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return d({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.internalNavigation=function(e){return d({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(m)return Promise.resolve(y(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=d({type:"GET_REMOTE_CONFIG"}).then(function(n){return m=n,y(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=l,e.logEvent=function(e){var n=e.category,t=e.action,o=e.label,r=e.value,i=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;o||(o="null_label"),r||(r=0);var u=w({eventCategory:n,eventAction:t,eventLabel:function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}(o),eventValue:r},i);return E({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(u)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:u}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",w(w({},u),{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,o=e.variable,r=e.value,i=e.label;if(!t||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:o,value:r}),Promise.resolve();var a={timingCategory:t,timingVar:o,timingValue:r=Math.round(r),timingLabel:i},u=t;return E({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("NovumTracker.send",w(((t={hitType:"timing",hitCallback:n}).dimension8=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return l()?d({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return l()?d({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(n))},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return l()?d({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyPageLoaded=function(){return d({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return f("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return f("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e){return d({type:"RENEW_SESSION",payload:{accessToken:e||null}}).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return d({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return d({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return d({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return d({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return d({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return d({type:"VIBRATION",payload:{type:e}})},e.setCustomerHash=function(e){return d({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setScreenName=function(e,n){return e?E({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(o){var r=e.startsWith("/")?e:"/"+e;r!==g?(g=r,t(function(){t.getAll().filter(T).forEach(function(e){e.set("page",r),e.send("pageView",w(w({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),E({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var o,r=h[e];return r?(t("NovumTracker.set",((o={})["dimension"+r]=String(n),o)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.setWebViewTitle=function(e){return l()?p({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return d({type:"SHARE",payload:e})},e.updateNavigationBar=p,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@tef-novum/webview-bridge", | ||
"version": "2.19.0", | ||
"version": "2.20.0", | ||
"description": "JavaScript library to access to native functionality. Requires a webview with a postMessage bridge.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/webview-bridge-cjs.js", |
@@ -677,2 +677,24 @@ <p align="center"> | ||
### setTrackingProperty | ||
Sets a property related to some specific tracking system | ||
- Available for app versions 12.4 and higher | ||
```typescript | ||
setTrackingProperty: (system: string, name: string, value?: string) => Promise<void>; | ||
``` | ||
- `system`: Tracking system that will handle the property | ||
- `name`: name of the property | ||
- `value`: value of the property (nullable) | ||
#### Example | ||
```javascript | ||
import {setTrackingProperty} from '@tef-novum/webview-bridge'; | ||
setTrackingProperty('some_system', 'some_property_name', 'some_property_value'); | ||
``` | ||
## Error handling | ||
@@ -679,0 +701,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
202003
0.77%4072
0.54%711
3.19%