Skip to content

Fix(fit52)/non fatal crash and async interceptor #1368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RNInstabug.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm}"

s.dependency 'React-Core'
use_instabug!(s)
s.dependency 'Instabug'
end
1 change: 1 addition & 0 deletions examples/default/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target 'InstabugExample' do
config = use_native_modules!
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/bug-INSD-13172_defensive_checks_for_cp_crash_reporting_apis/14.2.0/Instabug.podspec'
# Flags change depending on the env values.
flags = get_default_flags()

Expand Down
14 changes: 8 additions & 6 deletions examples/default/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PODS:
- hermes-engine (0.75.4):
- hermes-engine/Pre-built (= 0.75.4)
- hermes-engine/Pre-built (0.75.4)
- Instabug (14.1.0)
- Instabug (14.2.0)
- instabug-reactnative-ndk (0.1.0):
- DoubleConversion
- glog
Expand Down Expand Up @@ -1624,7 +1624,7 @@ PODS:
- ReactCommon/turbomodule/core
- Yoga
- RNInstabug (14.1.0):
- Instabug (= 14.1.0)
- Instabug
- React-Core
- RNReanimated (3.16.1):
- DoubleConversion
Expand Down Expand Up @@ -1768,6 +1768,7 @@ DEPENDENCIES:
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- Instabug (from `https://ios-releases.instabug.com/custom/bug-INSD-13172_defensive_checks_for_cp_crash_reporting_apis/14.2.0/Instabug.podspec`)
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
- OCMock
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
Expand Down Expand Up @@ -1847,7 +1848,6 @@ SPEC REPOS:
trunk:
- Google-Maps-iOS-Utils
- GoogleMaps
- Instabug
- OCMock
- SocketRocket

Expand All @@ -1865,6 +1865,8 @@ EXTERNAL SOURCES:
hermes-engine:
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
:tag: hermes-2024-08-15-RNv0.75.1-4b3bf912cc0f705b51b71ce1a5b8bd79b93a451b
Instabug:
:podspec: https://ios-releases.instabug.com/custom/bug-INSD-13172_defensive_checks_for_cp_crash_reporting_apis/14.2.0/Instabug.podspec
instabug-reactnative-ndk:
:path: "../node_modules/instabug-reactnative-ndk"
RCT-Folly:
Expand Down Expand Up @@ -2017,7 +2019,7 @@ SPEC CHECKSUMS:
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0
Instabug: 8cbca8974168c815658133e2813f5ac3a36f8e20
Instabug: bbf4326971f2bfff4837ee21380294684edf434b
instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
Expand Down Expand Up @@ -2084,14 +2086,14 @@ SPEC CHECKSUMS:
ReactCommon: 6a952e50c2a4b694731d7682aaa6c79bc156e4ad
RNCClipboard: 2821ac938ef46f736a8de0c8814845dde2dcbdfb
RNGestureHandler: 511250b190a284388f9dd0d2e56c1df76f14cfb8
RNInstabug: 96e629f47c0af2e9455fbcf800d12049f980d873
RNInstabug: b77a5561ccf3806073944bc085a4e4b31f91d31d
RNReanimated: f42a5044d121d68e91680caacb0293f4274228eb
RNScreens: c7ceced6a8384cb9be5e7a5e88e9e714401fd958
RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d
RNVectorIcons: 6382277afab3c54658e9d555ee0faa7a37827136
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6

PODFILE CHECKSUM: 63bf073bef3872df95ea45e7c9c023a331ebb3c3
PODFILE CHECKSUM: d0f5dd57994563cb2f723e9f4877847ff62de5b2

COCOAPODS: 1.14.0
9 changes: 9 additions & 0 deletions ios/RNInstabug/InstabugCrashReportingBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ + (BOOL)requiresMainQueueSetup
userAttributes:(nullable NSDictionary *)userAttributes fingerprint:(nullable NSString *)fingerprint nonFatalExceptionLevel:(IBGNonFatalLevel)nonFatalExceptionLevel
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {

if([fingerprint isKindOfClass:NSNull.class]){
fingerprint = nil;
}

if([userAttributes isKindOfClass:NSNull.class]){
userAttributes = nil;
}

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
[IBGCrashReporting cp_reportNonFatalCrashWithStackTrace:stackTrace level:nonFatalExceptionLevel groupingString:fingerprint userAttributes:userAttributes];
Expand Down
11 changes: 6 additions & 5 deletions src/utils/XhrNetworkInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const getTraceparentHeader = async (networkData: NetworkData) => {
});
};

export const injectHeaders = async (
export const injectHeaders = (
networkData: NetworkData,
featureFlags: {
isW3cExternalTraceIDEnabled: boolean;
Expand Down Expand Up @@ -113,10 +113,7 @@ export const injectHeaders = async (
return injectionMethodology;
};

const identifyCaughtHeader = async (
networkData: NetworkData,
isW3cCaughtHeaderEnabled: boolean,
) => {
const identifyCaughtHeader = (networkData: NetworkData, isW3cCaughtHeaderEnabled: boolean) => {
if (isW3cCaughtHeaderEnabled) {
networkData.w3cCaughtHeader = networkData.requestHeaders.traceparent;
return networkData.requestHeaders.traceparent;
Expand Down Expand Up @@ -314,6 +311,10 @@ export default {
if (traceparent) {
this.setRequestHeader('Traceparent', traceparent);
}
if (this.readyState === this.UNSENT) {
return; // Prevent sending the request if not opened
}

originalXHRSend.apply(this, [data]);
};
isInterceptorEnabled = true;
Expand Down