New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tef-novum/webview-bridge

Package Overview
Dependencies
Maintainers
7
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tef-novum/webview-bridge - npm Package Compare versions

Comparing version 3.8.0 to 3.9.0

5

CHANGELOG.md
# CHANGELOG
## v.3.9.0 - 2022-06-16
- Analytics: added support for GA4 with gtag script in web. Removed old web UA
support with google analytics.js script
## v.3.8.0 - 2022-06-08

@@ -4,0 +9,0 @@

37

dist/src/analytics.d.ts

@@ -0,5 +1,9 @@

/** @deprecated */
export 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_WEBAPP_INSTALLED: CustomDimensionIdx;
export declare const CD_NOVUM_UID: CustomDimensionIdx;
export declare const CD_EVENT_VALUE: CustomDimensionIdx;
/** @deprecated */
export declare const CD_WEBAPP_INSTALLED = 4;
/** @deprecated */
export declare const CD_NOVUM_UID = 7;
/** @deprecated */
export declare const CD_EVENT_VALUE = 8;
declare type LegacyAnalyticsEvent = {

@@ -39,28 +43,7 @@ /** Typically the object that was interacted with (e.g. 'Video') */

}>) => Promise<void>;
export declare const setScreenName: (screenName: string, fieldsObject?: {
export declare const setScreenName: (screenName: string, params?: {
[key: string]: any;
} | undefined) => Promise<void>;
declare const USER_PROPERTY_TO_CUSTOM_DIMENSION: {
readonly obIds: 1;
readonly paymentModels: 2;
readonly serviceWorkerStatus: 3;
readonly isAdmin: 5;
readonly hasIpComms: 6;
readonly af_source: 9;
readonly af_campaign: 10;
readonly novum_uid_session: 11;
readonly user_logged: 12;
readonly currentSubscriptionId: 13;
readonly currentSubscriptionType: 14;
readonly currentPaymentModel: 15;
readonly webviewBrowserVersion: 16;
readonly activatedRoles: 17;
readonly appInstanceId: 18;
readonly experimentflag: 20;
readonly friendsApps: 24;
readonly accountLineSelector: 25;
readonly OneClickDisplayed: 26;
};
declare type UserPropertyName = keyof typeof USER_PROPERTY_TO_CUSTOM_DIMENSION;
export declare const setUserProperty: (name: UserPropertyName | string, value: string) => Promise<void>;
declare type KnownUserPropertyName = 'obIds' | 'paymentModels' | 'serviceWorkerStatus' | 'isAdmin' | 'hasIpComms' | 'af_source' | 'af_campaign' | 'novum_uid_session' | 'user_logged' | 'currentSubscriptionId' | 'currentSubscriptionType' | 'currentPaymentModel' | 'webviewBrowserVersion' | 'activatedRoles' | 'appInstanceId' | 'experimentflag' | 'friendsApps' | 'accountLineSelector' | 'OneClickDisplayed';
export declare const setUserProperty: (name: KnownUserPropertyName | string, value: string) => Promise<void>;
export declare const setCustomerHash: (hash: string) => Promise<void>;

@@ -67,0 +50,0 @@ export declare const getCustomerHash: () => Promise<{

@@ -518,30 +518,10 @@ define(['exports'], (function (exports) { 'use strict';

var CD_OB_IDS = 1; // from sessionInfo
var CD_PAYMENT_MODELS = 2; // from sessionInfo
var CD_SERVICE_WORKER_STATUS = 3;
/** @deprecated */
var CD_WEBAPP_INSTALLED = 4;
var CD_SUBSCRIPTION_ADMIN = 5; // from sessionInfo
var CD_SUBSCRIPTION_WITH_IPCOMMS = 6; // from sessionInfo
/** @deprecated */
var CD_NOVUM_UID = 7;
/** @deprecated */
var CD_EVENT_VALUE = 8;
var CD_AF_SOURCE = 9;
var CD_AF_CAMPAIGN = 10;
var CD_NOVUM_UID_SESSION = 11;
var CD_USER_LOGGED = 12;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var CD_WEBVIEW_BROWSER_VERSION = 16;
var CD_ACTIVATED_ROLES = 17;
var CD_APP_INSTANCE_ID = 18;
var CD_EXPERIMENT_FLAG = 20;
var CD_FRIENDS_APPS = 24;
var CD_ACOUNT_LINE_SELECTOR = 25;
var CD_ONE_CLICK_DISPLAYED = 26;
var DEFAULT_EVENT_LABEL = 'null_label';
var DEFAULT_EVENT_VALUE = 0;
var VALID_TRACKERS = ['NovumTracker', 'OBARGTracker'];
var isTrackerValid = function (tracker) {
return VALID_TRACKERS.indexOf(tracker.get('name')) >= 0;
};
var withAnalytics = function (_a) {

@@ -562,7 +542,7 @@ var onAndroid = _a.onAndroid, onIos = _a.onIos, onWeb = _a.onWeb;

}
else if (window.ga &&
// @ts-ignore
window.ga.loaded) {
else if (
// @ts-ignore TS thinks gtag is always available, but it may not be the case if the page has not loaded the gtag script
window.gtag) {
// Use Google Analytics when webapp is outside the native app webview
return onWeb(window.ga);
return onWeb(window.gtag);
}

@@ -586,2 +566,13 @@ else {

}; // Replace spaces with underscores
var sanitizeParams = function (params) {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
return params;
};
var getLegacyAnalyticsEventParams = function (_a) {

@@ -597,2 +588,3 @@ var category = _a.category, action = _a.action, label = _a.label, value = _a.value, fieldsObject = __rest(_a, ["category", "action", "label", "value"]);

};
var currentScreenName = '';
var logEvent = function (event) {

@@ -613,12 +605,7 @@ var name = event.name, params = __rest(event, ["name"]);

else {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
params = sanitizeParams(params);
name = sanitize(name);
}
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -639,5 +626,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
ga('NovumTracker.send', 'event', __assign(__assign({}, params), { hitCallback: resolve }));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -648,2 +635,4 @@ },

var logEcommerceEvent = function (name, params) {
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -699,6 +688,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function () {
return new Promise(function (resolve) {
var _a;
ga('NovumTracker.send', __assign((_a = { hitType: 'timing', hitCallback: resolve }, _a["dimension".concat(CD_EVENT_VALUE)] = String(value), _a), params));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -708,4 +696,3 @@ },

};
var currentPageName;
var setScreenName = function (screenName, fieldsObject) {
var setScreenName = function (screenName, params) {
if (!screenName) {

@@ -729,22 +716,6 @@ console.warn('Missing analytics screenName');

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
// Page name should start with '/'
var pageName = screenName.startsWith('/')
? screenName
: "/".concat(screenName);
if (pageName !== currentPageName) {
currentPageName = pageName;
ga(function () {
// we have two trackers in movistar ARG, we want to track the PV in both trackers
var trackers = ga.getAll().filter(isTrackerValid);
trackers.forEach(function (tracker) {
tracker.set('page', pageName);
tracker.send('pageView', __assign(__assign({}, fieldsObject), { hitCallback: resolve }));
});
});
}
else {
resolve();
}
gtag('event', 'screen_view', __assign(__assign({ screenName: screenName, previousScreenName: currentScreenName }, sanitizeParams(params !== null && params !== void 0 ? params : {})), { event_callback: resolve }));
currentScreenName = screenName;
});

@@ -754,23 +725,2 @@ },

};
var USER_PROPERTY_TO_CUSTOM_DIMENSION = {
obIds: CD_OB_IDS,
paymentModels: CD_PAYMENT_MODELS,
serviceWorkerStatus: CD_SERVICE_WORKER_STATUS,
isAdmin: CD_SUBSCRIPTION_ADMIN,
hasIpComms: CD_SUBSCRIPTION_WITH_IPCOMMS,
af_source: CD_AF_SOURCE,
af_campaign: CD_AF_CAMPAIGN,
novum_uid_session: CD_NOVUM_UID_SESSION,
user_logged: CD_USER_LOGGED,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
webviewBrowserVersion: CD_WEBVIEW_BROWSER_VERSION,
activatedRoles: CD_ACTIVATED_ROLES,
appInstanceId: CD_APP_INSTANCE_ID,
experimentflag: CD_EXPERIMENT_FLAG,
friendsApps: CD_FRIENDS_APPS,
accountLineSelector: CD_ACOUNT_LINE_SELECTOR,
OneClickDisplayed: CD_ONE_CLICK_DISPLAYED,
};
var setUserProperty = function (name, value) {

@@ -797,12 +747,5 @@ if (!name || !value) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
var _a;
var dimensionIdx = USER_PROPERTY_TO_CUSTOM_DIMENSION[name];
if (!dimensionIdx) {
console.warn('No custom dimension defined for user property', name);
return Promise.resolve();
}
ga('NovumTracker.set', (_a = {},
_a["dimension".concat(dimensionIdx)] = String(value),
_a));
gtag('set', 'user_properties', (_a = {}, _a[name] = sanitize(value), _a));
return Promise.resolve();

@@ -809,0 +752,0 @@ },

@@ -520,30 +520,10 @@ 'use strict';

var CD_OB_IDS = 1; // from sessionInfo
var CD_PAYMENT_MODELS = 2; // from sessionInfo
var CD_SERVICE_WORKER_STATUS = 3;
/** @deprecated */
var CD_WEBAPP_INSTALLED = 4;
var CD_SUBSCRIPTION_ADMIN = 5; // from sessionInfo
var CD_SUBSCRIPTION_WITH_IPCOMMS = 6; // from sessionInfo
/** @deprecated */
var CD_NOVUM_UID = 7;
/** @deprecated */
var CD_EVENT_VALUE = 8;
var CD_AF_SOURCE = 9;
var CD_AF_CAMPAIGN = 10;
var CD_NOVUM_UID_SESSION = 11;
var CD_USER_LOGGED = 12;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var CD_WEBVIEW_BROWSER_VERSION = 16;
var CD_ACTIVATED_ROLES = 17;
var CD_APP_INSTANCE_ID = 18;
var CD_EXPERIMENT_FLAG = 20;
var CD_FRIENDS_APPS = 24;
var CD_ACOUNT_LINE_SELECTOR = 25;
var CD_ONE_CLICK_DISPLAYED = 26;
var DEFAULT_EVENT_LABEL = 'null_label';
var DEFAULT_EVENT_VALUE = 0;
var VALID_TRACKERS = ['NovumTracker', 'OBARGTracker'];
var isTrackerValid = function (tracker) {
return VALID_TRACKERS.indexOf(tracker.get('name')) >= 0;
};
var withAnalytics = function (_a) {

@@ -564,7 +544,7 @@ var onAndroid = _a.onAndroid, onIos = _a.onIos, onWeb = _a.onWeb;

}
else if (window.ga &&
// @ts-ignore
window.ga.loaded) {
else if (
// @ts-ignore TS thinks gtag is always available, but it may not be the case if the page has not loaded the gtag script
window.gtag) {
// Use Google Analytics when webapp is outside the native app webview
return onWeb(window.ga);
return onWeb(window.gtag);
}

@@ -588,2 +568,13 @@ else {

}; // Replace spaces with underscores
var sanitizeParams = function (params) {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
return params;
};
var getLegacyAnalyticsEventParams = function (_a) {

@@ -599,2 +590,3 @@ var category = _a.category, action = _a.action, label = _a.label, value = _a.value, fieldsObject = __rest(_a, ["category", "action", "label", "value"]);

};
var currentScreenName = '';
var logEvent = function (event) {

@@ -615,12 +607,7 @@ var name = event.name, params = __rest(event, ["name"]);

else {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
params = sanitizeParams(params);
name = sanitize(name);
}
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -641,5 +628,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
ga('NovumTracker.send', 'event', __assign(__assign({}, params), { hitCallback: resolve }));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -650,2 +637,4 @@ },

var logEcommerceEvent = function (name, params) {
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -701,6 +690,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function () {
return new Promise(function (resolve) {
var _a;
ga('NovumTracker.send', __assign((_a = { hitType: 'timing', hitCallback: resolve }, _a["dimension".concat(CD_EVENT_VALUE)] = String(value), _a), params));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -710,4 +698,3 @@ },

};
var currentPageName;
var setScreenName = function (screenName, fieldsObject) {
var setScreenName = function (screenName, params) {
if (!screenName) {

@@ -731,22 +718,6 @@ console.warn('Missing analytics screenName');

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
// Page name should start with '/'
var pageName = screenName.startsWith('/')
? screenName
: "/".concat(screenName);
if (pageName !== currentPageName) {
currentPageName = pageName;
ga(function () {
// we have two trackers in movistar ARG, we want to track the PV in both trackers
var trackers = ga.getAll().filter(isTrackerValid);
trackers.forEach(function (tracker) {
tracker.set('page', pageName);
tracker.send('pageView', __assign(__assign({}, fieldsObject), { hitCallback: resolve }));
});
});
}
else {
resolve();
}
gtag('event', 'screen_view', __assign(__assign({ screenName: screenName, previousScreenName: currentScreenName }, sanitizeParams(params !== null && params !== void 0 ? params : {})), { event_callback: resolve }));
currentScreenName = screenName;
});

@@ -756,23 +727,2 @@ },

};
var USER_PROPERTY_TO_CUSTOM_DIMENSION = {
obIds: CD_OB_IDS,
paymentModels: CD_PAYMENT_MODELS,
serviceWorkerStatus: CD_SERVICE_WORKER_STATUS,
isAdmin: CD_SUBSCRIPTION_ADMIN,
hasIpComms: CD_SUBSCRIPTION_WITH_IPCOMMS,
af_source: CD_AF_SOURCE,
af_campaign: CD_AF_CAMPAIGN,
novum_uid_session: CD_NOVUM_UID_SESSION,
user_logged: CD_USER_LOGGED,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
webviewBrowserVersion: CD_WEBVIEW_BROWSER_VERSION,
activatedRoles: CD_ACTIVATED_ROLES,
appInstanceId: CD_APP_INSTANCE_ID,
experimentflag: CD_EXPERIMENT_FLAG,
friendsApps: CD_FRIENDS_APPS,
accountLineSelector: CD_ACOUNT_LINE_SELECTOR,
OneClickDisplayed: CD_ONE_CLICK_DISPLAYED,
};
var setUserProperty = function (name, value) {

@@ -799,12 +749,5 @@ if (!name || !value) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
var _a;
var dimensionIdx = USER_PROPERTY_TO_CUSTOM_DIMENSION[name];
if (!dimensionIdx) {
console.warn('No custom dimension defined for user property', name);
return Promise.resolve();
}
ga('NovumTracker.set', (_a = {},
_a["dimension".concat(dimensionIdx)] = String(value),
_a));
gtag('set', 'user_properties', (_a = {}, _a[name] = sanitize(value), _a));
return Promise.resolve();

@@ -811,0 +754,0 @@ },

@@ -519,30 +519,10 @@ var webviewBridge = (function (exports) {

var CD_OB_IDS = 1; // from sessionInfo
var CD_PAYMENT_MODELS = 2; // from sessionInfo
var CD_SERVICE_WORKER_STATUS = 3;
/** @deprecated */
var CD_WEBAPP_INSTALLED = 4;
var CD_SUBSCRIPTION_ADMIN = 5; // from sessionInfo
var CD_SUBSCRIPTION_WITH_IPCOMMS = 6; // from sessionInfo
/** @deprecated */
var CD_NOVUM_UID = 7;
/** @deprecated */
var CD_EVENT_VALUE = 8;
var CD_AF_SOURCE = 9;
var CD_AF_CAMPAIGN = 10;
var CD_NOVUM_UID_SESSION = 11;
var CD_USER_LOGGED = 12;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var CD_WEBVIEW_BROWSER_VERSION = 16;
var CD_ACTIVATED_ROLES = 17;
var CD_APP_INSTANCE_ID = 18;
var CD_EXPERIMENT_FLAG = 20;
var CD_FRIENDS_APPS = 24;
var CD_ACOUNT_LINE_SELECTOR = 25;
var CD_ONE_CLICK_DISPLAYED = 26;
var DEFAULT_EVENT_LABEL = 'null_label';
var DEFAULT_EVENT_VALUE = 0;
var VALID_TRACKERS = ['NovumTracker', 'OBARGTracker'];
var isTrackerValid = function (tracker) {
return VALID_TRACKERS.indexOf(tracker.get('name')) >= 0;
};
var withAnalytics = function (_a) {

@@ -563,7 +543,7 @@ var onAndroid = _a.onAndroid, onIos = _a.onIos, onWeb = _a.onWeb;

}
else if (window.ga &&
// @ts-ignore
window.ga.loaded) {
else if (
// @ts-ignore TS thinks gtag is always available, but it may not be the case if the page has not loaded the gtag script
window.gtag) {
// Use Google Analytics when webapp is outside the native app webview
return onWeb(window.ga);
return onWeb(window.gtag);
}

@@ -587,2 +567,13 @@ else {

}; // Replace spaces with underscores
var sanitizeParams = function (params) {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
return params;
};
var getLegacyAnalyticsEventParams = function (_a) {

@@ -598,2 +589,3 @@ var category = _a.category, action = _a.action, label = _a.label, value = _a.value, fieldsObject = __rest(_a, ["category", "action", "label", "value"]);

};
var currentScreenName = '';
var logEvent = function (event) {

@@ -614,12 +606,7 @@ var name = event.name, params = __rest(event, ["name"]);

else {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
params = sanitizeParams(params);
name = sanitize(name);
}
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -640,5 +627,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
ga('NovumTracker.send', 'event', __assign(__assign({}, params), { hitCallback: resolve }));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -649,2 +636,4 @@ },

var logEcommerceEvent = function (name, params) {
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -700,6 +689,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function () {
return new Promise(function (resolve) {
var _a;
ga('NovumTracker.send', __assign((_a = { hitType: 'timing', hitCallback: resolve }, _a["dimension".concat(CD_EVENT_VALUE)] = String(value), _a), params));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -709,4 +697,3 @@ },

};
var currentPageName;
var setScreenName = function (screenName, fieldsObject) {
var setScreenName = function (screenName, params) {
if (!screenName) {

@@ -730,22 +717,6 @@ console.warn('Missing analytics screenName');

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
// Page name should start with '/'
var pageName = screenName.startsWith('/')
? screenName
: "/".concat(screenName);
if (pageName !== currentPageName) {
currentPageName = pageName;
ga(function () {
// we have two trackers in movistar ARG, we want to track the PV in both trackers
var trackers = ga.getAll().filter(isTrackerValid);
trackers.forEach(function (tracker) {
tracker.set('page', pageName);
tracker.send('pageView', __assign(__assign({}, fieldsObject), { hitCallback: resolve }));
});
});
}
else {
resolve();
}
gtag('event', 'screen_view', __assign(__assign({ screenName: screenName, previousScreenName: currentScreenName }, sanitizeParams(params !== null && params !== void 0 ? params : {})), { event_callback: resolve }));
currentScreenName = screenName;
});

@@ -755,23 +726,2 @@ },

};
var USER_PROPERTY_TO_CUSTOM_DIMENSION = {
obIds: CD_OB_IDS,
paymentModels: CD_PAYMENT_MODELS,
serviceWorkerStatus: CD_SERVICE_WORKER_STATUS,
isAdmin: CD_SUBSCRIPTION_ADMIN,
hasIpComms: CD_SUBSCRIPTION_WITH_IPCOMMS,
af_source: CD_AF_SOURCE,
af_campaign: CD_AF_CAMPAIGN,
novum_uid_session: CD_NOVUM_UID_SESSION,
user_logged: CD_USER_LOGGED,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
webviewBrowserVersion: CD_WEBVIEW_BROWSER_VERSION,
activatedRoles: CD_ACTIVATED_ROLES,
appInstanceId: CD_APP_INSTANCE_ID,
experimentflag: CD_EXPERIMENT_FLAG,
friendsApps: CD_FRIENDS_APPS,
accountLineSelector: CD_ACOUNT_LINE_SELECTOR,
OneClickDisplayed: CD_ONE_CLICK_DISPLAYED,
};
var setUserProperty = function (name, value) {

@@ -798,12 +748,5 @@ if (!name || !value) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
var _a;
var dimensionIdx = USER_PROPERTY_TO_CUSTOM_DIMENSION[name];
if (!dimensionIdx) {
console.warn('No custom dimension defined for user property', name);
return Promise.resolve();
}
ga('NovumTracker.set', (_a = {},
_a["dimension".concat(dimensionIdx)] = String(value),
_a));
gtag('set', 'user_properties', (_a = {}, _a[name] = sanitize(value), _a));
return Promise.resolve();

@@ -810,0 +753,0 @@ },

@@ -1,1 +0,1 @@

var webviewBridge=function(e){"use strict";var n=1,t=function(){return"webapp-".concat(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(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=void 0,f=function(){return!l()&&(r()||i())},p=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),f=JSON.stringify({type:o,id:i,payload:u});return null===d||void 0===d||d("[WebView Bridge] SEND:",f),l?(setTimeout(function(){l(f)}),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: ".concat(n.type,". Expecting ").concat(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;null===d||void 0===d||d("[WebView Bridge] RCVD:",e);try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var y=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)}},m=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return f()?p({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())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=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)};function T(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}var E,h=["NovumTracker","OBARGTracker"],A=function(e){return h.indexOf(e.get("name"))>=0},P=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()},S=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},_=function(e){return S(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_")},I={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};return 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 p({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return p({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 p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(n),endTime:g(t),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return f()?p({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 p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(n){return v=n,w(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=f,e.logEcommerceEvent=function(e,n){return P({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=T(e,["name"]);if(u)Object.entries(s).forEach(function(e){var n=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(e,2),t=n[0],o=n[1];"string"==typeof o&&(s[t]=_(o))}),u=_(u);else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=T(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=b({eventCategory:t,eventAction:o,eventLabel:S(r),eventValue:i},a),u=e.category}return P({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",b(b({},s),{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 P({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",b(((t={hitType:"timing",hitCallback:n})["dimension".concat(8)]=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return f()?p({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 f()?p({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 f()?p({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e,n){return void 0===n&&(n={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},n.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){d=e},e.setScreenName=function(e,n){return e?P({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:"/".concat(e);r!==E?(E=r,t(function(){t.getAll().filter(A).forEach(function(e){e.set("page",r),e.send("pageView",b(b({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),P({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=I[e];return r?(t("NovumTracker.set",((o={})["dimension".concat(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 f()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.updateNavigationBar=m,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var webviewBridge=function(e){"use strict";var n=1,t=function(){return"webapp-".concat(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(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=void 0,f=function(){return!l()&&(r()||i())},p=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),f=JSON.stringify({type:o,id:i,payload:u});return null===d||void 0===d||d("[WebView Bridge] SEND:",f),l?(setTimeout(function(){l(f)}),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: ".concat(n.type,". Expecting ").concat(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;null===d||void 0===d||d("[WebView Bridge] RCVD:",e);try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var y=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)}},m=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return f()?p({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())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=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)};function E(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}var T=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.gtag?o(window.gtag):Promise.resolve()},h=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},A=function(e){return h(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_")},P=function(e){return Object.entries(e).forEach(function(n){var t=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(n,2),o=t[0],r=t[1];"string"==typeof r&&(e[o]=A(r))}),e},_="";return 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 p({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return p({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 p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(n),endTime:g(t),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return f()?p({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 p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(n){return v=n,w(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=f,e.logEcommerceEvent=function(e,n){return n=b(b({},n),{screenName:n.screenName||_}),T({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=E(e,["name"]);if(u)s=P(s),u=A(u);else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=E(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=b({eventCategory:t,eventAction:o,eventLabel:h(r),eventValue:i},a),u=e.category}return s=b(b({},s),{screenName:s.screenName||_}),T({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("event",u,b(b({},s),{event_callback: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 T({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(){return new Promise(function(e){gtag("event",u,b(b({},a),{event_callback:e}))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return f()?p({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 f()?p({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 f()?p({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e,n){return void 0===n&&(n={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},n.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){d=e},e.setScreenName=function(e,n){return e?T({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){t("event","screen_view",b(b({screenName:e,previousScreenName:_},P(null!==n&&void 0!==n?n:{})),{event_callback:o})),_=e})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),T({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;return t("set","user_properties",((o={})[e]=A(n),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.setWebViewTitle=function(e){return f()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.updateNavigationBar=m,Object.defineProperty(e,"__esModule",{value:!0}),e}({});

@@ -522,30 +522,10 @@ (function (global, factory) {

var CD_OB_IDS = 1; // from sessionInfo
var CD_PAYMENT_MODELS = 2; // from sessionInfo
var CD_SERVICE_WORKER_STATUS = 3;
/** @deprecated */
var CD_WEBAPP_INSTALLED = 4;
var CD_SUBSCRIPTION_ADMIN = 5; // from sessionInfo
var CD_SUBSCRIPTION_WITH_IPCOMMS = 6; // from sessionInfo
/** @deprecated */
var CD_NOVUM_UID = 7;
/** @deprecated */
var CD_EVENT_VALUE = 8;
var CD_AF_SOURCE = 9;
var CD_AF_CAMPAIGN = 10;
var CD_NOVUM_UID_SESSION = 11;
var CD_USER_LOGGED = 12;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var CD_WEBVIEW_BROWSER_VERSION = 16;
var CD_ACTIVATED_ROLES = 17;
var CD_APP_INSTANCE_ID = 18;
var CD_EXPERIMENT_FLAG = 20;
var CD_FRIENDS_APPS = 24;
var CD_ACOUNT_LINE_SELECTOR = 25;
var CD_ONE_CLICK_DISPLAYED = 26;
var DEFAULT_EVENT_LABEL = 'null_label';
var DEFAULT_EVENT_VALUE = 0;
var VALID_TRACKERS = ['NovumTracker', 'OBARGTracker'];
var isTrackerValid = function (tracker) {
return VALID_TRACKERS.indexOf(tracker.get('name')) >= 0;
};
var withAnalytics = function (_a) {

@@ -566,7 +546,7 @@ var onAndroid = _a.onAndroid, onIos = _a.onIos, onWeb = _a.onWeb;

}
else if (window.ga &&
// @ts-ignore
window.ga.loaded) {
else if (
// @ts-ignore TS thinks gtag is always available, but it may not be the case if the page has not loaded the gtag script
window.gtag) {
// Use Google Analytics when webapp is outside the native app webview
return onWeb(window.ga);
return onWeb(window.gtag);
}

@@ -590,2 +570,13 @@ else {

}; // Replace spaces with underscores
var sanitizeParams = function (params) {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
return params;
};
var getLegacyAnalyticsEventParams = function (_a) {

@@ -601,2 +592,3 @@ var category = _a.category, action = _a.action, label = _a.label, value = _a.value, fieldsObject = __rest(_a, ["category", "action", "label", "value"]);

};
var currentScreenName = '';
var logEvent = function (event) {

@@ -617,12 +609,7 @@ var name = event.name, params = __rest(event, ["name"]);

else {
// Some params may contain strings with accents (some of them may be copies/translations), so we need to sanitize them
Object.entries(params).forEach(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (typeof value === 'string') {
// @ts-ignore - params is a new object created from event destructuring, so TS shouldn't complain about it being readonly
params[key] = sanitize(value);
}
});
params = sanitizeParams(params);
name = sanitize(name);
}
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -643,5 +630,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
ga('NovumTracker.send', 'event', __assign(__assign({}, params), { hitCallback: resolve }));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -652,2 +639,4 @@ },

var logEcommerceEvent = function (name, params) {
// set screen name if not set
params = __assign(__assign({}, params), { screenName: params.screenName || currentScreenName });
return withAnalytics({

@@ -703,6 +692,5 @@ onAndroid: function (androidFirebase) {

},
onWeb: function (ga) {
onWeb: function () {
return new Promise(function (resolve) {
var _a;
ga('NovumTracker.send', __assign((_a = { hitType: 'timing', hitCallback: resolve }, _a["dimension".concat(CD_EVENT_VALUE)] = String(value), _a), params));
gtag('event', name, __assign(__assign({}, params), { event_callback: resolve }));
});

@@ -712,4 +700,3 @@ },

};
var currentPageName;
var setScreenName = function (screenName, fieldsObject) {
var setScreenName = function (screenName, params) {
if (!screenName) {

@@ -733,22 +720,6 @@ console.warn('Missing analytics screenName');

},
onWeb: function (ga) {
onWeb: function (gtag) {
return new Promise(function (resolve) {
// Page name should start with '/'
var pageName = screenName.startsWith('/')
? screenName
: "/".concat(screenName);
if (pageName !== currentPageName) {
currentPageName = pageName;
ga(function () {
// we have two trackers in movistar ARG, we want to track the PV in both trackers
var trackers = ga.getAll().filter(isTrackerValid);
trackers.forEach(function (tracker) {
tracker.set('page', pageName);
tracker.send('pageView', __assign(__assign({}, fieldsObject), { hitCallback: resolve }));
});
});
}
else {
resolve();
}
gtag('event', 'screen_view', __assign(__assign({ screenName: screenName, previousScreenName: currentScreenName }, sanitizeParams(params !== null && params !== void 0 ? params : {})), { event_callback: resolve }));
currentScreenName = screenName;
});

@@ -758,23 +729,2 @@ },

};
var USER_PROPERTY_TO_CUSTOM_DIMENSION = {
obIds: CD_OB_IDS,
paymentModels: CD_PAYMENT_MODELS,
serviceWorkerStatus: CD_SERVICE_WORKER_STATUS,
isAdmin: CD_SUBSCRIPTION_ADMIN,
hasIpComms: CD_SUBSCRIPTION_WITH_IPCOMMS,
af_source: CD_AF_SOURCE,
af_campaign: CD_AF_CAMPAIGN,
novum_uid_session: CD_NOVUM_UID_SESSION,
user_logged: CD_USER_LOGGED,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
webviewBrowserVersion: CD_WEBVIEW_BROWSER_VERSION,
activatedRoles: CD_ACTIVATED_ROLES,
appInstanceId: CD_APP_INSTANCE_ID,
experimentflag: CD_EXPERIMENT_FLAG,
friendsApps: CD_FRIENDS_APPS,
accountLineSelector: CD_ACOUNT_LINE_SELECTOR,
OneClickDisplayed: CD_ONE_CLICK_DISPLAYED,
};
var setUserProperty = function (name, value) {

@@ -801,12 +751,5 @@ if (!name || !value) {

},
onWeb: function (ga) {
onWeb: function (gtag) {
var _a;
var dimensionIdx = USER_PROPERTY_TO_CUSTOM_DIMENSION[name];
if (!dimensionIdx) {
console.warn('No custom dimension defined for user property', name);
return Promise.resolve();
}
ga('NovumTracker.set', (_a = {},
_a["dimension".concat(dimensionIdx)] = String(value),
_a));
gtag('set', 'user_properties', (_a = {}, _a[name] = sanitize(value), _a));
return Promise.resolve();

@@ -813,0 +756,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="undefined"!=typeof globalThis?globalThis:e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return"webapp-".concat(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(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=void 0,f=function(){return!l()&&(r()||i())},p=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),f=JSON.stringify({type:o,id:i,payload:u});return null===d||void 0===d||d("[WebView Bridge] SEND:",f),l?(setTimeout(function(){l(f)}),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: ".concat(n.type,". Expecting ").concat(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;null===d||void 0===d||d("[WebView Bridge] RCVD:",e);try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var y=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)}},m=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return f()?p({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())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=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)};function T(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}var E,h=["NovumTracker","OBARGTracker"],A=function(e){return h.indexOf(e.get("name"))>=0},P=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()},S=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},_=function(e){return S(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_")},I={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 p({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return p({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 p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(n),endTime:g(t),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return f()?p({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 p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(n){return v=n,w(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=f,e.logEcommerceEvent=function(e,n){return P({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=T(e,["name"]);if(u)Object.entries(s).forEach(function(e){var n=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(e,2),t=n[0],o=n[1];"string"==typeof o&&(s[t]=_(o))}),u=_(u);else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=T(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=b({eventCategory:t,eventAction:o,eventLabel:S(r),eventValue:i},a),u=e.category}return P({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",b(b({},s),{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 P({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",b(((t={hitType:"timing",hitCallback:n})["dimension".concat(8)]=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return f()?p({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 f()?p({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 f()?p({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e,n){return void 0===n&&(n={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},n.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){d=e},e.setScreenName=function(e,n){return e?P({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:"/".concat(e);r!==E?(E=r,t(function(){t.getAll().filter(A).forEach(function(e){e.set("page",r),e.send("pageView",b(b({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),P({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=I[e];return r?(t("NovumTracker.set",((o={})["dimension".concat(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 f()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.updateNavigationBar=m,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-".concat(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(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},f=void 0,d=function(){return!l()&&(r()||i())},p=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 null===f||void 0===f||f("[WebView Bridge] SEND:",d),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: ".concat(n.type,". Expecting ").concat(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;null===f||void 0===f||f("[WebView Bridge] RCVD:",e);try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var y=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)}},m=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return d()?p({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())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=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)};function E(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}var T=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.gtag?o(window.gtag):Promise.resolve()},h=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},A=function(e){return h(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_")},P=function(e){return Object.entries(e).forEach(function(n){var t=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(n,2),o=t[0],r=t[1];"string"==typeof r&&(e[o]=A(r))}),e},_="";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 p({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return p({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 p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(n),endTime:g(t),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return d()?p({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 p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(n){return v=n,w(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,n){return n=b(b({},n),{screenName:n.screenName||_}),T({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=E(e,["name"]);if(u)s=P(s),u=A(u);else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=E(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=b({eventCategory:t,eventAction:o,eventLabel:h(r),eventValue:i},a),u=e.category}return s=b(b({},s),{screenName:s.screenName||_}),T({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("event",u,b(b({},s),{event_callback: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 T({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(){return new Promise(function(e){gtag("event",u,b(b({},a),{event_callback:e}))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return d()?p({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 d()?p({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 d()?p({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e,n){return void 0===n&&(n={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},n.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){f=e},e.setScreenName=function(e,n){return e?T({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){t("event","screen_view",b(b({screenName:e,previousScreenName:_},P(null!==n&&void 0!==n?n:{})),{event_callback:o})),_=e})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),T({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;return t("set","user_properties",((o={})[e]=A(n),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.setWebViewTitle=function(e){return d()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.updateNavigationBar=m,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@tef-novum/webview-bridge",
"version": "3.8.0",
"version": "3.9.0",
"description": "JavaScript library to access to native functionality. Requires a webview with a postMessage bridge.",

@@ -35,3 +35,3 @@ "main": "./dist/webview-bridge-cjs.js",

"@telefonica/ts-to-flow": "1.1.6",
"@types/google.analytics": "0.0.42",
"@types/gtag.js": "^0.0.10",
"@types/jest": "^27.0.3",

@@ -38,0 +38,0 @@ "@typescript-eslint/eslint-plugin": "^5.6.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc