@posthog/react-native-plugin 2.9.4 → 2.10.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.
@@ -94,5 +94,5 @@ dependencies {
94
94
  implementation "com.posthog:posthog-android:3.66.0"
95
95
 
96
96
  testImplementation "junit:junit:4.13.2"
97
+ testImplementation "org.json:json:20250517"
97
98
  }
98
-
@@ -11,6 +11,8 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
11
11
  import com.facebook.react.bridge.ReactMethod
12
12
  import com.facebook.react.bridge.ReadableMap
13
13
  import com.facebook.react.bridge.UiThreadUtil
14
+ import com.facebook.react.bridge.WritableArray
15
+ import com.facebook.react.bridge.WritableMap
14
16
  import com.facebook.react.common.JavascriptException
15
17
  import com.facebook.react.modules.core.DeviceEventManagerModule
16
18
  import com.posthog.PostHog
@@ -23,6 +25,11 @@ import com.posthog.internal.PostHogPreferences
23
25
  import com.posthog.internal.PostHogPreferences.Companion.ANONYMOUS_ID
24
26
  import com.posthog.internal.PostHogPreferences.Companion.DISTINCT_ID
25
27
  import com.posthog.internal.PostHogSessionManager
28
+ import java.text.ParseException
29
+ import java.text.SimpleDateFormat
30
+ import java.util.Date
31
+ import java.util.Locale
32
+ import java.util.TimeZone
26
33
  import java.util.UUID
27
34
 
28
35
  class PosthogReactNativePluginModule(
@@ -394,6 +401,54 @@ class PosthogReactNativePluginModule(
394
401
  }
395
402
  }
396
403
 
