@mixpanel/react-native-session-replay 0.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.
Files changed (38) hide show
  1. package/LICENSE +20 -0
  2. package/MixpanelReactNativeSessionReplay.podspec +26 -0
  3. package/README.md +200 -0
  4. package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeMixpanelReactNativeSessionReplaySpec.java +54 -0
  5. package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
  6. package/android/app/build/generated/source/codegen/jni/MixpanelReactNativeSessionReplaySpec-generated.cpp +56 -0
  7. package/android/app/build/generated/source/codegen/jni/MixpanelReactNativeSessionReplaySpec.h +31 -0
  8. package/android/app/build/generated/source/codegen/jni/react/renderer/components/MixpanelReactNativeSessionReplaySpec/MixpanelReactNativeSessionReplaySpecJSI-generated.cpp +54 -0
  9. package/android/app/build/generated/source/codegen/jni/react/renderer/components/MixpanelReactNativeSessionReplaySpec/MixpanelReactNativeSessionReplaySpecJSI.h +107 -0
  10. package/android/build.gradle +89 -0
  11. package/android/gradle.properties +5 -0
  12. package/android/src/main/AndroidManifest.xml +2 -0
  13. package/android/src/main/java/com/mixpanelreactnativesessionreplay/MixpanelReactNativeSessionReplayModule.kt +287 -0
  14. package/android/src/main/java/com/mixpanelreactnativesessionreplay/MixpanelReactNativeSessionReplayPackage.kt +38 -0
  15. package/android/src/main/java/com/mixpanelreactnativesessionreplay/MixpanelSessionReplayView.kt +26 -0
  16. package/android/src/main/java/com/mixpanelreactnativesessionreplay/MixpanelSessionReplayViewManager.kt +29 -0
  17. package/ios/MixpanelReactNativeSessionReplay.h +5 -0
  18. package/ios/MixpanelReactNativeSessionReplay.mm +87 -0
  19. package/ios/MixpanelSessionReplayViewManager.mm +36 -0
  20. package/ios/MixpanelSwiftSessionReplay.swift +93 -0
  21. package/lib/module/MixpanelSessionReplayView.js +5 -0
  22. package/lib/module/MixpanelSessionReplayView.js.map +1 -0
  23. package/lib/module/NativeMixpanelReactNativeSessionReplay.js +5 -0
  24. package/lib/module/NativeMixpanelReactNativeSessionReplay.js.map +1 -0
  25. package/lib/module/index.js +188 -0
  26. package/lib/module/index.js.map +1 -0
  27. package/lib/module/package.json +1 -0
  28. package/lib/typescript/package.json +1 -0
  29. package/lib/typescript/src/MixpanelSessionReplayView.d.ts +7 -0
  30. package/lib/typescript/src/MixpanelSessionReplayView.d.ts.map +1 -0
  31. package/lib/typescript/src/NativeMixpanelReactNativeSessionReplay.d.ts +11 -0
  32. package/lib/typescript/src/NativeMixpanelReactNativeSessionReplay.d.ts.map +1 -0
  33. package/lib/typescript/src/index.d.ts +117 -0
  34. package/lib/typescript/src/index.d.ts.map +1 -0
  35. package/package.json +171 -0
  36. package/src/MixpanelSessionReplayView.tsx +10 -0
  37. package/src/NativeMixpanelReactNativeSessionReplay.ts +19 -0
  38. package/src/index.tsx +220 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mixpanel
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "MixpanelReactNativeSessionReplay"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported }
14
+ s.source = { :git => "https://github.com/ketanmixpanel/mp-session-replay.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
17
+ s.private_header_files = "ios/**/*.h"
18
+ s.dependency 'MixpanelSessionReplay', '1.1.4'
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+ end
26
+ end
package/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # Mixpanel React Native Session Replay
2
+
3
+ Official React Native turbo module for Mixpanel Session Replay. Capture and analyze user interactions in your mobile app by bridging Mixpanel's native iOS and Android session replay SDKs to React Native.
4
+
5
+ ## Features
6
+
7
+ - 🎥 **Session Recording** - Capture user interactions and screen recordings
8
+ - 🔒 **Privacy First** - Built-in data masking for sensitive information
9
+ - âš¡ **High Performance** - Native implementation with minimal JavaScript overhead
10
+ - 🎯 **Selective Recording** - Configurable sampling rates and recording controls
11
+ - 📱 **Cross Platform** - Unified API for both iOS and Android
12
+ - 🚀 **New Architecture Ready** - Built as a Turbo Module for React Native's new architecture
13
+
14
+ ## Installation
15
+
16
+ ```sh
17
+ npm install @mixpanel/react-native-session-replay
18
+ ```
19
+
20
+ or
21
+
22
+ ```sh
23
+ yarn add @mixpanel/react-native-session-replay
24
+ ```
25
+
26
+ ### Platform Setup
27
+
28
+ #### iOS
29
+ The SDK dependencies are automatically added via CocoaPods. Your project must target iOS 13 or later.
30
+
31
+ ```sh
32
+ cd ios && pod install
33
+ ```
34
+
35
+ #### Android
36
+ Dependencies are automatically added through Gradle. Requirements:
37
+ - Minimum Android SDK 21+
38
+ - Kotlin support enabled
39
+
40
+ ## Quick Start
41
+
42
+ ```typescript
43
+ import {
44
+ initialize,
45
+ startRecording,
46
+ stopRecording,
47
+ isRecording,
48
+ MPSessionReplayConfig,
49
+ MPSessionReplayMask,
50
+ } from '@mixpanel/react-native-session-replay';
51
+
52
+ // Initialize session replay
53
+ const config = new MPSessionReplayConfig({
54
+ wifiOnly: false,
55
+ recordingSessionsPercent: 100,
56
+ autoStartRecording: true,
57
+ autoMaskedViews: [MPSessionReplayMask.Image, MPSessionReplayMask.Text],
58
+ flushInterval: 5,
59
+ enableLogging: true,
60
+ });
61
+
62
+ await initialize(token, distinctId, config).catch((error) => {
63
+ console.error('Initialization error:', error);
64
+ });
65
+
66
+ // Control recording
67
+ await startRecording();
68
+ await stopRecording();
69
+
70
+ // Check recording status
71
+ const recording = await isRecording();
72
+ ```
73
+
74
+ ## Configuration
75
+
76
+ ### MPSessionReplayConfig
77
+
78
+ ```typescript
79
+ class MPSessionReplayConfig {
80
+ wifiOnly: boolean; // Only transmit on WiFi (default: true)
81
+ recordingSessionsPercent: number; // Sampling rate 0-100 (default: 100)
82
+ autoMaskedViews: MPSessionReplayMask[]; // Views to auto-mask (default: all)
83
+ autoStartRecording: boolean; // Start recording automatically (default: true)
84
+ flushInterval: number; // Flush interval in seconds (default: 10)
85
+ enableLogging: boolean; // Enable verbose logging (default: false)
86
+ }
87
+ ```
88
+
89
+ ### Configuration Options
90
+
91
+ #### wifiOnly
92
+ Controls whether replay events are sent only over WiFi.
93
+
94
+ - **true** - Events are flushed only when connected to WiFi. Without WiFi, events are queued in memory and will be lost if the app is killed before WiFi becomes available.
95
+ - **false** - Events are flushed over any network connection, including cellular.
96
+ - **Default:** `true`
97
+
98
+ #### recordingSessionsPercent
99
+ Sets the sampling rate for automatic session recording.
100
+
101
+ Accepts values from 0 to 100, representing the percentage of sessions that will automatically start recording.
102
+
103
+ - **0** - No automatic recording
104
+ - **100** - Record all sessions
105
+ - **Default:** `100`
106
+ - **Note:** This only applies to automatic recording. Manual calls to `startRecording()` are not affected.
107
+
108
+ #### autoMaskedViews
109
+ Specifies which view types are automatically masked by the SDK.
110
+
111
+ By default, the SDK masks image, text, web, and map views (iOS only). You can customize this behavior through configuration.
112
+
113
+ #### autoStartRecording
114
+ Determines whether recording starts automatically on initialization.
115
+
116
+ - **true** - Recording starts automatically when initialized. The SDK stops and restarts recording as the app moves between background and foreground. Each new session uses `recordingSessionsPercent` to determine if recording should begin.
117
+ - **false** - Recording only starts when you explicitly call `startRecording()`.
118
+ - **Default:** `true`
119
+
120
+ #### flushInterval
121
+ Sets how often screenshots are sent to Mixpanel, in seconds.
122
+
123
+ Screenshots are collected in batches of 10 and sent after each flush interval. Adjust this value to control how quickly screenshots are uploaded.
124
+
125
+ - **Default:** `10` seconds
126
+
127
+ #### enableLogging
128
+ Enables debug logging for development and troubleshooting.
129
+
130
+ - **true** - Prints verbose debug logs including internal events, configuration status etc...
131
+ - **false** - No logs from the Session Replay SDK will be printed.
132
+ - **Default:** `false`
133
+
134
+ ## API Methods
135
+
136
+ ### initialize(token: string, distinctId: string, config: MPSessionReplayConfig): Promise<void>
137
+ Initializes the session replay system with your configuration. Checks remote settings to confirm recording is enabled, then creates a new session replay instance. Any existing instance is deinitialized first.
138
+
139
+ **Returns:** Promise that resolves when initialization completes successfully.
140
+
141
+ **Throws:** Error if initialization fails.
142
+
143
+ ### startRecording(): Promise<void>
144
+ Manually starts session recording. Has no effect if recording is already active.
145
+
146
+ Recording continues until you stop it manually or the app moves to the background.
147
+
148
+ ### stopRecording(): Promise<void>
149
+ Stops the current recording session and performs cleanup.
150
+
151
+ ### isRecording(): Promise<boolean>
152
+ Returns whether recording is currently active.
153
+
154
+ ### identify(distinctId: string): Promise<void>
155
+ Updates the distinct ID for session replays after initialization.
156
+
157
+ **Best practice:** Call `identify()` on the main Mixpanel SDK first, then call it on the Session Replay SDK. This ensures users are properly merged.
158
+
159
+ ## Privacy & Security
160
+
161
+ The SDK automatically masks sensitive information to protect user privacy. Text input fields are always masked and cannot be disabled.
162
+
163
+ Additional configurable masking options:
164
+ - Images
165
+ - Text elements
166
+ - WebView content
167
+ - Apple Maps (iOS only)
168
+
169
+ ## Example App
170
+
171
+ Test the integration using the example app:
172
+
173
+ ```sh
174
+ # Install dependencies
175
+ yarn
176
+
177
+ # Start Metro bundler
178
+ yarn example start
179
+
180
+ # Run on iOS
181
+ yarn example ios
182
+
183
+ # Run on Android
184
+ yarn example android
185
+ ```
186
+
187
+ ## Requirements
188
+
189
+ - React Native 0.70 or higher
190
+ - iOS 13.0 or higher
191
+ - Android API Level 21 or higher
192
+ - New Architecture support
193
+
194
+ ## Contributing
195
+
196
+ See our [contributing guide](CONTRIBUTING.md) to learn how to contribute and understand the development workflow.
197
+
198
+ ## License
199
+
200
+ MIT
@@ -0,0 +1,54 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJavaSpec.js
9
+ *
10
+ * @nolint
11
+ */
12
+
13
+ package com.facebook.fbreact.specs;
14
+
15
+ import com.facebook.proguard.annotations.DoNotStrip;
16
+ import com.facebook.react.bridge.Promise;
17
+ import com.facebook.react.bridge.ReactApplicationContext;
18
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
19
+ import com.facebook.react.bridge.ReactMethod;
20
+ import com.facebook.react.turbomodule.core.interfaces.TurboModule;
21
+ import javax.annotation.Nonnull;
22
+
23
+ public abstract class NativeMixpanelReactNativeSessionReplaySpec extends ReactContextBaseJavaModule implements TurboModule {
24
+ public static final String NAME = "MixpanelReactNativeSessionReplay";
25
+
26
+ public NativeMixpanelReactNativeSessionReplaySpec(ReactApplicationContext reactContext) {
27
+ super(reactContext);
28
+ }
29
+
30
+ @Override
31
+ public @Nonnull String getName() {
32
+ return NAME;
33
+ }
34
+
35
+ @ReactMethod
36
+ @DoNotStrip
37
+ public abstract void initialize(String token, String distinctId, String configJSON, Promise promise);
38
+
39
+ @ReactMethod
40
+ @DoNotStrip
41
+ public abstract void startRecording(Promise promise);
42
+
43
+ @ReactMethod
44
+ @DoNotStrip
45
+ public abstract void stopRecording(Promise promise);
46
+
47
+ @ReactMethod
48
+ @DoNotStrip
49
+ public abstract void isRecording(Promise promise);
50
+
51
+ @ReactMethod
52
+ @DoNotStrip
53
+ public abstract void identify(String distinctId, Promise promise);
54
+ }
@@ -0,0 +1,36 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/MixpanelReactNativeSessionReplaySpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_MixpanelReactNativeSessionReplaySpec
13
+ OBJECT
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_MixpanelReactNativeSessionReplaySpec PUBLIC . react/renderer/components/MixpanelReactNativeSessionReplaySpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_MixpanelReactNativeSessionReplaySpec
21
+ fbjni
22
+ jsi
23
+ # We need to link different libraries based on whether we are building rncore or not, that's necessary
24
+ # because we want to break a circular dependency between react_codegen_rncore and reactnative
25
+ reactnative
26
+ )
27
+
28
+ target_compile_options(
29
+ react_codegen_MixpanelReactNativeSessionReplaySpec
30
+ PRIVATE
31
+ -DLOG_TAG=\"ReactNative\"
32
+ -fexceptions
33
+ -frtti
34
+ -std=c++20
35
+ -Wall
36
+ )
@@ -0,0 +1,56 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "MixpanelReactNativeSessionReplaySpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ static facebook::jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_initialize(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
+ static jmethodID cachedMethodId = nullptr;
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "initialize", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
18
+ }
19
+
20
+ static facebook::jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_startRecording(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
21
+ static jmethodID cachedMethodId = nullptr;
22
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "startRecording", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
23
+ }
24
+
25
+ static facebook::jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_stopRecording(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
26
+ static jmethodID cachedMethodId = nullptr;
27
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "stopRecording", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
28
+ }
29
+
30
+ static facebook::jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_isRecording(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
31
+ static jmethodID cachedMethodId = nullptr;
32
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "isRecording", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
33
+ }
34
+
35
+ static facebook::jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_identify(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
36
+ static jmethodID cachedMethodId = nullptr;
37
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "identify", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
38
+ }
39
+
40
+ NativeMixpanelReactNativeSessionReplaySpecJSI::NativeMixpanelReactNativeSessionReplaySpecJSI(const JavaTurboModule::InitParams &params)
41
+ : JavaTurboModule(params) {
42
+ methodMap_["initialize"] = MethodMetadata {3, __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_initialize};
43
+ methodMap_["startRecording"] = MethodMetadata {0, __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_startRecording};
44
+ methodMap_["stopRecording"] = MethodMetadata {0, __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_stopRecording};
45
+ methodMap_["isRecording"] = MethodMetadata {0, __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_isRecording};
46
+ methodMap_["identify"] = MethodMetadata {1, __hostFunction_NativeMixpanelReactNativeSessionReplaySpecJSI_identify};
47
+ }
48
+
49
+ std::shared_ptr<TurboModule> MixpanelReactNativeSessionReplaySpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
50
+ if (moduleName == "MixpanelReactNativeSessionReplay") {
51
+ return std::make_shared<NativeMixpanelReactNativeSessionReplaySpecJSI>(params);
52
+ }
53
+ return nullptr;
54
+ }
55
+
56
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ /**
20
+ * JNI C++ class for module 'NativeMixpanelReactNativeSessionReplay'
21
+ */
22
+ class JSI_EXPORT NativeMixpanelReactNativeSessionReplaySpecJSI : public JavaTurboModule {
23
+ public:
24
+ NativeMixpanelReactNativeSessionReplaySpecJSI(const JavaTurboModule::InitParams &params);
25
+ };
26
+
27
+
28
+ JSI_EXPORT
29
+ std::shared_ptr<TurboModule> MixpanelReactNativeSessionReplaySpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
+
31
+ } // namespace facebook::react
@@ -0,0 +1,54 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "MixpanelReactNativeSessionReplaySpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_initialize(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeMixpanelReactNativeSessionReplayCxxSpecJSI *>(&turboModule)->initialize(
16
+ rt,
17
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
18
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
19
+ count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt)
20
+ );
21
+ }
22
+ static jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_startRecording(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
23
+ return static_cast<NativeMixpanelReactNativeSessionReplayCxxSpecJSI *>(&turboModule)->startRecording(
24
+ rt
25
+ );
26
+ }
27
+ static jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_stopRecording(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
28
+ return static_cast<NativeMixpanelReactNativeSessionReplayCxxSpecJSI *>(&turboModule)->stopRecording(
29
+ rt
30
+ );
31
+ }
32
+ static jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_isRecording(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
33
+ return static_cast<NativeMixpanelReactNativeSessionReplayCxxSpecJSI *>(&turboModule)->isRecording(
34
+ rt
35
+ );
36
+ }
37
+ static jsi::Value __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_identify(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
38
+ return static_cast<NativeMixpanelReactNativeSessionReplayCxxSpecJSI *>(&turboModule)->identify(
39
+ rt,
40
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
41
+ );
42
+ }
43
+
44
+ NativeMixpanelReactNativeSessionReplayCxxSpecJSI::NativeMixpanelReactNativeSessionReplayCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
45
+ : TurboModule("MixpanelReactNativeSessionReplay", jsInvoker) {
46
+ methodMap_["initialize"] = MethodMetadata {3, __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_initialize};
47
+ methodMap_["startRecording"] = MethodMetadata {0, __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_startRecording};
48
+ methodMap_["stopRecording"] = MethodMetadata {0, __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_stopRecording};
49
+ methodMap_["isRecording"] = MethodMetadata {0, __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_isRecording};
50
+ methodMap_["identify"] = MethodMetadata {1, __hostFunction_NativeMixpanelReactNativeSessionReplayCxxSpecJSI_identify};
51
+ }
52
+
53
+
54
+ } // namespace facebook::react
@@ -0,0 +1,107 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+ class JSI_EXPORT NativeMixpanelReactNativeSessionReplayCxxSpecJSI : public TurboModule {
19
+ protected:
20
+ NativeMixpanelReactNativeSessionReplayCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
+
22
+ public:
23
+ virtual jsi::Value initialize(jsi::Runtime &rt, jsi::String token, jsi::String distinctId, jsi::String configJSON) = 0;
24
+ virtual jsi::Value startRecording(jsi::Runtime &rt) = 0;
25
+ virtual jsi::Value stopRecording(jsi::Runtime &rt) = 0;
26
+ virtual jsi::Value isRecording(jsi::Runtime &rt) = 0;
27
+ virtual jsi::Value identify(jsi::Runtime &rt, jsi::String distinctId) = 0;
28
+
29
+ };
30
+
31
+ template <typename T>
32
+ class JSI_EXPORT NativeMixpanelReactNativeSessionReplayCxxSpec : public TurboModule {
33
+ public:
34
+ jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
35
+ return delegate_.create(rt, propName);
36
+ }
37
+
38
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
39
+ return delegate_.getPropertyNames(runtime);
40
+ }
41
+
42
+ static constexpr std::string_view kModuleName = "MixpanelReactNativeSessionReplay";
43
+
44
+ protected:
45
+ NativeMixpanelReactNativeSessionReplayCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
46
+ : TurboModule(std::string{NativeMixpanelReactNativeSessionReplayCxxSpec::kModuleName}, jsInvoker),
47
+ delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
48
+
49
+
50
+ private:
51
+ class Delegate : public NativeMixpanelReactNativeSessionReplayCxxSpecJSI {
52
+ public:
53
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
54
+ NativeMixpanelReactNativeSessionReplayCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
55
+
56
+ }
57
+
58
+ jsi::Value initialize(jsi::Runtime &rt, jsi::String token, jsi::String distinctId, jsi::String configJSON) override {
59
+ static_assert(
60
+ bridging::getParameterCount(&T::initialize) == 4,
61
+ "Expected initialize(...) to have 4 parameters");
62
+
63
+ return bridging::callFromJs<jsi::Value>(
64
+ rt, &T::initialize, jsInvoker_, instance_, std::move(token), std::move(distinctId), std::move(configJSON));
65
+ }
66
+ jsi::Value startRecording(jsi::Runtime &rt) override {
67
+ static_assert(
68
+ bridging::getParameterCount(&T::startRecording) == 1,
69
+ "Expected startRecording(...) to have 1 parameters");
70
+
71
+ return bridging::callFromJs<jsi::Value>(
72
+ rt, &T::startRecording, jsInvoker_, instance_);
73
+ }
74
+ jsi::Value stopRecording(jsi::Runtime &rt) override {
75
+ static_assert(
76
+ bridging::getParameterCount(&T::stopRecording) == 1,
77
+ "Expected stopRecording(...) to have 1 parameters");
78
+
79
+ return bridging::callFromJs<jsi::Value>(
80
+ rt, &T::stopRecording, jsInvoker_, instance_);
81
+ }
82
+ jsi::Value isRecording(jsi::Runtime &rt) override {
83
+ static_assert(
84
+ bridging::getParameterCount(&T::isRecording) == 1,
85
+ "Expected isRecording(...) to have 1 parameters");
86
+
87
+ return bridging::callFromJs<jsi::Value>(
88
+ rt, &T::isRecording, jsInvoker_, instance_);
89
+ }
90
+ jsi::Value identify(jsi::Runtime &rt, jsi::String distinctId) override {
91
+ static_assert(
92
+ bridging::getParameterCount(&T::identify) == 2,
93
+ "Expected identify(...) to have 2 parameters");
94
+
95
+ return bridging::callFromJs<jsi::Value>(
96
+ rt, &T::identify, jsInvoker_, instance_, std::move(distinctId));
97
+ }
98
+
99
+ private:
100
+ friend class NativeMixpanelReactNativeSessionReplayCxxSpec;
101
+ T *instance_;
102
+ };
103
+
104
+ Delegate delegate_;
105
+ };
106
+
107
+ } // namespace facebook::react
@@ -0,0 +1,89 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['MixpanelReactNativeSessionReplay_' + name]
4
+ }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
16
+ }
17
+
18
+
19
+ apply plugin: "com.android.library"
20
+ apply plugin: "kotlin-android"
21
+
22
+ apply plugin: "com.facebook.react"
23
+
24
+ def getExtOrIntegerDefault(name) {
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["MixpanelReactNativeSessionReplay_" + name]).toInteger()
26
+ }
27
+
28
+ android {
29
+ namespace "com.mixpanelreactnativesessionreplay"
30
+
31
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
32
+
33
+ defaultConfig {
34
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
36
+ }
37
+
38
+ buildFeatures {
39
+ buildConfig true
40
+ }
41
+
42
+ buildTypes {
43
+ release {
44
+ minifyEnabled false
45
+ }
46
+ }
47
+
48
+ lintOptions {
49
+ disable "GradleCompatible"
50
+ }
51
+
52
+ compileOptions {
53
+ sourceCompatibility JavaVersion.VERSION_1_8
54
+ targetCompatibility JavaVersion.VERSION_1_8
55
+ }
56
+
57
+ sourceSets {
58
+ main {
59
+ java.srcDirs += [
60
+ "generated/java",
61
+ "generated/jni"
62
+ ]
63
+ }
64
+ }
65
+ }
66
+
67
+ repositories {
68
+ mavenCentral()
69
+ google()
70
+ }
71
+
72
+ def kotlin_version = getExtOrDefault("kotlinVersion")
73
+
74
+ dependencies {
75
+ implementation "com.facebook.react:react-android"
76
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77
+
78
+ // Mixpanel Android SDK dependency (minimum v8.0.2)
79
+ implementation "com.mixpanel.android:mixpanel-android:8.0.2"
80
+
81
+ // Mixpanel Android Session Replay SDK dependency
82
+ implementation "com.mixpanel.android:mixpanel-android-session-replay:1.0.3"
83
+ }
84
+
85
+ react {
86
+ jsRootDir = file("../src/")
87
+ libraryName = "MixpanelReactNativeSessionReplay"
88
+ codegenJavaPackageName = "com.mixpanelreactnativesessionreplay"
89
+ }
@@ -0,0 +1,5 @@
1
+ MixpanelReactNativeSessionReplay_kotlinVersion=2.0.21
2
+ MixpanelReactNativeSessionReplay_minSdkVersion=24
3
+ MixpanelReactNativeSessionReplay_targetSdkVersion=34
4
+ MixpanelReactNativeSessionReplay_compileSdkVersion=35
5
+ MixpanelReactNativeSessionReplay_ndkVersion=27.1.12297006