Skip to content
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

MacOS support #2240

Merged
merged 8 commits into from
May 6, 2022
Merged
Changes from 3 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
22 changes: 18 additions & 4 deletions ios/RNSentry.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,28 @@ + (BOOL)requiresMainQueueSetup {
}
}


ospfranco marked this conversation as resolved.
Show resolved Hide resolved
// Enable the App start and Frames tracking measurements
if ([mutableOptions valueForKey:@"enableAutoPerformanceTracking"] != nil) {
BOOL enableAutoPerformanceTracking = (BOOL)[mutableOptions valueForKey:@"enableAutoPerformanceTracking"];

PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracking;
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracking;
#endif
}


ospfranco marked this conversation as resolved.
Show resolved Hide resolved
[SentrySDK startWithOptionsObject:sentryOptions];

#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
BOOL appIsActive = [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive;
#else
BOOL appIsActive = [[NSApplication sharedApplication] isActive];
marandaneto marked this conversation as resolved.
Show resolved Hide resolved
#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 +174,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 +225,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 +252,9 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event
} else {
resolve(nil);
}
#else
resolve(nil);
#endif
}

RCT_EXPORT_METHOD(fetchNativeRelease:(RCTPromiseResolveBlock)resolve
Expand Down