Skip to content

Commit b55ce14

Browse files
feat: added support for enableSessionReplayOniOS26AndLater (#42)
1 parent ff29768 commit b55ce14

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

android/src/main/java/com/mixpanelreactnativesessionreplay/MixpanelReactNativeSessionReplayModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class MixpanelReactNativeSessionReplayModule(reactContext: ReactApplicationConte
307307

308308
companion object {
309309
const val NAME = "MixpanelReactNativeSessionReplay"
310-
const val LIB_VERSION = "1.0.0"
310+
const val LIB_VERSION = "1.0.1"
311311
const val MP_LIB = "react-native-sr"
312312
}
313313
}

ios/MixpanelSwiftSessionReplay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import MixpanelSessionReplay
33
import UIKit
44

55
@objc public class MixpanelSwiftSessionReplay: NSObject {
6-
static let libVersion = "0.2.1"
6+
static let libVersion = "1.0.1"
77
static let mpLib = "react-native-sr"
88

99
@objc public static func startRecording(recordingSessionsPercent: Double = 100.0) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mixpanel/react-native-session-replay",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Official React Native turbo module for Mixpanel Session Replay",
55
"main": "./lib/module/index.js",
66
"types": "./lib/typescript/src/index.d.ts",

src/__tests__/index.test.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,60 @@ describe('MPSessionReplayConfig', () => {
219219
expect(parsed).toHaveProperty('flushInterval');
220220
expect(parsed).toHaveProperty('enableLogging');
221221
});
222+
223+
describe('platform-specific config', () => {
224+
beforeEach(() => {
225+
jest.resetModules();
226+
});
227+
228+
it('should include enableSessionReplayOniOS26AndLater for iOS', () => {
229+
jest.doMock('react-native', () => ({
230+
Platform: {
231+
OS: 'ios',
232+
select: (obj: any) => obj.ios ?? obj.default,
233+
},
234+
requireNativeComponent: jest.fn(() => 'MockedNativeComponent'),
235+
}));
236+
237+
const { MPSessionReplayConfig: IOSConfig } = require('../index');
238+
const config = new IOSConfig();
239+
const json = config.toJSON();
240+
const parsed = JSON.parse(json);
241+
242+
expect(parsed).toHaveProperty('enableSessionReplayOniOS26AndLater', true);
243+
});
244+
245+
it('should NOT include enableSessionReplayOniOS26AndLater for Android', () => {
246+
jest.doMock('react-native', () => ({
247+
Platform: {
248+
OS: 'android',
249+
select: (obj: any) => obj.android ?? obj.default,
250+
},
251+
requireNativeComponent: jest.fn(() => 'MockedNativeComponent'),
252+
}));
253+
254+
const { MPSessionReplayConfig: AndroidConfig } = require('../index');
255+
const config = new AndroidConfig();
256+
const json = config.toJSON();
257+
const parsed = JSON.parse(json);
258+
259+
expect(parsed).not.toHaveProperty('enableSessionReplayOniOS26AndLater');
260+
});
261+
262+
it('should return empty string for unsupported platforms', () => {
263+
jest.doMock('react-native', () => ({
264+
Platform: {
265+
OS: 'web',
266+
select: (obj: any) => obj.default,
267+
},
268+
requireNativeComponent: jest.fn(() => 'MockedNativeComponent'),
269+
}));
270+
271+
const { MPSessionReplayConfig: WebConfig } = require('../index');
272+
const config = new WebConfig();
273+
const json = config.toJSON();
274+
275+
expect(json).toBe('');
276+
});
277+
});
222278
});

src/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ export class MPSessionReplayConfig {
118118
autoStartRecording: this.autoStartRecording,
119119
flushInterval: this.flushInterval,
120120
enableLogging: this.enableLogging,
121+
// iOS-specific config to enable session replay on iOS 26 and later
122+
...Platform.select({
123+
ios: { enableSessionReplayOniOS26AndLater: true },
124+
default: {},
125+
}),
121126
};
122127

123128
if (Platform.OS === 'ios' || Platform.OS === 'android') {

0 commit comments

Comments
 (0)