diff --git a/CHANGELOG.md b/CHANGELOG.md index 851b933ca4..9adbd32833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- feat: Support macOS (#2240) by @ospfranco + ## 3.4.2 - fix: Fix cold start appearing again after js bundle reload on Android. #2229 diff --git a/ios/RNSentry.m b/ios/RNSentry.m index f98bcd09fb..eb9e8238b1 100644 --- a/ios/RNSentry.m +++ b/ios/RNSentry.m @@ -90,13 +90,21 @@ + (BOOL)requiresMainQueueSetup { BOOL enableAutoPerformanceTracking = (BOOL)[mutableOptions valueForKey:@"enableAutoPerformanceTracking"]; PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracking; +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracking; +#endif } [SentrySDK startWithOptionsObject:sentryOptions]; +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + BOOL appIsActive = [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive; +#else + BOOL appIsActive = [[NSApplication sharedApplication] isActive]; +#endif + // If the app is active/in foreground, and we have not sent the SentryHybridSdkDidBecomeActive notification, send it. - if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive && !sentHybridSdkDidBecomeActive && sentryOptions.enableAutoSessionTracking) { + if (appIsActive && !sentHybridSdkDidBecomeActive && sentryOptions.enableAutoSessionTracking) { [[NSNotificationCenter defaultCenter] postNotificationName:@"SentryHybridSdkDidBecomeActive" object:nil]; @@ -164,9 +172,9 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event NSDictionary *serializedScope = [scope serialize]; // Scope serializes as 'context' instead of 'contexts' as it does for the event. NSDictionary *tempContexts = [serializedScope valueForKey:@"context"]; - + NSMutableDictionary *user = [NSMutableDictionary new]; - + NSDictionary *tempUser = [serializedScope valueForKey:@"user"]; if (tempUser != nil) { [user addEntriesFromDictionary:[tempUser valueForKey:@"user"]]; @@ -174,7 +182,7 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event [user setValue:PrivateSentrySDKOnly.installationID forKey:@"id"]; } [contexts setValue:user forKey:@"user"]; - + if (tempContexts != nil) { [contexts setValue:tempContexts forKey:@"context"]; } @@ -215,6 +223,7 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event rejecter:(RCTPromiseRejectBlock)reject) { +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST if (PrivateSentrySDKOnly.isFramesTrackingRunning) { SentryScreenFrames *frames = PrivateSentrySDKOnly.currentScreenFrames; @@ -241,6 +250,9 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event } else { resolve(nil); } +#else + resolve(nil); +#endif } RCT_EXPORT_METHOD(fetchNativeRelease:(RCTPromiseResolveBlock)resolve