UNPKG

klaviyo-react-native-sdk

Version:
96 lines (94 loc) 2.99 kB
"use strict"; import { KlaviyoReactNativeSdk } from "./KlaviyoReactNativeSdk.js"; import { formatProfile } from "./Profile.js"; /** * Implementation of the {@link KlaviyoInterface} */ export const Klaviyo = { initialize(apiKey) { KlaviyoReactNativeSdk.initialize(apiKey); }, setProfile(profile) { KlaviyoReactNativeSdk.setProfile(formatProfile(profile)); }, setExternalId(externalId) { KlaviyoReactNativeSdk.setExternalId(externalId); }, getExternalId(callback) { return KlaviyoReactNativeSdk.getExternalId(callback); }, setEmail(email) { KlaviyoReactNativeSdk.setEmail(email); }, getEmail(callback) { return KlaviyoReactNativeSdk.getEmail(callback); }, setPhoneNumber(phoneNumber) { KlaviyoReactNativeSdk.setPhoneNumber(phoneNumber); }, getPhoneNumber(callback) { return KlaviyoReactNativeSdk.getPhoneNumber(callback); }, setProfileAttribute(propertyKey, value) { KlaviyoReactNativeSdk.setProfileAttribute(propertyKey, value); }, setBadgeCount(count) { // checking if method exists since this is iOS only and don't want a // runtime error on android if (KlaviyoReactNativeSdk.setBadgeCount) { KlaviyoReactNativeSdk.setBadgeCount(count); } else { console.log('setBadgeCount is not available on this platform'); } }, resetProfile() { KlaviyoReactNativeSdk.resetProfile(); }, setPushToken(token) { KlaviyoReactNativeSdk.setPushToken(token); }, getPushToken(callback) { return KlaviyoReactNativeSdk.getPushToken(callback); }, createEvent(event) { KlaviyoReactNativeSdk.createEvent(event); }, registerForInAppForms(configuration) { KlaviyoReactNativeSdk.registerForInAppForms(configuration); }, unregisterFromInAppForms: () => { KlaviyoReactNativeSdk.unregisterFromInAppForms(); }, registerGeofencing() { KlaviyoReactNativeSdk.registerGeofencing(); }, unregisterGeofencing() { KlaviyoReactNativeSdk.unregisterGeofencing(); }, getCurrentGeofences(callback) { KlaviyoReactNativeSdk.getCurrentGeofences(callback); }, /** * Resolves a Klaviyo tracking link to a Universal Link URL, * then handles navigation to the resolved URL. * @param urlStr - The tracking link to be handled */ handleUniversalTrackingLink(urlStr) { if (!urlStr || urlStr.trim() === '') { console.error('[Klaviyo] Error: Empty tracking link provided'); return false; } // Validate that the URL is a Klaviyo universal tracking link using regex // Pattern: https://domain/u/path const klaviyoTrackingLinkPattern = /^https:\/\/[^/]+\/u\/.*$/; if (!klaviyoTrackingLinkPattern.test(urlStr)) { console.warn('[Klaviyo] Warning: Not a Klaviyo tracking link'); return false; } KlaviyoReactNativeSdk.handleUniversalTrackingLink(urlStr); return true; } }; export { EventName } from "./Event.js"; export { ProfileProperty } from "./Profile.js"; //# sourceMappingURL=index.js.map