react-native-acoustic-connect-beta
Version:
BETA: React native plugin for Acoustic Connect
111 lines (105 loc) • 5.58 kB
text/typescript
// Copyright (C) 2025 Acoustic, L.P. All rights reserved.
//
// NOTICE: This file contains material that is confidential and proprietary to
// Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
// industrial property rights of Acoustic, L.P. except as may be provided in an agreement with
// Acoustic, L.P. Any unauthorized copying or distribution of content from this file is
// prohibited.
//
//
// Created by Omar Hernandez on 5/9/25.
//
import { type HybridObject } from 'react-native-nitro-modules'
// Define a named type for the anonymous object
export type KeyValueObject = {
placeholder: string; // Add a placeholder property to avoid the "empty struct" error
[key: string]: unknown;
};
export type ConnectMonitoringLevelType = 'Ignore' | 'CellularAndWiFi' | 'WiFi'
export interface AcousticConnectRN extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
/**
* Re-enables the Connect SDK after a prior {@link disable} call.
*
* The SDK auto-initialises at module load time using the values from
* `ConnectConfig.json` at the consumer's project root — so for most apps
* there is no need to call `enable()` at all. The method exists as the
* pair of {@link disable}: if a consent flow, A/B-test gate, or opt-out
* toggle previously called `disable()`, calling `enable()` brings the
* SDK back up using the same bundled configuration.
*
* @returns `true` when the call was accepted and dispatched to the native
* SDK. `false` only when the platform cannot satisfy a precondition
* (e.g. Android without an `Application` context yet).
*
* @remarks
* **Single source of truth.** All configuration (AppKey, PostMessageUrl,
* push, platform extras) lives in `ConnectConfig.json` at the consumer's
* project root. The podspec (iOS) and `config.gradle` (Android) bake
* those values into the bundled config that the native bridge reads at
* init time. There is no runtime override path — by design, to eliminate
* the inconsistency surface that runtime arguments would create against
* the bundled config.
*
* **Idempotency.** Owned by the native SDK. iOS
* `ConnectSDK.shared.enable(with:)` short-circuits via
* `guard !isEnabled else { return }` in its internal `enableCore`; the
* Android `Connect.init` / `Connect.enable` pair behaves the same way
* once the SDK is running.
*
* **Threading.** Returns synchronously; the native SDK call is
* fire-and-forget on the main thread / actor.
*
* @example User opt-in after a prior opt-out
* ```ts
* import AcousticConnectRN from 'react-native-acoustic-connect-beta'
*
* function onUserOptIn() {
* AcousticConnectRN.enable()
* }
* ```
*/
enable(): boolean
/**
* Disables the Connect SDK and stops all data capture.
*
* After this call the SDK flushes pending data to the backend, stops
* listening for events, and releases push state. Call {@link enable}
* to bring the SDK back up using the same bundled configuration.
*
* @returns `true` when the call was accepted and dispatched. Idempotent —
* calling `disable()` on an already-disabled SDK is safe.
*
* @example User opt-out flow
* ```ts
* import AcousticConnectRN from 'react-native-acoustic-connect-beta'
*
* function onUserOptOut() {
* AcousticConnectRN.disable()
* }
* ```
*/
disable(): boolean
setBooleanConfigItemForKey(key: string, value: boolean, moduleName: string): boolean
setStringItemForKey(key: string, value: string, moduleName: string): boolean
setNumberItemForKey(key: string, value: number, moduleName: string): boolean
setConfigItemForKey(key: string, value: string | number | boolean, moduleName: string): boolean
getBooleanConfigItemForKey(theDefault: boolean, key: string, moduleName: string): boolean
getStringItemForKey(theDefault: string, key: string, moduleName: string): string | null | undefined
getNumberItemForKey(theDefault: number, key: string, moduleName: string): number
logCustomEvent(eventName: string, values: Record<string, string | number | boolean>, level: number): boolean
logSignal(values: Record<string, string | number | boolean>, level: number): boolean
logExceptionEvent(message: string, stackInfo: string, unhandled: boolean): boolean
logLocation(): boolean
logLocationWithLatitudeLongitude(latitude: number, longitude: number, level: number): boolean
logClickEvent(target: number, controlId: string): boolean
logTextChangeEvent(target: number, controlId: string, text: string | null | undefined): boolean
setCurrentScreenName(logicalPageName: string): boolean
logScreenViewContextLoad(logicalPageName: string | null | undefined, referrer:string | null | undefined): boolean
logScreenViewContextUnload(logicalPageName: string | null | undefined, referrer:string | null | undefined): boolean
logScreenLayout(name: string, delay: number): boolean
// New dialog event handling methods
logDialogShowEvent(dialogId: string, dialogTitle: string, dialogType: string): boolean
logDialogDismissEvent(dialogId: string, dismissReason: string): boolean
logDialogButtonClickEvent(dialogId: string, buttonText: string, buttonIndex: number): boolean
logDialogCustomEvent(dialogId: string, eventName: string, values: Record<string, string | number | boolean>): boolean
}