@amplitude/session-replay-react-native 1.0.3-video-analytics-5.0 → 1.2.0-video-analytics-6.0

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 (34) hide show
  1. package/AmplitudeSessionReplayReactNative.podspec +2 -2
  2. package/README.md +12 -6
  3. package/android/build.gradle +2 -2
  4. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +22 -21
  5. package/android/src/oldarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeSpec.kt +2 -2
  6. package/ios/AMPNativeSessionReplay.mm +2 -2
  7. package/ios/NativeSessionReplay.swift +20 -22
  8. package/lib/commonjs/native-module.js.map +1 -1
  9. package/lib/commonjs/session-replay-config.js.map +1 -1
  10. package/lib/commonjs/session-replay.js +55 -5
  11. package/lib/commonjs/session-replay.js.map +1 -1
  12. package/lib/commonjs/specs/NativeAmpSessionReplay.js.map +1 -1
  13. package/lib/commonjs/version.js +1 -1
  14. package/lib/module/native-module.js.map +1 -1
  15. package/lib/module/session-replay-config.js.map +1 -1
  16. package/lib/module/session-replay.js +55 -5
  17. package/lib/module/session-replay.js.map +1 -1
  18. package/lib/module/specs/NativeAmpSessionReplay.js.map +1 -1
  19. package/lib/module/version.js +1 -1
  20. package/lib/typescript/native-module.d.ts +16 -12
  21. package/lib/typescript/native-module.d.ts.map +1 -1
  22. package/lib/typescript/session-replay-config.d.ts +5 -3
  23. package/lib/typescript/session-replay-config.d.ts.map +1 -1
  24. package/lib/typescript/session-replay.d.ts +21 -4
  25. package/lib/typescript/session-replay.d.ts.map +1 -1
  26. package/lib/typescript/specs/NativeAmpSessionReplay.d.ts +2 -2
  27. package/lib/typescript/specs/NativeAmpSessionReplay.d.ts.map +1 -1
  28. package/lib/typescript/version.d.ts +1 -1
  29. package/package.json +1 -1
  30. package/src/native-module.ts +17 -13
  31. package/src/session-replay-config.ts +5 -3
  32. package/src/session-replay.ts +61 -7
  33. package/src/specs/NativeAmpSessionReplay.ts +4 -2
  34. package/src/version.ts +1 -1
@@ -16,8 +16,8 @@ Pod::Spec.new do |s|
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
- s.dependency 'AmplitudeSessionReplay', '>=0.11.1'
20
- s.dependency 'AmplitudeCore', '>=1.4.2'
19
+ s.dependency 'AmplitudeSessionReplay', '>=0.12.6'
20
+ s.dependency 'AmplitudeCore', '>=1.5.2'
21
21
 
22
22
  # This code is to support RN prior to 0.71.0. Should be removed when we drop support for RN < 0.71.0.
23
23
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
package/README.md CHANGED
@@ -25,19 +25,25 @@ which itself requires React Native 0.74 or newer.
25
25
 
26
26
  ### Session Replay React Native Standalone SDK
27
27
 
28
- Initialize SDK with your amplidude API Key
28
+ Initialize the SDK with your Amplitude API key and the session identifier that
29
+ matches the Session ID on your analytics events:
30
+
29
31
  ```js
30
32
  import { init, SessionReplayConfig } from '@amplitude/session-replay-react-native';
31
33
 
32
- const config: SessionReplayConfig = {
33
- apiKey: 'YOUR_API_KEY',
34
- deviceId: 'YOUR_DEVICE_ID',
35
- sessionId: Date.now()
36
- }
34
+ const config: SessionReplayConfig = {
35
+ apiKey: 'YOUR_API_KEY',
36
+ deviceId: 'YOUR_DEVICE_ID',
37
+ sessionId: Date.now(),
38
+ };
37
39
 
38
40
  await init(config);
39
41
  ```
40
42
 
