UNPKG

skip-event-bridge

Version:
1,446 lines (1,161 loc) 60.6 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } /* eslint-disable vars-on-top */ var getType = function (value) { return Object.prototype.toString.call(value).replace(/\W/g, '').slice(6); }; var isType = function (value, type) { return getType(value).toLowerCase() === type.toLowerCase(); }; var makeTrustworthy = function (obj) { if (Array.isArray(obj)) { obj.forEach(function (element) { makeTrustworthy(element); }); return obj; } var newObj = Object.keys(obj).reduce(function (prev, curr) { var obj$1; var key = curr.replace(/_/g, ' '); var value = obj[curr]; if (Array.isArray(value) && !value.length) { return prev; } if (value === null || value === undefined) { return prev; } if (value instanceof Date) { return prev; } if (!isType(value, 'date') && typeof value === 'object') { value = makeTrustworthy(value); } return Object.assign({}, prev, ( obj$1 = {}, obj$1[key] = value, obj$1 )); }, {}); return newObj; }; var EventAction = function EventAction () {}; EventAction.prototype.appReviewed = function appReviewed (sender, review) { // TODO: Check payload sender('App Reviewed', makeTrustworthy(review)); }; EventAction.prototype.charged = function charged (sender, completed) { sender('Charged', makeTrustworthy(completed)); }; EventAction.prototype.deepLinkClicked = function deepLinkClicked (sender) { // TODO: Check payload sender('Deep Link Clicked', null); }; EventAction.prototype.deepLinkOpened = function deepLinkOpened (sender, deepLink) { sender('Deep Link Opened', makeTrustworthy(deepLink)); }; EventAction.prototype.login = function login (sender, status) { sender('Login', makeTrustworthy(status)); }; EventAction.prototype.logout = function logout (sender) { sender('Logout', null); }; EventAction.prototype.onUserLogin = function onUserLogin (sender, user) { sender(makeTrustworthy(user)); }; EventAction.prototype.orderSubmited = function orderSubmited (sender, order) { var Items = order.Items; var base = _objectWithoutPropertiesLoose(order, ["Items"]); sender(makeTrustworthy(base), makeTrustworthy(Items)); }; EventAction.prototype.passwordResetSent = function passwordResetSent (sender) { // TODO: Check payload sender('Password Reset Sent', null); }; EventAction.prototype.signUpStarted = function signUpStarted (sender, status) { sender('Sign Up Started', makeTrustworthy(status)); }; EventAction.prototype.forgotPassword = function forgotPassword (sender) { sender('Password Reset Sent', null); }; EventAction.prototype.visitsHomePage = function visitsHomePage (sender, pageVisited) { sender('Visits Home Page', makeTrustworthy(pageVisited)); }; EventAction.prototype.visitsJoinPage = function visitsJoinPage (sender, pageVisited) { sender('Visits Join Page', makeTrustworthy(pageVisited)); }; EventAction.prototype.visitsPremiumPage = function visitsPremiumPage (sender, pageVisited) { sender('Visits Premium Page', makeTrustworthy(pageVisited)); }; EventAction.prototype.visitsFreePage = function visitsFreePage (sender, pageVisited) { sender('Visits Free Page', makeTrustworthy(pageVisited)); }; EventAction.prototype.visitsOnboarding = function visitsOnboarding (sender, pageVisited) { sender('Visits OnBoarding', makeTrustworthy(pageVisited)); }; EventAction.prototype.visitsDashboard = function visitsDashboard (sender, pageVisited) { sender('Visits Dashboard Page', makeTrustworthy(pageVisited)); }; EventAction.prototype.visitsBusinessProfile = function visitsBusinessProfile (sender, pageVisited) { sender('Visits Business Profile Page', makeTrustworthy(pageVisited)); }; EventAction.prototype.visitsRemindersPage = function visitsRemindersPage (sender, pageVisited) { sender('Visits Reminders Page', makeTrustworthy(pageVisited)); }; EventAction.prototype.userClicksSignUp = function userClicksSignUp (sender, pageVisited) { sender('User Clicks Sign Up', makeTrustworthy(pageVisited)); }; EventAction.prototype.userCompletesBusinessProfile = function userCompletesBusinessProfile (sender, pageVisited) { sender('User Completes Business Profile', makeTrustworthy(pageVisited)); }; EventAction.prototype.userClickTodoItem = function userClickTodoItem (sender, todoItemType) { sender('User Click ToDo Item', makeTrustworthy(todoItemType)); }; EventAction.prototype.userConfirmsSubscription = function userConfirmsSubscription (sender, subscription) { sender('User Confirms Subscription', makeTrustworthy(subscription)); }; EventAction.prototype.userScheduledOnboardingCall = function userScheduledOnboardingCall (sender, pageVisited) { sender('User Scheduled Onboarding Call', makeTrustworthy(pageVisited)); }; EventAction.prototype.userFeaturedBusinessOnSkip = function userFeaturedBusinessOnSkip (sender, payload) { sender('User Featured Business on Skip', makeTrustworthy(payload)); }; EventAction.prototype.accountCreated = function accountCreated (sender, payload) { sender('Account Created', makeTrustworthy(payload)); }; EventAction.prototype.accountCreatedError = function accountCreatedError (sender, payload) { sender('Account Created Error', makeTrustworthy(payload)); }; EventAction.prototype.clickedAnnual = function clickedAnnual (sender, payload) { sender('Clicked Annual', makeTrustworthy(payload)); }; EventAction.prototype.clickedAutoSubCheckbox = function clickedAutoSubCheckbox (sender, payload) { sender('Clicked Auto Sub Checkbox', makeTrustworthy(payload)); }; EventAction.prototype.clickedCardNumberField = function clickedCardNumberField (sender, payload) { sender('Clicked Card Number Field', makeTrustworthy(payload)); }; EventAction.prototype.clickedCheckAvailability = function clickedCheckAvailability (sender, payload) { sender('Clicked Check Availability', makeTrustworthy(payload)); }; EventAction.prototype.clickedConfirm = function clickedConfirm (sender, payload) { sender('Clicked Confirm', makeTrustworthy(payload)); }; EventAction.prototype.clickedContinuetoDashboard = function clickedContinuetoDashboard (sender, payload) { sender('Clicked Continue to Dashboard', makeTrustworthy(payload)); }; EventAction.prototype.clickedDownloadApp = function clickedDownloadApp (sender, payload) { sender('Clicked Download App', makeTrustworthy(payload)); }; EventAction.prototype.clickedFunding = function clickedFunding (sender, payload) { sender('Clicked Funding', makeTrustworthy(payload)); }; EventAction.prototype.clickedLogin = function clickedLogin (sender, payload) { sender('Clicked Login', makeTrustworthy(payload)); }; EventAction.prototype.clickedMonthly = function clickedMonthly (sender, payload) { sender('Clicked Monthly', makeTrustworthy(payload)); }; EventAction.prototype.clickedPrivacyPolicy = function clickedPrivacyPolicy (sender, payload) { sender('Clicked Privacy Policy', makeTrustworthy(payload)); }; EventAction.prototype.clickedReferralEmailField = function clickedReferralEmailField (sender, payload) { sender('Clicked Referral Email Field', makeTrustworthy(payload)); }; EventAction.prototype.clickedReviewReadMore = function clickedReviewReadMore (sender, payload) { sender('Clicked Review Read More', makeTrustworthy(payload)); }; EventAction.prototype.clickedSaveNewPassword = function clickedSaveNewPassword (sender, payload) { sender('Clicked Save New Password', makeTrustworthy(payload)); }; EventAction.prototype.clickedSendInvites = function clickedSendInvites (sender, payload) { sender('Clicked Send Invites', makeTrustworthy(payload)); }; EventAction.prototype.clickedTermsandConditions = function clickedTermsandConditions (sender, payload) { sender('Clicked Terms and Conditions', makeTrustworthy(payload)); }; EventAction.prototype.paymentVerifiedError = function paymentVerifiedError (sender, payload) { sender('Payment Verified Error', makeTrustworthy(payload)); }; EventAction.prototype.paymentVerifiedSuccess = function paymentVerifiedSuccess (sender, payload) { sender('Payment Verified Success', makeTrustworthy(payload)); }; EventAction.prototype.saveNewPasswordError = function saveNewPasswordError (sender, payload) { sender('Save New Password Error', makeTrustworthy(payload)); }; EventAction.prototype.viewedCalendlyCalendar = function viewedCalendlyCalendar (sender, payload) { sender('Viewed Calendly Calendar', makeTrustworthy(payload)); }; EventAction.prototype.viewedNewPasswordPage = function viewedNewPasswordPage (sender, payload) { sender('Viewed New Password Page', makeTrustworthy(payload)); }; EventAction.prototype.viewedPaymentInfo = function viewedPaymentInfo (sender, payload) { sender('Viewed Payment Info', makeTrustworthy(payload)); }; EventAction.prototype.viewedPlusPage = function viewedPlusPage (sender, payload) { sender('Viewed Plus Page', makeTrustworthy(payload)); }; EventAction.prototype.viewedPremiumConciergePage = function viewedPremiumConciergePage (sender, payload) { sender('Viewed Premium Concierge Page', makeTrustworthy(payload)); }; EventAction.prototype.viewedPlatinumConciergePage = function viewedPlatinumConciergePage (sender, payload) { sender('Viewed Platinum Concierge Page', makeTrustworthy(payload)); }; // plop EventAction.prototype.addedLoanApplicationTracking = function addedLoanApplicationTracking (sender, payload) { sender('Added Loan Application Tracking', makeTrustworthy(payload)); }; EventAction.prototype.clickedServiceFlow = function clickedServiceFlow (sender, payload) { sender('Clicked Service Flow', makeTrustworthy(payload)); }; EventAction.prototype.upgradedFromAccountDetails = function upgradedFromAccountDetails (sender, payload) { sender('Upgraded From Account Details', makeTrustworthy(payload)); }; EventAction.prototype.upgradedFromLatestFundingOpportunity = function upgradedFromLatestFundingOpportunity (sender, payload) { sender('Upgraded From Latest Funding Opportunity', makeTrustworthy(payload)); }; EventAction.prototype.addedFundingGoal = function addedFundingGoal (sender, payload) { sender('Added Funding Goal', makeTrustworthy(payload)); }; EventAction.prototype.clickOnBlog = function clickOnBlog (sender, payload) { sender('Click on Blog', makeTrustworthy(payload)); }; EventAction.prototype.notInterestedInFundingOpportunity = function notInterestedInFundingOpportunity (sender, payload) { sender('Not Interested in Funding Opportunity', makeTrustworthy(payload)); }; EventAction.prototype.sharedReferralLink = function sharedReferralLink (sender, payload) { sender('Shared Referral Link', makeTrustworthy(payload)); }; EventAction.prototype.exitedAddBusinessModal = function exitedAddBusinessModal (sender, payload) { sender('Exited Add Business Modal', makeTrustworthy(payload)); }; EventAction.prototype.addedBusiness = function addedBusiness (sender, payload) { sender('Added Business', makeTrustworthy(payload)); }; EventAction.prototype.invitesAFriend = function invitesAFriend (sender, payload) { sender('Invites a Friend', makeTrustworthy(payload)); }; var MapProvider = function MapProvider() { this.providers = {}; }; MapProvider.prototype.addProvider = function addProvider (provider) { var id = Math.random().toString(36).substr(2); this.providers[id] = provider; return id; }; MapProvider.prototype.deleteProvider = function deleteProvider (id) { delete this.providers[id]; }; MapProvider.prototype.getProviders = function getProviders (ids) { var this$1 = this; var providers = ids.map(function (id) { return this$1.providers[id]; }); return providers.length ? providers : Object.keys(this.providers).reduce(function (prev, curr) { var provider = this$1.providers[curr]; return prev.concat( [provider]); }, []); }; /* eslint-disable @typescript-eslint/no-explicit-any */ var SkipEventSdk = function SkipEventSdk() { this.map = new MapProvider(); this.action = new EventAction(); }; /** * @description Adds an error handler * @param {ErrorHandler} errorHandler */ SkipEventSdk.prototype.addErrorHandler = function addErrorHandler (errorHandler) { this.errorHandler = errorHandler; }; /** * @description Adds an logger handler * @param {LoggerHandler} logger */ SkipEventSdk.prototype.addLogger = function addLogger (logger) { this.logger = logger; }; /** * @description Adds a new event provider * @param {Provider} provider - New provider * @returns {string} - Provider ID */ SkipEventSdk.prototype.addProvider = function addProvider (provider) { return this.map.addProvider(provider); }; /** * @description Removes a new event provider * @param {string} id - Provider ID * @memberof SkipEventSdk */ SkipEventSdk.prototype.deleteProvider = function deleteProvider (id) { this.map.deleteProvider(id); }; /** * @description Run the provider method * @private * @param {Function} action - Provider method * @param {*} payload - Provider method parameter * @param {string} providerName - Provider instance name */ SkipEventSdk.prototype.execute = function execute (action, payload, providerName) { try { action(payload); } catch (err) { if (typeof this.errorHandler === 'function') { this.errorHandler(providerName, { name: action.name, stack: String(err), message: String(err) }); } } }; /** * @description Checks whether the provider has the method. * @private * @param {Provider} provider * @param {ProviderAttr} method * @returns {boolean} */ SkipEventSdk.prototype.hasMethod = function hasMethod (provider, method) { return method in provider && typeof provider[method] === 'function'; }; /** * @description Scroll through the list of providers and perform their functions * @private * @param {ProviderAttr} keyFn - Provider method name * @param {*} payload - Provider method parameter * @param {Array<string>} [ids=[]] - Provider IDs */ SkipEventSdk.prototype.runAll = function runAll (keyFn, payload, ids) { var this$1 = this; if ( ids === void 0 ) ids = []; try { this.map.getProviders(ids).forEach(function (provider) { if (this$1.hasMethod(provider, keyFn)) { var action = provider[keyFn].bind(provider); this$1.execute(action, payload, provider.constructor.name); if (typeof this$1.logger === 'function') { this$1.logger(provider.constructor.name, keyFn); } } }); } catch (err) { if (typeof this.errorHandler === 'function') { this.errorHandler('Error before providers', { name: keyFn, stack: String(err), message: String(err) }); } } }; SkipEventSdk.prototype.tryAppReviewed = function tryAppReviewed (payload, ids) { this.runAll('appReviewed', payload, ids); }; SkipEventSdk.prototype.tryCharged = function tryCharged (payload, ids) { this.runAll('charged', payload, ids); }; SkipEventSdk.prototype.tryDeepLinkClicked = function tryDeepLinkClicked (payload, ids) { this.runAll('deepLinkClicked', payload, ids); }; SkipEventSdk.prototype.tryDeepLinkOpened = function tryDeepLinkOpened (payload, ids) { this.runAll('deepLinkOpened', payload, ids); }; SkipEventSdk.prototype.tryLogin = function tryLogin (payload, ids) { this.runAll('login', payload, ids); }; SkipEventSdk.prototype.tryLogout = function tryLogout (payload, ids) { this.runAll('logout', payload, ids); }; SkipEventSdk.prototype.tryOnUserLogin = function tryOnUserLogin (payload, ids) { this.runAll('onUserLogin', payload, ids); }; SkipEventSdk.prototype.tryOnUserSelectReasons = function tryOnUserSelectReasons (payload, ids) { this.runAll('onUserSelectReasons', payload, ids); }; SkipEventSdk.prototype.trySetUserLocation = function trySetUserLocation (payload, ids) { this.runAll('setUserLocation', payload, ids); }; SkipEventSdk.prototype.tryUpdateFCMtoken = function tryUpdateFCMtoken (payload, ids) { this.runAll('updateFCMtoken', payload, ids); }; SkipEventSdk.prototype.tryUserClicksSignUp = function tryUserClicksSignUp (payload, ids) { this.runAll('userClicksSignUp', payload, ids); }; SkipEventSdk.prototype.tryVisitsHomePage = function tryVisitsHomePage (payload, ids) { this.runAll('visitsHomePage', payload, ids); }; SkipEventSdk.prototype.tryVisitsJoinPage = function tryVisitsJoinPage (payload, ids) { this.runAll('visitsJoinPage', payload, ids); }; SkipEventSdk.prototype.tryVisitsPremiumPage = function tryVisitsPremiumPage (payload, ids) { this.runAll('visitsPremiumPage', payload, ids); }; SkipEventSdk.prototype.tryVisitsFreePage = function tryVisitsFreePage (payload, ids) { this.runAll('visitsFreePage', payload, ids); }; SkipEventSdk.prototype.tryVisitsOnboarding = function tryVisitsOnboarding (payload, ids) { this.runAll('visitsOnboarding', payload, ids); }; SkipEventSdk.prototype.tryVisitsDashboard = function tryVisitsDashboard (payload, ids) { this.runAll('visitsDashboard', payload, ids); }; SkipEventSdk.prototype.tryVisitsBusinessProfile = function tryVisitsBusinessProfile (payload, ids) { this.runAll('visitsBusinessProfile', payload, ids); }; SkipEventSdk.prototype.tryVisitsRemindersPage = function tryVisitsRemindersPage (payload, ids) { this.runAll('visitsRemindersPage', payload, ids); }; SkipEventSdk.prototype.tryUserCompletesBusinessProfile = function tryUserCompletesBusinessProfile (payload, ids) { this.runAll('userCompletesBusinessProfile', payload, ids); }; SkipEventSdk.prototype.tryUserClickTodoItem = function tryUserClickTodoItem (payload, ids) { this.runAll('userClickTodoItem', payload, ids); }; SkipEventSdk.prototype.tryUserConfirmsSubscription = function tryUserConfirmsSubscription (payload, ids) { this.runAll('userConfirmsSubscription', payload, ids); }; SkipEventSdk.prototype.tryUserScheduledOnboardingCall = function tryUserScheduledOnboardingCall (payload, ids) { this.runAll('userScheduledOnboardingCall', payload, ids); }; SkipEventSdk.prototype.tryUserFeaturedBusinessOnSkip = function tryUserFeaturedBusinessOnSkip (payload, ids) { this.runAll('userFeaturedBusinessOnSkip', payload, ids); }; SkipEventSdk.prototype.tryAccountCreated = function tryAccountCreated (payload, ids) { this.runAll('accountCreated', payload, ids); }; SkipEventSdk.prototype.tryAccountCreatedError = function tryAccountCreatedError (payload, ids) { this.runAll('accountCreatedError', payload, ids); }; SkipEventSdk.prototype.tryClickedAnnual = function tryClickedAnnual (payload, ids) { this.runAll('clickedAnnual', payload, ids); }; SkipEventSdk.prototype.tryClickedAutoSubCheckbox = function tryClickedAutoSubCheckbox (payload, ids) { this.runAll('clickedAutoSubCheckbox', payload, ids); }; SkipEventSdk.prototype.tryClickedCardNumberField = function tryClickedCardNumberField (payload, ids) { this.runAll('clickedCardNumberField', payload, ids); }; SkipEventSdk.prototype.tryClickedCheckAvailability = function tryClickedCheckAvailability (payload, ids) { this.runAll('clickedCheckAvailability', payload, ids); }; SkipEventSdk.prototype.tryClickedConfirm = function tryClickedConfirm (payload, ids) { this.runAll('clickedConfirm', payload, ids); }; SkipEventSdk.prototype.tryClickedContinuetoDashboard = function tryClickedContinuetoDashboard (payload, ids) { this.runAll('clickedContinuetoDashboard', payload, ids); }; SkipEventSdk.prototype.tryClickedDownloadApp = function tryClickedDownloadApp (payload, ids) { this.runAll('clickedDownloadApp', payload, ids); }; SkipEventSdk.prototype.tryClickedFunding = function tryClickedFunding (payload, ids) { this.runAll('clickedFunding', payload, ids); }; SkipEventSdk.prototype.tryClickedLogin = function tryClickedLogin (payload, ids) { this.runAll('clickedLogin', payload, ids); }; SkipEventSdk.prototype.tryClickedMonthly = function tryClickedMonthly (payload, ids) { this.runAll('clickedMonthly', payload, ids); }; SkipEventSdk.prototype.tryClickedPrivacyPolicy = function tryClickedPrivacyPolicy (payload, ids) { this.runAll('clickedPrivacyPolicy', payload, ids); }; SkipEventSdk.prototype.tryClickedReferralEmailField = function tryClickedReferralEmailField (payload, ids) { this.runAll('clickedReferralEmailField', payload, ids); }; SkipEventSdk.prototype.tryClickedReviewReadMore = function tryClickedReviewReadMore (payload, ids) { this.runAll('clickedReviewReadMore', payload, ids); }; SkipEventSdk.prototype.tryClickedSaveNewPassword = function tryClickedSaveNewPassword (payload, ids) { this.runAll('clickedSaveNewPassword', payload, ids); }; SkipEventSdk.prototype.tryClickedSendInvites = function tryClickedSendInvites (payload, ids) { this.runAll('clickedSendInvites', payload, ids); }; SkipEventSdk.prototype.tryClickedTermsandConditions = function tryClickedTermsandConditions (payload, ids) { this.runAll('clickedTermsandConditions', payload, ids); }; SkipEventSdk.prototype.tryPaymentVerifiedError = function tryPaymentVerifiedError (payload, ids) { this.runAll('paymentVerifiedError', payload, ids); }; SkipEventSdk.prototype.tryPaymentVerifiedSuccess = function tryPaymentVerifiedSuccess (payload, ids) { this.runAll('paymentVerifiedSuccess', payload, ids); }; SkipEventSdk.prototype.trySaveNewPasswordError = function trySaveNewPasswordError (payload, ids) { this.runAll('saveNewPasswordError', payload, ids); }; SkipEventSdk.prototype.tryViewedCalendlyCalendar = function tryViewedCalendlyCalendar (payload, ids) { this.runAll('viewedCalendlyCalendar', payload, ids); }; SkipEventSdk.prototype.tryViewedNewPasswordPage = function tryViewedNewPasswordPage (payload, ids) { this.runAll('viewedNewPasswordPage', payload, ids); }; SkipEventSdk.prototype.tryViewedPaymentInfo = function tryViewedPaymentInfo (payload, ids) { this.runAll('viewedPaymentInfo', payload, ids); }; SkipEventSdk.prototype.tryViewedPlusPage = function tryViewedPlusPage (payload, ids) { this.runAll('viewedPlusPage', payload, ids); }; SkipEventSdk.prototype.tryViewedPremiumConciergePage = function tryViewedPremiumConciergePage (payload, ids) { this.runAll('viewedPremiumConciergePage', payload, ids); }; SkipEventSdk.prototype.tryViewedPlatinumConciergePage = function tryViewedPlatinumConciergePage (payload, ids) { this.runAll('viewedPlatinumConciergePage', payload, ids); }; // plop SkipEventSdk.prototype.tryAddedLoanApplicationTracking = function tryAddedLoanApplicationTracking (payload, ids) { this.runAll('addedLoanApplicationTracking', payload, ids); }; SkipEventSdk.prototype.tryClickedServiceFlow = function tryClickedServiceFlow (payload, ids) { this.runAll('clickedServiceFlow', payload, ids); }; SkipEventSdk.prototype.tryUpgradedFromAccountDetails = function tryUpgradedFromAccountDetails (payload, ids) { this.runAll('upgradedFromAccountDetails', payload, ids); }; SkipEventSdk.prototype.tryUpgradedFromLatestFundingOpportunity = function tryUpgradedFromLatestFundingOpportunity (payload, ids) { this.runAll('upgradedFromLatestFundingOpportunity', payload, ids); }; SkipEventSdk.prototype.tryAddedFundingGoal = function tryAddedFundingGoal (payload, ids) { this.runAll('addedFundingGoal', payload, ids); }; SkipEventSdk.prototype.tryClickOnBlog = function tryClickOnBlog (payload, ids) { this.runAll('clickOnBlog', payload, ids); }; SkipEventSdk.prototype.tryNotInterestedInFundingOpportunity = function tryNotInterestedInFundingOpportunity (payload, ids) { this.runAll('notInterestedInFundingOpportunity', payload, ids); }; SkipEventSdk.prototype.trySharedReferralLink = function trySharedReferralLink (payload, ids) { this.runAll('sharedReferralLink', payload, ids); }; SkipEventSdk.prototype.tryExitedAddBusinessModal = function tryExitedAddBusinessModal (payload, ids) { this.runAll('exitedAddBusinessModal', payload, ids); }; SkipEventSdk.prototype.tryAddedBusiness = function tryAddedBusiness (payload, ids) { this.runAll('addedBusiness', payload, ids); }; SkipEventSdk.prototype.tryInvitesAFriend = function tryInvitesAFriend (payload, ids) { this.runAll('invitesAFriend', payload, ids); }; var GenericStrategy = function GenericStrategy () {}; /* eslint-disable @typescript-eslint/consistent-type-assertions */ var onLoginTransformProfile = function (costumer) { var userProfile = { Uid: costumer.uid, Identity: costumer.uid, Name: costumer.displayName, Email: costumer.email, UserEmail: costumer.email, Phone: costumer.phoneNumber, Photo: costumer.photoURL }; return userProfile; }; var onLoginOnboardingReasons = function (costumer) { var _a, _b, _c, _d; var onboardingReasonsTitle = (_a = costumer === null || costumer === void 0 ? void 0 : costumer.onboardingReasons) === null || _a === void 0 ? void 0 : _a.map(function (reason) { return reason === null || reason === void 0 ? void 0 : reason.title; }); var onboardingReasonsTitleId = (_b = costumer === null || costumer === void 0 ? void 0 : costumer.onboardingReasons) === null || _b === void 0 ? void 0 : _b.map(function (reason) { return reason === null || reason === void 0 ? void 0 : reason.id; }); var account = costumer === null || costumer === void 0 ? void 0 : costumer.account; if (onboardingReasonsTitle.length > 0) { var userProfile$1 = { Identity: costumer === null || costumer === void 0 ? void 0 : costumer.id, Email: account === null || account === void 0 ? void 0 : account.email, Onboarding_Reasons: onboardingReasonsTitle, Onboarding_Reasons_Id: onboardingReasonsTitleId, Membership_Type: (_c = account === null || account === void 0 ? void 0 : account.membership) === null || _c === void 0 ? void 0 : _c.type }; return userProfile$1; } var userProfile = { Identity: costumer === null || costumer === void 0 ? void 0 : costumer.id, Email: account === null || account === void 0 ? void 0 : account.email, Membership_Type: (_d = account === null || account === void 0 ? void 0 : account.membership) === null || _d === void 0 ? void 0 : _d.type }; return userProfile; }; /* eslint-disable @typescript-eslint/camelcase */ var WebStrategy = /*@__PURE__*/(function (GenericStrategy) { function WebStrategy(provider, debug) { GenericStrategy.call(this); this.action = new EventAction(); this.provider = provider; this.debug = debug; } if ( GenericStrategy ) WebStrategy.__proto__ = GenericStrategy; WebStrategy.prototype = Object.create( GenericStrategy && GenericStrategy.prototype ); WebStrategy.prototype.constructor = WebStrategy; WebStrategy.prototype.addEvent = function addEvent (eventName, payload) { if ( payload === void 0 ) payload = {}; if (!payload) { // eslint-disable-next-line no-param-reassign payload = {}; } // eslint-disable-next-line no-param-reassign payload.channel = 'Web'; if (window && window.location.href) { var ref = new URLSearchParams(window.location.href.split('?')[1]).get('ref'); // eslint-disable-next-line no-param-reassign payload.ref = ref; } this.provider.event.push(eventName, payload); if (this.debug) { console.log('Event send to Providers: ', eventName, payload); } }; WebStrategy.prototype.charged = function charged (payload) { var completed = payload.completed; this.action.charged(this.addEvent.bind(this), completed); }; WebStrategy.prototype.login = function login (payload) { this.action.login(this.addEvent.bind(this), payload); }; WebStrategy.prototype.logout = function logout () { this.action.logout(this.addEvent.bind(this)); }; WebStrategy.prototype.onUserLogin = function onUserLogin (payload) { var authUser = payload.authUser; var userProfile = onLoginTransformProfile(authUser); if (this.debug) { console.log('Profile send: ', userProfile); } if (!userProfile) { return; } this.provider.onUserLogin.push({ Site: makeTrustworthy(userProfile) }); }; WebStrategy.prototype.onUserSelectReasons = function onUserSelectReasons (payload) { var user = payload.user; var userProfile = onLoginOnboardingReasons(user); if (this.debug) { console.log('Profile send: ', userProfile); } if (!userProfile) { return; } this.provider.onUserLogin.push({ Site: makeTrustworthy(userProfile) }); }; WebStrategy.prototype.orderSubmited = function orderSubmited () {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.passwordResetSent = function passwordResetSent () { this.action.passwordResetSent(this.addEvent.bind(this)); }; WebStrategy.prototype.productAddedToSkipList = function productAddedToSkipList () {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.productRemovedFromSkipList = function productRemovedFromSkipList () {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.signUpStarted = function signUpStarted (payload) { var product = payload.product; this.action.signUpStarted(this.addEvent.bind(this), product); }; WebStrategy.prototype.deepLinkClicked = function deepLinkClicked () {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.deepLinkOpened = function deepLinkOpened () {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.setUserLocation = function setUserLocation () {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.updateFCMtoken = function updateFCMtoken () {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.visitsHomePage = function visitsHomePage (payload) { var url = payload.url; if (!url) { return; } this.action.visitsHomePage(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.visitsJoinPage = function visitsJoinPage (payload) { var url = payload.url; if (!url) { return; } this.action.visitsJoinPage(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.visitsPremiumPage = function visitsPremiumPage (payload) { var url = payload.url; if (!url) { return; } this.action.visitsPremiumPage(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.visitsFreePage = function visitsFreePage (payload) { var url = payload.url; if (!url) { return; } this.action.visitsFreePage(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.visitsOnboarding = function visitsOnboarding (payload) { var url = payload.url; if (!url) { return; } this.action.visitsOnboarding(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.visitsDashboard = function visitsDashboard (payload) { var url = payload.url; if (!url) { return; } this.action.visitsDashboard(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.visitsBusinessProfile = function visitsBusinessProfile (payload) { var url = payload.url; if (!url) { return; } this.action.visitsBusinessProfile(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.visitsRemindersPage = function visitsRemindersPage (payload) { var url = payload.url; if (!url) { return; } this.action.visitsRemindersPage(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.userClicksSignUp = function userClicksSignUp (payload) { var url = payload.url; if (!url) { return; } this.action.userClicksSignUp(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.userCompletesBusinessProfile = function userCompletesBusinessProfile (payload) { var url = payload.url; if (!url) { return; } this.action.userCompletesBusinessProfile(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.userClickTodoItem = function userClickTodoItem (payload) { var todoType = payload.todoType; if (!todoType) { return; } this.action.userClickTodoItem(this.addEvent.bind(this), { TodoType: todoType }); }; WebStrategy.prototype.userConfirmsSubscription = function userConfirmsSubscription (payload) { var selectedPlan = payload.selectedPlan; var url = payload.url; var billingInterval = payload.billingInterval; if (!selectedPlan) { return; } this.action.userConfirmsSubscription(this.addEvent.bind(this), { Selected_Plan: selectedPlan, Current_Page: url, Billing_Interval: billingInterval }); }; WebStrategy.prototype.userScheduledOnboardingCall = function userScheduledOnboardingCall (payload) { var url = payload.url; if (!url) { return; } this.action.userScheduledOnboardingCall(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.appReviewed = function appReviewed (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.userFeaturedBusinessOnSkip = function userFeaturedBusinessOnSkip (payload) { this.action.userFeaturedBusinessOnSkip(this.addEvent.bind(this), payload); }; // CONTINUE FROM HERE WebStrategy.prototype.accountCreated = function accountCreated (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.accountCreated(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.accountCreatedError = function accountCreatedError (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.accountCreatedError(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.clickedAnnual = function clickedAnnual (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.clickedAnnual(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.clickedAutoSubCheckbox = function clickedAutoSubCheckbox (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.clickedCardNumberField = function clickedCardNumberField (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.clickedCardNumberField(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.clickedCheckAvailability = function clickedCheckAvailability (payload) { var url = payload.url; var source = payload.source; var billingInterval = payload.billingInterval; if (!url || !source || !billingInterval) { return; } this.action.clickedCheckAvailability(this.addEvent.bind(this), { Current_Page: url, source: source, Billing_Interval: billingInterval }); }; WebStrategy.prototype.clickedConfirm = function clickedConfirm (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.clickedConfirm(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.clickedContinuetoDashboard = function clickedContinuetoDashboard (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.clickedMonthly(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.clickedDownloadApp = function clickedDownloadApp (payload) { var url = payload.url; var source = payload.source; if (!url) { return; } this.action.clickedDownloadApp(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.clickedFunding = function clickedFunding (payload) { var url = payload.url; var cta = payload.cta; if (!url || !cta) { return; } this.action.clickedFunding(this.addEvent.bind(this), { Current_Page: url, cta: cta }); }; WebStrategy.prototype.clickedLogin = function clickedLogin (payload) { var url = payload.url; if (!url) { return; } this.action.clickedDownloadApp(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.clickedMonthly = function clickedMonthly (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.clickedMonthly(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.clickedPrivacyPolicy = function clickedPrivacyPolicy (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.clickedReferralEmailField = function clickedReferralEmailField (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.clickedReviewReadMore = function clickedReviewReadMore (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.clickedSaveNewPassword = function clickedSaveNewPassword (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.clickedSendInvites = function clickedSendInvites (payload) { var url = payload.url; var invite1 = payload.invite1; var invite2 = payload.invite2; if (!url) { return; } this.action.clickedSendInvites(this.addEvent.bind(this), { Current_Page: url, invite1: invite1, invite2: invite2 }); }; WebStrategy.prototype.clickedTermsandConditions = function clickedTermsandConditions (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.paymentVerifiedError = function paymentVerifiedError (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.paymentVerifiedError(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.paymentVerifiedSuccess = function paymentVerifiedSuccess (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.paymentVerifiedSuccess(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.saveNewPasswordError = function saveNewPasswordError (payload) {// NOTE: It doesn't have implementation for web. }; WebStrategy.prototype.viewedCalendlyCalendar = function viewedCalendlyCalendar (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.viewedCalendlyCalendar(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.viewedNewPasswordPage = function viewedNewPasswordPage (payload) { var url = payload.url; if (!url) { return; } this.action.viewedNewPasswordPage(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.viewedPaymentInfo = function viewedPaymentInfo (payload) { var url = payload.url; var source = payload.source; if (!url || !source) { return; } this.action.viewedPaymentInfo(this.addEvent.bind(this), { Current_Page: url, source: source }); }; WebStrategy.prototype.viewedPlusPage = function viewedPlusPage (payload) { var url = payload.url; if (!url) { return; } this.action.viewedPlusPage(this.addEvent.bind(this), { Current_Page: url }); }; WebStrategy.prototype.viewedPremiumConciergePage = function viewedPremiumConciergePage (payload) { var url = payload.url; if (!url) { return; } this.action.viewedPremiumConciergePage(this.addEvent.bind(this), { Current_Page: url }); }; // plop WebStrategy.prototype.addedLoanApplicationTracking = function addedLoanApplicationTracking (payload) { var businessId = payload.businessId; if (!businessId) { return; } this.action.addedLoanApplicationTracking(this.addEvent.bind(this), { businessId: businessId }); }; WebStrategy.prototype.clickedServiceFlow = function clickedServiceFlow (payload) { var serviceFlowName = payload.serviceFlowName; if (!serviceFlowName) { return; } this.action.clickedServiceFlow(this.addEvent.bind(this), { serviceFlowName: serviceFlowName }); }; WebStrategy.prototype.upgradedFromAccountDetails = function upgradedFromAccountDetails (payload) { var userData = payload.userData; if (!userData) { return; } this.action.upgradedFromAccountDetails(this.addEvent.bind(this), { userData: userData }); }; WebStrategy.prototype.upgradedFromLatestFundingOpportunity = function upgradedFromLatestFundingOpportunity (payload) { var opportunity = payload.opportunity; if (!opportunity) { return; } this.action.upgradedFromLatestFundingOpportunity(this.addEvent.bind(this), { opportunity: opportunity }); }; WebStrategy.prototype.addedFundingGoal = function addedFundingGoal (payload) { var fundingGoal = payload.fundingGoal; if (!fundingGoal) { return; } this.action.addedFundingGoal(this.addEvent.bind(this), { fundingGoal: fundingGoal }); }; WebStrategy.prototype.clickOnBlog = function clickOnBlog (payload) { this.action.clickOnBlog(this.addEvent.bind(this), {}); }; WebStrategy.prototype.notInterestedInFundingOpportunity = function notInterestedInFundingOpportunity (payload) { var opportunity = payload.opportunity; if (!opportunity) { return; } this.action.notInterestedInFundingOpportunity(this.addEvent.bind(this), { opportunity: opportunity }); }; WebStrategy.prototype.sharedReferralLink = function sharedReferralLink (payload) { var referralCode = payload.referralCode; if (!referralCode) { return; } this.action.sharedReferralLink(this.addEvent.bind(this), { referralCode: referralCode }); }; WebStrategy.prototype.exitedAddBusinessModal = function exitedAddBusinessModal (payload) { var userId = payload.userId; if (!userId) { return; } this.action.exitedAddBusinessModal(this.addEvent.bind(this), { userId: userId }); }; WebStrategy.prototype.addedBusiness = function addedBusiness (payload) { var userId = payload.userId; if (!userId) { return; } this.action.addedBusiness(this.addEvent.bind(this), { userId: userId }); }; WebStrategy.prototype.invitesAFriend = function invitesAFriend (payload) { var emailList = payload.emailList; if (!emailList) { return; } this.action.invitesAFriend(this.addEvent.bind(this), { emailList: emailList }); }; WebStrategy.prototype.viewedPlatinumConciergePage = function viewedPlatinumConciergePage (payload) { var url = payload.url; if (!url) { return; } this.action.viewedPlatinumConciergePage(this.addEvent.bind(this), { Current_Page: url }); }; return WebStrategy; }(GenericStrategy)); /* eslint-disable @typescript-eslint/camelcase */ var WebClevertapStrategy = /*@__PURE__*/(function (WebStrategy) { function WebClevertapStrategy(clevertap, debug) { WebStrategy.call(this, clevertap, debug); } if ( WebStrategy ) WebClevertapStrategy.__proto__ = WebStrategy; WebClevertapStrategy.prototype = Object.create( WebStrategy && WebStrategy.prototype ); WebClevertapStrategy.prototype.constructor = WebClevertapStrategy; WebClevertapStrategy.prototype.addEvent = function addEvent (eventName, payload) { if ( payload === void 0 ) payload = {}; if (!payload) { // eslint-disable-next-line no-param-reassign payload = {}; } // eslint-disable-next-line no-param-reassign payload.channel = 'Web'; if (window && window.location.href) { var ref = new URLSearchParams(window.location.href.split('?')[1]).get('ref'); // eslint-disable-next-line no-param-reassign payload.ref = ref; } this.provider.event.push(eventName, payload); if (this.debug) { console.log('Event send to Clevertap: ', eventName, payload); } }; WebClevertapStrategy.prototype.onUserLogin = function onUserLogin (payload) { var authUser = payload.authUser; var userProfile = onLoginTransformProfile(authUser); if (this.debug) { console.log('Profile send: ', userProfile); } if (!userProfile) { return; } // same as clevertap.onUserLogin.push on https://developer.clevertap.com/docs/concepts-user-profiles this.provider.onUserLogin.push({ Site: makeTrustworthy(userProfile) }); }; WebClevertapStrategy.prototype.onUserSelectReasons = function onUserSelectReasons (payload) { var user = payload.user; var userProfile = onLoginOnboardingReasons(user); if (this.debug) { console.log('Profile send: ', userProfile); } if (!userProfile) { return; } // same as clevertap.onUserLogin.push on https://developer.clevertap.com/docs/concepts-user-profiles this.provider.onUserLogin.push({ Site: makeTrustworthy(userProfile) }); }; return WebClevertapStrategy; }(WebStrategy)); /* eslint-disable @typescript-eslint/consistent-type-assertions */ /* eslint-disable-camelcase */ /* eslint-disable @typescript-eslint/camelcase */ /* eslint-disable @typescript-eslint/no-explicit-any */ // #region Product var intoOrderSubmited = function (cart, order) { var items = []; var orderSubmited = { cart_id: cart.hash, order_id: order.id, Items: items, channel: 'Mobile' }; return orderSubmited; }; var immutableCustomerIntoUserProfile = function (costumer) { var userProfile = { Identity: costumer.uid, Name: costumer.displayName, Email: costumer.email, Phone: costumer.phoneNumber, Photo: costumer.photoURL }; return userProfile; }; /* eslint-disable @typescript-eslint/camelcase */ var MobileStrategy = /*@__PURE__*/(function (GenericStrategy) { function MobileStrategy(provider, debug) { GenericStrategy.call(this); this.action = new EventAction(); this.provider = provider; this.debug = debug; } if ( GenericStrategy ) MobileStrategy.__proto__ = GenericStrategy; MobileStrategy.prototype = Object.create( GenericStrategy && GenericStrategy.prototype ); MobileStrategy.prototype.constructor = MobileStrategy; MobileStrategy.prototype.addEvent = function addEvent (eventName, payload) { if (!payload) { // eslint-disable-next-line no-param-reassign payload = {}; } // eslint-disable-next-line no-param-reassign payload.channel = 'Mobile'; this.provider.recordEvent(eventName, payload); if (this.debug) { console.log('Event send to Providers: ', eventName, payload); } }; MobileStrategy.prototype.addCharged = function addCharged (details, items) { this.provider.recordChargedEvent(details, items); if (this.debug) { console.log('Event Charged send to Providers: ', details, items); } }; MobileStrategy.prototype.appReviewed = function appReviewed (payload) { var store = payload.store; var thumbs = payload.thumbs; var body = payload.body; var review = { store: store, thumbs: thumbs, body: body }; this.action.appReviewed(this.addEvent.bind(this), review); }; // eslint-disable-next-line @typescript-eslint/no-unused-vars MobileStrategy.prototype.deepLinkClicked = function deepLinkClicked (payload) {// NOTE: It doesn't have implementation. }; MobileStrategy.prototype.deepLinkOpened = function deepLinkOpened (payload) { var url = payload.url; var success = payload.success; if (!url) { return; } this.action.deepLinkOpened(this.addEvent.bind(this), { url: url, success: success }); }; MobileStrategy.prototype.orderSubmited = function orderSubmited (payload) { var cart = payload.cart; var order = payload.order; if (!order) { return; } var orderSubmited = intoOrderSubmited(cart.toJS(), order); this.action.orderSubmited(this.addCharged.bind(this), orderSubmited); }; MobileStrategy.prototype.passwordResetSent = function passwordResetSent () { this.action.passwordResetSent(this.addEvent.bind(this)); }; MobileStrategy.prototype.login = function login (payload) { this.action.login(this.addEvent.bind(this), { status: payload }); }; MobileStrategy.prototype.logout = function logout () { this.action.logout(this.addEvent.bind(this)); }; MobileStrategy.prototype.signUpStarted = function signUpStarted (payload) { this.action.signUpStarted(this.addEvent.bind(this), payload); }; MobileStrategy.prototype.forgotPassword = function forgotPassword () { this.action.forgotPassword(this.addEvent.bind(this)); }; MobileStrategy.prototype.userClicksSignUp = function userClicksSignUp (payload) { var url = payload.url; if (!url) { return; } this.action.userClicksSignUp(this.addEvent.bind(this), { Current_Page: url }); }; MobileStrategy.prototype.charged = function charged (payload) {// NOTE: It doesn't have implementation for APP yet. }; MobileStrategy.prototype.onUserLogin = function onUserLogin (payload) {// NOTE: It doesn't have implementation for APP yet. }; MobileStrategy.prototype.onUserSelectReasons = function onUserSelectReasons (payload) {// NOTE: It doesn't have implementation for APP yet. }; MobileStrategy.prototype.setUserLocation = function setUserLocation (payload) {// NOTE: It doesn't have implementation