Skip to content

Commit

Permalink
MacOS support (#2240)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Franco authored May 6, 2022
1 parent 372ef4a commit 41efbfb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 16 additions & 4 deletions ios/RNSentry.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -164,17 +172,17 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event
NSDictionary<NSString *, id> *serializedScope = [scope serialize];
// Scope serializes as 'context' instead of 'contexts' as it does for the event.
NSDictionary<NSString *, id> *tempContexts = [serializedScope valueForKey:@"context"];

NSMutableDictionary<NSString *, id> *user = [NSMutableDictionary new];

NSDictionary<NSString *, id> *tempUser = [serializedScope valueForKey:@"user"];
if (tempUser != nil) {
[user addEntriesFromDictionary:[tempUser valueForKey:@"user"]];
} else {
[user setValue:PrivateSentrySDKOnly.installationID forKey:@"id"];
}
[contexts setValue:user forKey:@"user"];

if (tempContexts != nil) {
[contexts setValue:tempContexts forKey:@"context"];
}
Expand Down Expand Up @@ -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;

Expand All @@ -241,6 +250,9 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event
} else {
resolve(nil);
}
#else
resolve(nil);
#endif
}

RCT_EXPORT_METHOD(fetchNativeRelease:(RCTPromiseResolveBlock)resolve
Expand Down

0 comments on commit 41efbfb

Please sign in to comment.