UNPKG

appmetrica-capacitor7

Version:
241 lines (236 loc) 7.44 kB
'use strict'; var core = require('@capacitor/core'); exports.Gender = void 0; (function (Gender) { Gender[Gender["MALE"] = 0] = "MALE"; Gender[Gender["FEMALE"] = 1] = "FEMALE"; Gender[Gender["OTHER"] = 2] = "OTHER"; })(exports.Gender || (exports.Gender = {})); class UserProfile { constructor() { this.updates = []; } apply(update) { this.updates.push(update); return this; } applyFromArray(updatesArray) { this.updates.push(...updatesArray); return this; } } class UserProfileUpdate { constructor(attributeName, methodName, key, ...values) { this.attributeName = attributeName; this.methodName = methodName; this.key = key; this.values = values; } } class BirthDateAttribute { constructor() { this.attributeName = 'birthDate'; } withAge(age) { return new UserProfileUpdate(this.attributeName, 'withAge', null, age); } withBirthDate(yearOrDate, month, day) { const args = []; if (typeof yearOrDate !== 'number') { args.push(yearOrDate.getDate(), yearOrDate.getMonth(), yearOrDate.getFullYear()); } else { args.push(yearOrDate); if (month !== undefined) args.push(month); if (day !== undefined) args.push(day); } return new UserProfileUpdate(this.attributeName, 'withBirthDate', null, ...args); } withValueReset() { return new UserProfileUpdate(this.attributeName, 'withValueReset', null); } } class GenderAttribute { constructor() { this.attributeName = 'gender'; } withValue(value) { return new UserProfileUpdate(this.attributeName, 'withValue', null, value.toString()); } withValueReset() { return new UserProfileUpdate(this.attributeName, 'withValueReset', null); } } class NameAttribute { constructor() { this.attributeName = 'name'; } withValue(value) { return new UserProfileUpdate(this.attributeName, 'withValue', null, value); } withValueReset() { return new UserProfileUpdate(this.attributeName, 'withValueReset', null); } } class NotificationsEnabledAttribute { constructor() { this.attributeName = 'notificationsEnabled'; } withValue(value) { return new UserProfileUpdate(this.attributeName, 'withValue', null, value); } withValueReset() { return new UserProfileUpdate(this.attributeName, 'withValueReset', null); } } class CustomBooleanAttribute { constructor(key) { this.attributeName = 'customBoolean'; this.key = key; } withValue(value) { return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); } withValueIfUndefined(value) { return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); } withValueReset() { return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); } } class CustomCounterAttribute { constructor(key) { this.attributeName = 'customCounter'; this.key = key; } withDelta(value) { return new UserProfileUpdate(this.attributeName, 'withDelta', this.key, value); } } class CustomNumberAttribute { constructor(key) { this.attributeName = 'customNumber'; this.key = key; } withValue(value) { return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); } withValueIfUndefined(value) { return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); } withValueReset() { return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); } } class CustomStringAttribute { constructor(key) { this.attributeName = 'customString'; this.key = key; } withValue(value) { return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); } withValueIfUndefined(value) { return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); } withValueReset() { return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); } } class ProfileAttribute { static BirthDate() { return new BirthDateAttribute(); } static Gender() { return new GenderAttribute(); } static Name() { return new NameAttribute(); } static NotificationsEnabled() { return new NotificationsEnabledAttribute(); } static CustomBool(key) { return new CustomBooleanAttribute(key); } static CustomCounter(key) { return new CustomCounterAttribute(key); } static CustomNumber(key) { return new CustomNumberAttribute(key); } static CustomString(key) { return new CustomStringAttribute(key); } } const CapacitorAppmetrica = core.registerPlugin('Appmetrica', { // web: () => import('./web').then(m => new m.AppmetricaWeb()), }); class Appmetrica { constructor() { this.appmetrica = CapacitorAppmetrica; } activate(apiKey, options = {}) { return this.appmetrica.activate(Object.assign({ apiKey }, options)); } pauseSession() { return this.appmetrica.pauseSession(); } sendEventsBuffer() { return this.appmetrica.sendEventsBuffer(); } resumeSession() { return this.appmetrica.resumeSession(); } setLocationTracking(enabled) { return this.appmetrica.setLocationTracking({ enabled }); } setStatisticsSending(enabled) { return this.appmetrica.setStatisticsSending({ enabled }); } setLocation(location) { return this.appmetrica.setLocation({ location }); } reportAppOpen(url) { return this.appmetrica.reportAppOpen({ url }); } reportError(identifier, message, parameters) { return this.appmetrica.reportError({ identifier, message, parameters }); } reportEvent(name, parameters) { return this.appmetrica.reportEvent({ name, parameters }); } reportReferralUrl(referralUrl) { return this.appmetrica.reportReferralUrl({ referralUrl }); } setUserProfileID(id) { return this.appmetrica.setUserProfileID({ id }); } getDeviceID() { return this.appmetrica.getDeviceID().then(({ deviceID }) => deviceID); } reportUserProfile(profile) { const updates = profile.updates.map(m => ({ attributeName: m.attributeName, methodName: m.methodName, key: m.key, values: m.values, })); return this.appmetrica.reportUserProfile({ updates }); } } exports.Appmetrica = Appmetrica; exports.BirthDateAttribute = BirthDateAttribute; exports.CustomBooleanAttribute = CustomBooleanAttribute; exports.CustomCounterAttribute = CustomCounterAttribute; exports.CustomNumberAttribute = CustomNumberAttribute; exports.CustomStringAttribute = CustomStringAttribute; exports.GenderAttribute = GenderAttribute; exports.NameAttribute = NameAttribute; exports.NotificationsEnabledAttribute = NotificationsEnabledAttribute; exports.ProfileAttribute = ProfileAttribute; exports.UserProfile = UserProfile; exports.UserProfileUpdate = UserProfileUpdate; //# sourceMappingURL=plugin.cjs.js.map