UNPKG

skip-event-bridge

Version:
34 lines (27 loc) 1.2 kB
/* eslint-disable @typescript-eslint/no-explicit-any */ import MobileStrategy from './MobileStrategy'; import EventAction from '../EventAction'; import { Provider, ProviderMethod } from '../types'; export default class MobileFirebaseStrategy extends MobileStrategy implements Provider { // eslint-disable-next-line no-useless-constructor constructor(firebase: any, debug: boolean) { super(null, debug); this.action = new EventAction(); this.provider = firebase; } addEvent(eventName: string, payload: Record<string, any>): void { if (payload) { this.provider.analytics().logEvent(eventName.substr(0, 31).replace(/ /g, '_'), payload); } else { this.provider.analytics().logEvent(eventName.substr(0, 31).replace(/ /g, '_')); } if (this.debug) console.log('Event send to Firebase: ', eventName.substr(0, 31).replace(/ /g, '_'), payload); } addCharged(details: any, items: object): void { if (!details || items) return; // eslint-disable-next-line no-param-reassign details.items = items; if (this.debug) console.log('Event Charged send to Firebase: ', details); this.provider.analytics().logEvent('Charged', details); } }