import { Exponea } from './ExponeaImpl'; import type { InAppMessageCallbackImpl } from './ExponeaListeners'; import { SegmentationDataCallback } from './ExponeaListeners'; import { FlushMode, LogLevel } from './NativeExponea'; import type { OpenedPush, InAppMessage, InAppMessageButton, Segment, Consent, ConsentSources, Recommendation, RecommendationOptions, AppInboxMessage, AppInboxAction, AppInboxStyle, JsonObject, ExponeaProject, PushAction, InAppMessageAction, InAppMessageActionType, InAppContentBlock, InAppContentBlockAction } from './NativeExponea'; import EventType from './EventType'; import type Configuration from './Configuration'; import type { IntegrationConfig, ProjectConfig } from './Configuration'; import type { CustomerIdentity } from './CustomerIdentity'; import type { SdkAuthError } from './SdkAuthError'; import { SdkAuthErrorCode } from './SdkAuthError'; export { default as AppInboxButton } from './AppInboxButton'; export { default as InAppContentBlocksPlaceholder } from './InAppContentBlocksPlaceholder'; export { default as ContentBlockCarouselView } from './ContentBlockCarouselView'; export type { AppInboxButtonProps } from './AppInboxButton'; export type { InAppContentBlocksPlaceholderProps } from './InAppContentBlocksPlaceholder'; export type { ContentBlockCarouselViewProps } from './ContentBlockCarouselView'; export type { OpenedPush, InAppMessage, InAppMessageButton, Segment, Consent, ConsentSources, Recommendation, RecommendationOptions, AppInboxMessage, AppInboxAction, AppInboxStyle, JsonObject, ExponeaProject, PushAction, InAppMessageAction, InAppMessageActionType, InAppContentBlock, InAppContentBlockAction, InAppMessageCallbackImpl as InAppMessageCallback, CustomerIdentity, SdkAuthError, }; export type { ProjectConfig, StreamConfig, IntegrationConfig, } from './Configuration'; export { FlushMode, LogLevel, EventType, SegmentationDataCallback, SdkAuthErrorCode, }; export { PushTokenTrackingFrequency, PushNotificationImportance, HttpLoggingLevel, } from './Configuration'; /** * # Exponea React Native SDK - Architectural Design * * ## Two-Interface Architecture * * This SDK implements a sophisticated two-interface pattern to handle the technical * limitations of React Native's code generation while providing a unified public API. * * ### Interface A: TurboModule Methods * * These are methods that communicate with native code using React Native's TurboModule * architecture. They are defined in `NativeExponea.ts` and can be auto-generated by * React Native's codegen because they use only codegen-supported types. * * **Characteristics:** * - Extend `TurboModule` from React Native * - Return `Promise` for async operations or primitive types * - Use only codegen-compatible types: `string`, `number`, `boolean`, `Object` * - Use `Readonly<{ [key: string]: Type }>` for object parameters * - Follow request-response communication pattern (JS → Native → Response) * * **Examples:** * ```typescript * await Exponea.configure(config); // Promise * const cookie = await Exponea.getCustomerCookie(); // Promise * await Exponea.trackEvent('event_name', {}); // Promise * ``` * * **Why these work with codegen:** * - Simple type signatures that can be serialized across the bridge * - No function callbacks (only return values) * - No complex nested optional properties * - No class-based types * * ### Interface B: Listener Methods * * These methods handle event-driven communication from native code to JavaScript. * They are implemented in `ExponeaListeners.ts` and **cannot** be generated by * codegen because they require functionality that codegen doesn't support. * * **Characteristics:** * - Use `NativeEventEmitter` for native → JS communication * - Store callback references in JavaScript-side variables * - Handle event streaming (continuous events, not single responses) * - Use complex callback types with optional methods * - Implement stateful lifecycle management (set/remove) * * **Examples:** * ```typescript * // Set up event listener * Exponea.setPushOpenedListener((openedPush) => { * console.log('Push opened:', openedPush); * }); * * // Native sends events whenever they occur * // Native → NativeEventEmitter → JavaScript callback * * // Clean up when done * Exponea.removePushOpenedListener(); * ``` * * **Why these cannot use codegen:** * - Callbacks are functions stored in JavaScript memory, not serialized data * - Event emitter pattern requires bidirectional communication * - Callback types like `InAppMessageCallbackImpl` have optional nested functions * - Stateful management requires storing references outside the module * - Codegen only supports request-response, not event streaming * * ### Codegen Type Limitations * * React Native's codegen has strict type requirements for cross-platform compatibility: * * **✅ Supported by codegen:** * - Primitive types: `string`, `number`, `boolean` * - Generic `Object` type * - `Promise` for async operations * - Simple arrays: `Array` * - `Readonly<{ [key: string]: Type }>` for read-only objects * * **❌ Not supported by codegen:** * - Function types as parameters: `(param: Type) => void` * - Optional method signatures: `method?: () => void` * - Classes with state * - Complex nested optional properties * - Index signatures on regular interfaces (see NativeExponea.ts:43-44) * - Event emitter patterns * * ### How The Interfaces Combine * * The `ExponeaType` interface (this interface) combines both patterns seamlessly: * * ```typescript * export interface ExponeaType { * // Interface A: TurboModule methods * configure(configMap: Object): Promise; * trackEvent(eventName: string, properties: Object): Promise; * * // Interface B: Listener methods * setPushOpenedListener(listener: (openedPush: OpenedPush) => void): void; * registerSegmentationDataCallback(callback: SegmentationDataCallback): void; * } * ``` * * The implementation (`ExponeaImpl.ts`) delegates to the appropriate subsystem: * - Interface A methods → `NativeExponea` (TurboModule) * - Interface B methods → `ExponeaListeners` (JavaScript event handlers) * * ### Communication Patterns Comparison * * | Aspect | Interface A (TurboModule) | Interface B (Listeners) | * |--------|--------------------------|-------------------------| * | Direction | JavaScript → Native | Native → JavaScript | * | Pattern | Request-response | Event streaming | * | Data Flow | Bridge serialization | NativeEventEmitter | * | Type System | Codegen-compatible | Custom (non-codegen) | * | State | Stateless | Stateful (stores callbacks) | * | Return Type | `Promise` or primitive | `void` | * | Use Case | Method calls, data queries | Event notifications, callbacks | * * ### Developer Guidance * * **Use Interface A (TurboModule methods) when:** * - You need to send data to native code * - You want to query native state * - You're making a one-time request * - You need a return value (Promise) * * **Use Interface B (Listener methods) when:** * - You want to receive events from native code * - Native code needs to notify your app of state changes * - You need continuous event updates (not just one response) * - The event timing is unpredictable (push notifications, user actions) * * @see {@link ./NativeExponea.ts} for Interface A (TurboModule) definitions * @see {@link ./ExponeaListeners.ts} for Interface B (Listener) implementations * @see {@link ./ExponeaImpl.ts} for the delegation pattern implementation * * @remarks * This architectural pattern allows the SDK to leverage React Native's modern * TurboModule performance for request-response operations while maintaining * sophisticated event-driven patterns for asynchronous notifications. * * @public */ export interface ExponeaType { /** Configures Exponea SDK. Should only be called once. You need to configure ExponeaSDK before calling most methods. * Optionally accepts a `CustomerIdentity` so initial customer IDs and Stream JWT can be applied during init. */ configure(configuration: Configuration, customerIdentity?: CustomerIdentity): Promise; isConfigured(): Promise; /** Resolves to cookie of the current customer */ getCustomerCookie(): Promise; /** * Identifies current customer with new customer ids and properties. * @deprecated Use `identifyCustomer(customerIdentity, properties?)` instead. */ identifyCustomer(customerIds: Record, properties: JsonObject): Promise; /** * Identifies current customer using a `CustomerIdentity` (customer IDs + * optional Stream JWT). `properties` is optional and defaults to an empty map. */ identifyCustomer(customerIdentity: CustomerIdentity, properties?: JsonObject): Promise; /** * Anonymizes current customer and creates a new one. Push token is cleared on Exponea backend. * Optionally changes default Exponea project and event routing. * @deprecated Use `anonymize(integrationConfig?, integrationRouteMap?)` instead. */ anonymize(exponeaProject: ExponeaProject, projectMapping?: { [key in EventType]?: Array; }): Promise; /** * Anonymizes the current customer and creates a new anonymous one. * The push token is cleared on the Exponea backend. * * Optionally switches the default configuration integration to a different * `ProjectConfig` or `StreamConfig`, and overrides the per-event-type * project routing map. * * Calling `anonymize()` with no arguments keeps the existing integration * configuration and simply resets the customer identity. * * @param integrationConfig - Optional new integration to use after anonymization. * Pass a `ProjectConfig` for a standard project or a `StreamConfig` for a * stream-based integration. If omitted, the current integration is retained. * @param integrationRouteMap - Optional per-event-type routing overrides. * Only applicable when `integrationConfig` is a `ProjectConfig`; ignored * for `StreamConfig`. */ anonymize(integrationConfig?: IntegrationConfig, integrationRouteMap?: { [key in EventType]?: Array; }): Promise; /** Sets a Stream JWT auth token. Only effective with StreamConfig integrations. */ setSdkAuthToken(token: string): Promise; /** Get default properties tracked with every event */ getDefaultProperties(): Promise; /** Set default properties tracked with every event. * Only use for reconfiguration, preferred way of setting default properties is configuration object. */ setDefaultProperties(properties: JsonObject): Promise; /** Tracks custom event to Exponea backend */ trackEvent(eventName: string, properties: JsonObject, timestamp?: number): Promise; /** Manually tracks session start. Only usable when automaticSessionTracking is disabled in Configuration */ trackSessionStart(timestamp?: number): Promise; /** Manually tracks session end. Only usable when automaticSessionTracking is disabled in Configuration */ trackSessionEnd(timestamp?: number): Promise; /** Fetches consents for the current customer */ fetchConsents(): Promise>; /** Fetches recommendations based on RecommendationOptions */ fetchRecommendations(options: RecommendationOptions): Promise>; /** * Requests authorization and subsequently registers for receiving notifications for both Android and iOS platform */ requestPushAuthorization(): Promise; /** * Requests authorization and subsequently registers for receiving notifications for iOS platform * @deprecated use `requestPushAuthorization` instead */ requestIosPushAuthorization(): Promise; /** Sets whether automatic session tracking is enabled */ setAutomaticSessionTracking(enabled: boolean): Promise; /** Sets session timeout in seconds */ setSessionTimeout(timeout: number): Promise; /** Sets whether automatic push notification tracking is enabled */ setAutoPushNotification(enabled: boolean): Promise; /** Sets campaign TTL in seconds */ setCampaignTTL(seconds: number): Promise; /** Manually tracks push notification token to Exponea */ trackPushToken(token: string): Promise; /** Manually tracks HMS push notification token to Exponea (Huawei Mobile Services) */ trackHmsPushToken(token: string): Promise; /** Sets App Inbox provider with custom styling */ setAppInboxProvider(withStyle: AppInboxStyle): Promise; /** Tracks App Inbox message opened event (respects tracking consent) */ trackAppInboxOpened(message: AppInboxMessage): Promise; /** Tracks App Inbox message opened event (ignores tracking consent) */ trackAppInboxOpenedWithoutTrackingConsent(message: AppInboxMessage): Promise; /** Tracks App Inbox message click event (respects tracking consent) */ trackAppInboxClick(action: AppInboxAction, message: AppInboxMessage): Promise; /** Tracks App Inbox message click event (ignores tracking consent) */ trackAppInboxClickWithoutTrackingConsent(action: AppInboxAction, message: AppInboxMessage): Promise; /** Marks App Inbox message as read */ markAppInboxAsRead(message: AppInboxMessage): Promise; /** Fetches all App Inbox messages for the current customer */ fetchAppInbox(): Promise>; /** Fetches a specific App Inbox message by ID */ fetchAppInboxItem(messageId: string): Promise; /** Tracks push notification delivery event (respects tracking consent) */ trackDeliveredPush(params: Record): Promise; /** Tracks push notification delivery event (ignores tracking consent) */ trackDeliveredPushWithoutTrackingConsent(params: Record): Promise; /** Tracks push notification click event (respects tracking consent) */ trackClickedPush(params: Record): Promise; /** Tracks push notification click event (ignores tracking consent) */ trackClickedPushWithoutTrackingConsent(params: Record): Promise; /** Tracks payment event */ trackPaymentEvent(params: Record): Promise; /** Checks if notification payload belongs to Exponea */ isExponeaPushNotification(params: Record): Promise; /** Tracks in-app message click event (respects tracking consent) */ trackInAppMessageClick(message: InAppMessage, buttonText: string | null | undefined, buttonUrl: string | null | undefined): Promise; /** Tracks in-app message click event (ignores tracking consent) */ trackInAppMessageClickWithoutTrackingConsent(message: InAppMessage, buttonText: string | null | undefined, buttonUrl: string | null | undefined): Promise; /** Tracks in-app message close event (respects tracking consent) */ trackInAppMessageClose(message: InAppMessage, buttonText: string | null | undefined, interaction: boolean): Promise; /** Tracks in-app message close event (ignores tracking consent) */ trackInAppMessageCloseWithoutTrackingConsent(message: InAppMessage, buttonText: string | null | undefined, interaction: boolean): Promise; /** Tracks in-app content block click event (respects tracking consent) */ trackInAppContentBlockClick(params: Record): Promise; /** Tracks in-app content block click event (ignores tracking consent) */ trackInAppContentBlockClickWithoutTrackingConsent(params: Record): Promise; /** Tracks in-app content block close event (respects tracking consent) */ trackInAppContentBlockClose(params: Record): Promise; /** Tracks in-app content block close event (ignores tracking consent) */ trackInAppContentBlockCloseWithoutTrackingConsent(params: Record): Promise; /** Tracks in-app content block shown event (respects tracking consent) */ trackInAppContentBlockShown(params: Record): Promise; /** Tracks in-app content block shown event (ignores tracking consent) */ trackInAppContentBlockShownWithoutTrackingConsent(params: Record): Promise; /** Tracks in-app content block error event (respects tracking consent) */ trackInAppContentBlockError(params: Record): Promise; /** Tracks in-app content block error event (ignores tracking consent) */ trackInAppContentBlockErrorWithoutTrackingConsent(params: Record): Promise; /** Fetches customer segments for the given category */ getSegments(exposingCategory: string, force?: boolean): Promise>; /** Stops all SDK tracking and integration */ stopIntegration(): Promise; /** Clears all local customer data from device storage */ clearLocalCustomerData(appGroup?: string): Promise; /** Enable automatic push notification diagnostics *before* configuring the SDK to help you with push notification integration */ checkPushSetup(): Promise; /** Resolves to current FlushMode used by the SDK */ getFlushMode(): Promise; /** Sets the Flush mode of the SDK */ setFlushMode(flushMode: FlushMode): Promise; /** Gets the period with which events are tracked to Exponea backend. Only valid in PERIOD FlushMode */ getFlushPeriod(): Promise; /** Sets the period with which events are tracked to Exponea backend. Only valid in PERIOD FlushMode */ setFlushPeriod(period: number): Promise; /** Resolves to current LogLevel native SDK uses. */ getLogLevel(): Promise; /** Sets LogLevel for native SDK. */ setLogLevel(level: LogLevel): Promise; /** Flushes data to Exponea backend. Only usable in MANUAL FlushMode */ flushData(): Promise; /** * Sets a listener to handle push notification opened events. * @see ExponeaListeners.setPushOpenedListener */ setPushOpenedListener(listener: (openedPush: OpenedPush) => void): void; /** * Removes the push notification opened event listener. * @see ExponeaListeners.removePushOpenedListener */ removePushOpenedListener(): void; /** * Sets a listener to handle push notification received events. * @see ExponeaListeners.setPushReceivedListener */ setPushReceivedListener(listener: (data: JsonObject) => void): void; /** * Removes the push notification received event listener. * @see ExponeaListeners.removePushReceivedListener */ removePushReceivedListener(): void; /** * Sets a callback handler for in-app message lifecycle events. * @see ExponeaListeners.setInAppMessageCallback */ setInAppMessageCallback(callback: InAppMessageCallbackImpl): void; /** * Removes the in-app message callback handler. * @see ExponeaListeners.removeInAppMessageCallback */ removeInAppMessageCallback(): void; /** * Registers a callback to receive customer segmentation data updates. * @see ExponeaListeners.registerSegmentationDataCallback */ registerSegmentationDataCallback(callback: SegmentationDataCallback): void; /** * Unregisters a previously registered segmentation data callback. * @see ExponeaListeners.unregisterSegmentationDataCallback */ unregisterSegmentationDataCallback(callback: SegmentationDataCallback): void; /** * Registers a callback called when the native SDK reports an auth-token error. * @see ExponeaListeners.setSdkAuthErrorCallback */ setSdkAuthErrorCallback(callback: (error: SdkAuthError) => void): void; /** * Removes the previously registered auth callback handler. * @see ExponeaListeners.removeSdkAuthErrorCallback */ removeSdkAuthErrorCallback(): void; } export default Exponea; export declare const configure: (configuration: Configuration, customerIdentity?: CustomerIdentity) => Promise; export declare const isConfigured: () => Promise; export declare const getCustomerCookie: () => Promise; export declare const identifyCustomer: { (customerIds: Record, properties: JsonObject): Promise; (customerIdentity: CustomerIdentity, properties?: JsonObject): Promise; }; export declare const anonymize: { (exponeaProject: ExponeaProject, projectMapping?: { [key in EventType]?: Array; }): Promise; (integrationConfig?: IntegrationConfig, integrationRouteMap?: { [key in EventType]?: Array; }): Promise; }; export declare const setSdkAuthToken: (token: string) => Promise; export declare const getDefaultProperties: () => Promise; export declare const setDefaultProperties: (properties: JsonObject) => Promise; export declare const trackEvent: (eventName: string, properties: JsonObject, timestamp?: number) => Promise; export declare const trackSessionStart: (timestamp?: number) => Promise; export declare const trackSessionEnd: (timestamp?: number) => Promise; export declare const fetchConsents: () => Promise>; export declare const fetchRecommendations: (options: RecommendationOptions) => Promise>; export declare const requestPushAuthorization: () => Promise; export declare const requestIosPushAuthorization: () => Promise; export declare const setAutomaticSessionTracking: (enabled: boolean) => Promise; export declare const setSessionTimeout: (timeout: number) => Promise; export declare const setAutoPushNotification: (enabled: boolean) => Promise; export declare const setCampaignTTL: (seconds: number) => Promise; export declare const trackPushToken: (token: string) => Promise; export declare const trackHmsPushToken: (token: string) => Promise; export declare const setAppInboxProvider: (withStyle: AppInboxStyle) => Promise; export declare const trackAppInboxOpened: (message: AppInboxMessage) => Promise; export declare const trackAppInboxOpenedWithoutTrackingConsent: (message: AppInboxMessage) => Promise; export declare const trackAppInboxClick: (action: AppInboxAction, message: AppInboxMessage) => Promise; export declare const trackAppInboxClickWithoutTrackingConsent: (action: AppInboxAction, message: AppInboxMessage) => Promise; export declare const markAppInboxAsRead: (message: AppInboxMessage) => Promise; export declare const fetchAppInbox: () => Promise>; export declare const fetchAppInboxItem: (messageId: string) => Promise; export declare const trackDeliveredPush: (params: Record) => Promise; export declare const trackDeliveredPushWithoutTrackingConsent: (params: Record) => Promise; export declare const trackClickedPush: (params: Record) => Promise; export declare const trackClickedPushWithoutTrackingConsent: (params: Record) => Promise; export declare const trackPaymentEvent: (params: Record) => Promise; export declare const isExponeaPushNotification: (params: Record) => Promise; export declare const trackInAppMessageClick: (message: InAppMessage, buttonText: string | null | undefined, buttonUrl: string | null | undefined) => Promise; export declare const trackInAppMessageClickWithoutTrackingConsent: (message: InAppMessage, buttonText: string | null | undefined, buttonUrl: string | null | undefined) => Promise; export declare const trackInAppMessageClose: (message: InAppMessage, buttonText: string | null | undefined, interaction: boolean) => Promise; export declare const trackInAppMessageCloseWithoutTrackingConsent: (message: InAppMessage, buttonText: string | null | undefined, interaction: boolean) => Promise; export declare const trackInAppContentBlockClick: (params: Record) => Promise; export declare const trackInAppContentBlockClickWithoutTrackingConsent: (params: Record) => Promise; export declare const trackInAppContentBlockClose: (params: Record) => Promise; export declare const trackInAppContentBlockCloseWithoutTrackingConsent: (params: Record) => Promise; export declare const trackInAppContentBlockShown: (params: Record) => Promise; export declare const trackInAppContentBlockShownWithoutTrackingConsent: (params: Record) => Promise; export declare const trackInAppContentBlockError: (params: Record) => Promise; export declare const trackInAppContentBlockErrorWithoutTrackingConsent: (params: Record) => Promise; export declare const getSegments: (exposingCategory: string, force?: boolean) => Promise>; export declare const stopIntegration: () => Promise; export declare const clearLocalCustomerData: (appGroup?: string) => Promise; export declare const checkPushSetup: () => Promise; export declare const getFlushMode: () => Promise; export declare const setFlushMode: (flushMode: FlushMode) => Promise; export declare const getFlushPeriod: () => Promise; export declare const setFlushPeriod: (period: number) => Promise; export declare const getLogLevel: () => Promise; export declare const setLogLevel: (level: LogLevel) => Promise; export declare const flushData: () => Promise; export declare const setPushOpenedListener: (listener: (openedPush: OpenedPush) => void) => void; export declare const removePushOpenedListener: () => void; export declare const setPushReceivedListener: (listener: (data: JsonObject) => void) => void; export declare const removePushReceivedListener: () => void; export declare const setInAppMessageCallback: (callback: InAppMessageCallbackImpl) => void; export declare const removeInAppMessageCallback: () => void; export declare const registerSegmentationDataCallback: (callback: SegmentationDataCallback) => void; export declare const unregisterSegmentationDataCallback: (callback: SegmentationDataCallback) => void; export declare const setSdkAuthErrorCallback: (callback: (error: SdkAuthError) => void) => void; export declare const removeSdkAuthErrorCallback: () => void; //# sourceMappingURL=index.d.ts.map