import { NativeModules, Platform } from 'react-native'; const LINKING_ERROR = `The package 'posthog-react-native-session-replay' doesn't seem to be linked. Make sure: \n\n` + Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; const PosthogReactNativeSessionReplay = NativeModules.PosthogReactNativeSessionReplay ? NativeModules.PosthogReactNativeSessionReplay : new Proxy( {}, { get() { throw new Error(LINKING_ERROR); }, } ); export function start( sessionId: string, sdkOptions: { [key: string]: any }, sdkReplayConfig: { [key: string]: any }, decideReplayConfig: { [key: string]: any } ): Promise { return PosthogReactNativeSessionReplay.start( sessionId, sdkOptions, sdkReplayConfig, decideReplayConfig ); } export function startSession(sessionId: string): Promise { return PosthogReactNativeSessionReplay.startSession(sessionId); } export function endSession(): Promise { return PosthogReactNativeSessionReplay.endSession(); } export function isEnabled(): Promise { return PosthogReactNativeSessionReplay.isEnabled(); } export function identify( distinctId: string, anonymousId: string ): Promise { return PosthogReactNativeSessionReplay.identify(distinctId, anonymousId); } export function startRecording(resumeCurrent: boolean): Promise { return PosthogReactNativeSessionReplay.startRecording(resumeCurrent); } export function stopRecording(): Promise { return PosthogReactNativeSessionReplay.stopRecording(); } export interface PostHogReactNativeSessionReplayModule { start: ( sessionId: string, sdkOptions: { [key: string]: any }, // options from SDK such as apiKey sdkReplayConfig: { [key: string]: any }, // config from SDK decideReplayConfig: { [key: string]: any } // config from Decide API ) => Promise; startSession: (sessionId: string) => Promise; endSession: () => Promise; isEnabled: () => Promise; identify: (distinctId: string, anonymousId: string) => Promise; startRecording: (resumeCurrent: boolean) => Promise; stopRecording: () => Promise; } const PostHogReactNativeSessionReplay: PostHogReactNativeSessionReplayModule = { start, startSession, endSession, isEnabled, identify, startRecording, stopRecording, }; export default PostHogReactNativeSessionReplay;