404
+ /**
405
+ * Capture a fatal JavaScript exception through the native SDK.
406
+ *
407
+ * The JS layer has already run `before_send` and built the final payload; this only hands
408
+ * it to posthog-android. A `$exception` carrying `$exception_level: "fatal"` takes the
409
+ * SDK's fatal path, which writes the record to its own disk queue synchronously before
410
+ * returning — the durability the JS event queue cannot promise while AsyncStorage is still
411
+ * draining. Delivery, retry and the relaunch flush are then the native SDK's job.
412
+ *
413
+ * The JS side drops its own copy of the event when this path is taken, so this must not
414
+ * silently no-op: a rejection tells JS the capture did not happen.
415
+ */
416
+ @ReactMethod
417
+ fun captureFatalException(
418
+ distinctId: String,
419
+ timestamp: String,
420
+ properties: ReadableMap,
421
+ promise: Promise,
422
+ ) {
423
+ try {
424
+ val parsedTimestamp = parseIso8601(timestamp)
425
+ if (parsedTimestamp == null) {
426
+ promise.reject(FATAL_CAPTURE_ERROR_CODE, "captureFatalException: invalid timestamp '$timestamp'")
427
+ return
428
+ }
429
+ // capture() returns silently when the SDK was never set up. JS gives up its own copy of
430
+ // the event before calling this, so a false success would lose the crash without a
431
+ // trace; report it instead.
432
+ if (PostHog.getConfig<PostHogConfig>() == null) {
433
+ promise.reject(FATAL_CAPTURE_ERROR_CODE, "captureFatalException: the native SDK is not set up")
434
+ return
435
+ }
436
+ // ReadableMap.toHashMap() is HashMap<String, Any?>; the native API takes Map<String, Any>?.
437
+ @Suppress("UNCHECKED_CAST")
438
+ val nativeProperties = properties.toHashMap() as Map<String, Any>
439
+ PostHog.capture(
440
+ event = "\$exception",
441
+ distinctId = distinctId.takeIf { it.isNotEmpty() },
442
+ properties = nativeProperties,
443
+ timestamp = parsedTimestamp,
444
+ )
445
+ promise.resolve(null)
446
+ } catch (e: Throwable) {
447
+ logError("captureFatalException", e)
448
+ promise.reject(FATAL_CAPTURE_ERROR_CODE, e)
449
+ }
450
+ }
451
+
397
452
  private fun getMap(
398
453
  map: ReadableMap?,
399
454
  key: String,
@@ -570,6 +625,7 @@ class PosthogReactNativePluginModule(
570
625
  const val DEFAULT_THROTTLE_DELAY_MS = 1000
571
626
 
572
627
  private const val PUSH_ERROR_CODE = "PosthogReactNativePluginError"
628
+ private const val FATAL_CAPTURE_ERROR_CODE = "PosthogReactNativePluginFatalCaptureError"
573
629
  private const val PUSH_IDENTITY_EVENT = "PostHogPushIdentityRequest"
574
630
  private const val PUSH_IDENTITY_REPLY_TTL_MS = 15_000L
575
631
 
@@ -646,6 +702,23 @@ class PosthogReactNativePluginModule(
646
702
  }
647
703
  }
648
704
 
705
+ // The JS layer sends an ISO-8601 UTC timestamp (`Date#toISOString`). Parse it explicitly
706
+ // rather than trusting a locale-dependent default, and treat anything unparseable as a
707
+ // caller error: silently substituting "now" would attribute the crash to the wrong instant.
708
+ internal fun parseIso8601(value: String): Date? {
709
+ if (value.isEmpty()) {
710
+ return null
711
+ }
712
+ val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US)
713
+ format.timeZone = TimeZone.getTimeZone("UTC")
714
+ format.isLenient = false
715
+ return try {
716
+ format.parse(value)
717
+ } catch (_: ParseException) {
718
+ null
719
+ }
720
+ }
721
+
649
722
  private fun hasKey(
650
723
  map: ReadableMap?,
651
724
  key: String,
@@ -43,6 +43,12 @@ RCT_EXTERN_METHOD(addExceptionStep:(NSString)message
43
43
  withResolver:(RCTPromiseResolveBlock)resolve
44
44
  withRejecter:(RCTPromiseRejectBlock)reject)
45
45
 
46
+ RCT_EXTERN_METHOD(captureFatalException:(NSString)distinctId
47
+ withTimestamp:(NSString)timestamp
48
+ withProperties:(NSDictionary)properties
49
+ withResolver:(RCTPromiseResolveBlock)resolve
50
+ withRejecter:(RCTPromiseRejectBlock)reject)
51
+
46
52
  RCT_EXTERN_METHOD(reset:(NSString)distinctId
47
53
  withAnonymousId:(NSString)anonymousId
48
54
  withResolver:(RCTPromiseResolveBlock)resolve
@@ -27,6 +27,26 @@ private func containsFatalJsErrorMarker(_ text: String?) -> Bool {
27
27
  return fatalJsErrorMarkers.contains { text.contains($0) }
28
28
  }
29
29
 
30
+ private let fatalCaptureErrorCode = "PosthogReactNativePluginFatalCaptureError"
31
+
32
+ /// Holds the JS-approved properties for the thread on which the JS layer's own fatal capture
33
+ /// is running, so `beforeSend` can tell that capture apart from a native re-report of the same
34
+ /// crash — and can put back the values native's own enrichment would otherwise win.
35
+ private let jsFatalCaptureKey = "com.posthog.reactnative.jsFatalCapture"
36
+
37
+ private var jsFatalCaptureProperties: [String: Any]? {
38
+ Thread.current.threadDictionary[jsFatalCaptureKey] as? [String: Any]
39
+ }
40
+
41
+ /// The JS layer sends an ISO-8601 UTC timestamp (`Date#toISOString`). Parse it explicitly so
42
+ /// an unparseable value is a caller error rather than a silent substitution of "now", which
43
+ /// would attribute the crash to the wrong instant.
44
+ private let iso8601Formatter: ISO8601DateFormatter = {
45
+ let formatter = ISO8601DateFormatter()
46
+ formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
47
+ return formatter
48
+ }()
49
+
30
50
  private func isReactNativeFatalJsError(_ event: PostHogEvent) -> Bool {
31
51
  guard event.event == "$exception",
32
52
  let exceptionList = event.properties["$exception_list"] as? [[String: Any]]
@@ -246,6 +266,22 @@ public class PosthogReactNativePlugin: RCTEventEmitter {
246
266
  // React Native rethrows fatal JS errors natively (RCTFatalException / ExceptionsManager).
247
267
  // The JS layer already captured them, so drop the native duplicate.
248
268
  config.setBeforeSend { event in
269
+ // The JS layer's own fatal capture is the event we want; only native re-reports
270
+ // of a crash JS already captured are duplicates. Matching the event name as well
271
+ // as the thread-local keeps anything else posthog-ios emits on this thread during
272
+ // the call from having this event's properties written over it.
273
+ if event.event == "$exception", let jsProperties = jsFatalCaptureProperties {
274
+ // `buildProperties` keeps its own value on a key clash (`{ current, _ in
275
+ // current }`), so native's enrichment silently wins over what JS decided —
276
+ // `$process_person_profile` from `personProfiles: 'never'`, or any value the
277
+ // app's `before_send` rewrote. Put the JS-approved values back. Android has
278
+ // the opposite precedence (`putAll` after its own context), so this keeps the
279
+ // two platforms agreeing.
280
+ for (key, value) in jsProperties {
281
+ event.properties[key] = value
282
+ }
283
+ return event
284
+ }
249
285
  if isReactNativeFatalJsError(event) {
250
286
  return nil
251
287
  }
@@ -506,6 +542,55 @@ public class PosthogReactNativePlugin: RCTEventEmitter {
506
542
  resolve(nil)
507
543
  }
508
544
 
545
+ /// Capture a fatal JavaScript exception through the native SDK.
546
+ ///
547
+ /// The JS layer has already run `before_send` and built the final payload; this only
548
+ /// hands it to posthog-ios, whose `capture` writes the record to its own disk queue
549
+ /// synchronously on the calling thread — the durability the JS event queue cannot
550
+ /// promise while AsyncStorage is still draining. Delivery, retry and the relaunch flush
551
+ /// are then the native SDK's job.
552
+ ///
553
+ /// The JS side drops its own copy of the event when this path is taken, so this must not
554
+ /// silently no-op: a rejection tells JS the capture did not happen.
555
+ @objc(captureFatalException:withTimestamp:withProperties:withResolver:withRejecter:)
556
+ func captureFatalException(
557
+ distinctId: String, timestamp: String, properties: [String: Any],
558
+ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
559
+ ) {
560
+ guard let date = iso8601Formatter.date(from: timestamp) else {
561
+ reject(
562
+ fatalCaptureErrorCode,
563
+ "captureFatalException: invalid timestamp '\(timestamp)'", nil
564
+ )
565
+ return
566
+ }
567
+ // capture() returns silently when the SDK is not capturing. `isOptOut()` is true both
568
+ // when it was never set up and when the user opted out; JS gates on both before
569
+ // calling, so either answer here means the event was dropped. It has already given up
570
+ // its own copy, so report the loss rather than resolving successfully.
571
+ guard !PostHogSDK.shared.isOptOut() else {
572
+ reject(
573
+ fatalCaptureErrorCode,
574
+ "captureFatalException: the native SDK is not capturing (not set up, or opted out)", nil
575
+ )
576
+ return
577
+ }
578
+ // `beforeSend` below drops native re-reports of fatal JS errors to avoid duplicating
579
+ // what JS already captured. This event *is* the JS capture, so hand the filter the
580
+ // JS-approved properties for the duration of the call: it passes the event through
581
+ // and restores those values over native's enrichment. A thread-local keeps a
582
+ // concurrent native crash report on another thread subject to the filter as usual.
583
+ Thread.current.threadDictionary[jsFatalCaptureKey] = properties
584
+ defer { Thread.current.threadDictionary.removeObject(forKey: jsFatalCaptureKey) }
585
+ PostHogSDK.shared.capture(
586
+ "$exception",
587
+ distinctId: distinctId.isEmpty ? nil : distinctId,
588
+ properties: properties,
589
+ timestamp: date
590
+ )
591
+ resolve(nil)
592
+ }
593
+
509
594
  @objc(registerPushNotificationToken:withAppId:withResolver:withRejecter:)
510
595
  func registerPushNotificationToken(
511
596
  deviceToken: String, appId: String?, resolve: RCTPromiseResolveBlock,
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.addExceptionStep = addExceptionStep;
7
+ exports.captureFatalException = captureFatalException;
7
8
  exports.capturePushNotificationOpened = capturePushNotificationOpened;
8
9
  exports.default = void 0;
9
10
  exports.endSession = endSession;
@@ -65,6 +66,25 @@ function stopRecording() {
65
66
  function addExceptionStep(message, properties) {
66
67
  return PosthogReactNativePlugin.addExceptionStep(message, properties ?? {});
67
68
  }
69
+
70
+ /**
71
+ * Captures a fatal JS exception through the embedded native SDK.
72
+ *
73
+ * The JS layer has already run `before_send` and built the final payload. Native captures it
74
+ * as a `$exception` with `$exception_level: "fatal"`, which both native SDKs write to their
75
+ * own disk queue synchronously before returning — durability the JS event queue cannot offer
76
+ * while AsyncStorage is still draining. Native then owns delivery, retry and the relaunch
77
+ * flush, so nothing needs recovering on the next launch.
78
+ *
79
+ * `timestamp` is an ISO-8601 UTC string (`Date#toISOString`). The promise rejects if the
80
+ * capture did not happen, because the JS caller drops its own copy of the event when this
81
+ * path is taken.
82
+ *
83
+ * @internal Used by `posthog-react-native`'s fatal handler. Not part of the public API.
84
+ */
85
+ function captureFatalException(distinctId, timestamp, properties) {
86
+ return PosthogReactNativePlugin.captureFatalException(distinctId, timestamp, properties);
87
+ }
68
88
  function registerPushNotificationToken(deviceToken, appId) {
69
89
  return PosthogReactNativePlugin.registerPushNotificationToken(deviceToken, appId);
70
90
  }
@@ -133,6 +153,7 @@ const PostHogReactNativePlugin = {
133
153
  startRecording,
134
154
  stopRecording,
135
155
  addExceptionStep,
156
+ captureFatalException,
136
157
  registerPushNotificationToken,
137
158
  unregisterPushNotificationToken,
138
159
  setOptOut,
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","PosthogReactNativePlugin","NativeModules","Proxy","get","Error","setup","sessionId","sdkOptions","pluginConfig","start","sdkReplayConfig","decideReplayConfig","startSession","endSession","isEnabled","identify","distinctId","anonymousId","reset","startRecording","resumeCurrent","stopRecording","addExceptionStep","message","properties","registerPushNotificationToken","deviceToken","appId","unregisterPushNotificationToken","setOptOut","optOut","capturePushNotificationOpened","PUSH_IDENTITY_EVENT","pushIdentitySubscription","setPushIdentityProvider","provider","remove","emitter","NativeEventEmitter","addListener","request","token","minted","e","console","warn","providePushIdentityToken","requestId","PostHogReactNativePlugin","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,aAAa,GACjB,uFAAuF,GACvFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,wBAAwB,GAAGC,0BAAa,CAACD,wBAAwB,GACnEC,0BAAa,CAACD,wBAAwB,GACtC,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AA8CE,SAASU,KAAKA,CACnBC,SAAiB,EACjBC,UAAuC,EACvCC,YAA4C,GAAG,CAAC,CAAC,EAClC;EACf,OAAOR,wBAAwB,CAACK,KAAK,CAACC,SAAS,EAAEC,UAAU,EAAEC,YAAY,CAAC;AAC5E;AAEO,SAASC,KAAKA,CACnBH,SAAiB,EACjBC,UAAuC,EACvCG,eAA4C,EAC5CC,kBAA+C,EAChC;EACf,OAAOX,wBAAwB,CAACS,KAAK,CAACH,SAAS,EAAEC,UAAU,EAAEG,eAAe,EAAEC,kBAAkB,CAAC;AACnG;AAEO,SAASC,YAAYA,CAACN,SAAiB,EAAiB;EAC7D,OAAON,wBAAwB,CAACY,YAAY,CAACN,SAAS,CAAC;AACzD;AAEO,SAASO,UAAUA,CAAA,EAAkB;EAC1C,OAAOb,wBAAwB,CAACa,UAAU,C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AA4B;AAExD,IAAIC,wBAAyD;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CAACC,QAAqC,EAAQ;EACnFF,wBAAwB,EAAEG,MAAM,CAAC,CAAC;EAClC;EACA;EACA,MAAMC,OAAO,GAAG,IAAIC,+BAAkB,CAACtC,wBAAwB,CAAC;EAChEiC,wBAAwB,GAAGI,OAAO,CAACE,WAAW,CAC5CP,mBAAmB,EACnB,MAAOQ,OAAiE,IAAK;IAC3E,IAAIC,KAAoB,GAAG,IAAI;IAC/B,IAAI;MACF,MAAMC,MAAM,GAAG,MAAMP,QAAQ,CAACK,OAAO,CAACxB,UAAU,EAAEwB,OAAO,CAACb,KAAK,CAAC;MAChEc,KAAK,GAAG,OAAOC,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,IAAI;IACpD,CAAC,CAAC,OAAOC,CAAC,EAAE;MACV;MACAC,OAAO,CAACC,IAAI,CAAC,yCAAyCF,CAAC,mDAAmD,CAAC;IAC7G;IACA,IAAI;MACF,MAAM3C,wBAAwB,CAAC8C,wBAAwB,CAACN,OAAO,CAACO,SAAS,EAAEN,KAAK,CAAC;IACnF,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV;MACAC,OAAO,CAACC,IAAI,CAAC,8DAA8DF,CAAC,EAAE,CAAC;IACjF;EACF,CACF,CAAC;AACH;AA8CA,MAAMK,wBAAwD,GAAG;EAC/D3C,KAAK;EACLI,KAAK;EACLG,YAAY;EACZC,UAAU;EACVC,SAAS;EACTC,QAAQ;EACRG,KAAK;EACLC,cAAc;EACdE,aAAa;EACbC,gBAAgB;EAChBG,6BAA6B;EAC7BG,+BAA+B;EAC/BC,SAAS;EACTE,6BAA6B;EAC7BG;AACF,CAAC;AAAA,IAAAe,QAAA,GAAAC,OAAA,CAAAnD,OAAA,GAEciD,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","PosthogReactNativePlugin","NativeModules","Proxy","get","Error","setup","sessionId","sdkOptions","pluginConfig","start","sdkReplayConfig","decideReplayConfig","startSession","endSession","isEnabled","identify","distinctId","anonymousId","reset","startRecording","resumeCurrent","stopRecording","addExceptionStep","message","properties","captureFatalException","timestamp","registerPushNotificationToken","deviceToken","appId","unregisterPushNotificationToken","setOptOut","optOut","capturePushNotificationOpened","PUSH_IDENTITY_EVENT","pushIdentitySubscription","setPushIdentityProvider","provider","remove","emitter","NativeEventEmitter","addListener","request","token","minted","e","console","warn","providePushIdentityToken","requestId","PostHogReactNativePlugin","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,aAAa,GACjB,uFAAuF,GACvFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,wBAAwB,GAAGC,0BAAa,CAACD,wBAAwB,GACnEC,0BAAa,CAACD,wBAAwB,GACtC,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AA8CE,SAASU,KAAKA,CACnBC,SAAiB,EACjBC,UAAuC,EACvCC,YAA4C,GAAG,CAAC,CAAC,EAClC;EACf,OAAOR,wBAAwB,CAACK,KAAK,CAACC,SAAS,EAAEC,UAAU,EAAEC,YAAY,CAAC;AAC5E;AAEO,SAASC,KAAKA,CACnBH,SAAiB,EACjBC,UAAuC,EACvCG,eAA4C,EAC5CC,kBAA+C,EAChC;EACf,OAAOX,wBAAwB,CAACS,KAAK,CAACH,SAAS,EAAEC,UAAU,EAAEG,eAAe,EAAEC,kBAAkB,CAAC;AACnG;AAEO,SAASC,YAAYA,CAACN,SAAiB,EAAiB;EAC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wD,GAAG;EAC/D7C,KAAK;EACLI,KAAK;EACLG,YAAY;EACZC,UAAU;EACVC,SAAS;EACTC,QAAQ;EACRG,KAAK;EACLC,cAAc;EACdE,aAAa;EACbC,gBAAgB;EAChBG,qBAAqB;EACrBE,6BAA6B;EAC7BG,+BAA+B;EAC/BC,SAAS;EACTE,6BAA6B;EAC7BG;AACF,CAAC;AAAA,IAAAe,QAAA,GAAAC,OAAA,CAAArD,OAAA,GAEcmD,wBAAwB","ignoreList":[]}
@@ -46,6 +46,25 @@ export function stopRecording() {
46
46
  export function addExceptionStep(message, properties) {
47
47
  return PosthogReactNativePlugin.addExceptionStep(message, properties ?? {});
48
48
  }
49
+
50
+ /**
51
+ * Captures a fatal JS exception through the embedded native SDK.
52
+ *
53
+ * The JS layer has already run `before_send` and built the final payload. Native captures it
54
+ * as a `$exception` with `$exception_level: "fatal"`, which both native SDKs write to their
55
+ * own disk queue synchronously before returning — durability the JS event queue cannot offer
56
+ * while AsyncStorage is still draining. Native then owns delivery, retry and the relaunch
57
+ * flush, so nothing needs recovering on the next launch.
58
+ *
59
+ * `timestamp` is an ISO-8601 UTC string (`Date#toISOString`). The promise rejects if the
60
+ * capture did not happen, because the JS caller drops its own copy of the event when this
61
+ * path is taken.
62
+ *
63
+ * @internal Used by `posthog-react-native`'s fatal handler. Not part of the public API.
64
+ */
65
+ export function captureFatalException(distinctId, timestamp, properties) {
66
+ return PosthogReactNativePlugin.captureFatalException(distinctId, timestamp, properties);
67
+ }
49
68
  export function registerPushNotificationToken(deviceToken, appId) {
50
69
  return PosthogReactNativePlugin.registerPushNotificationToken(deviceToken, appId);
51
70
  }
@@ -114,6 +133,7 @@ const PostHogReactNativePlugin = {
114
133
  startRecording,
115
134
  stopRecording,
116
135
  addExceptionStep,
136
+ captureFatalException,
117
137
  registerPushNotificationToken,
118
138
  unregisterPushNotificationToken,
119
139
  setOptOut,
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","LINKING_ERROR","select","ios","default","PosthogReactNativePlugin","Proxy","get","Error","setup","sessionId","sdkOptions","pluginConfig","start","sdkReplayConfig","decideReplayConfig","startSession","endSession","isEnabled","identify","distinctId","anonymousId","reset","startRecording","resumeCurrent","stopRecording","addExceptionStep","message","properties","registerPushNotificationToken","deviceToken","appId","unregisterPushNotificationToken","setOptOut","optOut","capturePushNotificationOpened","PUSH_IDENTITY_EVENT","pushIdentitySubscription","setPushIdentityProvider","provider","remove","emitter","addListener","request","token","minted","e","console","warn","providePushIdentityToken","requestId","PostHogReactNativePlugin"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GACjB,uFAAuF,GACvFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,wBAAwB,GAAGN,aAAa,CAACM,wBAAwB,GACnEN,aAAa,CAACM,wBAAwB,GACtC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AA8CL,OAAO,SAASQ,KAAKA,CACnBC,SAAiB,EACjBC,UAAuC,EACvCC,YAA4C,GAAG,CAAC,CAAC,EAClC;EACf,OAAOP,wBAAwB,CAACI,KAAK,CAACC,SAAS,EAAEC,UAAU,EAAEC,YAAY,CAAC;AAC5E;AAEA,OAAO,SAASC,KAAKA,CACnBH,SAAiB,EACjBC,UAAuC,EACvCG,eAA4C,EAC5CC,kBAA+C,EAChC;EACf,OAAOV,wBAAwB,CAACQ,KAAK,CAACH,SAAS,EAAEC,UAAU,EAAEG,eAAe,EAAEC,kBAAkB,CAAC;AACnG;AAEA,OAAO,SAASC,YAAYA,CAACN,SAAiB,EAAiB;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AC7BG,+BAA+B;EAC/BC,SAAS;EACTE,6BAA6B;EAC7BG;AACF,CAAC;AAED,eAAea,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","LINKING_ERROR","select","ios","default","PosthogReactNativePlugin","Proxy","get","Error","setup","sessionId","sdkOptions","pluginConfig","start","sdkReplayConfig","decideReplayConfig","startSession","endSession","isEnabled","identify","distinctId","anonymousId","reset","startRecording","resumeCurrent","stopRecording","addExceptionStep","message","properties","captureFatalException","timestamp","registerPushNotificationToken","deviceToken","appId","unregisterPushNotificationToken","setOptOut","optOut","capturePushNotificationOpened","PUSH_IDENTITY_EVENT","pushIdentitySubscription","setPushIdentityProvider","provider","remove","emitter","addListener","request","token","minted","e","console","warn","providePushIdentityToken","requestId","PostHogReactNativePlugin"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GACjB,uFAAuF,GACvFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,wBAAwB,GAAGN,aAAa,CAACM,wBAAwB,GACnEN,aAAa,CAACM,wBAAwB,GACtC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AA8CL,OAAO,SAASQ,KAAKA,CACnBC,SAAiB,EACjBC,UAAuC,EACvCC,YAA4C,GAAG,CAAC,CAAC,EAClC;EACf,OAAOP,wBAAwB,CAACI,KAAK,CAACC,SAAS,EAAEC,UAAU,EAAEC,YAAY,CAAC;AAC5E;AAEA,OAAO,SAASC,KAAKA,CACnBH,SAAiB,EACjBC,UAAuC,EACvCG,eAA4C,EAC5CC,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AC7G;IACA,IAAI;MACF,MAAM3C,wBAAwB,CAAC8C,wBAAwB,CAACN,OAAO,CAACO,SAAS,EAAEN,KAAK,CAAC;IACnF,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV;MACAC,OAAO,CAACC,IAAI,CAAC,8DAA8DF,CAAC,EAAE,CAAC;IACjF;EACF,CACF,CAAC;AACH;AAoDA,MAAMK,wBAAwD,GAAG;EAC/D5C,KAAK;EACLI,KAAK;EACLG,YAAY;EACZC,UAAU;EACVC,SAAS;EACTC,QAAQ;EACRG,KAAK;EACLC,cAAc;EACdE,aAAa;EACbC,gBAAgB;EAChBG,qBAAqB;EACrBE,6BAA6B;EAC7BG,+BAA+B;EAC/BC,SAAS;EACTE,6BAA6B;EAC7BG;AACF,CAAC;AAED,eAAea,wBAAwB","ignoreList":[]}
@@ -52,6 +52,22 @@ export declare function reset(distinctId: string, anonymousId: string): Promise<
52
52
  export declare function startRecording(resumeCurrent: boolean): Promise<void>;
53
53
  export declare function stopRecording(): Promise<void>;
54
54
  export declare function addExceptionStep(message: string, properties?: PostHogReactNativePluginMap): Promise<void>;
55
+ /**
56
+ * Captures a fatal JS exception through the embedded native SDK.
57
+ *
58
+ * The JS layer has already run `before_send` and built the final payload. Native captures it
59
+ * as a `$exception` with `$exception_level: "fatal"`, which both native SDKs write to their
60
+ * own disk queue synchronously before returning — durability the JS event queue cannot offer
61
+ * while AsyncStorage is still draining. Native then owns delivery, retry and the relaunch
62
+ * flush, so nothing needs recovering on the next launch.
63
+ *
64
+ * `timestamp` is an ISO-8601 UTC string (`Date#toISOString`). The promise rejects if the
65
+ * capture did not happen, because the JS caller drops its own copy of the event when this
66
+ * path is taken.
67
+ *
68
+ * @internal Used by `posthog-react-native`'s fatal handler. Not part of the public API.
69
+ */
70
+ export declare function captureFatalException(distinctId: string, timestamp: string, properties: PostHogReactNativePluginMap): Promise<void>;
55
71
  export declare function registerPushNotificationToken(deviceToken: string, appId: string | null): Promise<void>;
56
72
  export declare function unregisterPushNotificationToken(): Promise<void>;
57
73
  /**
@@ -89,6 +105,7 @@ export interface PostHogReactNativePluginModule {
89
105
  startRecording: (resumeCurrent: boolean) => Promise<void>;
90
106
  stopRecording: () => Promise<void>;
91
107
  addExceptionStep: (message: string, properties?: PostHogReactNativePluginMap) => Promise<void>;
108
+ captureFatalException: (distinctId: string, timestamp: string, properties: PostHogReactNativePluginMap) => Promise<void>;
92
109
  registerPushNotificationToken: (deviceToken: string, appId: string | null) => Promise<void>;
93
110
  unregisterPushNotificationToken: () => Promise<void>;
94
111
  setOptOut: (optOut: boolean) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAoBA,MAAM,MAAM,2BAA2B,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAEhE,MAAM,WAAW,2CAA2C;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,2BAA2B,CAAA;IAC7C,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;CACjD;AAED,MAAM,WAAW,4CAA4C;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,2CAA2C;IAC1D,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,cAAc,CAAC,EAAE,4CAA4C,CAAA;CAC9D;AAED,MAAM,WAAW,kCAAkC;IACjD,oCAAoC,CAAC,EAAE,OAAO,CAAA;IAC9C,6BAA6B,CAAC,EAAE,OAAO,CAAA;IACvC;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAA;CACtC;AAED,MAAM,WAAW,uCAAuC;IACtD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EA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EAAE,CAAC,UAAU,EAAE,2BAA2B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEzF,uBAAuB,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,IAAI,CAAA;CACzE;AAED,QAAA,MAAM,wBAAwB,EAAE,8BAiB/B,CAAA;eAEc,wBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAME"}
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../../vitest.config.ts"],"names":[],"mappings":""}
@@ -52,6 +52,22 @@ export declare function reset(distinctId: string, anonymousId: string): Promise<
52
52
  export declare function startRecording(resumeCurrent: boolean): Promise<void>;
53
53
  export declare function stopRecording(): Promise<void>;
54
54
  export declare function addExceptionStep(message: string, properties?: PostHogReactNativePluginMap): Promise<void>;
55
+ /**
56
+ * Captures a fatal JS exception through the embedded native SDK.
57
+ *
58
+ * The JS layer has already run `before_send` and built the final payload. Native captures it
59
+ * as a `$exception` with `$exception_level: "fatal"`, which both native SDKs write to their
60
+ * own disk queue synchronously before returning — durability the JS event queue cannot offer
61
+ * while AsyncStorage is still draining. Native then owns delivery, retry and the relaunch
62
+ * flush, so nothing needs recovering on the next launch.
63
+ *
64
+ * `timestamp` is an ISO-8601 UTC string (`Date#toISOString`). The promise rejects if the
65
+ * capture did not happen, because the JS caller drops its own copy of the event when this
66
+ * path is taken.
67
+ *
68
+ * @internal Used by `posthog-react-native`'s fatal handler. Not part of the public API.
69
+ */
70
+ export declare function captureFatalException(distinctId: string, timestamp: string, properties: PostHogReactNativePluginMap): Promise<void>;
55
71
  export declare function registerPushNotificationToken(deviceToken: string, appId: string | null): Promise<void>;
56
72
  export declare function unregisterPushNotificationToken(): Promise<void>;
57
73
  /**
@@ -89,6 +105,7 @@ export interface PostHogReactNativePluginModule {
89
105
  startRecording: (resumeCurrent: boolean) => Promise<void>;
90
106
  stopRecording: () => Promise<void>;
91
107
  addExceptionStep: (message: string, properties?: PostHogReactNativePluginMap) => Promise<void>;
108
+ captureFatalException: (distinctId: string, timestamp: string, properties: PostHogReactNativePluginMap) => Promise<void>;
92
109
  registerPushNotificationToken: (deviceToken: string, appId: string | null) => Promise<void>;
93
110
  unregisterPushNotificationToken: () => Promise<void>;
94
111
  setOptOut: (optOut: boolean) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAoBA,MAAM,MAAM,2BAA2B,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAEhE,MAAM,WAAW,2CAA2C;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,2BAA2B,CAAA;IAC7C,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;CACjD;AAED,MAAM,WAAW,4CAA4C;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,2CAA2C;IAC1D,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,cAAc,CAAC,EAAE,4CAA4C,CAAA;CAC9D;AAED,MAAM,WAAW,kCAAkC;IACjD,oCAAoC,CAAC,EAAE,OAAO,CAAA;IAC9C,6BAA6B,CAAC,EAAE,OAAO,CAAA;IACvC;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAA;CACtC;AAED,MAAM,WAAW,uCAAuC;IACtD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,2CAA2C,CAAA;IAC3D,aAAa,CAAC,EAAE,2CAA2C,CAA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IAAI,CAAA;CACzE;AAED,QAAA,MAAM,wBAAwB,EAAE,8BAiB/B,CAAA;eAEc,wBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAME"}
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../../vitest.config.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/react-native-plugin",
3
- "version": "2.9.4",
3
+ "version": "2.10.0",
4
4
  "description": "PostHog React Native plugin for iOS and Android integrations",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -62,7 +62,7 @@
62
62
  "react": "18.3.1",
63
63
  "react-native": "0.75.3",
64
64
  "react-native-builder-bob": "^0.30.2",
65
- "typescript": "5.8.2",
65
+ "typescript": "7.0.2",
66
66
  "vitest": "^1.6.1"
67
67
  },
68
68
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -116,6 +116,29 @@ export function addExceptionStep(message: string, properties?: PostHogReactNativ
116
116
  return PosthogReactNativePlugin.addExceptionStep(message, properties ?? {})
117
117
  }
118
118
 
119
+ /**
120
+ * Captures a fatal JS exception through the embedded native SDK.
121
+ *
122
+ * The JS layer has already run `before_send` and built the final payload. Native captures it
123
+ * as a `$exception` with `$exception_level: "fatal"`, which both native SDKs write to their
124
+ * own disk queue synchronously before returning — durability the JS event queue cannot offer
125
+ * while AsyncStorage is still draining. Native then owns delivery, retry and the relaunch
126
+ * flush, so nothing needs recovering on the next launch.
127
+ *
128
+ * `timestamp` is an ISO-8601 UTC string (`Date#toISOString`). The promise rejects if the
129
+ * capture did not happen, because the JS caller drops its own copy of the event when this
130
+ * path is taken.
131
+ *
132
+ * @internal Used by `posthog-react-native`'s fatal handler. Not part of the public API.
133
+ */
134
+ export function captureFatalException(
135
+ distinctId: string,
136
+ timestamp: string,
137
+ properties: PostHogReactNativePluginMap
138
+ ): Promise<void> {
139
+ return PosthogReactNativePlugin.captureFatalException(distinctId, timestamp, properties)
140
+ }
141
+
119
142
  export function registerPushNotificationToken(deviceToken: string, appId: string | null): Promise<void> {
120
143
  return PosthogReactNativePlugin.registerPushNotificationToken(deviceToken, appId)
121
144
  }
@@ -214,6 +237,12 @@ export interface PostHogReactNativePluginModule {
214
237
 
215
238
  addExceptionStep: (message: string, properties?: PostHogReactNativePluginMap) => Promise<void>
216
239
 
240
+ captureFatalException: (
241
+ distinctId: string,
242
+ timestamp: string,
243
+ properties: PostHogReactNativePluginMap
244
+ ) => Promise<void>
245
+
217
246
  registerPushNotificationToken: (deviceToken: string, appId: string | null) => Promise<void>
218
247
 
219
248
  unregisterPushNotificationToken: () => Promise<void>
@@ -236,6 +265,7 @@ const PostHogReactNativePlugin: PostHogReactNativePluginModule = {
236
265
  startRecording,
237
266
  stopRecording,
238
267
  addExceptionStep,
268
+ captureFatalException,
239
269
  registerPushNotificationToken,
240
270
  unregisterPushNotificationToken,
241
271
  setOptOut,