@layers/react-native 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug-overlay.d.mts +1 -1
- package/dist/debug-overlay.d.ts +1 -1
- package/dist/{index-BqcbQZEP.d.mts → index-CV1b1Unu.d.mts} +2 -1
- package/dist/{index-BqcbQZEP.d.mts.map → index-CV1b1Unu.d.mts.map} +1 -1
- package/dist/{index-fU6euPnq.d.ts → index-CVKv9D9g.d.ts} +2 -1
- package/dist/{index-fU6euPnq.d.ts.map → index-CVKv9D9g.d.ts.map} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/{src-ym3bM4JE.js → src-BpWI0u2E.js} +18 -1
- package/dist/{src-BNoj1E-e.mjs → src-q7SXK2Zt.mjs} +20 -3
- package/dist/src-q7SXK2Zt.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/src-BNoj1E-e.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-q7SXK2Zt.mjs","names":["properties: EventProperties","properties: Record<string, unknown>","attrs: Record<string, string>","props: EventProperties","_activeSubscriptions: Set<string>","_connectedSDK: LayersReactNative | null","userProps: Record<string, unknown>","previousScreen: string | null","properties: Record<string, unknown>","useEffect: typeof import('react').useEffect | null","core: LayersCore","options: SurveysModuleOptions","featureFlagValues: Record<string, boolean>","SDK_VERSION: string","clipboardData: ClipboardAttribution | null","appOpenProps: Record<string, unknown>","status: ATTStatus","requestATT","updates: DeviceContext","platform: string | undefined","response: Response","payload: Record<string, unknown>","ctx: DeviceContext","merged: Record<string, unknown>","properties: Record<string, unknown>","deviceModel: string","appVersion: string | undefined","context: DeviceContext","lastEmittedState: string | null","SKANManagerImpl","keys: string[]","_asyncStorage: AsyncStorageStatic | undefined","_asyncStoragePromise: Promise<AsyncStorageStatic | null> | null","text: string | null","out: Record<string, string>","params: Record<string, string>"],"sources":["../src/standard-events.ts","../src/superwall.ts","../src/commerce.ts","../src/revenuecat.ts","../src/background-flush.ts","../src/navigation-tracking.ts","../src/surveys.ts","../src/index.ts"],"sourcesContent":["// Standard event types for Layers Analytics.\n// These 18 events match the canonical Layers event taxonomy\n// and are consistent across all SDK platforms.\nimport type { EventProperties } from '@layers/core-wasm';\n\n/**\n * Predefined standard event name constants.\n *\n * Usage:\n * ```ts\n * import { StandardEvents } from '@layers/react-native';\n * layers.track(StandardEvents.PURCHASE, { amount: 9.99, currency: 'USD' });\n * ```\n */\nexport const StandardEvents = {\n APP_INSTALL: 'app_install',\n APP_OPEN: 'app_open',\n LOGIN: 'login',\n SIGN_UP: 'sign_up',\n REGISTER: 'register',\n PURCHASE: 'purchase_success',\n ADD_TO_CART: 'add_to_cart',\n ADD_TO_WISHLIST: 'add_to_wishlist',\n INITIATE_CHECKOUT: 'initiate_checkout',\n BEGIN_CHECKOUT: 'begin_checkout',\n START_TRIAL: 'start_trial',\n SUBSCRIBE: 'subscribe',\n LEVEL_START: 'level_start',\n LEVEL_COMPLETE: 'level_complete',\n TUTORIAL_COMPLETE: 'tutorial_complete',\n SEARCH: 'search',\n VIEW_ITEM: 'view_item',\n VIEW_CONTENT: 'view_content',\n SHARE: 'share',\n DEEP_LINK: 'deep_link_opened',\n SCREEN_VIEW: 'screen_view'\n} as const;\n\n/** Union type of all standard event name strings. */\nexport type StandardEventName = (typeof StandardEvents)[keyof typeof StandardEvents];\n\n// ---------------------------------------------------------------------------\n// Typed helper functions for building standard event payloads.\n// Each returns { event: string; properties: EventProperties } suitable for\n// destructuring into a track() call.\n// ---------------------------------------------------------------------------\n\nexport interface StandardEventPayload {\n event: StandardEventName;\n properties: EventProperties;\n}\n\n/** Build a login event. */\nexport function loginEvent(method?: string): StandardEventPayload {\n const properties: EventProperties = {};\n if (method !== undefined) properties.method = method;\n return { event: StandardEvents.LOGIN, properties };\n}\n\n/** Build a sign-up event. */\nexport function signUpEvent(method?: string): StandardEventPayload {\n const properties: EventProperties = {};\n if (method !== undefined) properties.method = method;\n return { event: StandardEvents.SIGN_UP, properties };\n}\n\n/** Build a register event. */\nexport function registerEvent(method?: string): StandardEventPayload {\n const properties: EventProperties = {};\n if (method !== undefined) properties.method = method;\n return { event: StandardEvents.REGISTER, properties };\n}\n\n/** Build a purchase event. */\nexport function purchaseEvent(\n amount: number,\n currency = 'USD',\n itemId?: string\n): StandardEventPayload {\n const properties: EventProperties = { amount, currency };\n if (itemId !== undefined) properties.item_id = itemId;\n return { event: StandardEvents.PURCHASE, properties };\n}\n\n/** Build an add-to-cart event. */\nexport function addToCartEvent(itemId: string, price: number, quantity = 1): StandardEventPayload {\n return {\n event: StandardEvents.ADD_TO_CART,\n properties: { item_id: itemId, price, quantity }\n };\n}\n\n/** Build an add-to-wishlist event. */\nexport function addToWishlistEvent(\n itemId: string,\n name?: string,\n price?: number\n): StandardEventPayload {\n const properties: EventProperties = { item_id: itemId };\n if (name !== undefined) properties.name = name;\n if (price !== undefined) properties.price = price;\n return { event: StandardEvents.ADD_TO_WISHLIST, properties };\n}\n\n/** Build an initiate-checkout event. */\nexport function initiateCheckoutEvent(\n value: number,\n currency = 'USD',\n itemCount?: number\n): StandardEventPayload {\n const properties: EventProperties = { value, currency };\n if (itemCount !== undefined) properties.item_count = itemCount;\n return { event: StandardEvents.INITIATE_CHECKOUT, properties };\n}\n\n/** Build a start-trial event. */\nexport function startTrialEvent(plan?: string, durationDays?: number): StandardEventPayload {\n const properties: EventProperties = {};\n if (plan !== undefined) properties.plan = plan;\n if (durationDays !== undefined) properties.duration_days = durationDays;\n return { event: StandardEvents.START_TRIAL, properties };\n}\n\n/** Build a subscribe event. */\nexport function subscribeEvent(\n plan: string,\n amount: number,\n currency = 'USD'\n): StandardEventPayload {\n return {\n event: StandardEvents.SUBSCRIBE,\n properties: { plan, amount, currency }\n };\n}\n\n/** Build a level-start event. */\nexport function levelStartEvent(level: string): StandardEventPayload {\n return { event: StandardEvents.LEVEL_START, properties: { level } };\n}\n\n/** Build a level-complete event. */\nexport function levelCompleteEvent(level: string, score?: number): StandardEventPayload {\n const properties: EventProperties = { level };\n if (score !== undefined) properties.score = score;\n return { event: StandardEvents.LEVEL_COMPLETE, properties };\n}\n\n/** Build a tutorial-complete event. */\nexport function tutorialCompleteEvent(name?: string): StandardEventPayload {\n const properties: EventProperties = {};\n if (name !== undefined) properties.name = name;\n return { event: StandardEvents.TUTORIAL_COMPLETE, properties };\n}\n\n/** Build a search event. */\nexport function searchEvent(query: string, resultCount?: number): StandardEventPayload {\n const properties: EventProperties = { query };\n if (resultCount !== undefined) properties.result_count = resultCount;\n return { event: StandardEvents.SEARCH, properties };\n}\n\n/** Build a view-item event. */\nexport function viewItemEvent(\n itemId: string,\n name?: string,\n category?: string\n): StandardEventPayload {\n const properties: EventProperties = { item_id: itemId };\n if (name !== undefined) properties.name = name;\n if (category !== undefined) properties.category = category;\n return { event: StandardEvents.VIEW_ITEM, properties };\n}\n\n/** Build a view-content event. */\nexport function viewContentEvent(\n contentId: string,\n contentType?: string,\n name?: string\n): StandardEventPayload {\n const properties: EventProperties = { content_id: contentId };\n if (contentType !== undefined) properties.content_type = contentType;\n if (name !== undefined) properties.name = name;\n return { event: StandardEvents.VIEW_CONTENT, properties };\n}\n\n/** Build a share event. */\nexport function shareEvent(\n contentType: string,\n method?: string,\n contentId?: string\n): StandardEventPayload {\n const properties: EventProperties = { content_type: contentType };\n if (method !== undefined) properties.method = method;\n if (contentId !== undefined) properties.content_id = contentId;\n return { event: StandardEvents.SHARE, properties };\n}\n\n/** Build a screen-view event. */\nexport function screenViewEvent(name: string, screenClass?: string): StandardEventPayload {\n const properties: EventProperties = { screen_name: name };\n if (screenClass !== undefined) properties.screen_class = screenClass;\n return { event: StandardEvents.SCREEN_VIEW, properties };\n}\n","// Superwall integration for @layers/react-native.\n//\n// Provides helper functions that bridge Layers analytics with Superwall's\n// React Native SDK. Does NOT import @superwall/react-native-superwall directly —\n// uses structural typing to avoid a hard dependency.\nimport type { LayersReactNative } from './index.js';\n\n// ---------------------------------------------------------------------------\n// Structural interfaces matching Superwall types (no import required)\n// ---------------------------------------------------------------------------\n\n/** Minimal subset of Superwall's PaywallInfo used by this integration. */\nexport interface SuperwallPaywallInfo {\n identifier: string;\n name?: string;\n url?: string;\n products?: { id: string }[];\n experiment?: {\n id: string;\n variantId: string;\n };\n}\n\n/** Minimal subset of Superwall's event info. */\nexport interface SuperwallEventInfo {\n event: {\n rawName?: string;\n type?: string;\n };\n params?: Record<string, unknown>;\n}\n\n/** Product info from a Superwall paywall purchase. */\nexport interface SuperwallProduct {\n productIdentifier?: string;\n id?: string;\n price?: number;\n currencyCode?: string;\n currency?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Generic event forwarding\n// ---------------------------------------------------------------------------\n\n/**\n * Forward any Superwall event to Layers, prefixed with `superwall_`.\n *\n * Wire this up in your Superwall delegate / event handler:\n * ```ts\n * import Superwall from '@superwall/react-native-superwall';\n * import { superwallOnEvent } from '@layers/react-native';\n *\n * Superwall.instance.setDelegate({\n * handleSuperwallEvent(eventInfo) {\n * superwallOnEvent(sdk, eventInfo);\n * }\n * });\n * ```\n */\nexport function superwallOnEvent(sdk: LayersReactNative, eventInfo: SuperwallEventInfo): void {\n try {\n const eventName = eventInfo.event.rawName ?? eventInfo.event.type ?? 'unknown';\n const properties: Record<string, unknown> = { source: 'superwall' };\n if (eventInfo.params) {\n Object.assign(properties, eventInfo.params);\n }\n sdk.track(`superwall_${eventName}`, properties);\n } catch {\n // safe fail — SDK never crashes the host app\n }\n}\n\n// ---------------------------------------------------------------------------\n// Typed paywall events\n// ---------------------------------------------------------------------------\n\n/**\n * Track that a paywall was presented to the user.\n *\n * ```ts\n * superwallTrackPresentation(sdk, paywallInfo);\n * ```\n */\nexport function superwallTrackPresentation(\n sdk: LayersReactNative,\n paywallInfo: SuperwallPaywallInfo\n): void {\n try {\n if (!paywallInfo) return;\n\n const properties: Record<string, unknown> = {\n paywall_id: paywallInfo.identifier,\n placement: paywallInfo.name ?? 'unknown',\n source: 'superwall'\n };\n if (paywallInfo.url) {\n properties.url = paywallInfo.url;\n }\n if (paywallInfo.experiment) {\n properties.ab_test = {\n id: paywallInfo.experiment.id,\n variant: paywallInfo.experiment.variantId\n };\n }\n sdk.track('paywall_show', properties);\n } catch {\n // safe fail\n }\n}\n\n/**\n * Track that a paywall was dismissed.\n *\n * ```ts\n * superwallTrackDismiss(sdk, paywallInfo);\n * ```\n */\nexport function superwallTrackDismiss(\n sdk: LayersReactNative,\n paywallInfo: SuperwallPaywallInfo\n): void {\n try {\n if (!paywallInfo) return;\n\n sdk.track('paywall_dismiss', {\n paywall_id: paywallInfo.identifier,\n source: 'superwall'\n });\n } catch {\n // safe fail\n }\n}\n\n/**\n * Track a purchase initiated from a Superwall paywall.\n *\n * ```ts\n * superwallTrackPurchase(sdk, paywallInfo, product);\n * ```\n */\nexport function superwallTrackPurchase(\n sdk: LayersReactNative,\n paywallInfo: SuperwallPaywallInfo,\n product?: SuperwallProduct\n): void {\n try {\n const properties: Record<string, unknown> = {\n paywall_id: paywallInfo?.identifier ?? 'unknown',\n source: 'superwall'\n };\n\n if (product) {\n const productId = product.productIdentifier ?? product.id;\n if (productId) properties.product_id = productId;\n if (product.price != null) properties.price = product.price;\n const currency = product.currencyCode ?? product.currency;\n if (currency) properties.currency = currency;\n }\n\n sdk.track('paywall_purchase', properties);\n } catch {\n // safe fail\n }\n}\n\n/**\n * Track that a paywall was skipped (e.g. holdout, no rule match).\n *\n * ```ts\n * superwallTrackSkip(sdk, paywallInfo, 'holdout');\n * ```\n */\nexport function superwallTrackSkip(\n sdk: LayersReactNative,\n paywallInfo: SuperwallPaywallInfo | null,\n reason: string\n): void {\n try {\n sdk.track('paywall_skip', {\n paywall_id: paywallInfo?.identifier ?? 'unknown',\n reason,\n source: 'superwall'\n });\n } catch {\n // safe fail\n }\n}\n\n// ---------------------------------------------------------------------------\n// User attributes\n// ---------------------------------------------------------------------------\n\n/**\n * Get Layers attribution data formatted as Superwall user attributes.\n *\n * Pass the returned object to `Superwall.instance.setUserAttributes()`:\n * ```ts\n * const attrs = superwallUserAttributes(sdk);\n * Superwall.instance.setUserAttributes(attrs);\n * ```\n */\nexport function superwallUserAttributes(sdk: LayersReactNative): Record<string, string> {\n const attrs: Record<string, string> = {};\n try {\n const sessionId = sdk.getSessionId();\n if (sessionId) attrs.layers_session_id = sessionId;\n\n const userId = sdk.getAppUserId();\n if (userId) attrs.layers_user_id = userId;\n } catch {\n // safe fail\n }\n return attrs;\n}\n","// Commerce module for @layers/react-native.\n// Cross-platform purchase, subscription, cart, and refund tracking helpers.\n// Each function accepts a LayersReactNative instance and tracks the appropriate\n// event with standardized properties consistent with the iOS CommerceModule\n// and Android CommerceModule.\nimport type { EventProperties } from '@layers/core-wasm';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Minimal Layers SDK interface required by the commerce module. */\nexport interface CommerceTracker {\n track(event: string, properties?: EventProperties): void;\n}\n\n/** Purchase details for trackPurchase. */\nexport interface PurchaseParams {\n productId: string;\n /** Unit price of the item. Revenue is computed as `price * quantity`. */\n price: number;\n currency: string;\n transactionId?: string;\n quantity?: number;\n isRestored?: boolean;\n store?: string;\n properties?: EventProperties;\n}\n\n/** Subscription details for trackSubscription. */\nexport interface SubscriptionParams {\n productId: string;\n /** Unit price of the subscription. */\n price: number;\n currency: string;\n period?: string;\n transactionId?: string;\n isRenewal?: boolean;\n isTrial?: boolean;\n subscriptionGroupId?: string;\n originalTransactionId?: string;\n properties?: EventProperties;\n}\n\n/** Cart item for order and checkout tracking. */\nexport interface CartItem {\n productId: string;\n name: string;\n price: number;\n quantity?: number;\n category?: string;\n}\n\n/** Order details for trackOrder. */\nexport interface OrderParams {\n orderId: string;\n items: CartItem[];\n subtotal: number;\n currency?: string;\n tax?: number;\n shipping?: number;\n discount?: number;\n couponCode?: string;\n properties?: EventProperties;\n}\n\n/** Refund details for trackRefund. */\nexport interface RefundParams {\n transactionId: string;\n amount: number;\n currency: string;\n reason?: string;\n properties?: EventProperties;\n}\n\n/** Purchase failure details for trackPurchaseFailed. */\nexport interface PurchaseFailedParams {\n productId: string;\n currency: string;\n errorCode: string | number;\n errorMessage?: string;\n properties?: EventProperties;\n}\n\n// ---------------------------------------------------------------------------\n// Purchase tracking\n// ---------------------------------------------------------------------------\n\n/**\n * Track a successful purchase.\n *\n * ```ts\n * import { trackPurchase } from '@layers/react-native';\n *\n * trackPurchase(sdk, {\n * productId: 'premium_monthly',\n * price: 9.99,\n * currency: 'USD',\n * transactionId: 'txn_abc123',\n * });\n * ```\n */\nexport function trackPurchase(sdk: CommerceTracker, params: PurchaseParams): void {\n const quantity = params.quantity ?? 1;\n const props: EventProperties = {\n product_id: params.productId,\n price: params.price,\n currency: params.currency,\n quantity,\n revenue: params.price * quantity,\n ...params.properties\n };\n if (params.transactionId !== undefined) props.transaction_id = params.transactionId;\n if (params.isRestored !== undefined) props.is_restored = params.isRestored;\n if (params.store !== undefined) props.store = params.store;\n\n sdk.track('purchase_success', props);\n}\n\n/**\n * Track a failed purchase attempt.\n */\nexport function trackPurchaseFailed(sdk: CommerceTracker, params: PurchaseFailedParams): void {\n const props: EventProperties = {\n product_id: params.productId,\n currency: params.currency,\n error_code: params.errorCode,\n ...params.properties\n };\n if (params.errorMessage !== undefined) props.error_message = params.errorMessage;\n\n sdk.track('purchase_failed', props);\n}\n\n// ---------------------------------------------------------------------------\n// Subscription tracking\n// ---------------------------------------------------------------------------\n\n/**\n * Track a subscription purchase or renewal.\n *\n * ```ts\n * import { trackSubscription } from '@layers/react-native';\n *\n * trackSubscription(sdk, {\n * productId: 'pro_annual',\n * price: 49.99,\n * currency: 'USD',\n * period: 'P1Y',\n * });\n * ```\n */\nexport function trackSubscription(sdk: CommerceTracker, params: SubscriptionParams): void {\n const props: EventProperties = {\n product_id: params.productId,\n price: params.price,\n currency: params.currency,\n quantity: 1,\n revenue: params.price,\n ...params.properties\n };\n if (params.transactionId !== undefined) props.transaction_id = params.transactionId;\n if (params.period !== undefined) props.period = params.period;\n if (params.isRenewal !== undefined) props.is_renewal = params.isRenewal;\n if (params.isTrial !== undefined) props.is_trial = params.isTrial;\n if (params.subscriptionGroupId !== undefined)\n props.subscription_group_id = params.subscriptionGroupId;\n if (params.originalTransactionId !== undefined)\n props.original_transaction_id = params.originalTransactionId;\n\n sdk.track('subscribe', props);\n}\n\n// ---------------------------------------------------------------------------\n// Order / cart tracking\n// ---------------------------------------------------------------------------\n\n/**\n * Track a completed order with multiple line items.\n */\nexport function trackOrder(sdk: CommerceTracker, params: OrderParams): void {\n const currency = params.currency ?? 'USD';\n let total = params.subtotal;\n if (params.tax !== undefined) total += params.tax;\n if (params.shipping !== undefined) total += params.shipping;\n if (params.discount !== undefined) total -= params.discount;\n\n const props: EventProperties = {\n order_id: params.orderId,\n subtotal: params.subtotal,\n total,\n currency,\n item_count: params.items.length,\n revenue: total,\n product_ids: params.items.map((i) => i.productId).join(','),\n ...params.properties\n };\n if (params.tax !== undefined) props.tax = params.tax;\n if (params.shipping !== undefined) props.shipping = params.shipping;\n if (params.discount !== undefined) props.discount = params.discount;\n if (params.couponCode !== undefined) props.coupon_code = params.couponCode;\n\n sdk.track('purchase_success', props);\n}\n\n/**\n * Track an item being added to the cart.\n */\nexport function trackAddToCart(\n sdk: CommerceTracker,\n item: CartItem,\n properties?: EventProperties\n): void {\n const quantity = item.quantity ?? 1;\n const props: EventProperties = {\n product_id: item.productId,\n product_name: item.name,\n price: item.price,\n quantity,\n value: item.price * quantity,\n ...properties\n };\n if (item.category !== undefined) props.category = item.category;\n\n sdk.track('add_to_cart', props);\n}\n\n/**\n * Track an item being removed from the cart.\n */\nexport function trackRemoveFromCart(\n sdk: CommerceTracker,\n item: CartItem,\n properties?: EventProperties\n): void {\n const quantity = item.quantity ?? 1;\n const props: EventProperties = {\n product_id: item.productId,\n product_name: item.name,\n price: item.price,\n quantity,\n ...properties\n };\n if (item.category !== undefined) props.category = item.category;\n\n sdk.track('remove_from_cart', props);\n}\n\n/**\n * Track beginning the checkout flow.\n */\nexport function trackBeginCheckout(\n sdk: CommerceTracker,\n items: CartItem[],\n currency = 'USD',\n properties?: EventProperties\n): void {\n const total = items.reduce((sum, item) => sum + item.price * (item.quantity ?? 1), 0);\n const props: EventProperties = {\n item_count: items.length,\n value: total,\n currency,\n product_ids: items.map((i) => i.productId).join(','),\n ...properties\n };\n\n sdk.track('begin_checkout', props);\n}\n\n// ---------------------------------------------------------------------------\n// Product view tracking\n// ---------------------------------------------------------------------------\n\n/**\n * Track viewing a product detail page.\n */\nexport function trackViewProduct(\n sdk: CommerceTracker,\n productId: string,\n name: string,\n price: number,\n currency = 'USD',\n category?: string,\n properties?: EventProperties\n): void {\n const props: EventProperties = {\n product_id: productId,\n product_name: name,\n price,\n currency,\n ...properties\n };\n if (category !== undefined) props.category = category;\n\n sdk.track('view_item', props);\n}\n\n// ---------------------------------------------------------------------------\n// Refund tracking\n// ---------------------------------------------------------------------------\n\n/**\n * Track a refund.\n */\nexport function trackRefund(sdk: CommerceTracker, params: RefundParams): void {\n const props: EventProperties = {\n transaction_id: params.transactionId,\n amount: params.amount,\n currency: params.currency,\n ...params.properties\n };\n if (params.reason !== undefined) props.reason = params.reason;\n\n sdk.track('refund', props);\n}\n","// RevenueCat integration for @layers/react-native.\n// Provides helper functions that bridge Layers to RevenueCat's React Native SDK.\n// Does NOT import RevenueCat directly — consumers pass their Purchases instance.\nimport type { LayersReactNative } from './index.js';\n\n/**\n * Minimal interface for RevenueCat's CustomerInfo object.\n * Avoids a hard dependency on `react-native-purchases`.\n */\nexport interface RevenueCatCustomerInfo {\n readonly activeSubscriptions: string[];\n readonly originalAppUserId: string;\n}\n\n/**\n * Minimal interface for RevenueCat's PurchasesPackage object.\n */\nexport interface RevenueCatPackage {\n readonly product: {\n readonly identifier: string;\n readonly price: number;\n readonly currencyCode: string;\n };\n}\n\n/**\n * Options for configuring the RevenueCat integration.\n */\nexport interface RevenueCatConfig {\n /** The Layers SDK instance to bridge events to. */\n sdk: LayersReactNative;\n /**\n * Callback invoked when a new subscription is detected.\n * By default, new subscriptions are tracked as `subscription_start` events.\n * Set to `null` to disable automatic subscription tracking.\n */\n onSubscriptionStart?: ((productId: string) => void) | null;\n}\n\n// Internal state\nlet _isConnected = false;\nlet _activeSubscriptions: Set<string> = new Set();\nlet _isInitialLoadDone = false;\nlet _connectedSDK: LayersReactNative | null = null;\n\n/**\n * Connect Layers to your existing RevenueCat Purchases instance.\n *\n * Listens for customer info updates to detect new subscriptions and syncs\n * subscriber status to Layers user properties.\n *\n * @example\n * ```ts\n * import Purchases from 'react-native-purchases';\n * import { LayersReactNative, connectRevenueCat } from '@layers/react-native';\n *\n * const sdk = new LayersReactNative();\n * await layers.init({ appId: 'your-app-id', environment: 'production' });\n *\n * connectRevenueCat({\n * sdk,\n * purchases: Purchases,\n * });\n * ```\n *\n * @param config - Configuration including the SDK instance.\n * @param purchases - The RevenueCat Purchases instance (duck-typed to avoid hard dependency).\n */\nexport function connectRevenueCat(\n config: RevenueCatConfig,\n purchases: {\n addCustomerInfoUpdateListener: (\n listener: (info: RevenueCatCustomerInfo) => void\n ) => { remove: () => void } | void;\n getCustomerInfo: () => Promise<{ customerInfo: RevenueCatCustomerInfo }>;\n }\n): void {\n if (_isConnected) return;\n\n try {\n if (!purchases) return;\n if (typeof purchases.addCustomerInfoUpdateListener !== 'function') return;\n if (typeof purchases.getCustomerInfo !== 'function') return;\n\n _connectedSDK = config.sdk;\n\n // Listen for future customer info updates\n purchases.addCustomerInfoUpdateListener((info: RevenueCatCustomerInfo) => {\n handleCustomerInfoUpdate(config, info, false);\n });\n\n // Fetch current customer info for initial state\n purchases\n .getCustomerInfo()\n .then(({ customerInfo }) => {\n handleCustomerInfoUpdate(config, customerInfo, true);\n })\n .catch(() => {\n // Silently ignore errors fetching initial customer info\n });\n\n _isConnected = true;\n } catch {\n // Never crash the host app\n }\n}\n\n/**\n * Track a RevenueCat package purchase manually.\n *\n * @example\n * ```ts\n * const offerings = await Purchases.getOfferings();\n * const pkg = offerings.current?.availablePackages[0];\n * if (pkg) trackRevenueCatPurchase(sdk, pkg);\n * ```\n */\nexport function trackRevenueCatPurchase(\n sdk: LayersReactNative,\n rcPackage: RevenueCatPackage,\n store?: string\n): void {\n try {\n if (!rcPackage?.product) return;\n\n let resolvedStore = store ?? 'app_store';\n if (!store) {\n try {\n const { Platform } = require('react-native');\n resolvedStore = Platform.OS === 'ios' ? 'app_store' : 'play_store';\n } catch {\n // Fallback to app_store if Platform is not available\n }\n }\n\n sdk.track('purchase_success', {\n product_id: rcPackage.product.identifier ?? '',\n price: rcPackage.product.price ?? 0,\n currency: rcPackage.product.currencyCode ?? 'USD',\n store: resolvedStore,\n source: 'revenuecat'\n });\n } catch {\n // Never crash the host app\n }\n}\n\n/**\n * Manually sync RevenueCat subscriber attributes to Layers user properties.\n *\n * This is called automatically when using `connectRevenueCat()`, but can also\n * be called manually if needed.\n */\nexport function syncRevenueCatAttributes(\n sdk: LayersReactNative,\n customerInfo: RevenueCatCustomerInfo\n): void {\n try {\n const isSubscriber =\n Array.isArray(customerInfo.activeSubscriptions) &&\n customerInfo.activeSubscriptions.length > 0;\n\n const userProps: Record<string, unknown> = {\n is_subscriber: isSubscriber\n };\n\n if (customerInfo.originalAppUserId) {\n userProps.revenuecat_original_app_user_id = customerInfo.originalAppUserId;\n }\n\n void sdk.setUserProperties(userProps);\n } catch {\n // Never crash the host app\n }\n}\n\n/**\n * Reset RevenueCat integration state. For testing only.\n */\nexport function resetRevenueCatForTesting(): void {\n _isConnected = false;\n _activeSubscriptions = new Set();\n _isInitialLoadDone = false;\n _connectedSDK = null;\n}\n\n/**\n * Whether the RevenueCat integration is currently connected.\n */\nexport function isRevenueCatConnected(): boolean {\n return _isConnected;\n}\n\n// Internal: handle customer info updates\nfunction handleCustomerInfoUpdate(\n config: RevenueCatConfig,\n info: RevenueCatCustomerInfo,\n isInitialLoad: boolean\n): void {\n try {\n const currentSubs = new Set<string>(\n Array.isArray(info.activeSubscriptions) ? info.activeSubscriptions : []\n );\n\n if (isInitialLoad && _isInitialLoadDone) return;\n\n // Track new subscriptions (only after initial load)\n if (!isInitialLoad && _isInitialLoadDone && _connectedSDK) {\n for (const subId of currentSubs) {\n if (!_activeSubscriptions.has(subId)) {\n if (config.onSubscriptionStart !== null) {\n if (config.onSubscriptionStart) {\n config.onSubscriptionStart(subId);\n } else {\n _connectedSDK.track('subscription_start', {\n product_id: subId,\n source: 'revenuecat'\n });\n }\n }\n }\n }\n }\n\n _activeSubscriptions = currentSubs;\n _isInitialLoadDone = true;\n\n // Sync user properties\n if (_connectedSDK) {\n syncRevenueCatAttributes(_connectedSDK, info);\n }\n } catch {\n // Never crash the host app\n }\n}\n","// Background flush support for the Layers React Native SDK.\n//\n// Since React Native cannot directly access BGAppRefreshTask (iOS) or\n// WorkManager (Android) from JavaScript, this module provides handler\n// factories compatible with popular background task libraries:\n//\n// - `react-native-background-fetch` (bare RN projects)\n// - `expo-task-manager` (Expo managed workflow)\n//\n// The handler simply calls flush() on the SDK instance when invoked\n// by the OS-scheduled background task.\n//\n// ## Usage with react-native-background-fetch\n//\n// ```typescript\n// import BackgroundFetch from 'react-native-background-fetch';\n// import { createBackgroundFlushHandler, BACKGROUND_FLUSH_TASK_NAME } from '@layers/react-native';\n//\n// const handler = createBackgroundFlushHandler(() => sdkInstance);\n// BackgroundFetch.configure(\n// { minimumFetchInterval: 15, taskId: BACKGROUND_FLUSH_TASK_NAME },\n// handler,\n// (taskId) => BackgroundFetch.finish(taskId)\n// );\n// ```\n//\n// ## Usage with expo-task-manager\n//\n// ```typescript\n// import * as TaskManager from 'expo-task-manager';\n// import { registerExpoBackgroundFlush, BACKGROUND_FLUSH_TASK_NAME } from '@layers/expo';\n//\n// registerExpoBackgroundFlush(TaskManager, () => sdkInstance);\n//\n// // In app.json or app.config.js, register the background fetch task:\n// // (also requires expo-background-fetch to schedule it)\n// ```\nimport type { LayersReactNative } from './index.js';\n\n/**\n * Task identifier for Layers background flush.\n *\n * Use this constant when registering the background task with\n * `react-native-background-fetch`, `expo-task-manager`, or any\n * other background task scheduler.\n */\nexport const BACKGROUND_FLUSH_TASK_NAME = 'com.layers.sdk.background-flush';\n\n/**\n * Minimum recommended interval (in minutes) between background flushes.\n * Both iOS and Android enforce a minimum of ~15 minutes for background\n * fetch tasks.\n */\nexport const BACKGROUND_FLUSH_MIN_INTERVAL_MINUTES = 15;\n\n/**\n * Result type returned by the background flush handler.\n * Compatible with both `react-native-background-fetch` and\n * `expo-task-manager` result conventions.\n */\nexport interface BackgroundFlushResult {\n /** Whether the flush completed successfully. */\n success: boolean;\n /** Number of events flushed, if available. */\n eventsFlushed?: number;\n}\n\n/**\n * Creates a background flush handler function.\n *\n * The returned async function, when called by a background task scheduler,\n * will flush any queued events via the Layers SDK. It is safe to call even\n * if the SDK is not initialized (it will silently no-op).\n *\n * @param getSDK - A getter that returns the current LayersReactNative\n * instance, or `null` if the SDK is not yet initialized.\n * @returns An async handler suitable for use with background task libraries.\n *\n * @example\n * ```typescript\n * const handler = createBackgroundFlushHandler(() => mySDKInstance);\n * ```\n */\nexport function createBackgroundFlushHandler(\n getSDK: () => LayersReactNative | null\n): () => Promise<BackgroundFlushResult> {\n return async (): Promise<BackgroundFlushResult> => {\n const sdk = getSDK();\n if (!sdk) {\n return { success: false };\n }\n\n try {\n await sdk.flush();\n return { success: true };\n } catch {\n return { success: false };\n }\n };\n}\n\n/**\n * Registers a background flush task with `expo-task-manager`.\n *\n * This must be called at module scope (outside of any component) as\n * `expo-task-manager` requires tasks to be defined before the app mounts.\n *\n * @param taskManager - The `expo-task-manager` module (import * as TaskManager from 'expo-task-manager').\n * @param getSDK - A getter that returns the current LayersReactNative\n * instance, or `null` if the SDK is not yet initialized.\n *\n * @example\n * ```typescript\n * import * as TaskManager from 'expo-task-manager';\n * import { registerExpoBackgroundFlush } from '@layers/expo';\n *\n * let sdk: LayersReactNative | null = null;\n * registerExpoBackgroundFlush(TaskManager, () => sdk);\n *\n * // Later, in your app initialization:\n * sdk = new LayersReactNative({ appId: '...', environment: 'production' });\n * await layers.init();\n * ```\n */\nexport function registerExpoBackgroundFlush(\n taskManager: { defineTask: (taskName: string, handler: () => Promise<void>) => void },\n getSDK: () => LayersReactNative | null\n): void {\n const handler = createBackgroundFlushHandler(getSDK);\n taskManager.defineTask(BACKGROUND_FLUSH_TASK_NAME, async () => {\n await handler();\n });\n}\n","// React Navigation auto-capture (Tier 2).\n//\n// Two integration shapes are exposed:\n//\n// 1. `useLayersNavigationTracking(sdk, navigationRef)` — a React hook\n// that subscribes to a React Navigation `NavigationContainerRef.onStateChange`\n// and emits a `$screen_view` event each time the current route changes.\n// The hook also tracks the previous screen so the event payload can\n// carry `previous_screen_name` / `previous_screen_class` (useful for\n// funnel analysis without joining adjacent events).\n//\n// 2. `createNavigationListener(sdk)` — a lower-level factory returning a\n// `(state) => void` callback suitable for passing directly to\n// `<NavigationContainer onStateChange={...}>` or\n// `navigationRef.addListener('state', ...)`. The callback maintains\n// its own previous-route closure so consumers don't need to manage\n// state.\n//\n// Both shapes do the same thing — the hook is the convenience wrapper.\n//\n// Resilience:\n// - All of these helpers `require('react')` and `require('@react-navigation/...')`\n// lazily so the package can be imported in environments where those\n// peer dependencies are missing without exploding at import time.\n// - If react-navigation is not installed, `createNavigationListener`\n// still returns a callable function (no-op) so consumers can wire it\n// up unconditionally.\nimport type { EventProperties } from '@layers/core-wasm';\n\n/** Minimal SDK surface — supplied by LayersReactNative. */\nexport interface NavigationTrackingHooks {\n screen(screenName: string, properties?: EventProperties): void;\n enableDebug?: boolean;\n}\n\n/**\n * Internal route shape — matches React Navigation's\n * `NavigationState.routes[i]` structure but only the fields we read.\n */\ninterface RouteSnapshot {\n name: string;\n params?: Record<string, unknown>;\n}\n\n/** State shape we pull from `NavigationState`. */\ninterface NavigationStateSnapshot {\n index?: number;\n routes?: Array<RouteSnapshot & { state?: NavigationStateSnapshot }>;\n}\n\n/**\n * Build a stateful listener that emits `$screen_view` whenever the active\n * route changes. The returned function should be passed to React\n * Navigation's `onStateChange` prop or `navigationRef.addListener('state',\n * cb)`. It returns nothing — the SDK records the event side-effecting.\n *\n * The listener:\n * - resolves the deepest active route via `getActiveRouteName()`\n * semantics so nested stack/tab navigators correctly report the\n * leaf screen\n * - de-dupes consecutive identical names (some RN versions emit the\n * same state twice on re-renders)\n * - attaches route params + previous screen on the screen event\n */\nexport function createNavigationListener(sdk: NavigationTrackingHooks) {\n let previousScreen: string | null = null;\n return function onStateChange(state: NavigationStateSnapshot | undefined): void {\n if (!state) return;\n const currentRoute = resolveActiveRoute(state);\n if (!currentRoute) return;\n if (currentRoute.name === previousScreen) return; // de-dupe\n const properties: Record<string, unknown> = {\n ...(currentRoute.params ?? {}),\n screen_name: currentRoute.name\n };\n if (previousScreen) {\n properties.previous_screen_name = previousScreen;\n }\n try {\n sdk.screen(currentRoute.name, properties);\n if (sdk.enableDebug) {\n console.log(`[Layers] $screen_view: ${currentRoute.name}`);\n }\n } catch {\n // best-effort — never blow up navigation\n }\n previousScreen = currentRoute.name;\n };\n}\n\n/**\n * React hook that subscribes to a React Navigation NavigationContainerRef\n * and emits a `$screen_view` for each route change. Pass the SDK instance\n * and the same `navigationRef` you give to `<NavigationContainer ref={...}>`.\n *\n * ```tsx\n * import { createNavigationContainerRef } from '@react-navigation/native';\n * const navigationRef = createNavigationContainerRef();\n *\n * function Root() {\n * useLayersNavigationTracking(layers, navigationRef);\n * return <NavigationContainer ref={navigationRef}>...</NavigationContainer>;\n * }\n * ```\n *\n * The hook is implemented via a lazy `require('react')` so it only fails\n * if React itself is unavailable — consumers without React Navigation can\n * still call it and it will silently no-op.\n */\nexport function useLayersNavigationTracking(\n sdk: NavigationTrackingHooks,\n navigationRef: { addListener?: (event: string, cb: (...args: unknown[]) => void) => () => void }\n): void {\n let useEffect: typeof import('react').useEffect | null = null;\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const React = require('react') as typeof import('react');\n useEffect = React.useEffect;\n } catch {\n // React not available — silently no-op.\n return;\n }\n if (!useEffect) return;\n\n // Bind the callback once per (sdk, navigationRef) pair. The previous-\n // screen state lives inside `createNavigationListener`'s closure so\n // each useEffect run starts fresh.\n useEffect(() => {\n if (!navigationRef?.addListener) return undefined;\n const listener = createNavigationListener(sdk);\n const unsubscribe = navigationRef.addListener('state', (event: unknown) => {\n // React Navigation passes either `{ data: { state } }` (newer) or\n // the raw state object (older). Handle both shapes.\n const maybeData = (event as { data?: { state?: NavigationStateSnapshot } } | undefined)?.data;\n const state = maybeData?.state ?? (event as NavigationStateSnapshot | undefined);\n listener(state);\n });\n return () => {\n try {\n if (typeof unsubscribe === 'function') unsubscribe();\n } catch {\n // best-effort\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [sdk, navigationRef]);\n}\n\n/**\n * Walk a NavigationState tree and return the active leaf route. Mirrors\n * React Navigation's own `getActiveRouteName()` helper without taking a\n * peer-dep on `@react-navigation/native`.\n *\n * Exported for testing.\n * @internal\n */\nexport function resolveActiveRoute(\n state: NavigationStateSnapshot | undefined\n): RouteSnapshot | null {\n if (!state || !Array.isArray(state.routes) || state.routes.length === 0) {\n return null;\n }\n const idx = typeof state.index === 'number' ? state.index : state.routes.length - 1;\n const route = state.routes[idx];\n if (!route) return null;\n if (route.state) {\n const inner = resolveActiveRoute(route.state);\n if (inner) return inner;\n }\n return { name: route.name, ...(route.params != null && { params: route.params }) };\n}\n","// Tier 8 — In-product surveys & messaging on React Native.\n//\n// Owns:\n// - Delegating to the WASM survey manager for definitions/targeting/auto-events\n// (same Rust core as web, no native bridge required).\n// - State for the eligible survey + show/dismiss callbacks. The actual\n// `<Modal>` chrome lives in `surveys-component.tsx` (a react-native render\n// component) so consumer apps that don't render UI never bundle React.\n//\n// The chrome is a pure-JS `<Modal>` (per the Tier 8 brief — \"pure RN\n// simpler, ship that\"). No native bridge, no `UIAlertController` /\n// `BottomSheetDialogFragment` wiring.\nimport type {\n LayersCore,\n SurveyDefinition,\n SurveyResponse,\n SurveyTargetingContext\n} from '@layers/core-wasm';\n\nexport interface SurveysModuleOptions {\n enabled?: boolean;\n /** Caller-supplied person properties for targeting. */\n personProperties?: Record<string, unknown>;\n /** Caller-supplied feature flag resolver. */\n resolveFeatureFlag?: (flagKey: string) => boolean | string | null | undefined;\n /**\n * Optional `AsyncStorage`-style persistence for the show-history map.\n * The RN SDK passes its existing `AsyncStorage` adapter automatically.\n */\n persistence?: {\n read(key: string): Promise<string | null>;\n write(key: string, value: string): Promise<void>;\n };\n}\n\nconst SHOW_HISTORY_STORAGE_KEY = 'layers:surveys:show-history';\n\n/**\n * Public surveys API exposed via `LayersReactNative.surveys`.\n *\n * Render the actual chrome by mounting `<LayersSurveyModal />` from\n * `@layers/react-native/surveys-component` somewhere in your app tree\n * and binding it to the eligible survey via `surveys.getActive()`.\n */\nexport class SurveysModule {\n private hydrated = false;\n private listeners: Set<(active: SurveyDefinition[]) => void> = new Set();\n\n constructor(\n private readonly core: LayersCore,\n private readonly options: SurveysModuleOptions = {}\n ) {\n if (this.options.persistence) {\n void this.hydrate();\n } else {\n this.hydrated = true;\n }\n }\n\n get enabled(): boolean {\n return this.options.enabled !== false;\n }\n\n knownIds(): string[] {\n return this.core.knownSurveyIds();\n }\n\n /**\n * Return surveys currently eligible to show. Builds the targeting context\n * from caller-supplied person properties + feature flag values. URL\n * targeting is web-only so it's omitted.\n */\n getActive(): SurveyDefinition[] {\n if (!this.enabled) return [];\n return this.core.getActiveSurveys(this.buildContext());\n }\n\n /** Mark a survey as shown — emits `survey shown` auto-event. */\n markShown(surveyId: string): void {\n this.core.markSurveyShown(surveyId);\n void this.persistShowHistory();\n this.notify();\n }\n\n /** Mark a survey as dismissed — emits `survey dismissed` auto-event. */\n markDismissed(surveyId: string): void {\n this.core.markSurveyDismissed(surveyId);\n this.notify();\n }\n\n /** Submit a survey response — emits `survey sent` auto-event. */\n submit(surveyId: string, response: SurveyResponse): void {\n this.core.submitSurveyResponse(surveyId, response);\n this.notify();\n }\n\n /**\n * Subscribe to changes in the eligible-surveys list. The callback fires\n * after every show/dismiss/submit and after the show-history is hydrated\n * from persistence on init.\n */\n subscribe(listener: (active: SurveyDefinition[]) => void): () => void {\n this.listeners.add(listener);\n // Fire immediately so the consumer sees the current state.\n try {\n listener(this.getActive());\n } catch {\n // ignore\n }\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n configure(patch: Partial<SurveysModuleOptions>): void {\n Object.assign(this.options, patch);\n this.notify();\n }\n\n // ── Internals ──────────────────────────────────────────────────────\n\n private buildContext(): SurveyTargetingContext {\n const featureFlagValues: Record<string, boolean> = {};\n const resolver = this.options.resolveFeatureFlag;\n if (resolver) {\n // Walk ALL definitions (not just active ones — flag-gated surveys are\n // never active until their flag is resolved, so iterating the active\n // list creates a circular dependency).\n for (const def of this.allDefinitions()) {\n const flag = def?.targeting?.feature_flag;\n if (flag) {\n const v = resolver(flag);\n if (typeof v === 'boolean') featureFlagValues[flag] = v;\n else if (typeof v === 'string') featureFlagValues[flag] = v.length > 0 && v !== 'false';\n }\n }\n }\n return {\n person_properties: this.options.personProperties ?? {},\n feature_flag_values: featureFlagValues\n };\n }\n\n private allDefinitions(): SurveyDefinition[] {\n try {\n return JSON.parse(this.core.surveyDefinitionsJson()) as SurveyDefinition[];\n } catch {\n return [];\n }\n }\n\n private async hydrate(): Promise<void> {\n if (this.hydrated) return;\n try {\n const raw = await this.options.persistence?.read(SHOW_HISTORY_STORAGE_KEY);\n if (raw) this.core.seedSurveyShowHistory(raw);\n } catch {\n // best effort\n } finally {\n this.hydrated = true;\n this.notify();\n }\n }\n\n private async persistShowHistory(): Promise<void> {\n if (!this.options.persistence) return;\n try {\n const json = this.core.surveyShowHistoryJson();\n await this.options.persistence.write(SHOW_HISTORY_STORAGE_KEY, json);\n } catch {\n // best effort\n }\n }\n\n private notify(): void {\n if (this.listeners.size === 0) return;\n const actives = this.getActive();\n for (const l of this.listeners) {\n try {\n l(actives);\n } catch {\n // ignore listener errors\n }\n }\n }\n}\n\nexport type { SurveyDefinition, SurveyResponse, SurveyTargetingContext } from '@layers/core-wasm';\n","// @layers/react-native — React Native SDK.\n// Thin wrapper over @layers/core-wasm. Owns only:\n// - AsyncStorage persistence backend\n// - React Native device info (Platform, Dimensions)\n// - SKAN module (iOS-only conversion value management)\n// - ATT module (iOS-only App Tracking Transparency)\n// - Deep links via React Native Linking API\n// - AppState listener for background/foreground flush\n// - NetInfo for online/offline detection\nimport {\n FetchHttpClient,\n LayersCore,\n LayersError,\n MemoryPersistence,\n initWasm\n} from '@layers/core-wasm';\nimport type {\n BeforeSendHook,\n ConsentState,\n DeviceContext,\n Environment,\n EventProperties,\n FeatureFlagBootstrap,\n FeatureFlagValue,\n FeatureFlagsListener,\n GroupsState,\n PersistenceBackend,\n Platform as PlatformType,\n UserProperties\n} from '@layers/core-wasm';\n\nimport {\n getAdvertisingId,\n getVendorId,\n requestTrackingAuthorization as requestATT\n} from './att.js';\nimport type { ATTStatus } from './att.js';\nimport { SKANManager as SKANManagerImpl } from './skan.js';\n\nexport type {\n BeforeSendEvent,\n BeforeSendHook,\n ConsentState,\n DeviceContext,\n EcommerceItem,\n Environment,\n EventProperties,\n GroupsState,\n UserProperties,\n // Tier 4 — feature flags\n FeatureFlagValue,\n FeatureFlagBootstrap,\n FeatureFlagBootstrapData,\n FeatureFlagsListener,\n FeatureFlagDefinition,\n FeatureFlagCondition,\n FeatureFlagVariant\n} from '@layers/core-wasm';\n\nexport { LayersError } from '@layers/core-wasm';\n\n// Tier 1: typed event constants + builders (renamed `build*` to avoid\n// collision with the legacy single-arg helpers exported below).\nexport { LayersEvent } from '@layers/core-wasm';\nexport type {\n LayersEventName,\n TypedEventPayload,\n PurchaseEventParams,\n AddToCartEventParams,\n BeginCheckoutEventParams,\n ViewItemEventParams,\n RefundEventParams,\n SubscribeEventParams,\n StartTrialEventParams\n} from '@layers/core-wasm';\nexport {\n purchaseEvent as buildPurchaseEvent,\n addToCartEvent as buildAddToCartEvent,\n beginCheckoutEvent as buildBeginCheckoutEvent,\n viewItemEvent as buildViewItemEvent,\n refundEvent as buildRefundEvent,\n subscribeEvent as buildSubscribeEvent,\n startTrialEvent as buildStartTrialEvent\n} from '@layers/core-wasm';\n\nexport type { SKANConversionRule, SKANPresetConfig, SKANMetrics } from './skan.js';\nexport { SKANManager } from './skan.js';\nexport type { ATTStatus } from './att.js';\nexport {\n getATTStatus,\n requestTrackingAuthorization,\n isATTAvailable,\n getAdvertisingId,\n getVendorId\n} from './att.js';\n\nexport { StandardEvents } from './standard-events.js';\nexport type { StandardEventName, StandardEventPayload } from './standard-events.js';\nexport {\n loginEvent,\n signUpEvent,\n registerEvent,\n purchaseEvent,\n addToCartEvent,\n addToWishlistEvent,\n initiateCheckoutEvent,\n startTrialEvent,\n subscribeEvent,\n levelStartEvent,\n levelCompleteEvent,\n tutorialCompleteEvent,\n searchEvent,\n viewItemEvent,\n viewContentEvent,\n shareEvent,\n screenViewEvent\n} from './standard-events.js';\n\nexport type { SuperwallPaywallInfo, SuperwallEventInfo, SuperwallProduct } from './superwall.js';\nexport {\n superwallOnEvent,\n superwallTrackPresentation,\n superwallTrackDismiss,\n superwallTrackPurchase,\n superwallTrackSkip,\n superwallUserAttributes\n} from './superwall.js';\n\nexport type {\n CommerceTracker,\n PurchaseParams,\n SubscriptionParams,\n CartItem,\n OrderParams,\n RefundParams,\n PurchaseFailedParams\n} from './commerce.js';\nexport {\n trackPurchase,\n trackPurchaseFailed,\n trackSubscription,\n trackOrder,\n trackAddToCart,\n trackRemoveFromCart,\n trackBeginCheckout,\n trackViewProduct,\n trackRefund\n} from './commerce.js';\n\nexport type { RevenueCatCustomerInfo, RevenueCatPackage, RevenueCatConfig } from './revenuecat.js';\nexport {\n connectRevenueCat,\n trackRevenueCatPurchase,\n syncRevenueCatAttributes,\n isRevenueCatConnected,\n resetRevenueCatForTesting\n} from './revenuecat.js';\n\nexport type { BackgroundFlushResult } from './background-flush.js';\nexport {\n BACKGROUND_FLUSH_TASK_NAME,\n BACKGROUND_FLUSH_MIN_INTERVAL_MINUTES,\n createBackgroundFlushHandler,\n registerExpoBackgroundFlush\n} from './background-flush.js';\n\n// Tier 2: React Navigation auto-capture for $screen_view\nexport {\n useLayersNavigationTracking,\n createNavigationListener,\n resolveActiveRoute\n} from './navigation-tracking.js';\nexport type { NavigationTrackingHooks } from './navigation-tracking.js';\n// Tier 8 — Surveys & in-product messaging\nexport { SurveysModule } from './surveys.js';\nexport type { SurveysModuleOptions } from './surveys.js';\nexport type {\n SurveyAnswer,\n SurveyDefinition,\n SurveyDisplay,\n SurveyPosition,\n SurveyQuestion,\n SurveyResponse,\n SurveyTargeting,\n SurveyTargetingContext,\n SurveyType\n} from '@layers/core-wasm';\n\nexport interface LayersRNConfig {\n appId: string;\n environment: Environment;\n appUserId?: string;\n /** Verbose console logging. @default false */\n enableDebug?: boolean;\n /**\n * Enable per-device DebugView. The SDK generates and persists a stable\n * `debug_token` (UUID via AsyncStorage) and sends `X-Debug-Token: <uuid>`\n * on every event upload. Use {@link LayersReactNative.getDebugToken}\n * to retrieve the token for displaying in dev UIs.\n * @default false\n */\n debug?: boolean;\n baseUrl?: string;\n flushIntervalMs?: number;\n flushThreshold?: number;\n maxQueueSize?: number;\n /**\n * Whether to automatically fire an `app_open` event during init().\n * Set to `false` if you want to fire the event manually.\n * @default true\n */\n autoTrackAppOpen?: boolean;\n /**\n * Whether to automatically track `deep_link_opened` events when a deep link\n * is received. The tracked event includes the parsed URL components and all\n * query parameters (UTM params, click IDs like fbclid/gclid/ttclid, etc.)\n * as flat top-level properties.\n *\n * This listener runs in addition to any consumer-registered listener via\n * `setupDeepLinkListener()` -- it does not replace it.\n *\n * @default true\n */\n autoTrackDeepLinks?: boolean;\n /**\n * Whether to automatically emit `$app_background` / `$app_foreground`\n * lifecycle events on AppState transitions. The flush trigger on\n * background remains active regardless of this flag — only the EVENT\n * emission is gated.\n *\n * @default true\n */\n autoTrackAppLifecycle?: boolean;\n /**\n * Whether to emit `$first_open` on the very first launch for a given\n * install (gated by AsyncStorage). Subsequent launches do not emit it.\n *\n * Note: the Rust core emits `$first_open` on first init via the\n * super-properties / install-id machinery. Setting this to `false`\n * suppresses any *additional* emission from the wrapper layer; it\n * does not unwind events emitted by the core.\n *\n * @default true\n */\n autoTrackFirstOpen?: boolean;\n /**\n * Whether to emit `$app_update` on launch when the persisted app\n * version differs from the current `device_context.app_version`.\n *\n * @default true\n */\n autoTrackAppUpdate?: boolean;\n /**\n * Tier 4: optional bootstrap data for feature flags. Pre-seed flag values\n * so the first render after launch doesn't flicker from default-off to\n * actual-value while the first /config fetch is in flight.\n */\n bootstrap?: FeatureFlagBootstrap;\n}\n\ndeclare const __LAYERS_RN_VERSION__: string;\nconst SDK_VERSION: string =\n typeof __LAYERS_RN_VERSION__ !== 'undefined' ? __LAYERS_RN_VERSION__ : '0.1.0';\n\nexport type ErrorListener = (error: Error) => void;\n\n/**\n * Listener for SDK initialization timing metrics.\n *\n * @param mainThreadDurationMs Time spent in the synchronous portion of init\n * (core creation, device info collection, before background work).\n * @param totalDurationMs Total wall-clock time of the `init()` call,\n * including all async work (remote config fetch, attribution signals, app_open event).\n */\nexport type InitListener = (mainThreadDurationMs: number, totalDurationMs: number) => void;\n\nexport class LayersReactNative {\n private core!: LayersCore;\n // Backing store of the pre-init eager core; init() migrates its drained\n // events into the durable AsyncStorage backend (see init()).\n private readonly eagerPersistence: MemoryPersistence;\n private appUserId: string | undefined;\n private isOnline = true;\n private readonly enableDebug: boolean;\n private appStateSubscription: { remove(): void } | null = null;\n private netInfoUnsubscribe: (() => void) | null = null;\n private readonly config: LayersRNConfig;\n\n // set-user-once semantics: once appUserId is set, it cannot be changed\n // (must clearAppUserId first)\n private userIdLocked = false;\n\n // Error listeners\n private readonly errorListeners: Set<ErrorListener> = new Set();\n\n // SKAN manager auto-configured from remote config (iOS only)\n private _skanManager: SKANManagerImpl | null = null;\n private _lastSkanConfigStr: string | null = null;\n\n // Internal deep link listener unsubscribe (auto-tracking)\n private deepLinkUnsubscribe: (() => void) | null = null;\n\n // Recent events buffer for debug overlay (circular, last N events)\n private static readonly MAX_RECENT_EVENTS = 20;\n private _recentEvents: string[] = [];\n private _isInitialized = false;\n\n // Remote config polling timer (300s interval, matches Swift/Kotlin/Flutter/Unity SDKs)\n private _configPollTimer: ReturnType<typeof setInterval> | null = null;\n private static readonly CONFIG_POLL_INTERVAL_MS = 300_000; // 5 minutes\n\n // Cached AdServices attribution token (iOS only)\n private _adServicesToken: string | null = null;\n\n // Cached install referrer data (Android only)\n private _installReferrer: InstallReferrerData | null = null;\n\n // Parsed attribution params from the install referrer query string (Android).\n // Captured in initializeDeviceInfo so app_open / app_install can carry every\n // recognized click ID + UTM, matching the Flutter/Kotlin behavior (they add\n // all parsed params to the event properties, not just the 4 setAttributionData\n // fields). Without this, `click_id`, `gbraid`, `wbraid`, `rclid`, `li_fat_id`,\n // `sclid`, and the UTM params are silently discarded after parsing.\n private _installReferrerParams: Record<string, string> | null = null;\n\n // Whether the SDK had prior state (install_id existed) at initialization\n // time. When false, install event gating applies.\n private _hadPriorSdkState = false;\n\n // Attribution data stored for attachment to subsequent events.\n private _attributionDeeplinkId: string | null = null;\n private _attributionGclid: string | null = null;\n private _attributionFbclid: string | null = null;\n private _attributionFbc: string | null = null;\n private _attributionTtclid: string | null = null;\n private _attributionMsclkid: string | null = null;\n\n private static readonly ATTRIBUTION_DEEPLINK_ID_KEY = '@layers/deeplink_id';\n private static readonly ATTRIBUTION_GCLID_KEY = '@layers/gclid';\n private static readonly ATTRIBUTION_FBCLID_KEY = '@layers/fbclid';\n private static readonly ATTRIBUTION_FBC_KEY = '@layers/fbc';\n private static readonly ATTRIBUTION_TTCLID_KEY = '@layers/ttclid';\n private static readonly ATTRIBUTION_MSCLKID_KEY = '@layers/msclkid';\n\n // Init timing listener\n private _initListener: InitListener | null = null;\n\n constructor(config: LayersRNConfig) {\n this.enableDebug = config.enableDebug ?? false;\n this.appUserId = config.appUserId;\n this.config = config;\n\n // Create the core eagerly with an empty MemoryPersistence so that\n // track()/screen()/etc. work immediately (before init() is called).\n // init() will replace this with a fully-hydrated AsyncStorage backend.\n //\n // We deliberately do NOT pass `debug: true` to the eager core: the debug\n // token is meant to be a stable per-install UUID, but the eager core\n // would mint one in MemoryPersistence that is then thrown away on init().\n // The next launch would mint a different ephemeral one. Defer all debug\n // token work to the AsyncStorage-backed post-init core; pre-init events\n // are queued without an X-Debug-Token and flushed by the post-init core,\n // which adds the stable header at request time.\n const httpClient = new FetchHttpClient();\n // Kept as a field: init() shuts the eager core down, which drains any\n // pre-init events into this store — init() must copy them into the\n // durable AsyncStorage backend before discarding it.\n this.eagerPersistence = new MemoryPersistence();\n this.core = LayersCore.init({\n config: {\n appId: config.appId,\n environment: config.environment,\n ...(config.baseUrl != null && { baseUrl: config.baseUrl }),\n ...(config.enableDebug != null && { enableDebug: config.enableDebug }),\n ...(config.flushIntervalMs != null && { flushIntervalMs: config.flushIntervalMs }),\n ...(config.flushThreshold != null && { flushThreshold: config.flushThreshold }),\n ...(config.maxQueueSize != null && { maxQueueSize: config.maxQueueSize }),\n sdkVersion: `react-native/${SDK_VERSION}`,\n ...(config.bootstrap != null && { bootstrap: config.bootstrap })\n },\n httpClient,\n persistence: this.eagerPersistence\n });\n\n if (this.appUserId) {\n this.core.identify(this.appUserId);\n this.userIdLocked = true;\n }\n }\n\n async init(): Promise<void> {\n const initStartTime = Date.now();\n\n // Opportunistic WASM: Hermes gained WebAssembly support in RN 0.84\n // (Hermes V1, Feb 2026). Where it exists, load the real Rust core so\n // the post-init rebuild below binds to it. On older Hermes there is no\n // WebAssembly global — the (supported) JS fallback engine is the\n // production engine there. Note initWasm() swallows load failures\n // internally; isWasmReady() after the rebuild is the truthful signal\n // (see the warning below the rebuild).\n if (typeof WebAssembly !== 'undefined') {\n await initWasm();\n }\n\n // Re-create the core with a pre-loaded AsyncStorage persistence backend\n // so that events persisted in a prior session are properly rehydrated\n // (and, post-initWasm, so the rebuilt core binds the real Rust engine).\n try {\n const persistence = await createAsyncStoragePersistence(this.config.appId);\n const httpClient = new FetchHttpClient();\n // Shut down the eager core before replacing it. shutdown() drains any\n // pre-init events into the eager MemoryPersistence — copy them into\n // the durable backend (under fresh keys, so a prior session's\n // events_snapshot is never overwritten) BEFORE constructing the new\n // core, whose hydration pass then re-queues them. They used to be\n // garbage-collected with the eager store (audit H5).\n // Carry in-memory state (consent, super properties, groups, device\n // context) across the swap — pre-init setConsent etc. used to be\n // silently dropped by the rebuild.\n const migrationState = this.core.exportMigrationState();\n this.core.shutdown();\n try {\n let migrated = 0;\n for (const key of this.eagerPersistence.listKeys('events_')) {\n const data = this.eagerPersistence.read(key);\n if (data && data.length > 0) {\n persistence.write(`events_preinit_${String(migrated).padStart(3, '0')}`, data);\n migrated += 1;\n }\n // Consume the eager record either way — a second init() call must\n // not re-migrate (and re-deliver) the same pre-init events.\n this.eagerPersistence.delete(key);\n }\n } catch {\n // Best effort — worst case pre-init events are dropped, never\n // duplicated.\n }\n this.core = LayersCore.init({\n config: {\n appId: this.config.appId,\n environment: this.config.environment,\n ...(this.config.baseUrl != null && { baseUrl: this.config.baseUrl }),\n ...(this.config.enableDebug != null && { enableDebug: this.config.enableDebug }),\n ...(this.config.debug != null && { debug: this.config.debug }),\n ...(this.config.flushIntervalMs != null && {\n flushIntervalMs: this.config.flushIntervalMs\n }),\n ...(this.config.flushThreshold != null && {\n flushThreshold: this.config.flushThreshold\n }),\n ...(this.config.maxQueueSize != null && { maxQueueSize: this.config.maxQueueSize }),\n sdkVersion: `react-native/${SDK_VERSION}`,\n ...(this.config.bootstrap != null && { bootstrap: this.config.bootstrap })\n },\n httpClient,\n persistence\n });\n this.core.applyMigrationState(migrationState);\n\n if (this.appUserId) {\n this.core.identify(this.appUserId);\n }\n } catch {\n // AsyncStorage pre-load failed; keep using the eager core with MemoryPersistence\n }\n\n // Truthful fallback signal: initWasm() swallows load failures, so the\n // rebuilt core's engine flag is the only reliable indicator. Only warn\n // when WebAssembly EXISTS (RN 0.84+/Hermes V1) but the binary failed\n // to load — a Metro asset problem worth hearing about. On older Hermes\n // the fallback is the supported engine and stays quiet.\n if (typeof WebAssembly !== 'undefined' && !this.core.isWasmActive()) {\n console.warn(\n '[Layers] WebAssembly is available but the Rust core failed to load — ' +\n 'running on the JS fallback engine. Check Metro asset handling for layers_core_bg.wasm.'\n );\n }\n\n // Restore persisted attribution data BEFORE initializeDeviceInfo. The\n // install-referrer parser inside initializeDeviceInfo calls\n // setAttributionData and merges with this._attribution* fields, so those\n // fields need the prior-session values populated first — otherwise the\n // merge clobbers AsyncStorage with nulls for any click ID the referrer\n // didn't parse. The original invariant (\"restored before events are\n // tracked\") is still satisfied because initializeDeviceInfo does not\n // emit events.\n await this.restoreAttributionData();\n\n await this.initializeDeviceInfo();\n this.setupAppStateListener();\n this.setupNetInfoListener();\n\n // Main thread init complete — record timing\n const mainThreadDurationMs = Date.now() - initStartTime;\n\n // Remote config fetch is best-effort. The JS layer fetches the config\n // endpoint; when the WASM/Rust core is loaded, it applies sampling,\n // rate limits, and filtering internally. The JS fallback path does not\n // currently parse/apply the config response — a future enhancement\n // will add JS-side config application for non-WASM environments.\n await this.core.fetchRemoteConfig().catch(() => {});\n\n // Auto-configure SKAN from remote config (iOS only).\n // The server's remote config `skan` section drives preset/rules so consumers\n // don't need to call SKANManager.setPreset() manually.\n await this.configureSkanFromRemoteConfig();\n\n // Start periodic remote config polling (every 300s).\n // Matches Swift, Kotlin, Flutter, and Unity SDKs.\n this.startConfigPolling();\n\n // Clipboard attribution: on first iOS launch, check clipboard for Layers click URL\n let clipboardData: ClipboardAttribution | null = null;\n try {\n const { Platform } = require('react-native');\n if (Platform.OS === 'ios') {\n // Check remote config for clipboard_attribution_enabled flag.\n // Default to false: only read clipboard if the server explicitly enables it.\n let clipboardEnabled = false;\n try {\n const configJson = this.core.getRemoteConfigJson?.();\n if (configJson) {\n const config = JSON.parse(configJson);\n clipboardEnabled = config?.clipboard_attribution_enabled === true;\n }\n } catch {}\n if (clipboardEnabled) {\n clipboardData = await readClipboardAttribution();\n }\n }\n } catch {}\n\n // Auto-track app_open event with attribution signals and first launch detection\n if (this.config.autoTrackAppOpen !== false) {\n const appOpenProps: Record<string, unknown> = {};\n\n // First launch detection with install event gating (24-hour window).\n // The caller reads and persists the flag; shouldTreatAsNewInstall is pure.\n let isFirstLaunchByFlag = true;\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (AsyncStorage) {\n const flag = await AsyncStorage.getItem(FIRST_LAUNCH_TRACKED_KEY);\n if (flag === 'true') isFirstLaunchByFlag = false;\n }\n } catch {\n // best-effort\n }\n\n const isFirstLaunch = await shouldTreatAsNewInstall(\n isFirstLaunchByFlag,\n this._hadPriorSdkState,\n this.enableDebug\n );\n appOpenProps.is_first_launch = isFirstLaunch;\n\n // On a true first launch, if we have no attribution signal yet (iOS has\n // no Play Install Referrer; Android may not have Google Play Services),\n // ask the server to resolve us via device fingerprint against recent\n // /c/:appId clicks. This closes the web-to-app attribution gap for Meta\n // and TikTok on iOS where there's no alternative. Best-effort — any\n // failure is swallowed so we never block app_open.\n let hasAttribution =\n this._attributionFbclid != null ||\n this._attributionGclid != null ||\n this._attributionTtclid != null ||\n this._attributionMsclkid != null;\n if (isFirstLaunch && !hasAttribution) {\n try {\n await this.resolveClickFromFingerprint();\n } catch {\n // best-effort\n }\n }\n\n // Only persist the flag when we actually treated this as a new install.\n // If gated (isFirstLaunch === false due to install-time check), leave the\n // flag unset so a future launch can re-evaluate (e.g. after an app update\n // that changes the gating logic).\n if (isFirstLaunch) {\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (AsyncStorage) {\n await AsyncStorage.setItem(FIRST_LAUNCH_TRACKED_KEY, 'true');\n }\n } catch {\n // best-effort\n }\n }\n\n if (clipboardData) {\n appOpenProps.clipboard_attribution_url = clipboardData.clickUrl;\n appOpenProps.clipboard_click_id = clipboardData.clickId;\n }\n if (this._adServicesToken) {\n appOpenProps.adservices_token = this._adServicesToken;\n }\n if (this._installReferrer) {\n appOpenProps.install_referrer_url = this._installReferrer.referrerUrl;\n if (this._installReferrer.referrerClickTimestamp) {\n appOpenProps.install_referrer_click_timestamp =\n this._installReferrer.referrerClickTimestamp;\n }\n if (this._installReferrer.installBeginTimestamp) {\n appOpenProps.install_referrer_install_timestamp =\n this._installReferrer.installBeginTimestamp;\n }\n }\n // Spread every parsed install-referrer param (click IDs + UTM) into the\n // app_open / app_install event properties. Matches Flutter + Kotlin +\n // Unity behavior and ensures the server matcher receives click_id,\n // gbraid, wbraid, rclid, li_fat_id, sclid, etc. — not just the four\n // click IDs that flow through setAttributionData.\n if (this._installReferrerParams) {\n for (const [key, value] of Object.entries(this._installReferrerParams)) {\n if (appOpenProps[key] === undefined) {\n appOpenProps[key] = value;\n }\n }\n }\n // Send app_install before app_open on first launch for CAPI forwarding\n if (isFirstLaunch) {\n this.track('app_install', appOpenProps);\n }\n this.track('app_open', appOpenProps);\n\n // App-update detection: compare the persisted app_version against\n // the current device_context.app_version. Emit `$app_update` when\n // they differ. On first launch we just persist the version (no\n // event) so the next launch can compare against it.\n if (this.config.autoTrackAppUpdate !== false) {\n try {\n const ctx = this.core.getDeviceContext();\n const currentVersion =\n (ctx as Record<string, unknown>).appVersion ?? appOpenProps.app_version;\n if (currentVersion && typeof currentVersion === 'string') {\n const AsyncStorage = await loadAsyncStorage();\n if (AsyncStorage) {\n const previousVersion = await AsyncStorage.getItem(LAST_APP_VERSION_KEY);\n if (previousVersion && previousVersion !== currentVersion) {\n this.track('$app_update', {\n previous_version: previousVersion,\n current_version: currentVersion\n });\n }\n await AsyncStorage.setItem(LAST_APP_VERSION_KEY, currentVersion);\n }\n }\n } catch {\n // best-effort\n }\n }\n }\n\n // Auto-track deep link events (default: enabled).\n // Sets up an internal deep link listener that fires a `deep_link_opened`\n // event with the full parsed URL and all query params spread as top-level\n // properties. This runs in addition to any consumer-registered listener.\n if (this.config.autoTrackDeepLinks !== false) {\n this.setupDeepLinkAutoTracking();\n }\n\n this._isInitialized = true;\n\n // Measure total duration (including all async work)\n const totalDurationMs = Date.now() - initStartTime;\n\n if (this.enableDebug) {\n console.log(\n `[Layers] Init timing: mainThread=${String(mainThreadDurationMs)}ms, total=${String(totalDurationMs)}ms`\n );\n }\n\n // Notify init listener\n if (this._initListener) {\n try {\n this._initListener(mainThreadDurationMs, totalDurationMs);\n } catch (e) {\n if (this.enableDebug) {\n console.warn('[Layers] InitListener threw:', e);\n }\n }\n }\n }\n\n track(eventName: string, properties?: EventProperties): void {\n if (this.enableDebug) {\n console.log(\n `[Layers] track(\"${eventName}\", ${Object.keys(properties ?? {}).length} properties)`\n );\n }\n try {\n const merged = this.mergeAttributionProperties(properties);\n const depthBefore = this.core.queueDepth();\n this.core.track(eventName, merged, this.appUserId);\n const depthAfter = this.core.queueDepth();\n\n // Queue depth gating: verify event was accepted by core\n if (depthAfter <= depthBefore && this.enableDebug) {\n console.warn(\n `[Layers] track(\"${eventName}\") — event may not have been queued ` +\n `(depth before=${String(depthBefore)}, after=${String(depthAfter)})`\n );\n }\n\n // Record for debug overlay\n this.recordRecentEvent(eventName, properties);\n\n // Forward event to SKAN rule engine if auto-configured from remote config\n if (this._skanManager) {\n void this._skanManager\n .processEvent(eventName, (merged as Record<string, unknown>) ?? {})\n .catch(() => {});\n }\n } catch (e) {\n this.emitError(e);\n }\n }\n\n screen(screenName: string, properties?: EventProperties): void {\n if (this.enableDebug) {\n console.log(\n `[Layers] screen(\"${screenName}\", ${Object.keys(properties ?? {}).length} properties)`\n );\n }\n try {\n const merged = this.mergeAttributionProperties(properties);\n const depthBefore = this.core.queueDepth();\n this.core.screen(screenName, merged, this.appUserId);\n const depthAfter = this.core.queueDepth();\n\n // Queue depth gating: verify event was accepted by core\n if (depthAfter <= depthBefore && this.enableDebug) {\n console.warn(\n `[Layers] screen(\"${screenName}\") — event may not have been queued ` +\n `(depth before=${String(depthBefore)}, after=${String(depthAfter)})`\n );\n }\n\n this.recordRecentEvent(`screen:${screenName}`, properties);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n async setUserProperties(properties: UserProperties): Promise<void> {\n this.core.setUserProperties(properties as Record<string, unknown>);\n this.sendUserPropertiesAsync(properties as Record<string, unknown>, false);\n }\n\n async setUserPropertiesOnce(properties: UserProperties): Promise<void> {\n this.core.setUserPropertiesOnce(properties as Record<string, unknown>);\n this.sendUserPropertiesAsync(properties as Record<string, unknown>, true);\n }\n\n async setConsent(consent: ConsentState): Promise<void> {\n this.core.setConsent(consent);\n }\n\n // ── Tier 4: feature flags ──────────────────────────────────────────\n\n /** Evaluate a feature flag. Emits `$feature_flag_called` (deduped per session). */\n getFeatureFlag(flagKey: string): FeatureFlagValue | undefined {\n return this.core.getFeatureFlag(flagKey);\n }\n\n /** Convenience: returns true iff `getFeatureFlag(flagKey)` is truthy. */\n isFeatureEnabled(flagKey: string): boolean {\n return this.core.isFeatureEnabled(flagKey);\n }\n\n /** Look up the JSON payload attached to a flag. Does NOT emit exposure events. */\n getFeatureFlagPayload<T = unknown>(flagKey: string): T | undefined {\n return this.core.getFeatureFlagPayload<T>(flagKey);\n }\n\n /** Snapshot every accessible flag's current value. */\n getAllFlags(): Record<string, FeatureFlagValue> {\n return this.core.getAllFlags();\n }\n\n /** Force a /config refresh and re-fire any registered listeners. */\n async reloadFeatureFlags(): Promise<void> {\n return this.core.reloadFeatureFlags();\n }\n\n /** Override person properties used for flag evaluation only. */\n setPersonPropertiesForFlags(properties: Record<string, unknown>): void {\n try {\n this.core.setPersonPropertiesForFlags(properties);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Merge additional person properties into the flag-evaluation map. */\n mergePersonPropertiesForFlags(properties: Record<string, unknown>): void {\n try {\n this.core.mergePersonPropertiesForFlags(properties);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Subscribe to feature-flag refreshes. Returns an unsubscribe function. */\n onFeatureFlags(callback: FeatureFlagsListener): () => void {\n return this.core.onFeatureFlags(callback);\n }\n\n /** Seed bootstrap flag values + payloads after init. */\n setFeatureFlagBootstrap(bootstrap: FeatureFlagBootstrap): void {\n this.core.setFeatureFlagBootstrap(bootstrap);\n }\n\n // ── Tier 1: super-properties ─────────────────────────────────────────\n\n /**\n * Register one or more super-properties — auto-merged into every track /\n * screen call until cleared. Super-properties carry app-wide context\n * (plan tier, region, experiment bucket).\n */\n setSuperProperties(properties: Record<string, unknown>): void {\n try {\n this.core.setSuperProperties(properties);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Register super-properties only if their keys have not been set before. */\n setSuperPropertiesOnce(properties: Record<string, unknown>): void {\n try {\n this.core.setSuperPropertiesOnce(properties);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Remove a single super-property by key. */\n unregisterSuperProperty(key: string): void {\n try {\n this.core.unregisterSuperProperty(key);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Clear all registered super-properties. */\n clearSuperProperties(): void {\n try {\n this.core.clearSuperProperties();\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Snapshot the currently-registered super-properties. */\n getSuperProperties(): Record<string, unknown> {\n return this.core.getSuperProperties();\n }\n\n // ── Tier 1: timed events ─────────────────────────────────────────────\n\n /** Start a duration timer for the next `track(name)` call. */\n timeEvent(eventName: string): void {\n try {\n this.core.timeEvent(eventName);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Cancel a timed event without emitting it. Returns elapsed ms (0 if none). */\n cancelTimedEvent(eventName: string): number {\n try {\n return this.core.cancelTimedEvent(eventName);\n } catch (e) {\n this.emitError(e);\n return 0;\n }\n }\n\n // ── Tier 1: multi-group ──────────────────────────────────────────────\n\n /** Set membership for a single group_type. Empty `groupId` removes the type. */\n setGroup(groupType: string, groupId: string): void {\n try {\n this.core.setGroup(groupType, groupId);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Add a group membership without overwriting other types (alias for setGroup). */\n addGroup(groupType: string, groupId: string): void {\n try {\n this.core.addGroup(groupType, groupId);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Remove a group_type from the membership map. */\n removeGroup(groupType: string): void {\n try {\n this.core.removeGroup(groupType);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Snapshot the current $groups membership map. */\n getGroups(): GroupsState {\n return this.core.getGroups();\n }\n\n // ── Tier 1: user-property mutators ───────────────────────────────────\n\n /** Increment a numeric user property by `delta`. */\n increment(key: string, delta: number = 1): void {\n try {\n this.core.increment(key, delta);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Append a single value to a list-typed user property. */\n append(key: string, value: unknown): void {\n try {\n this.core.append(key, value);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Union (set-add) values into a list-typed user property. */\n union(key: string, values: unknown[]): void {\n try {\n this.core.union(key, values);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /** Remove a user property by key. */\n unset(key: string): void {\n try {\n this.core.unset(key);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n // ── Tier 1: identity accessors ───────────────────────────────────────\n\n /** Returns the current anonymous ID, rotated on `reset()`. */\n getAnonymousId(): string | null {\n return this.core.getAnonymousId();\n }\n\n /** Returns the current device ID (stable per install, rotated on `reset()`). */\n getDeviceId(): string | null {\n return this.core.getDeviceId();\n }\n\n /** Returns the monotonically-increasing session number. */\n getSessionNumber(): number {\n return this.core.getSessionNumber();\n }\n\n /** Returns the SDK first-open RFC3339 timestamp, or null. */\n getFirstOpenTime(): string | null {\n return this.core.getFirstOpenTime();\n }\n\n // ── Tier 1: before_send hook ─────────────────────────────────────────\n\n /**\n * Register a synchronous filter callback called for every track / screen\n * before the event reaches the queue. Return `null` to drop, or a modified\n * `BeforeSendEvent` to forward.\n *\n * Pass `null` to clear the hook.\n */\n setBeforeSend(hook: BeforeSendHook | null): void {\n this.core.setBeforeSend(hook);\n }\n\n /**\n * Request App Tracking Transparency authorization (iOS only).\n * After the user responds, this method automatically:\n * - Collects IDFA if authorized\n * - Updates device info with IDFA and ATT status\n * - Sets advertising consent based on ATT result\n *\n * Returns the ATT status string.\n */\n async requestTrackingPermission(): Promise<ATTStatus> {\n // Auto-detect expo-tracking-transparency and prefer it when available\n let status: ATTStatus;\n try {\n const ExpoTT = await import('expo-tracking-transparency').catch(() => null);\n if (ExpoTT) {\n const { status: expoStatus } = await ExpoTT.requestTrackingPermissionsAsync();\n const statusMap: Record<string, ATTStatus> = {\n granted: 'authorized',\n denied: 'denied',\n restricted: 'restricted',\n undetermined: 'not_determined'\n };\n status = statusMap[expoStatus] ?? 'not_determined';\n } else {\n status = await requestATT();\n }\n } catch {\n status = await requestATT();\n }\n\n // Update device context with ATT status and IDFA (if authorized)\n const currentContext = this.core.getDeviceContext();\n const updates: DeviceContext = { ...currentContext, attStatus: status };\n if (status === 'authorized') {\n try {\n const idfa = await getAdvertisingId();\n if (idfa) updates.idfa = idfa;\n } catch {\n // IDFA collection is best-effort\n }\n }\n this.core.setDeviceContext(updates);\n\n // Auto-set advertising consent based on ATT result\n const advertisingAllowed = status === 'authorized';\n this.core.setConsent({ advertising: advertisingAllowed });\n\n if (this.enableDebug) {\n console.log(\n `[Layers] ATT status: ${status}, advertising consent: ${String(advertisingAllowed)}`\n );\n }\n\n return status;\n }\n\n /**\n * Set the app user ID. Uses set-user-once semantics:\n * once set, subsequent calls are ignored until clearAppUserId() is called.\n */\n setAppUserId(appUserId: string): void {\n if (this.enableDebug) {\n console.log(`[Layers] setAppUserId(\"${appUserId}\")`);\n }\n if (this.userIdLocked && this.appUserId) {\n if (this.enableDebug) {\n console.warn('[Layers] appUserId already set. Call clearAppUserId() first to change it.');\n }\n return;\n }\n this.appUserId = appUserId;\n this.userIdLocked = true;\n this.core.identify(appUserId);\n }\n\n clearAppUserId(): void {\n this.appUserId = undefined;\n this.userIdLocked = false;\n }\n\n /**\n * Reset the SDK state: clears the user ID, unlocks set-user-once, drops\n * super-properties + multi-group memberships, rotates device / anonymous\n * IDs, and starts a new session.\n *\n * After reset(), the SDK behaves as if no user has been identified. Events\n * tracked after reset() will not carry the previous user's identity.\n */\n reset(): void {\n if (this.enableDebug) {\n console.log('[Layers] reset()');\n }\n // Clear JS-side user state\n this.appUserId = undefined;\n this.userIdLocked = false;\n\n // Delegate to the Rust core's reset() which:\n // - drops user_id\n // - rotates device_id + anonymous_id\n // - clears super-properties + groups\n // - drops queued events\n // - rotates session\n try {\n this.core.reset();\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /**\n * Associate all subsequent events with a group (company, team, organization).\n * Pass `undefined` or empty string to clear the group association.\n */\n group(groupId: string | undefined, properties?: EventProperties): void {\n if (this.enableDebug) {\n console.log(\n `[Layers] group(${groupId ? `\"${groupId}\"` : 'undefined'}, ${Object.keys(properties ?? {}).length} properties)`\n );\n }\n try {\n this.core.group(groupId ?? '', properties);\n } catch (e) {\n this.emitError(e);\n }\n }\n\n getAppUserId(): string | undefined {\n return this.appUserId;\n }\n\n getSessionId(): string {\n return this.core.getSessionId();\n }\n\n getConsentState(): ConsentState {\n return this.core.getConsentState();\n }\n\n setDeviceInfo(deviceInfo: DeviceContext): void {\n this.core.setDeviceContext(deviceInfo);\n }\n\n async flush(): Promise<void> {\n try {\n await this.core.flushAsync();\n } catch (e) {\n this.emitError(e);\n this.core.flush();\n }\n }\n\n /**\n * Flush all queued events synchronously (blocking).\n *\n * Drains all batches from the queue and sends them via HTTP, awaiting\n * each batch before proceeding. Does not return until all batches have\n * been sent or failed.\n *\n * This is useful for AppState background transitions where the app may\n * be suspended shortly after the call returns.\n */\n async flushBlocking(): Promise<void> {\n try {\n // Keep flushing until the queue is empty\n let depth = this.core.queueDepth();\n while (depth > 0) {\n await this.core.flushAsync();\n const newDepth = this.core.queueDepth();\n // Break if no progress was made (avoids infinite loop on persistent failures)\n if (newDepth >= depth) break;\n depth = newDepth;\n }\n } catch (e) {\n this.emitError(e);\n }\n }\n\n /**\n * Register an error listener. Errors from track/screen/flush\n * that would otherwise be silently dropped are forwarded here.\n */\n on(event: 'error', listener: ErrorListener): this {\n if (event === 'error') this.errorListeners.add(listener);\n return this;\n }\n\n /**\n * Remove a previously registered error listener.\n */\n off(event: 'error', listener: ErrorListener): this {\n if (event === 'error') this.errorListeners.delete(listener);\n return this;\n }\n\n /**\n * Set a listener to receive SDK initialization timing metrics.\n * Must be called **before** `init()` to receive the callback.\n * Pass `null` to clear the listener.\n *\n * @param listener A function receiving `(mainThreadDurationMs, totalDurationMs)`.\n * `mainThreadDurationMs` is the time spent before background work begins.\n * `totalDurationMs` is the total wall-clock time of the `init()` call.\n */\n setInitListener(listener: InitListener | null): void {\n this._initListener = listener;\n }\n\n /**\n * Returns the AdServices attribution token (iOS only), or null if not\n * available. Collected automatically during init() on iOS 14.3+.\n * Does NOT require ATT consent.\n */\n getAdServicesToken(): string | null {\n return this._adServicesToken;\n }\n\n /**\n * Returns the Google Play install referrer data (Android only), or null\n * if not available. Collected automatically during init() on Android.\n */\n getInstallReferrer(): InstallReferrerData | null {\n return this._installReferrer;\n }\n\n /**\n * Returns the auto-configured SKANManager instance, or null if SKAN was not\n * configured by the server's remote config.\n * On iOS, when remote config contains a `skan` section with `preset` or\n * `customRules`, the SDK automatically creates and configures a SKANManager.\n * Every `track()` call is automatically forwarded to SKAN rule evaluation.\n */\n getSkanManager(): SKANManagerImpl | null {\n return this._skanManager;\n }\n\n // --- Debug state accessors (used by LayersDebugOverlay) ---\n\n /** Whether the SDK has completed async initialization. */\n get isInitialized(): boolean {\n return this._isInitialized;\n }\n\n /** The configured environment ('development' | 'staging' | 'production'). */\n get environment(): Environment {\n return this.config.environment;\n }\n\n /** The configured app ID. */\n get appId(): string {\n return this.config.appId;\n }\n\n /** Number of events currently queued. */\n getQueueDepth(): number {\n return this.core.queueDepth();\n }\n\n /**\n * Return the per-device DebugView token, or null if `debug` was not enabled\n * in the constructor config.\n *\n * When debug mode is on the SDK persists a stable UUID via AsyncStorage\n * and sends it in the `X-Debug-Token` header on every event upload. This\n * lets dashboard UIs filter the live tail to events from this device only.\n */\n getDebugToken(): string | null {\n return this.core.getDebugToken();\n }\n\n /** Current device context from the core. */\n getDeviceContext(): DeviceContext {\n return this.core.getDeviceContext();\n }\n\n /** Whether the SDK believes the device is online. */\n getNetworkStatus(): boolean {\n return this.isOnline;\n }\n\n /** SDK version string. */\n getSdkVersion(): string {\n return SDK_VERSION;\n }\n\n /**\n * Returns the most recent tracked events (newest first).\n * Each entry is a formatted string like \"12:34:56 event_name (3 props)\".\n */\n getRecentEvents(): readonly string[] {\n return this._recentEvents;\n }\n\n /**\n * POST a device fingerprint to /clicks/resolve so the server can match this\n * first-launch install to a recent /c/:appId click captured in the browser\n * before the App Store / Play Store redirect. On a successful match, persist\n * the returned click IDs via setAttributionData so every subsequent event\n * (app_open, purchase_success, etc.) carries fbclid / gclid / ttclid / etc.\n *\n * This is the primary iOS web-to-app attribution path, since iOS has no\n * equivalent of Android's Play Install Referrer. Also serves as a fallback\n * for Android installs where the Install Referrer API returned nothing\n * (sideload, Amazon Appstore, testing).\n *\n * Best-effort: all errors are swallowed — this must never block app_open.\n */\n private async resolveClickFromFingerprint(): Promise<void> {\n const baseUrl = (this.config.baseUrl ?? 'https://in.layers.com').replace(/\\/$/, '');\n const deviceContext = this.core.getDeviceContext() as Record<string, unknown>;\n\n let platform: string | undefined;\n try {\n const { Platform } = require('react-native');\n platform = Platform.OS as string;\n } catch {\n platform = undefined;\n }\n\n // Intentionally no client-supplied timestamp — the server anchors the\n // /clicks/resolve lookback window to its own now() to prevent callers\n // from scanning historical clicks with crafted past timestamps.\n const fingerprint = {\n app_id: this.config.appId,\n platform,\n device_model: deviceContext.deviceModel ?? null,\n os_version: deviceContext.osVersion ?? null,\n locale: deviceContext.locale ?? null,\n timezone: deviceContext.timezone ?? null,\n screen_size: deviceContext.screenSize ?? null\n };\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 3000);\n let response: Response;\n try {\n response = await fetch(`${baseUrl}/clicks/resolve`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-App-Id': this.config.appId,\n 'X-SDK-Version': `react-native/${SDK_VERSION}`\n },\n body: JSON.stringify(fingerprint),\n signal: controller.signal\n });\n } finally {\n clearTimeout(timeoutId);\n }\n\n if (!response.ok) {\n if (this.enableDebug) {\n console.log(`[Layers] /clicks/resolve status=${response.status}`);\n }\n return;\n }\n\n const body = (await response.json()) as {\n success?: boolean;\n data?: {\n matched?: boolean;\n fbclid?: string | null;\n gclid?: string | null;\n ttclid?: string | null;\n msclkid?: string | null;\n click_id?: string | null;\n method?: string;\n confidence?: number;\n };\n };\n\n if (!body?.success || !body.data?.matched) {\n if (this.enableDebug) {\n console.log('[Layers] /clicks/resolve no-match');\n }\n return;\n }\n\n const { fbclid, gclid, ttclid, msclkid, method, confidence } = body.data;\n if (!fbclid && !gclid && !ttclid && !msclkid) return;\n\n try {\n await this.setAttributionData(\n this._attributionDeeplinkId,\n gclid ?? this._attributionGclid,\n fbclid ?? this._attributionFbclid,\n ttclid ?? this._attributionTtclid,\n msclkid ?? this._attributionMsclkid\n );\n if (this.enableDebug) {\n console.log(\n `[Layers] /clicks/resolve matched method=${String(method)} confidence=${String(confidence)} fbclid=${String(fbclid)}`\n );\n }\n } catch {\n // best-effort\n }\n }\n\n /**\n * Fire-and-forget POST to /users/properties.\n * Best-effort: errors are silently swallowed.\n */\n private sendUserPropertiesAsync(properties: Record<string, unknown>, setOnce: boolean): void {\n const baseUrl = (this.config.baseUrl ?? 'https://in.layers.com').replace(/\\/$/, '');\n const appUserId = this.appUserId ?? this.core.getSessionId();\n const payload: Record<string, unknown> = {\n app_id: this.config.appId,\n app_user_id: appUserId,\n properties,\n timestamp: new Date().toISOString()\n };\n if (setOnce) {\n payload.set_once = true;\n }\n\n fetch(`${baseUrl}/users/properties`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-App-Id': this.config.appId,\n 'X-SDK-Version': `react-native/${SDK_VERSION}`\n },\n body: JSON.stringify(payload)\n }).catch(() => {\n // Best-effort — don't throw on network errors\n });\n }\n\n private recordRecentEvent(eventName: string, properties?: EventProperties): void {\n const now = new Date();\n const time = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;\n const propCount = Object.keys(properties ?? {}).length;\n const entry = `${time} ${eventName}${propCount > 0 ? ` (${String(propCount)} props)` : ''}`;\n this._recentEvents.unshift(entry);\n if (this._recentEvents.length > LayersReactNative.MAX_RECENT_EVENTS) {\n this._recentEvents.pop();\n }\n }\n\n private emitError(error: unknown): void {\n const err = error instanceof Error ? error : new Error(String(error));\n for (const listener of this.errorListeners) {\n try {\n listener(err);\n } catch {}\n }\n if (this.enableDebug && this.errorListeners.size === 0) {\n console.warn('[Layers]', err.message);\n }\n }\n\n shutdown(): void {\n this.stopConfigPolling();\n if (this.appStateSubscription) {\n this.appStateSubscription.remove();\n this.appStateSubscription = null;\n }\n if (this.netInfoUnsubscribe) {\n this.netInfoUnsubscribe();\n this.netInfoUnsubscribe = null;\n }\n if (this.deepLinkUnsubscribe) {\n this.deepLinkUnsubscribe();\n this.deepLinkUnsubscribe = null;\n }\n this._attributionDeeplinkId = null;\n this._attributionGclid = null;\n this._attributionFbclid = null;\n this._attributionFbc = null;\n this._attributionTtclid = null;\n this._attributionMsclkid = null;\n this._initListener = null;\n this.core.shutdown();\n }\n\n // --- Attribution Data ---\n\n /**\n * Store attribution data that will be attached to all subsequent events.\n *\n * The values are persisted in AsyncStorage so they survive app restarts.\n * Pass `null` to clear a value.\n *\n * When set, click IDs (`gclid`, `fbclid`, `ttclid`, `msclkid`) are included\n * in every event's properties. For fbclid, a formatted `$fbc` parameter\n * (fb.1.{timestamp}.{fbclid}) is also included.\n *\n * @param deeplinkId Deep link identifier for server-side attribution matching.\n * @param gclid Google Click Identifier from ad click URLs.\n * @param fbclid Facebook Click Identifier from ad click URLs.\n * @param ttclid TikTok Click Identifier from ad click URLs.\n * @param msclkid Microsoft Click Identifier from ad click URLs.\n */\n async setAttributionData(\n deeplinkId: string | null = null,\n gclid: string | null = null,\n fbclid: string | null = null,\n ttclid: string | null = null,\n msclkid: string | null = null\n ): Promise<void> {\n this._attributionDeeplinkId = deeplinkId;\n this._attributionGclid = gclid;\n this._attributionFbclid = fbclid;\n this._attributionFbc = fbclid != null ? formatFbc(fbclid) : null;\n this._attributionTtclid = ttclid;\n this._attributionMsclkid = msclkid;\n\n // Update the Rust core's DeviceContext with the new deeplink_id so the\n // top-level event field is populated (not just the properties bag).\n try {\n const currentContext = this.core.getDeviceContext();\n const ctx: DeviceContext = { ...currentContext };\n if (deeplinkId) {\n ctx.deeplinkId = deeplinkId;\n } else {\n delete ctx.deeplinkId;\n }\n this.core.setDeviceContext(ctx);\n } catch {\n // DeviceContext update is best-effort\n }\n\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (AsyncStorage) {\n if (deeplinkId != null) {\n await AsyncStorage.setItem(LayersReactNative.ATTRIBUTION_DEEPLINK_ID_KEY, deeplinkId);\n } else {\n await AsyncStorage.removeItem(LayersReactNative.ATTRIBUTION_DEEPLINK_ID_KEY);\n }\n if (gclid != null) {\n await AsyncStorage.setItem(LayersReactNative.ATTRIBUTION_GCLID_KEY, gclid);\n } else {\n await AsyncStorage.removeItem(LayersReactNative.ATTRIBUTION_GCLID_KEY);\n }\n if (fbclid != null) {\n await AsyncStorage.setItem(LayersReactNative.ATTRIBUTION_FBCLID_KEY, fbclid);\n } else {\n await AsyncStorage.removeItem(LayersReactNative.ATTRIBUTION_FBCLID_KEY);\n }\n if (this._attributionFbc != null) {\n await AsyncStorage.setItem(LayersReactNative.ATTRIBUTION_FBC_KEY, this._attributionFbc);\n } else {\n await AsyncStorage.removeItem(LayersReactNative.ATTRIBUTION_FBC_KEY);\n }\n if (ttclid != null) {\n await AsyncStorage.setItem(LayersReactNative.ATTRIBUTION_TTCLID_KEY, ttclid);\n } else {\n await AsyncStorage.removeItem(LayersReactNative.ATTRIBUTION_TTCLID_KEY);\n }\n if (msclkid != null) {\n await AsyncStorage.setItem(LayersReactNative.ATTRIBUTION_MSCLKID_KEY, msclkid);\n } else {\n await AsyncStorage.removeItem(LayersReactNative.ATTRIBUTION_MSCLKID_KEY);\n }\n }\n } catch {\n // Persistence is best-effort\n }\n\n if (this.enableDebug) {\n console.log(\n `[Layers] setAttributionData(deeplinkId=${String(deeplinkId)}, gclid=${String(gclid)}, fbclid=${String(fbclid)}, ttclid=${String(ttclid)}, msclkid=${String(msclkid)})`\n );\n }\n }\n\n /**\n * Merge attribution properties (click IDs) into the given event properties,\n * if any attribution data is set. `deeplink_id` flows through DeviceContext\n * on the Rust core (set via `setAttributionData`), not through properties.\n */\n private mergeAttributionProperties(properties?: EventProperties): EventProperties | undefined {\n const merged: Record<string, unknown> = { ...(properties ?? {}) };\n let hasAttribution = false;\n\n if (this._attributionGclid != null && merged.gclid == null) {\n merged.gclid = this._attributionGclid;\n hasAttribution = true;\n }\n if (this._attributionFbclid != null && merged.fbclid == null) {\n merged.fbclid = this._attributionFbclid;\n hasAttribution = true;\n }\n if (this._attributionFbc != null && merged['$fbc'] == null) {\n merged['$fbc'] = this._attributionFbc;\n hasAttribution = true;\n }\n if (this._attributionTtclid != null && merged.ttclid == null) {\n merged.ttclid = this._attributionTtclid;\n hasAttribution = true;\n }\n if (this._attributionMsclkid != null && merged.msclkid == null) {\n merged.msclkid = this._attributionMsclkid;\n hasAttribution = true;\n }\n\n return hasAttribution ? (merged as EventProperties) : properties;\n }\n\n /**\n * Restore persisted attribution data from AsyncStorage.\n * Called during initialization to survive app restarts.\n */\n private async restoreAttributionData(): Promise<void> {\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (!AsyncStorage) return;\n\n const [deeplinkId, gclid, fbclid, fbc, ttclid, msclkid] = await Promise.all([\n AsyncStorage.getItem(LayersReactNative.ATTRIBUTION_DEEPLINK_ID_KEY),\n AsyncStorage.getItem(LayersReactNative.ATTRIBUTION_GCLID_KEY),\n AsyncStorage.getItem(LayersReactNative.ATTRIBUTION_FBCLID_KEY),\n AsyncStorage.getItem(LayersReactNative.ATTRIBUTION_FBC_KEY),\n AsyncStorage.getItem(LayersReactNative.ATTRIBUTION_TTCLID_KEY),\n AsyncStorage.getItem(LayersReactNative.ATTRIBUTION_MSCLKID_KEY)\n ]);\n\n this._attributionDeeplinkId = deeplinkId;\n this._attributionGclid = gclid;\n this._attributionFbclid = fbclid;\n this._attributionFbc = fbc;\n this._attributionTtclid = ttclid;\n this._attributionMsclkid = msclkid;\n\n // Sync restored deeplink_id to the Rust core's DeviceContext so the\n // top-level event field is populated from the first event onward.\n if (deeplinkId != null) {\n try {\n const currentContext = this.core.getDeviceContext();\n this.core.setDeviceContext({ ...currentContext, deeplinkId });\n } catch {\n // best-effort\n }\n }\n\n if (\n this.enableDebug &&\n (deeplinkId != null || gclid != null || fbclid != null || ttclid != null || msclkid != null)\n ) {\n console.log(\n `[Layers] Restored attribution data: deeplinkId=${String(deeplinkId)}, gclid=${String(gclid)}, fbclid=${String(fbclid)}, ttclid=${String(ttclid)}, msclkid=${String(msclkid)}`\n );\n }\n } catch {\n // Restoration is best-effort\n }\n }\n\n // --- Platform-specific: Deep link auto-tracking ---\n\n private _trackedDeepLinkUrls = new Set<string>();\n\n private setupDeepLinkAutoTracking(): void {\n this.deepLinkUnsubscribe = setupDeepLinkListener((data: DeepLinkData) => {\n // Deduplicate: getInitialURL and addEventListener can both fire for the\n // same URL on some RN versions. Skip if we already tracked this exact URL.\n if (this._trackedDeepLinkUrls.has(data.url)) return;\n this._trackedDeepLinkUrls.add(data.url);\n // Clear after a short delay so the same URL can be tracked if the user\n // taps the same link again later\n setTimeout(() => this._trackedDeepLinkUrls.delete(data.url), 2000);\n try {\n const properties: Record<string, unknown> = {\n ...data.queryParams,\n url: data.url,\n scheme: data.scheme,\n host: data.host,\n path: data.path\n };\n\n // Extract well-known attribution parameters as top-level properties\n // so they are easy to query server-side without parsing queryParams.\n const attributionKeys = [\n 'fbclid',\n 'gclid',\n 'ttclid',\n 'msclkid',\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_term',\n 'utm_content',\n 'dclid',\n 'li_fat_id',\n 'twclid',\n 'scclid',\n 'irclickid',\n 'af_sub1',\n 'af_sub2',\n 'af_sub3',\n 'af_sub4',\n 'af_sub5'\n ] as const;\n\n for (const key of attributionKeys) {\n if (data.queryParams[key]) {\n properties[key] = data.queryParams[key];\n }\n }\n\n // Auto-persist fbclid/gclid/ttclid/msclkid as attribution data\n // so they flow into all subsequent events.\n const fbclid = data.queryParams.fbclid;\n const gclid = data.queryParams.gclid;\n const ttclid = data.queryParams.ttclid;\n const msclkid = data.queryParams.msclkid;\n if (fbclid || gclid || ttclid || msclkid) {\n void this.setAttributionData(\n this._attributionDeeplinkId,\n gclid || this._attributionGclid,\n fbclid || this._attributionFbclid,\n ttclid || this._attributionTtclid,\n msclkid || this._attributionMsclkid\n );\n }\n\n this.track('deep_link_opened', properties);\n if (this.enableDebug) {\n console.log(`[Layers] auto-tracked deep_link_opened: ${data.url}`);\n }\n } catch (e) {\n this.emitError(e);\n }\n });\n }\n\n // --- Platform-specific: React Native device info ---\n\n private async initializeDeviceInfo(): Promise<void> {\n try {\n const { Platform, Dimensions, NativeModules } = require('react-native');\n const window = Dimensions.get('window');\n\n const platform =\n Platform.OS === 'ios' ? 'ios' : Platform.OS === 'android' ? 'android' : 'react-native';\n const osVersion =\n typeof Platform.Version === 'string' ? Platform.Version : String(Platform.Version);\n\n // Device model: use platform constants where available\n let deviceModel: string;\n if (Platform.OS === 'android') {\n const brand = Platform.constants?.Brand ?? '';\n const model = Platform.constants?.Model ?? '';\n deviceModel = brand && model ? `${brand} ${model}` : model || brand || 'Android';\n } else if (Platform.OS === 'ios') {\n // Try to get the real iOS model identifier from native module\n try {\n const model = await NativeModules.LayersDeviceInfo?.getModelIdentifier();\n deviceModel = model || 'iPhone';\n } catch {\n deviceModel = 'iPhone';\n }\n } else {\n deviceModel = 'unknown';\n }\n\n // Auto-detect app version from native platform APIs\n let appVersion: string | undefined;\n try {\n appVersion = await getAppVersion(Platform, NativeModules);\n } catch {\n // App version collection is best-effort\n }\n\n const context: DeviceContext = {\n platform: platform as PlatformType,\n osVersion,\n deviceModel,\n locale: getLocale(),\n screenSize: `${Math.round(window.width)}x${Math.round(window.height)}`,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n ...(appVersion != null && { appVersion })\n };\n\n // Auto-collect IDFV on iOS (first-party identifier, no ATT consent required)\n if (Platform.OS === 'ios') {\n try {\n const idfv = await getVendorId();\n if (idfv) context.idfv = idfv;\n } catch {\n // IDFV collection is best-effort\n }\n }\n\n // Auto-collect GAID on Android (Google Advertising ID)\n if (Platform.OS === 'android') {\n try {\n const gaid = await getGoogleAdvertisingId();\n if (gaid) context.idfa = gaid.id;\n if (gaid && gaid.isLimitAdTrackingEnabled != null) {\n context.attStatus = gaid.isLimitAdTrackingEnabled ? 'denied' : 'authorized';\n }\n } catch {\n // GAID collection is best-effort\n }\n }\n\n // Check for prior SDK state before getOrSetInstallId creates a new one\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (AsyncStorage) {\n const existingId = await AsyncStorage.getItem(INSTALL_ID_KEY);\n this._hadPriorSdkState = existingId != null;\n }\n } catch {\n // best-effort\n }\n\n // Auto-populate installId from persistent storage\n try {\n const installId = await getOrSetInstallId();\n if (installId) context.installId = installId;\n } catch {\n // installId collection is best-effort\n }\n\n this.core.setDeviceContext(context);\n } catch {\n // React Native APIs not available (e.g. in tests)\n const context: DeviceContext = {\n platform: 'react-native',\n osVersion: 'unknown',\n deviceModel: 'unknown',\n locale: 'en-US'\n };\n // Check for prior SDK state in fallback path too\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (AsyncStorage) {\n const existingId = await AsyncStorage.getItem(INSTALL_ID_KEY);\n this._hadPriorSdkState = existingId != null;\n }\n } catch {\n // best-effort\n }\n // Still try to populate installId in fallback path\n try {\n const installId = await getOrSetInstallId();\n if (installId) context.installId = installId;\n } catch {\n // best-effort\n }\n this.core.setDeviceContext(context);\n }\n\n // Collect attribution signals independently of device context\n // so a failure above doesn't prevent attribution collection.\n // Reset per-init state first so a subsequent init() run (e.g. after\n // reset() or a hot reload) doesn't re-use install-referrer params\n // from a prior session.\n this._installReferrerParams = null;\n try {\n const { Platform } = require('react-native');\n if (Platform.OS === 'ios') {\n try {\n const token = await getAdServicesToken();\n if (token) this._adServicesToken = token;\n } catch {\n // best-effort\n }\n }\n if (Platform.OS === 'android') {\n try {\n const referrer = await getInstallReferrer();\n if (referrer) {\n this._installReferrer = referrer;\n\n // Parse click IDs out of the Play Install Referrer string and\n // persist them via setAttributionData so subsequent events carry\n // them. This is the primary Android path for Meta/TikTok\n // web-to-app attribution: /c/:appId appends fbclid/ttclid/etc to\n // the referrer, and the server matcher resolves them to the\n // originating click.\n //\n // Merge with any previously restored attribution values (e.g. the\n // user may have manually called setAttributionData earlier) so we\n // don't clobber a deeplinkId that's already in effect.\n const parsed = parseInstallReferrerUrl(referrer.referrerUrl);\n // Stash ALL parsed params so the app_open props spread below\n // picks them up (click_id, gbraid, wbraid, rclid, li_fat_id,\n // sclid, utm_*) — not just the 4 click IDs setAttributionData\n // supports. Always assign (even if empty) so a subsequent init()\n // run with a blank referrer doesn't re-use stale values from a\n // prior session.\n this._installReferrerParams = Object.keys(parsed).length > 0 ? parsed : null;\n if (parsed.fbclid || parsed.gclid || parsed.ttclid || parsed.msclkid) {\n try {\n await this.setAttributionData(\n this._attributionDeeplinkId,\n parsed.gclid ?? this._attributionGclid,\n parsed.fbclid ?? this._attributionFbclid,\n parsed.ttclid ?? this._attributionTtclid,\n parsed.msclkid ?? this._attributionMsclkid\n );\n } catch {\n // best-effort\n }\n }\n }\n } catch {\n // best-effort\n }\n }\n } catch {\n // Platform not available\n }\n }\n\n // --- Platform-specific: AppState listener ---\n\n private setupAppStateListener(): void {\n try {\n const { AppState } = require('react-native');\n\n // Track lifecycle state changes so duplicate transitions (e.g.\n // active → inactive → background) don't fire duplicate events.\n let lastEmittedState: string | null = null;\n this.appStateSubscription = AppState.addEventListener('change', (nextAppState: string) => {\n if (nextAppState === 'background' || nextAppState === 'inactive') {\n // Emit $app_background on the first background-ish transition.\n // We collapse `inactive` (transient on iOS) into the same bucket\n // since both indicate the user is leaving the foreground.\n if (this.config.autoTrackAppLifecycle !== false && lastEmittedState !== 'background') {\n try {\n this.track('$app_background');\n lastEmittedState = 'background';\n } catch {\n // best-effort — never block the AppState callback\n }\n }\n // Use synchronous flush to persist events to disk before OS suspends\n // (async HTTP may not complete before suspension)\n this.core.flush();\n }\n if (nextAppState === 'active') {\n if (\n this.config.autoTrackAppLifecycle !== false &&\n lastEmittedState !== null && // skip the very first 'active' on init\n lastEmittedState !== 'active'\n ) {\n try {\n this.track('$app_foreground');\n lastEmittedState = 'active';\n } catch {\n // best-effort\n }\n } else if (lastEmittedState === null) {\n // First observed 'active' — record without emitting (init handles app_open).\n lastEmittedState = 'active';\n }\n if (this.isOnline) {\n void this.core.flushAsync().catch(() => {});\n }\n }\n });\n } catch {\n // AppState not available\n }\n }\n\n // --- Platform-specific: SKAN auto-configuration from remote config ---\n\n private async configureSkanFromRemoteConfig(): Promise<void> {\n // SKAN is iOS-only; skip on other platforms.\n try {\n const { Platform } = require('react-native');\n if (Platform.OS !== 'ios') return;\n } catch {\n // react-native not available (e.g. test env) — proceed with SKAN config\n }\n\n try {\n const configJson = this.core.getRemoteConfigJson?.();\n if (!configJson) return;\n\n const config = JSON.parse(configJson);\n const skanConfig = config?.skan;\n if (!skanConfig || skanConfig.enabled === false) {\n // SKAN disabled or removed from config — clear any existing manager\n this._skanManager = null;\n this._lastSkanConfigStr = null;\n return;\n }\n\n // Skip re-creation if SKAN config hasn't changed (avoids resetting state every poll)\n const skanConfigStr = JSON.stringify(skanConfig);\n if (this._skanManager && this._lastSkanConfigStr === skanConfigStr) return;\n\n const manager = new SKANManagerImpl();\n\n if (skanConfig.preset) {\n manager.setPreset(skanConfig.preset);\n } else if (skanConfig.customRules && Array.isArray(skanConfig.customRules)) {\n manager.setCustomRules(skanConfig.customRules);\n } else {\n // SKAN section present but no preset or rules — nothing to configure\n return;\n }\n\n await manager.initialize();\n this._skanManager = manager;\n this._lastSkanConfigStr = skanConfigStr;\n\n if (this.enableDebug) {\n const metrics = manager.getMetrics();\n console.log(\n `[Layers] SKAN auto-configured from remote config: preset=${metrics.currentPreset}, rules=${String(metrics.ruleCount)}`\n );\n }\n } catch {\n // SKAN auto-configuration is best-effort\n }\n }\n\n // --- Remote config polling ---\n\n private startConfigPolling(): void {\n this.stopConfigPolling();\n this._configPollTimer = setInterval(() => {\n void this.pollRemoteConfig();\n }, LayersReactNative.CONFIG_POLL_INTERVAL_MS);\n }\n\n private stopConfigPolling(): void {\n if (this._configPollTimer) {\n clearInterval(this._configPollTimer);\n this._configPollTimer = null;\n }\n }\n\n private async pollRemoteConfig(): Promise<void> {\n try {\n await this.core.fetchRemoteConfig();\n // Re-run SKAN configuration to pick up any changes\n await this.configureSkanFromRemoteConfig();\n if (this.enableDebug) {\n console.log('[Layers] Remote config updated (poll)');\n }\n } catch {\n // Config polling is best-effort — errors are silently ignored\n }\n }\n\n // --- Platform-specific: NetInfo listener ---\n\n private setupNetInfoListener(): void {\n try {\n const NetInfo = require('@react-native-community/netinfo');\n this.netInfoUnsubscribe = NetInfo.addEventListener(\n (state: { isConnected: boolean | null }) => {\n const wasOffline = !this.isOnline;\n this.isOnline = state.isConnected !== false;\n\n if (wasOffline && this.isOnline) {\n void this.core.flushAsync().catch(() => {});\n }\n }\n );\n } catch {\n // NetInfo not available — assume always online\n }\n }\n}\n\n// --- AsyncStorage persistence backend ---\n\nasync function createAsyncStoragePersistence(appId: string): Promise<PersistenceBackend> {\n const prefix = `layers_sdk_${appId}_`;\n const memoryStore = new Map<string, Uint8Array>();\n\n // Pre-load from AsyncStorage so that events persisted in a prior session\n // are available synchronously when the core hydrates on init.\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (AsyncStorage) {\n const allKeys = await AsyncStorage.getAllKeys();\n const sdkKeys = allKeys.filter((k) => k.startsWith(prefix));\n if (sdkKeys.length > 0) {\n const pairs = await AsyncStorage.multiGet(sdkKeys);\n for (const [key, value] of pairs) {\n if (value) {\n const shortKey = key.slice(prefix.length);\n memoryStore.set(shortKey, base64Decode(value));\n }\n }\n }\n }\n } catch {\n // Pre-load is best-effort; memoryStore stays empty\n }\n\n return {\n write(key: string, data: Uint8Array): void {\n memoryStore.set(key, new Uint8Array(data));\n // Fire-and-forget async write to AsyncStorage\n void writeToAsyncStorage(prefix + key, data);\n },\n read(key: string): Uint8Array | null {\n return memoryStore.get(key) ?? null;\n },\n delete(key: string): void {\n memoryStore.delete(key);\n void deleteFromAsyncStorage(prefix + key);\n },\n listKeys(keyPrefix: string): string[] {\n const keys: string[] = [];\n for (const k of memoryStore.keys()) {\n if (k.startsWith(keyPrefix)) {\n keys.push(k);\n }\n }\n keys.sort();\n return keys;\n }\n };\n}\n\n// Binary-safe base64 encoding that handles large arrays without stack overflow.\n// btoa(String.fromCharCode(...data)) spreads the entire array onto the call stack,\n// which crashes for event batches larger than ~125 KB.\nconst B64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst B64_LOOKUP = new Uint8Array(128);\nfor (let _i = 0; _i < B64_CHARS.length; _i += 1) {\n B64_LOOKUP[B64_CHARS.charCodeAt(_i)] = _i;\n}\n\nfunction base64Decode(str: string): Uint8Array {\n const lookup = B64_LOOKUP;\n // Strip padding to determine decoded length\n let len = str.length;\n if (str[len - 1] === '=') len -= 1;\n if (str[len - 1] === '=') len -= 1;\n const bytes = new Uint8Array(Math.floor((len * 3) / 4));\n let p = 0;\n for (let i = 0; i < len; i += 4) {\n const b0 = lookup[str.charCodeAt(i)]!;\n const b1 = lookup[str.charCodeAt(i + 1)]!;\n const b2 = i + 2 < len ? lookup[str.charCodeAt(i + 2)]! : 0;\n const b3 = i + 3 < len ? lookup[str.charCodeAt(i + 3)]! : 0;\n bytes[p] = (b0 << 2) | (b1 >> 4);\n p += 1;\n if (i + 2 < len) {\n bytes[p] = ((b1 & 0x0f) << 4) | (b2 >> 2);\n p += 1;\n }\n if (i + 3 < len) {\n bytes[p] = ((b2 & 0x03) << 6) | b3;\n p += 1;\n }\n }\n return bytes;\n}\n\nfunction base64Encode(bytes: Uint8Array): string {\n let result = '';\n const len = bytes.length;\n for (let i = 0; i < len; i += 3) {\n const b0 = bytes[i]!;\n const b1 = i + 1 < len ? bytes[i + 1]! : 0;\n const b2 = i + 2 < len ? bytes[i + 2]! : 0;\n result += B64_CHARS[(b0 >> 2)!]!;\n result += B64_CHARS[((b0 & 0x03) << 4) | (b1 >> 4)]!;\n result += i + 1 < len ? B64_CHARS[((b1 & 0x0f) << 2) | (b2 >> 6)]! : '=';\n result += i + 2 < len ? B64_CHARS[b2 & 0x3f]! : '=';\n }\n return result;\n}\n\nasync function writeToAsyncStorage(key: string, data: Uint8Array): Promise<void> {\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (!AsyncStorage) return;\n const encoded = base64Encode(data);\n await AsyncStorage.setItem(key, encoded);\n } catch {\n // Best effort\n }\n}\n\nasync function deleteFromAsyncStorage(key: string): Promise<void> {\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (!AsyncStorage) return;\n await AsyncStorage.removeItem(key);\n } catch {\n // Best effort\n }\n}\n\ninterface AsyncStorageStatic {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n getAllKeys(): Promise<readonly string[]>;\n multiGet(keys: readonly string[]): Promise<readonly [string, string | null][]>;\n}\n\nlet _asyncStorage: AsyncStorageStatic | undefined = undefined;\nlet _asyncStoragePromise: Promise<AsyncStorageStatic | null> | null = null;\n\nasync function loadAsyncStorage(): Promise<AsyncStorageStatic | null> {\n if (_asyncStorage) return _asyncStorage;\n if (!_asyncStoragePromise) {\n _asyncStoragePromise = import('@react-native-async-storage/async-storage')\n .then((mod): AsyncStorageStatic | null => {\n const storage = (mod.default ?? mod) as AsyncStorageStatic | null;\n if (storage) _asyncStorage = storage;\n return storage;\n })\n .catch((): null => null);\n }\n return _asyncStoragePromise;\n}\n\n// --- Locale helper ---\n\nfunction getLocale(): string {\n try {\n const { Platform, NativeModules } = require('react-native');\n if (Platform.OS === 'ios') {\n return (\n NativeModules.SettingsManager?.settings?.AppleLocale ??\n NativeModules.SettingsManager?.settings?.AppleLanguages?.[0] ??\n 'en-US'\n );\n }\n if (Platform.OS === 'android') {\n return NativeModules.I18nManager?.localeIdentifier ?? 'en-US';\n }\n } catch {\n // Fallback\n }\n return 'en-US';\n}\n\n// --- Install ID via AsyncStorage ---\n\nconst INSTALL_ID_KEY = 'layers_install_id';\nconst FIRST_LAUNCH_TRACKED_KEY = '@layers/first_launch_tracked';\n/**\n * Last-known app_version persisted across launches. Used to detect\n * `$app_update` (version increment) vs. `$first_open` (no prior value).\n */\nconst LAST_APP_VERSION_KEY = '@layers/last_app_version';\n\n/**\n * Maximum age of an app installation (in milliseconds) for which the SDK\n * will consider the first launch as a genuine new install. If the app was\n * installed more than 24 hours ago AND no prior Layers SDK state exists,\n * the SDK treats this as an existing app that just added the SDK — not a\n * new install — and suppresses `is_first_launch = true`.\n */\nconst INSTALL_EVENT_MAX_DIFF_MS = 24 * 60 * 60 * 1000;\n\nexport async function getOrSetInstallId(): Promise<string> {\n try {\n const AsyncStorage = await loadAsyncStorage();\n if (!AsyncStorage) return generateUUID();\n\n const existing = await AsyncStorage.getItem(INSTALL_ID_KEY);\n if (existing) return existing;\n\n const newId = generateUUID();\n await AsyncStorage.setItem(INSTALL_ID_KEY, newId);\n return newId;\n } catch {\n return generateUUID();\n }\n}\n\nfunction generateUUID(): string {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n// --- Install Event Gating (24-hour window) ---\n\n/**\n * Read the app's first install time from the native module.\n * Returns milliseconds since epoch, or null if not available.\n *\n * - Android: reads PackageInfo.firstInstallTime via PackageManager\n * - iOS: reads the Documents directory creation date as a proxy\n */\nexport async function getFirstInstallTime(): Promise<number | null> {\n try {\n const { NativeModules } = require('react-native');\n const mod = NativeModules.LayersDeviceInfo as\n | { getFirstInstallTime?(): Promise<number | null> }\n | undefined;\n if (!mod?.getFirstInstallTime) return null;\n const time = await mod.getFirstInstallTime();\n return time != null && Number.isFinite(time) ? time : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Determine whether this is a genuine new install or an existing app that\n * just added the Layers SDK.\n *\n * This is a pure function that takes pre-resolved inputs — the caller is\n * responsible for reading and persisting the `FIRST_LAUNCH_TRACKED_KEY`\n * flag in AsyncStorage. This mirrors the Android/Swift implementations\n * where the caller manages persistence.\n *\n * Logic (mirrors Android's `shouldTreatAsNewInstall`):\n * 1. If `isFirstLaunchByFlag` is `false` (flag already tracked), return `false`.\n * 2. If the SDK had prior state (`install_id` already existed in\n * AsyncStorage), trust the flag — this is a returning user whose\n * first-launch flag was not yet written (e.g. upgrade from an older\n * SDK version). Return `true`.\n * 3. If the SDK had NO prior state AND the app was installed more than\n * 24 hours ago, this is an existing app getting the SDK for the first\n * time — suppress `is_first_launch`. Return `false`.\n * 4. If the SDK had no prior state AND the app was installed within 24\n * hours, this is a genuine new install — allow `is_first_launch`.\n * Return `true`.\n *\n * @param isFirstLaunchByFlag Whether the first_launch flag has NOT been set yet (true = not yet tracked).\n * @param hadPriorSdkState Whether `install_id` already existed before init.\n * @param enableDebug Whether to log debug info.\n */\nexport async function shouldTreatAsNewInstall(\n isFirstLaunchByFlag: boolean,\n hadPriorSdkState: boolean,\n enableDebug = false,\n _getInstallTime: () => Promise<number | null> = getFirstInstallTime\n): Promise<boolean> {\n // 1. Flag already tracked — not a first launch\n if (!isFirstLaunchByFlag) return false;\n\n // 2. SDK had prior state — trust the flag: this is a real first launch\n if (hadPriorSdkState) return true;\n\n // 3 & 4. SDK has no prior state — check whether the app is a recent install\n try {\n const firstInstallTime = await _getInstallTime();\n if (firstInstallTime != null) {\n const elapsed = Date.now() - firstInstallTime;\n const isRecentInstall = elapsed <= INSTALL_EVENT_MAX_DIFF_MS;\n\n if (!isRecentInstall && enableDebug) {\n console.log(\n `[Layers] Install event gated: app installed ${Math.round(elapsed / 1000)}s ago ` +\n `(threshold=${INSTALL_EVENT_MAX_DIFF_MS / 1000}s), ` +\n 'no prior SDK state — suppressing is_first_launch'\n );\n }\n\n return isRecentInstall;\n }\n } catch {\n // best-effort\n }\n\n // If we can't read the install time, default to trusting it as a new install\n return true;\n}\n\n// --- Clipboard Attribution (iOS-only deferred deep links) ---\n\nexport interface ClipboardAttribution {\n clickUrl: string;\n clickId: string;\n}\n\nconst CLIPBOARD_CHECKED_KEY = '@layers/clipboard_checked';\n\nexport async function readClipboardAttribution(): Promise<ClipboardAttribution | null> {\n try {\n const { Platform } = require('react-native');\n if (Platform.OS !== 'ios') return null;\n } catch {\n return null;\n }\n\n // Check if we've already read clipboard (once per install)\n try {\n const AS = await loadAsyncStorage();\n if (AS) {\n const flag = await AS.getItem(CLIPBOARD_CHECKED_KEY);\n if (flag === 'true') return null;\n }\n } catch {}\n\n let text: string | null = null;\n try {\n // Try @react-native-clipboard/clipboard first (recommended)\n const Clipboard = await import('@react-native-clipboard/clipboard')\n .then((m) => m.default)\n .catch(() => null);\n if (Clipboard) {\n text = await Clipboard.getString();\n } else {\n // Fallback to deprecated RN Clipboard\n const { Clipboard: RNClipboard } = require('react-native');\n if (RNClipboard) {\n text = await RNClipboard.getString();\n }\n }\n } catch {}\n\n // Mark as checked regardless of result\n try {\n const AS = await loadAsyncStorage();\n if (AS) await AS.setItem(CLIPBOARD_CHECKED_KEY, 'true');\n } catch {}\n\n if (!text) return null;\n\n // Check for Layers click URL pattern\n const match = text.match(/https?:\\/\\/(in\\.layers\\.com|link\\.layers\\.com)\\/c\\/([^?\\s]+)/);\n if (!match) return null;\n\n return { clickUrl: text, clickId: match[2]! };\n}\n\n// --- App Version Helper ---\n\n/**\n * Attempt to read the host app version from platform-specific APIs.\n * On Android, reads from PackageInfo via Platform.constants or a native module.\n * On iOS, reads from the LayersDeviceInfo native module which can access the Info.plist.\n */\nasync function getAppVersion(\n Platform: { OS: string; constants?: Record<string, unknown> },\n NativeModules: Record<string, unknown>\n): Promise<string | undefined> {\n try {\n // Android: Platform.constants may include the app version via ReactNativeVersion\n // or we can use a native module\n if (Platform.OS === 'android') {\n const mod = NativeModules.LayersDeviceInfo as\n | { getAppVersion?(): Promise<string | null> }\n | undefined;\n if (mod?.getAppVersion) {\n const version = await mod.getAppVersion();\n if (version) return version;\n }\n }\n\n // iOS: use LayersDeviceInfo native module\n if (Platform.OS === 'ios') {\n const mod = NativeModules.LayersDeviceInfo as\n | { getAppVersion?(): Promise<string | null> }\n | undefined;\n if (mod?.getAppVersion) {\n const version = await mod.getAppVersion();\n if (version) return version;\n }\n }\n } catch {\n // Best-effort\n }\n return undefined;\n}\n\n// --- Google Advertising ID (Android only) ---\n\nexport interface GoogleAdvertisingInfo {\n id: string;\n isLimitAdTrackingEnabled: boolean;\n}\n\n/**\n * Fetch the Google Advertising ID (GAID) on Android via NativeModules.\n * Returns null on iOS or when the native module is not available.\n */\nexport async function getGoogleAdvertisingId(): Promise<GoogleAdvertisingInfo | null> {\n try {\n const { NativeModules, Platform } = require('react-native');\n if (Platform.OS !== 'android') return null;\n const mod = NativeModules.LayersAdvertisingId as\n | { getAdvertisingInfo?(): Promise<GoogleAdvertisingInfo | null> }\n | undefined;\n if (!mod?.getAdvertisingInfo) return null;\n const info = await mod.getAdvertisingInfo();\n if (!info || !info.id || info.id === '00000000-0000-0000-0000-000000000000') return null;\n return info;\n } catch {\n return null;\n }\n}\n\n// --- AdServices Attribution Token (iOS only) ---\n\n/**\n * Request the AdServices attribution token on iOS 14.3+.\n * Uses the LayersAdServices native module which calls AAAttribution.attributionToken().\n * Does NOT require ATT consent.\n * Returns null on Android or when the native module is not available.\n */\nexport async function getAdServicesToken(): Promise<string | null> {\n try {\n const { NativeModules, Platform } = require('react-native');\n if (Platform.OS !== 'ios') return null;\n const mod = NativeModules.LayersAdServices as\n | { getAttributionToken?(): Promise<string | null> }\n | undefined;\n if (!mod?.getAttributionToken) return null;\n return await mod.getAttributionToken();\n } catch {\n return null;\n }\n}\n\n// --- Install Referrer (Android only) ---\n\nexport interface InstallReferrerData {\n referrerUrl: string;\n referrerClickTimestamp?: number;\n installBeginTimestamp?: number;\n}\n\n/**\n * Known attribution params extracted from the Play Install Referrer string.\n * Keep in sync with layers sdk-ingest routes/click.ts::buildAndroidReferrerUrl\n * and the parallel allowlists in kotlin / unity / flutter SDKs.\n */\nconst INSTALL_REFERRER_ATTRIBUTION_PARAMS = new Set<string>([\n // UTM\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_content',\n 'utm_term',\n // Ad platform click IDs\n 'gclid',\n 'gbraid',\n 'wbraid', // Google\n 'fbclid', // Meta\n 'ttclid', // TikTok\n 'twclid', // X\n 'msclkid', // Microsoft\n 'li_fat_id', // LinkedIn\n 'sclid', // Snapchat\n 'rclid', // Reddit\n 'irclickid', // Impact\n // Layers click_id (primary key of sdk_clicks)\n 'click_id'\n]);\n\n/**\n * Parse a raw Play Install Referrer string into a map of recognized attribution\n * params. Accepts either a bare query string (`a=1&b=2`) or a full URL.\n * Returns an empty object on parse failure.\n */\nexport function parseInstallReferrerUrl(referrer: string): Record<string, string> {\n const out: Record<string, string> = {};\n if (!referrer) return out;\n try {\n let qs = referrer;\n const qIdx = qs.indexOf('?');\n if (qIdx >= 0) qs = qs.slice(qIdx + 1);\n // Some referrers arrive URL-encoded (e.g. Play wraps the referrer)\n if (!qs.includes('=') && qs.includes('%3D')) {\n qs = decodeURIComponent(qs);\n }\n for (const pair of qs.split('&')) {\n const eq = pair.indexOf('=');\n if (eq >= 0) {\n try {\n const key = decodeURIComponent(pair.slice(0, eq));\n const value = decodeURIComponent(pair.slice(eq + 1));\n if (value && INSTALL_REFERRER_ATTRIBUTION_PARAMS.has(key)) {\n out[key] = value;\n }\n } catch {\n // ignore individual malformed pair\n }\n }\n }\n } catch {\n // ignore overall parse failure\n }\n return out;\n}\n\n/**\n * Fetch the Google Play install referrer on Android via NativeModules.\n * Requires the `com.android.installreferrer` library on the native side.\n * Returns null on iOS or when the native module is not available.\n */\nexport async function getInstallReferrer(): Promise<InstallReferrerData | null> {\n try {\n const { NativeModules, Platform } = require('react-native');\n if (Platform.OS !== 'android') return null;\n const mod = NativeModules.LayersInstallReferrer as\n | { getInstallReferrer?(): Promise<InstallReferrerData | null> }\n | undefined;\n if (!mod?.getInstallReferrer) return null;\n const data = await mod.getInstallReferrer();\n if (!data || !data.referrerUrl) return null;\n return data;\n } catch {\n return null;\n }\n}\n\n// --- Facebook Click ID ($fbc) Formatter ---\n\n/**\n * Format a raw fbclid into the Meta Conversions API `$fbc` parameter format.\n *\n * The format is: `fb.{subdomainIndex}.{creationTime}.{fbclid}`\n * - `subdomainIndex`: always `1` for app SDKs\n * - `creationTime`: Unix timestamp in milliseconds when the fbclid was captured\n * - `fbclid`: the raw Facebook Click Identifier\n *\n * The timestamp is captured once at format time so that every event carries\n * the same `$fbc` value (the capture time, not the event time).\n *\n * @see https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc\n */\nexport function formatFbc(fbclid: string, timestampMs?: number): string {\n const ts = timestampMs ?? Date.now();\n return `fb.1.${ts}.${fbclid}`;\n}\n\n// --- Deep Links ---\n\nexport interface DeepLinkData {\n url: string;\n scheme: string;\n host: string;\n path: string;\n queryParams: Record<string, string>;\n timestamp: number;\n}\n\nexport function setupDeepLinkListener(onDeepLink: (data: DeepLinkData) => void): () => void {\n try {\n const { Linking } = require('react-native');\n\n const handler = (event: { url: string }) => {\n const parsed = parseDeepLink(event.url);\n if (parsed) onDeepLink(parsed);\n };\n\n const subscription = Linking.addEventListener('url', handler);\n\n // Check initial URL\n void Linking.getInitialURL().then((url: string | null) => {\n if (url) {\n const parsed = parseDeepLink(url);\n if (parsed) onDeepLink(parsed);\n }\n });\n\n return () => {\n if (subscription?.remove) {\n subscription.remove();\n }\n };\n } catch {\n return () => {};\n }\n}\n\nexport function parseDeepLink(url: string): DeepLinkData | null {\n try {\n const parsed = new URL(url);\n const params: Record<string, string> = {};\n parsed.searchParams.forEach((value, key) => {\n params[key] = value;\n });\n return {\n url,\n scheme: parsed.protocol.replace(':', ''),\n host: parsed.hostname,\n path: parsed.pathname,\n queryParams: params,\n timestamp: Date.now()\n };\n } catch {\n return null;\n }\n}\n\n// --- Expo Router Integration ---\n\n// Module-level map of `previous_screen_name` per SDK instance. We use a\n// WeakMap so the entry is GC'd when the SDK instance is released. This is\n// preferable to `useRef` here because the existing hook test infrastructure\n// only mocks `useEffect` from React (not `useRef`); using a module-level\n// map keeps the hook compatible with that test shape and gives us the\n// same `(from, to)` payload as the React Navigation observer.\nconst _expoRouterPreviousPath = new WeakMap<LayersReactNative, string>();\n\n/**\n * Hook that emits `$screen_view` for every Expo Router pathname change.\n *\n * The hook also tracks the previous pathname so the emitted event carries\n * `previous_screen_name`, matching the React Navigation observer in\n * `useLayersNavigationTracking`. This makes funnel analysis trivial\n * server-side: every screen event has a self-contained pair `(from, to)`\n * — no need to join adjacent rows.\n */\nexport function useLayersExpoRouterTracking(\n sdkInstance: LayersReactNative,\n usePathname: () => string,\n useGlobalSearchParams: () => Record<string, string | string[]>\n): void {\n const { useEffect } = require('react');\n const pathname = usePathname();\n const params = useGlobalSearchParams();\n const paramsString = JSON.stringify(params);\n\n useEffect(() => {\n if (pathname) {\n const properties: Record<string, unknown> = {};\n Object.entries(params).forEach(([key, value]) => {\n properties[key] = Array.isArray(value) ? value.join(',') : value;\n });\n const previous = _expoRouterPreviousPath.get(sdkInstance);\n if (previous && previous !== pathname) {\n properties.previous_screen_name = previous;\n }\n void sdkInstance.screen(pathname, properties);\n _expoRouterPreviousPath.set(sdkInstance, pathname);\n }\n }, [pathname, paramsString]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,iBAAiB;CAC5B,aAAa;CACb,UAAU;CACV,OAAO;CACP,SAAS;CACT,UAAU;CACV,UAAU;CACV,aAAa;CACb,iBAAiB;CACjB,mBAAmB;CACnB,gBAAgB;CAChB,aAAa;CACb,WAAW;CACX,aAAa;CACb,gBAAgB;CAChB,mBAAmB;CACnB,QAAQ;CACR,WAAW;CACX,cAAc;CACd,OAAO;CACP,WAAW;CACX,aAAa;CACd;;AAiBD,SAAgB,WAAW,QAAuC;CAChE,MAAMA,aAA8B,EAAE;AACtC,KAAI,WAAW,OAAW,YAAW,SAAS;AAC9C,QAAO;EAAE,OAAO,eAAe;EAAO;EAAY;;;AAIpD,SAAgB,YAAY,QAAuC;CACjE,MAAMA,aAA8B,EAAE;AACtC,KAAI,WAAW,OAAW,YAAW,SAAS;AAC9C,QAAO;EAAE,OAAO,eAAe;EAAS;EAAY;;;AAItD,SAAgB,cAAc,QAAuC;CACnE,MAAMA,aAA8B,EAAE;AACtC,KAAI,WAAW,OAAW,YAAW,SAAS;AAC9C,QAAO;EAAE,OAAO,eAAe;EAAU;EAAY;;;AAIvD,SAAgB,cACd,QACA,WAAW,OACX,QACsB;CACtB,MAAMA,aAA8B;EAAE;EAAQ;EAAU;AACxD,KAAI,WAAW,OAAW,YAAW,UAAU;AAC/C,QAAO;EAAE,OAAO,eAAe;EAAU;EAAY;;;AAIvD,SAAgB,eAAe,QAAgB,OAAe,WAAW,GAAyB;AAChG,QAAO;EACL,OAAO,eAAe;EACtB,YAAY;GAAE,SAAS;GAAQ;GAAO;GAAU;EACjD;;;AAIH,SAAgB,mBACd,QACA,MACA,OACsB;CACtB,MAAMA,aAA8B,EAAE,SAAS,QAAQ;AACvD,KAAI,SAAS,OAAW,YAAW,OAAO;AAC1C,KAAI,UAAU,OAAW,YAA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
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"mobile"
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@layers/core-wasm": "3.1.
|
|
69
|
+
"@layers/core-wasm": "3.1.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@react-native-async-storage/async-storage": ">=1.21.0",
|