43
+ Session Replay does not capture anything until a valid session id is set — a
44
+ positive number or a non-empty string. Until then the SDK stays configured but
45
+ idle, even after `start()`.
46
+
41
47
  To use Amplitude Session Replay with Amplitude Analytics, use the [`@amplitude/plugin-session-replay-react-native`](https://www.npmjs.com/package/@amplitude/plugin-session-replay-react-native) plugin package.
42
48
 
43
49
  ## Masking views
@@ -110,8 +110,8 @@ repositories {
110
110
  def kotlin_version = getExtOrDefault("kotlinVersion")
111
111
 
112
112
  dependencies {
113
- implementation("com.amplitude:session-replay-android:[0.24.0,0.25.0)")
114
- implementation("com.amplitude:analytics-android:[1.25.0,1.26.0)")
113
+ implementation("com.amplitude:session-replay-android:[0.31.1,0.32.0)")
114
+ implementation("com.amplitude:analytics-android:[1.33.0,1.34.0)")
115
115
 
116
116
  // For < 0.71, this will be from the local maven repo
117
117
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
@@ -18,7 +18,7 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
18
18
  private data class NativeConfig(
19
19
  val apiKey: String,
20
20
  val deviceId: String?,
21
- val sessionId: Long,
21
+ val customSessionId: String,
22
22
  val serverZone: String,
23
23
  val sampleRate: Double,
24
24
  val enableRemoteConfig: Boolean,
@@ -39,7 +39,8 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
39
39
  try {
40
40
  val apiKey = config.getString("apiKey") ?: throw IllegalArgumentException("apiKey is required")
41
41
  val deviceId = config.getString("deviceId")
42
- val sessionId = config.getDouble("sessionId").toLong()
42
+ val customSessionId = config.getString("customSessionId")
43
+ ?: throw IllegalArgumentException("customSessionId is required")
43
44
  val serverZone = config.getString("serverZone") ?: "US"
44
45
  val sampleRate = config.getDouble("sampleRate")
45
46
  val enableRemoteConfig = config.getBoolean("enableRemoteConfig")
@@ -65,7 +66,7 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
65
66
  setup:
66
67
  API Key: $apiKey
67
68
  Device Id: $deviceId
68
- Session Id: $sessionId
69
+ Custom Session Id: $customSessionId
69
70
  Server Zone: $serverZone
70
71
  Sample Rate: $sampleRate
71
72
  Enable Remote Config: $enableRemoteConfig
@@ -77,7 +78,7 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
77
78
  nativeConfig = NativeConfig(
78
79
  apiKey = apiKey,
79
80
  deviceId = deviceId,
80
- sessionId = sessionId,
81
+ customSessionId = customSessionId,
81
82
  serverZone = serverZone,
82
83
  sampleRate = sampleRate,
83
84
  enableRemoteConfig = enableRemoteConfig,
@@ -94,13 +95,22 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
94
95
  }
95
96
 
96
97
  @ReactMethod
97
- override fun setSessionId(sessionId: Double, promise: Promise) {
98
+ override fun setCustomSessionId(customSessionId: String, promise: Promise) {
98
99
  try {
99
- nativeConfig = requireNotNull(nativeConfig).copy(sessionId = sessionId.toLong())
100
- sessionReplay?.setSessionId(sessionId.toLong())
100
+ nativeConfig = requireNotNull(nativeConfig).copy(customSessionId = customSessionId)
101
+ sessionReplay?.setCustomSessionId(customSessionId)
101
102
  promise.resolve(null)
102
103
  } catch (e: Exception) {
103
- promise.reject("SET_SESSION_ID_ERROR", e.message, e)
104
+ promise.reject("SET_CUSTOM_SESSION_ID_ERROR", e.message, e)
105
+ }
106
+ }
107
+
108
+ @ReactMethod
109
+ override fun getCustomSessionId(promise: Promise) {
110
+ try {
111
+ promise.resolve(sessionReplay?.getCustomSessionId() ?: nativeConfig?.customSessionId ?: "-1")
112
+ } catch (e: Exception) {
113
+ promise.reject("GET_CUSTOM_SESSION_ID_ERROR", e.message, e)
104
114
  }
105
115
  }
106
116
 
@@ -140,17 +150,6 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
140
150
  }
141
151
  }
142
152
 
143
- @ReactMethod
144
- override fun getSessionId(promise: Promise) {
145
- try {
146
- val sessionId = sessionReplay?.getSessionId() ?: nativeConfig?.sessionId
147
- ?: throw IllegalStateException("SessionReplay is not initialized")
148
- promise.resolve(sessionId.toDouble())
149
- } catch (e: Exception) {
150
- promise.reject("GET_SESSION_ID_ERROR", e.message, e)
151
- }
152
- }
153
-
154
153
  @ReactMethod
155
154
  override fun start(promise: Promise) {
156
155
  try {
@@ -215,11 +214,11 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
215
214
  }
216
215
 
217
216
  private fun createSessionReplay(config: NativeConfig): SessionReplay {
218
- return SessionReplay(
217
+ val sessionReplay = SessionReplay(
219
218
  apiKey = config.apiKey,
220
219
  context = reactContext.applicationContext,
221
220
  deviceId = config.deviceId ?: "",
222
- sessionId = config.sessionId,
221
+ sessionId = -1L,
223
222
  optOut = config.optOut,
224
223
  sampleRate = config.sampleRate,
225
224
  logger = LogcatLogger.logger,
@@ -231,6 +230,8 @@ class SessionReplayReactNativeModule(private val reactContext: ReactApplicationC
231
230
  autoStart = false,
232
231
  privacyConfig = PrivacyConfig(maskLevel = config.maskLevel),
233
232
  )
233
+ sessionReplay.setCustomSessionId(config.customSessionId)
234
+ return sessionReplay
234
235
  }
235
236
 
236
237
  companion object {
@@ -10,10 +10,10 @@ import com.facebook.react.bridge.ReadableMap
10
10
  abstract class SessionReplayReactNativeSpec(reactContext: ReactApplicationContext) :
11
11
  ReactContextBaseJavaModule(reactContext) {
12
12
  abstract fun setup(config: ReadableMap, promise: Promise)
13
- abstract fun setSessionId(sessionId: Double, promise: Promise)
13
+ abstract fun setCustomSessionId(customSessionId: String, promise: Promise)
14
+ abstract fun getCustomSessionId(promise: Promise)
14
15
  abstract fun setDeviceId(deviceId: String?, promise: Promise)
15
16
  abstract fun setOptOut(optOut: Boolean, promise: Promise)
16
- abstract fun getSessionId(promise: Promise)
17
17
  abstract fun start(promise: Promise)
18
18
  abstract fun stop(promise: Promise)
19
19
  abstract fun flush(promise: Promise)
@@ -4,9 +4,9 @@
4
4
 
5
5
  RCT_EXTERN_METHOD(flush:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
6
6
 
7
- RCT_EXTERN_METHOD(getSessionId:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
7
+ RCT_EXTERN_METHOD(setCustomSessionId:(nonnull NSString)customSessionId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
8
8
 
9
- RCT_EXTERN_METHOD(setSessionId:(nonnull NSNumber)sessionId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
9
+ RCT_EXTERN_METHOD(getCustomSessionId:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
10
10
 
11
11
  RCT_EXTERN_METHOD(setDeviceId:(NSString)deviceId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
12
12
 
@@ -18,13 +18,13 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
18
18
  @objc(setup:resolve:reject:)
19
19
  func setup(_ config: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
20
20
  guard let apiKey = config["apiKey"] as? String,
21
- let sessionId = config["sessionId"] as? NSNumber,
22
21
  let serverZone = config["serverZone"] as? String,
23
22
  let sampleRate = config["sampleRate"] as? NSNumber,
24
23
  let enableRemoteConfig = config["enableRemoteConfig"] as? Bool,
25
24
  let logLevel = config["logLevel"] as? Int,
26
25
  let maskLevel = config["maskLevel"] as? String,
27
- let optOut = config["optOut"] as? Bool else {
26
+ let optOut = config["optOut"] as? Bool,
27
+ let customSessionId = config["customSessionId"] as? String else {
28
28
  reject("INVALID_CONFIG", "Invalid configuration parameters", nil)
29
29
  return
30
30
  }
@@ -38,7 +38,7 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
38
38
  setup:
39
39
  API Key: \(apiKey)
40
40
  Device ID: \(deviceId ?? "null")
41
- Session ID: \(sessionId)
41
+ Custom Session ID: \(customSessionId)
42
42
  Server Zone: \(serverZone)
43
43
  Sample Rate: \(sampleRate)
44
44
  Enable Remote Config: \(enableRemoteConfig)
@@ -51,7 +51,7 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
51
51
  sessionReplay = SessionReplay(
52
52
  apiKey: apiKey,
53
53
  deviceId: deviceId,
54
- sessionId: sessionId.int64Value,
54
+ sessionId: -1,
55
55
  optOut: optOut,
56
56
  sampleRate: Float(truncating: sampleRate),
57
57
  logger: createdLogger,
@@ -59,16 +59,27 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
59
59
  maskLevel: .fromString(maskLevel),
60
60
  enableRemoteConfig: enableRemoteConfig
61
61
  )
62
-
62
+
63
+ sessionReplay?.customSessionId = customSessionId
64
+
63
65
  resolve(nil)
64
66
  }
65
67
 
66
- @objc(setSessionId:resolve:reject:)
67
- func setSessionId(_ sessionId: NSNumber, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
68
- logger?.debug(message: "setSessionId: \(sessionId)")
69
- sessionReplay?.sessionId = sessionId.int64Value
68
+ @objc(setCustomSessionId:resolve:reject:)
69
+ func setCustomSessionId(_ customSessionId: NSString, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
70
+ logger?.debug(message: "setCustomSessionId: \(customSessionId)")
71
+ sessionReplay?.customSessionId = customSessionId as String
70
72
  resolve(nil)
71
73
  }
74
+
75
+ @objc(getCustomSessionId:reject:)
76
+ func getCustomSessionId(
77
+ _ resolve: RCTPromiseResolveBlock,
78
+ reject: RCTPromiseRejectBlock
79
+ ) {
80
+ logger?.debug(message: "getCustomSessionId")
81
+ resolve(sessionReplay?.customSessionId ?? "-1")
82
+ }
72
83
 
73
84
  @objc(setDeviceId:resolve:reject:)
74
85
  func setDeviceId(_ deviceId: NSString, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
@@ -84,19 +95,6 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
84
95
  resolve(nil)
85
96
  }
86
97
 
87
- @objc(getSessionId:reject:)
88
- func getSessionId(
89
- _ resolve: RCTPromiseResolveBlock,
90
- reject: RCTPromiseRejectBlock
91
- ) {
92
- logger?.debug(message: "getSessionId")
93
- if let sessionId = sessionReplay?.sessionId {
94
- resolve(NSNumber(value: sessionId))
95
- } else {
96
- resolve(nil)
97
- }
98
- }
99
-
100
98
  @objc(start:reject:)
101
99
  func start(_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
102
100
  logger?.debug(message: "start")
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_NativeAmpSessionReplay","_interopRequireDefault","e","__esModule","default","LINKING_ERROR","Platform","select","ios","NativeSessionReplay","exports","SessionReplaySpec","Proxy","get","Error"],"sourceRoot":"../../src","sources":["native-module.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA+D,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/D,MAAMG,aAAa,GACjB,iGAAiG,GACjGC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEJ,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAIE,+BAAiB,IACnD,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAwC;;AAE1C;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_NativeAmpSessionReplay","_interopRequireDefault","e","__esModule","default","LINKING_ERROR","Platform","select","ios","NativeSessionReplay","exports","SessionReplaySpec","Proxy","get","Error"],"sourceRoot":"../../src","sources":["native-module.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA+D,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/D,MAAMG,aAAa,GACjB,iGAAiG,GACjGC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEJ,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAIE,+BAAiB,IACnD,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAwC;;AAE1C;AACA;AACA;AACA;;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_analyticsTypes","require","getDefaultConfig","deviceId","enableRemoteConfig","logLevel","LogLevel","Warn","optOut","privacyConfig","sampleRate","serverZone","sessionId","exports"],"sourceRoot":"../../src","sources":["session-replay-config.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAqEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGO,MAAMC,gBAA6E,GAAGA,CAAA,KAAM;EACjG,OAAO;IACLC,QAAQ,EAAE,IAAI;IACdC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEC,wBAAQ,CAACC,IAAI;IACvBC,MAAM,EAAE,KAAK;IACb;IACA;IACA;IACA;IACAC,aAAa,EAAE,CAAC,CAAC;IACjBC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE,CAAC;EACd,CAAC;AACH,CAAC;AAACC,OAAA,CAAAX,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_analyticsTypes","require","getDefaultConfig","deviceId","enableRemoteConfig","logLevel","LogLevel","Warn","optOut","privacyConfig","sampleRate","serverZone","sessionId","exports"],"sourceRoot":"../../src","sources":["session-replay-config.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAuEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGO,MAAMC,gBAA6E,GAAGA,CAAA,KAAM;EACjG,OAAO;IACLC,QAAQ,EAAE,IAAI;IACdC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEC,wBAAQ,CAACC,IAAI;IACvBC,MAAM,EAAE,KAAK;IACb;IACA;IACA;IACA;IACAC,aAAa,EAAE,CAAC,CAAC;IACjBC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE,CAAC;EACd,CAAC;AACH,CAAC;AAACC,OAAA,CAAAX,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -53,6 +53,37 @@ function normalizeConfig(config) {
53
53
  let isInitialized = false;
54
54
  let logger = (0, _logger.createSessionReplayLogger)();
55
55
 
56
+ // Only canonical integers (no sign prefix, leading zeros, whitespace or hex)
57
+ // become numbers, so `String(getSessionId())` always equals the native value.
58
+ const CANONICAL_INTEGER = /^(0|-?[1-9]\d*)$/;
59
+
60
+ // A JS `number` is an IEEE-754 double with 53 bits of integer precision, not
61
+ // 64, so integers beyond `Number.MAX_SAFE_INTEGER` stay strings rather than
62
+ // being rounded.
63
+ function fromNativeSessionId(sessionId) {
64
+ if (!CANONICAL_INTEGER.test(sessionId)) {
65
+ return sessionId;
66
+ }
67
+ const numericSessionId = Number(sessionId);
68
+ return Number.isSafeInteger(numericSessionId) ? numericSessionId : sessionId;
69
+ }
70
+ function normalizeNumericSessionId(sessionId) {
71
+ if (sessionId === -1) {
72
+ return '-1';
73
+ }
74
+ if (!Number.isFinite(sessionId) || !Number.isInteger(sessionId) || sessionId <= 0) {
75
+ logger.warn('Invalid numeric sessionId; disabling session replay until a valid ID is set.', sessionId);
76
+ return '-1';
77
+ }
78
+ if (!Number.isSafeInteger(sessionId)) {
79
+ logger.warn('Unsafe numeric sessionId may already be rounded; forwarding its current value. Pass the exact ID as a string.', sessionId);
80
+ }
81
+ return String(sessionId);
82
+ }
83
+ function toNativeSessionId(sessionId) {
84
+ return typeof sessionId === 'number' ? normalizeNumericSessionId(sessionId) : sessionId;
85
+ }
86
+
56
87
  /**
57
88
  * Configure the SDK. Call `start()` explicitly to begin collecting replays.
58
89
  * This function must be called before any other session replay operations.
@@ -60,6 +91,9 @@ let logger = (0, _logger.createSessionReplayLogger)();
60
91
  * @param config - Configuration object containing API key, device ID, session ID, and other options
61
92
  * @returns Promise that resolves when initialization is complete. Native setup
62
93
  * failures are logged and do not reject the promise.
94
+ * Invalid numeric session IDs disable recording and are logged. Positive unsafe
95
+ * integers are logged and forwarded as their JavaScript value, which may already
96
+ * be rounded. Pass exact large IDs as strings.
63
97
  *
64
98
  * @example
65
99
  * ```typescript
@@ -100,12 +134,19 @@ async function init(config) {
100
134
  * Call whenever the session ID changes.
101
135
  * The Session ID you pass to the SDK must match the Session ID sent as event properties to Amplitude.
102
136
  *
103
- * @param sessionId - The new session identifier number
137
+ * Accepts a positive integer such as `Date.now()` or an opaque string such as a
138
+ * UUID. Invalid numeric IDs are logged and mapped to `-1`, disabling recording.
139
+ * Positive integers beyond `Number.MAX_SAFE_INTEGER` are logged and forwarded
140
+ * as their JavaScript value, which may already be rounded; pass exact IDs as strings.
141
+ *
142
+ * @param sessionId - The new session identifier
104
143
  * @returns Promise that resolves when the session ID is updated
105
144
  *
106
145
  * @example
107
146
  * ```typescript
108
147
  * await setSessionId(Date.now());
148
+ * // or an alphanumeric session ID
149
+ * await setSessionId('550e8400-e29b-41d4-a716-446655440000');
109
150
  * ```
110
151
  */
111
152
  async function setSessionId(sessionId) {
@@ -113,7 +154,7 @@ async function setSessionId(sessionId) {
113
154
  logger.warn('SessionReplay is not initialized');
114
155
  return;
115
156
  }
116
- await _nativeModule.NativeSessionReplay.setSessionId(sessionId);
157
+ await _nativeModule.NativeSessionReplay.setCustomSessionId(toNativeSessionId(sessionId));
117
158
  }
118
159
 
119
160
  /**
@@ -140,8 +181,15 @@ async function setDeviceId(deviceId) {
140
181
 
141
182
  /**
142
183
  * Get the current session identifier from the session replay SDK.
184
+ * Resolves to a number when the active session ID is a safe integer, and to a
185
+ * string otherwise — for example a UUID. `-1` means no session is set.
186
+ *
187
+ * 64-bit integers beyond `Number.MAX_SAFE_INTEGER` (2^53 - 1) resolve to their
188
+ * string form: a JavaScript `number` is a double with 53 bits of integer
189
+ * precision and cannot hold them exactly. A numeric string you set, such as
190
+ * `'123'`, resolves to the number `123`.
143
191
  *
144
- * @returns Promise that resolves to the current session ID number, or null if not initialized
192
+ * @returns Promise that resolves to the current session ID, or null if not initialized
145
193
  *
146
194
  * @example
147
195
  * ```typescript
@@ -156,7 +204,7 @@ async function getSessionId() {
156
204
  logger.warn('SessionReplay is not initialized');
157
205
  return null;
158
206
  }
159
- return await _nativeModule.NativeSessionReplay.getSessionId();
207
+ return fromNativeSessionId(await _nativeModule.NativeSessionReplay.getCustomSessionId());
160
208
  }
161
209
 
162
210
  /**
@@ -257,6 +305,7 @@ function nativeConfig(config) {
257
305
  // only takes a flat `maskLevel` string.
258
306
  const {
259
307
  privacyConfig,
308
+ sessionId,
260
309
  ...rest
261
310
  } = config;
262
311
  const resolvedMaskLevel = privacyConfig.maskLevel ?? 'medium';
@@ -264,7 +313,8 @@ function nativeConfig(config) {
264
313
  ...rest,
265
314
  logLevel: rest.logLevel,
266
315
  // TODO(SDKRN-15): Migrate native bridge to accept the full privacyConfig object instead of a flat maskLevel string.
267
- maskLevel: resolvedMaskLevel
316
+ maskLevel: resolvedMaskLevel,
317
+ customSessionId: toNativeSessionId(sessionId)
268
318
  };
269
319
  }
270
320
  async function privateInit(config, newLogger) {
@@ -1 +1 @@
1
- {"version":3,"names":["_nativeModule","require","_sessionReplayConfig","_logger","_version","normalizeConfig","config","maskLevel","privacyConfig","rest","undefined","isInitialized","logger","createSessionReplayLogger","init","warn","resolvedConfig","getDefaultConfig","setLogLevel","logLevel","log","VERSION","NativeSessionReplay","setup","nativeConfig","error","setSessionId","sessionId","setDeviceId","deviceId","getSessionId","flush","start","stop","setOptOut","optOut","teardown","resolvedMaskLevel","privateInit","newLogger"],"sourceRoot":"../../src","sources":["session-replay.ts"],"mappings":";;;;;;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AALA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,eAAeA,CAACC,MAA2B,EAA+B;EACjF,MAAM;IAAEC,SAAS;IAAEC,aAAa;IAAE,GAAGC;EAAK,CAAC,GAAGH,MAAM;EACpD,IAAIE,aAAa,KAAKE,SAAS,EAAE;IAC/B,OAAO;MAAE,GAAGD,IAAI;MAAED;IAAc,CAAC;EACnC;EACA,IAAID,SAAS,KAAKG,SAAS,EAAE;IAC3B,OAAO;MAAE,GAAGD,IAAI;MAAED,aAAa,EAAE;QAAED;MAAU;IAAE,CAAC;EAClD;EACA,OAAOE,IAAI;AACb;AAEA,IAAIE,aAAa,GAAG,KAAK;AACzB,IAAIC,MAAM,GAAG,IAAAC,iCAAyB,EAAC,CAAC;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,IAAIA,CAACR,MAA2B,EAAiB;EACrE,IAAIK,aAAa,EAAE;IACjBC,MAAM,CAACG,IAAI,CAAC,sCAAsC,CAAC;IACnD;EACF;;EAEA;EACA;EACA;EACA;EACA,MAAMC,cAA2C,GAAG;IAClD,GAAG,IAAAC,qCAAgB,EAAC,CAAC;IACrB,GAAGZ,eAAe,CAACC,MAAM;EAC3B,CAAC;EAEDM,MAAM,CAACM,WAAW,CAACF,cAAc,CAACG,QAAQ,CAAC;EAC3CP,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SAAS,IAAI,QAAQ;EACrG,OAAO;IACL,GAAGE,IAAI;IACPU,QAAQ,EAAEV,IAAI,CAACU,QAAiD;IAChE;IACAZ,SAAS,EAAE8B;EACb,CAAC;AACH;AAEO,eAAeC,WAAWA,CAC/BhC,MAA2B,EAC3BiC,SAAuD,EACxC;EACf3B,MAAM,GAAG2B,SAAS;EAClB,OAAOzB,IAAI,CAACR,MAAM,CAAC;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["_nativeModule","require","_sessionReplayConfig","_logger","_version","normalizeConfig","config","maskLevel","privacyConfig","rest","undefined","isInitialized","logger","createSessionReplayLogger","CANONICAL_INTEGER","fromNativeSessionId","sessionId","test","numericSessionId","Number","isSafeInteger","normalizeNumericSessionId","isFinite","isInteger","warn","String","toNativeSessionId","init","resolvedConfig","getDefaultConfig","setLogLevel","logLevel","log","VERSION","NativeSessionReplay","setup","nativeConfig","error","setSessionId","setCustomSessionId","setDeviceId","deviceId","getSessionId","getCustomSessionId","flush","start","stop","setOptOut","optOut","teardown","resolvedMaskLevel","customSessionId","privateInit","newLogger"],"sourceRoot":"../../src","sources":["session-replay.ts"],"mappings":";;;;;;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AALA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,eAAeA,CAACC,MAA2B,EAA+B;EACjF,MAAM;IAAEC,SAAS;IAAEC,aAAa;IAAE,GAAGC;EAAK,CAAC,GAAGH,MAAM;EACpD,IAAIE,aAAa,KAAKE,SAAS,EAAE;IAC/B,OAAO;MAAE,GAAGD,IAAI;MAAED;IAAc,CAAC;EACnC;EACA,IAAID,SAAS,KAAKG,SAAS,EAAE;IAC3B,OAAO;MAAE,GAAGD,IAAI;MAAED,aAAa,EAAE;QAAED;MAAU;IAAE,CAAC;EAClD;EAC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I,CAACtC,aAAa,EAAE;IAClBC,MAAM,CAACY,IAAI,CAAC,kCAAkC,CAAC;IAC/C;EACF;EACA,MAAMU,iCAAmB,CAACe,QAAQ,CAAC,CAAC;EACpCtC,aAAa,GAAG,KAAK;EACrBC,MAAM,GAAG,IAAAC,iCAAyB,EAAC,CAAC;AACtC;AAEA,SAASuB,YAAYA,CAAC9B,MAAmC,EAA6B;EACpF;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;IAAEE,aAAa;IAAEQ,SAAS;IAAE,GAAGP;EAAK,CAAC,GAAGH,MAAM;EACpD,MAAM4C,iBAAyD,GAAG1C,aAAa,CAACD,SAAS,IAAI,QAAQ;EACrG,OAAO;IACL,GAAGE,IAAI;IACPsB,QAAQ,EAAEtB,IAAI,CAACsB,QAAiD;IAChE;IACAxB,SAAS,EAAE2C,iBAAiB;IAC5BC,eAAe,EAAEzB,iBAAiB,CAACV,SAAS;EAC9C,CAAC;AACH;AAEO,eAAeoC,WAAWA,CAC/B9C,MAA2B,EAC3B+C,SAAuD,EACxC;EACfzC,MAAM,GAAGyC,SAAS;EAClB,OAAO1B,IAAI,CAACrB,MAAM,CAAC;AACrB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sourceRoot":"../../../src","sources":["specs/NativeAmpSessionReplay.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA;AACA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,gCAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sourceRoot":"../../../src","sources":["specs/NativeAmpSessionReplay.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAeA;AACA;AACA;AACA;AACA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,gCAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC","ignoreList":[]}
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VERSION = void 0;
7
- const VERSION = exports.VERSION = '1.0.3-video-analytics-5.0';
7
+ const VERSION = exports.VERSION = '1.2.0-video-analytics-6.0';
8
8
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","SessionReplaySpec","LINKING_ERROR","select","ios","default","NativeSessionReplay","Proxy","get","Error"],"sourceRoot":"../../src","sources":["native-module.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,iBAAiB,MAAM,gCAAgC;AAE9D,MAAMC,aAAa,GACjB,iGAAiG,GACjGF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAIL,iBAAiB,IACnD,IAAIM,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAwC;;AAE1C;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["Platform","SessionReplaySpec","LINKING_ERROR","select","ios","default","NativeSessionReplay","Proxy","get","Error"],"sourceRoot":"../../src","sources":["native-module.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,iBAAiB,MAAM,gCAAgC;AAE9D,MAAMC,aAAa,GACjB,iGAAiG,GACjGF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAIL,iBAAiB,IACnD,IAAIM,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAwC;;AAE1C;AACA;AACA;AACA;;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["LogLevel","getDefaultConfig","deviceId","enableRemoteConfig","logLevel","Warn","optOut","privacyConfig","sampleRate","serverZone","sessionId"],"sourceRoot":"../../src","sources":["session-replay-config.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,4BAA4B;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAqEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,MAAMC,gBAA6E,GAAGA,CAAA,KAAM;EACjG,OAAO;IACLC,QAAQ,EAAE,IAAI;IACdC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEJ,QAAQ,CAACK,IAAI;IACvBC,MAAM,EAAE,KAAK;IACb;IACA;IACA;IACA;IACAC,aAAa,EAAE,CAAC,CAAC;IACjBC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE,CAAC;EACd,CAAC;AACH,CAAC;AACD,SAASV,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["LogLevel","getDefaultConfig","deviceId","enableRemoteConfig","logLevel","Warn","optOut","privacyConfig","sampleRate","serverZone","sessionId"],"sourceRoot":"../../src","sources":["session-replay-config.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,4BAA4B;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAuEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,MAAMC,gBAA6E,GAAGA,CAAA,KAAM;EACjG,OAAO;IACLC,QAAQ,EAAE,IAAI;IACdC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEJ,QAAQ,CAACK,IAAI;IACvBC,MAAM,EAAE,KAAK;IACb;IACA;IACA;IACA;IACAC,aAAa,EAAE,CAAC,CAAC;IACjBC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE,CAAC;EACd,CAAC;AACH,CAAC;AACD,SAASV,QAAQ","ignoreList":[]}
@@ -38,6 +38,37 @@ function normalizeConfig(config) {
38
38
  let isInitialized = false;
39
39
  let logger = createSessionReplayLogger();
40
40
 
41
+ // Only canonical integers (no sign prefix, leading zeros, whitespace or hex)
42
+ // become numbers, so `String(getSessionId())` always equals the native value.
43
+ const CANONICAL_INTEGER = /^(0|-?[1-9]\d*)$/;
44
+
45
+ // A JS `number` is an IEEE-754 double with 53 bits of integer precision, not
46
+ // 64, so integers beyond `Number.MAX_SAFE_INTEGER` stay strings rather than
47
+ // being rounded.
48
+ function fromNativeSessionId(sessionId) {
49
+ if (!CANONICAL_INTEGER.test(sessionId)) {
50
+ return sessionId;
51
+ }
52
+ const numericSessionId = Number(sessionId);
53
+ return Number.isSafeInteger(numericSessionId) ? numericSessionId : sessionId;
54
+ }
55
+ function normalizeNumericSessionId(sessionId) {
56
+ if (sessionId === -1) {
57
+ return '-1';
58
+ }
59
+ if (!Number.isFinite(sessionId) || !Number.isInteger(sessionId) || sessionId <= 0) {
60
+ logger.warn('Invalid numeric sessionId; disabling session replay until a valid ID is set.', sessionId);
61
+ return '-1';
62
+ }
63
+ if (!Number.isSafeInteger(sessionId)) {
64
+ logger.warn('Unsafe numeric sessionId may already be rounded; forwarding its current value. Pass the exact ID as a string.', sessionId);
65
+ }
66
+ return String(sessionId);
67
+ }
68
+ function toNativeSessionId(sessionId) {
69
+ return typeof sessionId === 'number' ? normalizeNumericSessionId(sessionId) : sessionId;
70
+ }
71
+
41
72
  /**
42
73
  * Configure the SDK. Call `start()` explicitly to begin collecting replays.
43
74
  * This function must be called before any other session replay operations.
@@ -45,6 +76,9 @@ let logger = createSessionReplayLogger();
45
76
  * @param config - Configuration object containing API key, device ID, session ID, and other options
46
77
  * @returns Promise that resolves when initialization is complete. Native setup
47
78
  * failures are logged and do not reject the promise.
79
+ * Invalid numeric session IDs disable recording and are logged. Positive unsafe
80
+ * integers are logged and forwarded as their JavaScript value, which may already
81
+ * be rounded. Pass exact large IDs as strings.
48
82
  *
49
83
  * @example
50
84
  * ```typescript
@@ -85,12 +119,19 @@ export async function init(config) {
85
119
  * Call whenever the session ID changes.
86
120
  * The Session ID you pass to the SDK must match the Session ID sent as event properties to Amplitude.
87
121
  *
88
- * @param sessionId - The new session identifier number
122
+ * Accepts a positive integer such as `Date.now()` or an opaque string such as a
123
+ * UUID. Invalid numeric IDs are logged and mapped to `-1`, disabling recording.
124
+ * Positive integers beyond `Number.MAX_SAFE_INTEGER` are logged and forwarded
125
+ * as their JavaScript value, which may already be rounded; pass exact IDs as strings.
126
+ *
127
+ * @param sessionId - The new session identifier
89
128
  * @returns Promise that resolves when the session ID is updated
90
129
  *
91
130
  * @example
92
131
  * ```typescript
93
132
  * await setSessionId(Date.now());
133
+ * // or an alphanumeric session ID
134
+ * await setSessionId('550e8400-e29b-41d4-a716-446655440000');
94
135
  * ```
95
136
  */
96
137
  export async function setSessionId(sessionId) {
@@ -98,7 +139,7 @@ export async function setSessionId(sessionId) {
98
139
  logger.warn('SessionReplay is not initialized');
99
140
  return;
100
141
  }
101
- await NativeSessionReplay.setSessionId(sessionId);
142
+ await NativeSessionReplay.setCustomSessionId(toNativeSessionId(sessionId));
102
143
  }
103
144
 
104
145
  /**
@@ -125,8 +166,15 @@ export async function setDeviceId(deviceId) {
125
166
 
126
167
  /**
127
168
  * Get the current session identifier from the session replay SDK.
169
+ * Resolves to a number when the active session ID is a safe integer, and to a
170
+ * string otherwise — for example a UUID. `-1` means no session is set.
171
+ *
172
+ * 64-bit integers beyond `Number.MAX_SAFE_INTEGER` (2^53 - 1) resolve to their
173
+ * string form: a JavaScript `number` is a double with 53 bits of integer
174
+ * precision and cannot hold them exactly. A numeric string you set, such as
175
+ * `'123'`, resolves to the number `123`.
128
176
  *
129
- * @returns Promise that resolves to the current session ID number, or null if not initialized
177
+ * @returns Promise that resolves to the current session ID, or null if not initialized
130
178
  *
131
179
  * @example
132
180
  * ```typescript
@@ -141,7 +189,7 @@ export async function getSessionId() {
141
189
  logger.warn('SessionReplay is not initialized');
142
190
  return null;
143
191
  }
144
- return await NativeSessionReplay.getSessionId();
192
+ return fromNativeSessionId(await NativeSessionReplay.getCustomSessionId());
145
193
  }
146
194
 
147
195
  /**
@@ -242,6 +290,7 @@ function nativeConfig(config) {
242
290
  // only takes a flat `maskLevel` string.
243
291
  const {
244
292
  privacyConfig,
293
+ sessionId,
245
294
  ...rest
246
295
  } = config;
247
296
  const resolvedMaskLevel = privacyConfig.maskLevel ?? 'medium';
@@ -249,7 +298,8 @@ function nativeConfig(config) {
249
298
  ...rest,
250
299
  logLevel: rest.logLevel,
251
300
  // TODO(SDKRN-15): Migrate native bridge to accept the full privacyConfig object instead of a flat maskLevel string.
252
- maskLevel: resolvedMaskLevel
301
+ maskLevel: resolvedMaskLevel,
302
+ customSessionId: toNativeSessionId(sessionId)
253
303
  };
254
304
  }
255
305
  export async function privateInit(config, newLogger) {
@@ -1 +1 @@
1
- {"version":3,"names":["NativeSessionReplay","getDefaultConfig","createSessionReplayLogger","VERSION","normalizeConfig","config","maskLevel","privacyConfig","rest","undefined","isInitialized","logger","init","warn","resolvedConfig","setLogLevel","logLevel","log","setup","nativeConfig","error","setSessionId","sessionId","setDeviceId","deviceId","getSessionId","flush","start","stop","setOptOut","optOut","teardown","resolvedMaskLevel","privateInit","newLogger"],"sourceRoot":"../../src","sources":["session-replay.ts"],"mappings":"AAAA;;AAEA,SAASA,mBAAmB,QAAwC,iBAAiB;AACrF,SAASC,gBAAgB,QAA0D,yBAAyB;AAC5G,SAASC,yBAAyB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,WAAW;AAInC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAACC,MAA2B,EAA+B;EACjF,MAAM;IAAEC,SAAS;IAAEC,aAAa;IAAE,GAAGC;EAAK,CAAC,GAAGH,MAAM;EACpD,IAAIE,aAAa,KAAKE,SAAS,EAAE;IAC/B,OAAO;MAAE,GAAGD,IAAI;MAAED;IAAc,CAAC;EACnC;EACA,IAAID,SAAS,KAAKG,SAAS,EAAE;IAC3B,OAAO;MAAE,GAAGD,IAAI;MAAED,aAAa,EAAE;QAAED;MAAU;IAAE,CAAC;EAClD;EACA,OAAOE,IAAI;AACb;AAEA,IAAIE,aAAa,GAAG,KAAK;AACzB,IAAIC,MAAM,GAAGT,yBAAyB,CAAC,CAAC;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeU,IAAIA,CAACP,MAA2B,EAAiB;EACrE,IAAIK,aAAa,EAAE;IACjBC,MAAM,CAACE,IAAI,CAAC,sCAAsC,CAAC;IACnD;EACF;;EAEA;EACA;EACA;EACA;EACA,MAAMC,cAA2C,GAAG;IAClD,GAAGb,gBAAgB,CAAC,CAAC;IACrB,GAAGG,eAAe,CAACC,MAAM;EAC3B,CAAC;EAEDM,MAAM,CAACI,WAAW,CAACD,cAAc,CAACE,QAAQ,CAAC;EAC3CL,MAAM,CAACM,GAAG,CAAC,gEAAgEd,OAAO,gBAAgB,EAAEW,cAAc,CAAC;EAEnH,IAAI;IACF,MAAMd,mBAAmB,CAACkB,KAAK,CAACC,YAAY,CAACL,cAAc,CAAC,CAAC;IAC7DH,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EAAE0B;EACb,CAAC;AACH;AAEA,OAAO,eAAeC,WAAWA,CAC/B5B,MAA2B,EAC3B6B,SAAuD,EACxC;EACfvB,MAAM,GAAGuB,SAAS;EAClB,OAAOtB,IAAI,CAACP,MAAM,CAAC;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["NativeSessionReplay","getDefaultConfig","createSessionReplayLogger","VERSION","normalizeConfig","config","maskLevel","privacyConfig","rest","undefined","isInitialized","logger","CANONICAL_INTEGER","fromNativeSessionId","sessionId","test","numericSessionId","Number","isSafeInteger","normalizeNumericSessionId","isFinite","isInteger","warn","String","toNativeSessionId","init","resolvedConfig","setLogLevel","logLevel","log","setup","nativeConfig","error","setSessionId","setCustomSessionId","setDeviceId","deviceId","getSessionId","getCustomSessionId","flush","start","stop","setOptOut","optOut","teardown","resolvedMaskLevel","customSessionId","privateInit","newLogger"],"sourceRoot":"../../src","sources":["session-replay.ts"],"mappings":"AAAA;;AAEA,SAASA,mBAAmB,QAAwC,iBAAiB;AACrF,SAASC,gBAAgB,QAA0D,yBAAyB;AAC5G,SAASC,yBAAyB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,WAAW;AAInC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAACC,MAA2B,EAA+B;EACjF,MAAM;IAAEC,SAAS;IAAEC,aAAa;IAAE,GAAGC;EAAK,CAAC,GAAGH,MAAM;EACpD,IAAIE,aAAa,KAAKE,SAAS,EAAE;IAC/B,OAAO;MAAE,GAAGD,IAAI;MAAED;IAAc,CAAC;EACnC;EACA,IAAID,SAAS,KAAKG,SAAS,EAAE;IAC3B,OAAO;MAAE,GAAGD,IAAI;MAAED,aAAa,EAAE;QAAED;MAAU;IAAE,CAAC;EAClD;EACA,OAAOE,IAAI;AACb;AAEA,IAAIE,aAAa,GAAG,KAAK;AACzB,IAAIC,MAAM,GAAGT,yBAAyB,CAAC,CAAC;;AAExC;AACA;AACA,MAAMU,iBAAiB,GAAG,k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;EACF;EACA,MAAMtB,mBAAmB,CAAC4C,QAAQ,CAAC,CAAC;EACpClC,aAAa,GAAG,KAAK;EACrBC,MAAM,GAAGT,yBAAyB,CAAC,CAAC;AACtC;AAEA,SAAS6B,YAAYA,CAAC1B,MAAmC,EAA6B;EACpF;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;IAAEE,aAAa;IAAEO,SAAS;IAAE,GAAGN;EAAK,CAAC,GAAGH,MAAM;EACpD,MAAMwC,iBAAyD,GAAGtC,aAAa,CAACD,SAAS,IAAI,QAAQ;EACrG,OAAO;IACL,GAAGE,IAAI;IACPoB,QAAQ,EAAEpB,IAAI,CAACoB,QAAiD;IAChE;IACAtB,SAAS,EAAEuC,iBAAiB;IAC5BC,eAAe,EAAEtB,iBAAiB,CAACV,SAAS;EAC9C,CAAC;AACH;AAEA,OAAO,eAAeiC,WAAWA,CAC/B1C,MAA2B,EAC3B2C,SAAuD,EACxC;EACfrC,MAAM,GAAGqC,SAAS;EAClB,OAAOvB,IAAI,CAACpB,MAAM,CAAC;AACrB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","get"],"sourceRoot":"../../../src","sources":["specs/NativeAmpSessionReplay.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAClD;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA,eAAeA,mBAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","get"],"sourceRoot":"../../../src","sources":["specs/NativeAmpSessionReplay.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAClD;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA,eAAeA,mBAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.0.3-video-analytics-5.0';
1
+ export const VERSION = '1.2.0-video-analytics-6.0';
2
2
  //# sourceMappingURL=version.js.map
@@ -20,8 +20,12 @@ export interface NativeSessionReplayConfig {
20
20
  sampleRate: number;
21
21
  /** Amplitude server zone for data routing ('US' or 'EU') */
22
22
  serverZone: 'US' | 'EU';
23
- /** Current session identifier for correlating events with recordings */
24
- sessionId: number;
23
+ /**
24
+ * Alphanumeric session identifier — the only session id the native layer
25
+ * tracks. Always sent: the public `sessionId` in its string form, defaulting
26
+ * to `"-1"` when no session is set.
27
+ */
28
+ customSessionId: string;
25
29
  }
26
30
  /**
27
31
  * Interface defining the native session replay module specification.
@@ -37,12 +41,6 @@ export interface NativeSessionReplaySpec {
37
41
  * Forces immediate upload of recorded session data that may be buffered locally.
38
42
  */
39
43
  flush(): Promise<void>;
40
- /**
41
- * Retrieves the current session identifier from the native module.
42
- * @returns Promise resolving to the current session ID number
43
- * @note OLD ARCH: ideally we want to cache that on JS side to avoid bridge overhead
44
- */
45
- getSessionId(): Promise<number>;
46
44
  /**
47
45
  * Updates the device identifier used for session replay tracking.
48
46
  * @param deviceId - The device identifier string, or null to clear the device ID
@@ -50,11 +48,17 @@ export interface NativeSessionReplaySpec {
50
48
  */
51
49
  setDeviceId(deviceId: string | null): Promise<void>;
52
50
  /**
53
- * Updates the session identifier used for session replay tracking.
54
- * @param sessionId - The session identifier number
55
- * @note OLD ARCH: combine those into one method to avoid bridge overhead
51
+ * Updates the alphanumeric session identifier used for session replay tracking.
52
+ * This is the only native session-id setter; the public `setSessionId` maps
53
+ * onto it (as a string) in the JS layer.
54
+ * @param customSessionId - The custom session identifier string
55
+ */
56
+ setCustomSessionId(customSessionId: string): Promise<void>;
57
+ /**
58
+ * Retrieves the current alphanumeric session identifier from the native module.
59
+ * @returns Promise resolving to the active custom session ID
56
60
  */
57
- setSessionId(sessionId: number): Promise<void>;
61
+ getCustomSessionId(): Promise<string>;
58
62
  /**
59
63
  * Updates whether session replay collection is disabled for the current user.
60
64
  * @param optOut - Whether to opt out of session replay collection
@@ -1 +1 @@
1
- {"version":3,"file":"native-module.d.ts","sourceRoot":"","sources":["../../src/native-module.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,mBAAmB,yBAQU,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,0EAA0E;IAC1E,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oFAAoF;IACpF,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,kEAAkE;IAClE,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG,cAAc,CAAC;IAC/C,iEAAiE;IACjE,MAAM,EAAE,OAAO,CAAC;IAChB,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;OAIG;IACH,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhC;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IA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OAGG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
@@ -69,11 +69,13 @@ export interface SessionReplayConfig {
69
69
  */
70
70
  serverZone?: 'EU' | 'US';
71
71
  /**
72
- * Session identifier that matches the session ID sent with Amplitude events
73
- * Must match the Session ID passed as event properties to Amplitude
72
+ * Session identifier that matches the session ID sent with Amplitude events.
73
+ * Must match the Session ID passed as event properties to Amplitude.
74
+ * Accepts a positive integer such as `Date.now()` or an opaque string such as
75
+ * a UUID. Invalid numeric IDs disable recording; pass exact large IDs as strings.
74
76
  * @default -1
75
77
  */
76
- sessionId?: number;
78
+ sessionId?: string | number;
77
79
  }
78
80
  /**
79
81
  * Internal config shape used by the SDK after the public `SessionReplayConfig`
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay-config.d.ts","sourceRoot":"","sources":["../../src/session-replay-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,cAAc,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB;;;OAGG;IAC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SAAS,CAAC;IAEtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAEzB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;AAEjF,eAAO,MAAM,gBAAgB,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAexF,CAAC;AACF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -7,6 +7,9 @@ import { createSessionReplayLogger } from './logger';
7
7
  * @param config - Configuration object containing API key, device ID, session ID, and other options
8
8
  * @returns Promise that resolves when initialization is complete. Native setup
9
9
  * failures are logged and do not reject the promise.
10
+ * Invalid numeric session IDs disable recording and are logged. Positive unsafe
11
+ * integers are logged and forwarded as their JavaScript value, which may already
12
+ * be rounded. Pass exact large IDs as strings.
10
13
  *
11
14
  * @example
12
15
  * ```typescript
@@ -23,15 +26,22 @@ export declare function init(config: SessionReplayConfig): Promise<void>;
23
26
  * Call whenever the session ID changes.
24
27
  * The Session ID you pass to the SDK must match the Session ID sent as event properties to Amplitude.
25
28
  *
26
- * @param sessionId - The new session identifier number
29
+ * Accepts a positive integer such as `Date.now()` or an opaque string such as a
30
+ * UUID. Invalid numeric IDs are logged and mapped to `-1`, disabling recording.
31
+ * Positive integers beyond `Number.MAX_SAFE_INTEGER` are logged and forwarded
32
+ * as their JavaScript value, which may already be rounded; pass exact IDs as strings.
33
+ *
34
+ * @param sessionId - The new session identifier
27
35
  * @returns Promise that resolves when the session ID is updated
28
36
  *
29
37
  * @example
30
38
  * ```typescript
31
39
  * await setSessionId(Date.now());
40
+ * // or an alphanumeric session ID
41
+ * await setSessionId('550e8400-e29b-41d4-a716-446655440000');
32
42
  * ```
33
43
  */
34
- export declare function setSessionId(sessionId: number): Promise<void>;
44
+ export declare function setSessionId(sessionId: string | number): Promise<void>;
35
45
  /**
36
46
  * Update the device ID used for session replay tracking.
37
47
  * The Device ID you pass to the SDK must match the Device ID sent as event properties to Amplitude.
@@ -49,8 +59,15 @@ export declare function setSessionId(sessionId: number): Promise<void>;
49
59
  export declare function setDeviceId(deviceId: string | null): Promise<void>;
50
60
  /**
51
61
  * Get the current session identifier from the session replay SDK.
62
+ * Resolves to a number when the active session ID is a safe integer, and to a
63
+ * string otherwise — for example a UUID. `-1` means no session is set.
64
+ *
65
+ * 64-bit integers beyond `Number.MAX_SAFE_INTEGER` (2^53 - 1) resolve to their
66
+ * string form: a JavaScript `number` is a double with 53 bits of integer
67
+ * precision and cannot hold them exactly. A numeric string you set, such as
68
+ * `'123'`, resolves to the number `123`.
52
69
  *
53
- * @returns Promise that resolves to the current session ID number, or null if not initialized
70
+ * @returns Promise that resolves to the current session ID, or null if not initialized
54
71
  *
55
72
  * @example
56
73
  * ```typescript
@@ -60,7 +77,7 @@ export declare function setDeviceId(deviceId: string | null): Promise<void>;
60
77
  * }
61
78
  * ```
62
79
  */
63
- export declare function getSessionId(): Promise<number | null>;
80
+ export declare function getSessionId(): Promise<string | number | null>;
64
81
  /**
65
82
  * Flush any pending session replay data to the server.
66
83
  * Forces immediate upload of recorded session data that may be buffered locally.
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,mBAAmB,EAA+B,MAAM,yBAAyB,CAAC;AAC7G,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA4BrD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,IAAI,CAAC,MAAM,EAAE,mBAAmB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AkBG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAMxE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAMpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAM3C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAM3C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAM1C;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9D;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ9C;AAoBD,wBAAsB,WAAW,CAC/B,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,CAGf"}
@@ -2,10 +2,10 @@ import type { TurboModule } from 'react-native';
2
2
  import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
3
3
  export interface Spec extends TurboModule {
4
4
  setup(config: UnsafeObject): Promise<void>;
5
- setSessionId(sessionId: number): Promise<void>;
5
+ setCustomSessionId(customSessionId: string): Promise<void>;
6
+ getCustomSessionId(): Promise<string>;
6
7
  setDeviceId(deviceId: string | null): Promise<void>;
7
8
  setOptOut(optOut: boolean): Promise<void>;
8
- getSessionId(): Promise<number>;
9
9
  start(): Promise<void>;
10
10
  stop(): Promise<void>;
11
11
  flush(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeAmpSessionReplay.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeAmpSessionReplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAQ9E,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;;AAOD,wBAAuE"}
1
+ {"version":3,"file":"NativeAmpSessionReplay.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeAmpSessionReplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAQ9E,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG3C,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;;AAOD,wBAAuE"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.3-video-analytics-5.0";
1
+ export declare const VERSION = "1.2.0-video-analytics-6.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/session-replay-react-native",
3
- "version": "1.0.3-video-analytics-5.0",
3
+ "version": "1.2.0-video-analytics-6.0",
4
4
  "description": "Amplitude Session Replay for React Native",
5
5
  "keywords": [
6
6
  "analytics",
@@ -44,8 +44,12 @@ export interface NativeSessionReplayConfig {
44
44
  sampleRate: number;
45
45
  /** Amplitude server zone for data routing ('US' or 'EU') */
46
46
  serverZone: 'US' | 'EU';
47
- /** Current session identifier for correlating events with recordings */
48
- sessionId: number;
47
+ /**
48
+ * Alphanumeric session identifier — the only session id the native layer
49
+ * tracks. Always sent: the public `sessionId` in its string form, defaulting
50
+ * to `"-1"` when no session is set.
51
+ */
52
+ customSessionId: string;
49
53
  }
50
54
 
51
55
  /**
@@ -63,13 +67,6 @@ export interface NativeSessionReplaySpec {
63
67
  */
64
68
  flush(): Promise<void>;
65
69
 
66
- /**
67
- * Retrieves the current session identifier from the native module.
68
- * @returns Promise resolving to the current session ID number
69
- * @note OLD ARCH: ideally we want to cache that on JS side to avoid bridge overhead
70
- */
71
- getSessionId(): Promise<number>;
72
-
73
70
  /**
74
71
  * Updates the device identifier used for session replay tracking.
75
72
  * @param deviceId - The device identifier string, or null to clear the device ID
@@ -78,11 +75,18 @@ export interface NativeSessionReplaySpec {
78
75
  setDeviceId(deviceId: string | null): Promise<void>;
79
76
 
80
77
  /**
81
- * Updates the session identifier used for session replay tracking.
82
- * @param sessionId - The session identifier number
83
- * @note OLD ARCH: combine those into one method to avoid bridge overhead
78
+ * Updates the alphanumeric session identifier used for session replay tracking.
79
+ * This is the only native session-id setter; the public `setSessionId` maps
80
+ * onto it (as a string) in the JS layer.
81
+ * @param customSessionId - The custom session identifier string
82
+ */
83
+ setCustomSessionId(customSessionId: string): Promise<void>;
84
+
85
+ /**
86
+ * Retrieves the current alphanumeric session identifier from the native module.
87
+ * @returns Promise resolving to the active custom session ID
84
88
  */
85
- setSessionId(sessionId: number): Promise<void>;
89
+ getCustomSessionId(): Promise<string>;
86
90
 
87
91
  /**
88
92
  * Updates whether session replay collection is disabled for the current user.
@@ -81,11 +81,13 @@ export interface SessionReplayConfig {
81
81
  serverZone?: 'EU' | 'US';
82
82
 
83
83
  /**
84
- * Session identifier that matches the session ID sent with Amplitude events
85
- * Must match the Session ID passed as event properties to Amplitude
84
+ * Session identifier that matches the session ID sent with Amplitude events.
85
+ * Must match the Session ID passed as event properties to Amplitude.
86
+ * Accepts a positive integer such as `Date.now()` or an opaque string such as
87
+ * a UUID. Invalid numeric IDs disable recording; pass exact large IDs as strings.
86
88
  * @default -1
87
89
  */
88
- sessionId?: number;
90
+ sessionId?: string | number;
89
91
  }
90
92
 
91
93
  /**
@@ -30,6 +30,42 @@ function normalizeConfig(config: SessionReplayConfig): SessionReplayConfigIntern
30
30
  let isInitialized = false;
31
31
  let logger = createSessionReplayLogger();
32
32
 
33
+ // Only canonical integers (no sign prefix, leading zeros, whitespace or hex)
34
+ // become numbers, so `String(getSessionId())` always equals the native value.
35
+ const CANONICAL_INTEGER = /^(0|-?[1-9]\d*)$/;
36
+
37
+ // A JS `number` is an IEEE-754 double with 53 bits of integer precision, not
38
+ // 64, so integers beyond `Number.MAX_SAFE_INTEGER` stay strings rather than
39
+ // being rounded.
40
+ function fromNativeSessionId(sessionId: string): string | number {
41
+ if (!CANONICAL_INTEGER.test(sessionId)) {
42
+ return sessionId;
43
+ }
44
+ const numericSessionId = Number(sessionId);
45
+ return Number.isSafeInteger(numericSessionId) ? numericSessionId : sessionId;
46
+ }
47
+
48
+ function normalizeNumericSessionId(sessionId: number): string {
49
+ if (sessionId === -1) {
50
+ return '-1';
51
+ }
52
+ if (!Number.isFinite(sessionId) || !Number.isInteger(sessionId) || sessionId <= 0) {
53
+ logger.warn('Invalid numeric sessionId; disabling session replay until a valid ID is set.', sessionId);
54
+ return '-1';
55
+ }
56
+ if (!Number.isSafeInteger(sessionId)) {
57
+ logger.warn(
58
+ 'Unsafe numeric sessionId may already be rounded; forwarding its current value. Pass the exact ID as a string.',
59
+ sessionId,
60
+ );
61
+ }
62
+ return String(sessionId);
63
+ }
64
+
65
+ function toNativeSessionId(sessionId: string | number): string {
66
+ return typeof sessionId === 'number' ? normalizeNumericSessionId(sessionId) : sessionId;
67
+ }
68
+
33
69
  /**
34
70
  * Configure the SDK. Call `start()` explicitly to begin collecting replays.
35
71
  * This function must be called before any other session replay operations.
@@ -37,6 +73,9 @@ let logger = createSessionReplayLogger();
37
73
  * @param config - Configuration object containing API key, device ID, session ID, and other options
38
74
  * @returns Promise that resolves when initialization is complete. Native setup
39
75
  * failures are logged and do not reject the promise.
76
+ * Invalid numeric session IDs disable recording and are logged. Positive unsafe
77
+ * integers are logged and forwarded as their JavaScript value, which may already
78
+ * be rounded. Pass exact large IDs as strings.
40
79
  *
41
80
  * @example
42
81
  * ```typescript
@@ -79,20 +118,27 @@ export async function init(config: SessionReplayConfig): Promise<void> {
79
118
  * Call whenever the session ID changes.
80
119
  * The Session ID you pass to the SDK must match the Session ID sent as event properties to Amplitude.
81
120
  *
82
- * @param sessionId - The new session identifier number
121
+ * Accepts a positive integer such as `Date.now()` or an opaque string such as a
122
+ * UUID. Invalid numeric IDs are logged and mapped to `-1`, disabling recording.
123
+ * Positive integers beyond `Number.MAX_SAFE_INTEGER` are logged and forwarded
124
+ * as their JavaScript value, which may already be rounded; pass exact IDs as strings.
125
+ *
126
+ * @param sessionId - The new session identifier
83
127
  * @returns Promise that resolves when the session ID is updated
84
128
  *
85
129
  * @example
86
130
  * ```typescript
87
131
  * await setSessionId(Date.now());
132
+ * // or an alphanumeric session ID
133
+ * await setSessionId('550e8400-e29b-41d4-a716-446655440000');
88
134
  * ```
89
135
  */
90
- export async function setSessionId(sessionId: number): Promise<void> {
136
+ export async function setSessionId(sessionId: string | number): Promise<void> {
91
137
  if (!isInitialized) {
92
138
  logger.warn('SessionReplay is not initialized');
93
139
  return;
94
140
  }
95
- await NativeSessionReplay.setSessionId(sessionId);
141
+ await NativeSessionReplay.setCustomSessionId(toNativeSessionId(sessionId));
96
142
  }
97
143
 
98
144
  /**
@@ -119,8 +165,15 @@ export async function setDeviceId(deviceId: string | null): Promise<void> {
119
165
 
120
166
  /**
121
167
  * Get the current session identifier from the session replay SDK.
168
+ * Resolves to a number when the active session ID is a safe integer, and to a
169
+ * string otherwise — for example a UUID. `-1` means no session is set.
170
+ *
171
+ * 64-bit integers beyond `Number.MAX_SAFE_INTEGER` (2^53 - 1) resolve to their
172
+ * string form: a JavaScript `number` is a double with 53 bits of integer
173
+ * precision and cannot hold them exactly. A numeric string you set, such as
174
+ * `'123'`, resolves to the number `123`.
122
175
  *
123
- * @returns Promise that resolves to the current session ID number, or null if not initialized
176
+ * @returns Promise that resolves to the current session ID, or null if not initialized
124
177
  *
125
178
  * @example
126
179
  * ```typescript
@@ -130,12 +183,12 @@ export async function setDeviceId(deviceId: string | null): Promise<void> {
130
183
  * }
131
184
  * ```
132
185
  */
133
- export async function getSessionId(): Promise<number | null> {
186
+ export async function getSessionId(): Promise<string | number | null> {
134
187
  if (!isInitialized) {
135
188
  logger.warn('SessionReplay is not initialized');
136
189
  return null;
137
190
  }
138
- return await NativeSessionReplay.getSessionId();
191
+ return fromNativeSessionId(await NativeSessionReplay.getCustomSessionId());
139
192
  }
140
193
 
141
194
  /**
@@ -235,13 +288,14 @@ function nativeConfig(config: ResolvedSessionReplayConfig): NativeSessionReplayC
235
288
  // `undefined` (no user value and no baked-in default), so fall back to
236
289
  // `'medium'`. Strip `privacyConfig` from the spread because the native bridge
237
290
  // only takes a flat `maskLevel` string.
238
- const { privacyConfig, ...rest } = config;
291
+ const { privacyConfig, sessionId, ...rest } = config;
239
292
  const resolvedMaskLevel: NativeSessionReplayConfig['maskLevel'] = privacyConfig.maskLevel ?? 'medium';
240
293
  return {
241
294
  ...rest,
242
295
  logLevel: rest.logLevel as NativeSessionReplayConfig['logLevel'],
243
296
  // TODO(SDKRN-15): Migrate native bridge to accept the full privacyConfig object instead of a flat maskLevel string.
244
297
  maskLevel: resolvedMaskLevel,
298
+ customSessionId: toNativeSessionId(sessionId),
245
299
  };
246
300
  }
247
301
 
@@ -12,10 +12,12 @@ import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
12
12
  // JS callers actually use.
13
13
  export interface Spec extends TurboModule {
14
14
  setup(config: UnsafeObject): Promise<void>;
15
- setSessionId(sessionId: number): Promise<void>;
15
+ // The RN SDK drives session identity through customSessionId only; the numeric
16
+ // session id is mapped onto this (as a string) in the JS layer.
17
+ setCustomSessionId(customSessionId: string): Promise<void>;
18
+ getCustomSessionId(): Promise<string>;
16
19
  setDeviceId(deviceId: string | null): Promise<void>;
17
20
  setOptOut(optOut: boolean): Promise<void>;
18
- getSessionId(): Promise<number>;
19
21
  start(): Promise<void>;
20
22
  stop(): Promise<void>;
21
23
  flush(): Promise<void>;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.0.3-video-analytics-5.0';
1
+ export const VERSION = '1.2.0-video-analytics-6.0';