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

Bump sentry-cocoa/ fix issue 311 #316

Merged
merged 9 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## Unreleased

### Fixes

- Fix iOS not bundling ([#316](https://github.com/getsentry/sentry-cordova/pull/316))

### Dependencies

- Bump `sentry-wizard` to 3.10.0 ([#316](https://github.com/getsentry/sentry-cordova/pull/316))
- build(ios): Bump `sentry-cocoa` to 8.9.3 ([#316](https://github.com/getsentry/sentry-cordova/pull/316))
- [changelog](https://github.com/getsentry/sentry-cocoa/releases/tag/7.27.1)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.1...8.9.3)

### Warning, breaking changes

- The option `enableOutOfMemoryTracking` is now `enableWatchdogTerminationTracking`. The previous name will keep working but will be removed on a major version.
- Bump minimum supported OS versions to macOS 10.13, iOS 11.

## 1.1.5

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build:
cd src/ios; carthage update --use-xcframeworks; carthage build --use-xcframeworks --no-use-binaries
cd src/ios; carthage update --use-xcframeworks --platform ios; carthage build --use-xcframeworks --no-use-binaries --platform ios; rm -r Carthage/Build/SentrySwiftUI.xcframework
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@sentry/hub": "7.34.0",
"@sentry/types": "7.34.0",
"@sentry/utils": "7.34.0",
"@sentry/wizard": "^1.1.4"
"@sentry/wizard": "^3.10.0"
},
"devDependencies": {
"@sentry-internal/eslint-config-sdk": "7.34.0",
Expand Down
1 change: 1 addition & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<!-- We don't have a resource-file here since this adds it to Xcode project -->

<framework src="src/ios/Carthage/Build/Sentry.xcframework" custom="true" embed="true" />
<framework src="src/ios/Carthage/Build/SentryPrivate.xcframework" custom="true" embed="true" />
</platform>

<!-- browser -->
Expand Down
4 changes: 2 additions & 2 deletions scripts/plugin_add_rm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = function(ctx) {
module.exports = function (ctx) {
try {
if (!ctx.opts.plugins.some(plugin => plugin.includes('sentry-cordova'))) {
return;
}
} catch (e) {}
} catch (e) { }

console.log(`Sentry: running ${ctx.hook} - set SENTRY_SKIP_WIZARD=true to skip this`);

Expand Down
2 changes: 1 addition & 1 deletion src/ios/Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "getsentry/sentry-cocoa" "7.27.1"
github "getsentry/sentry-cocoa" "8.9.3"
lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved
64 changes: 61 additions & 3 deletions src/ios/SentryCordova.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import "SentryCordova.h"
#import <Sentry/Sentry.h>
#import <Sentry/PrivateSentrySDKOnly.h>
#import <Sentry/SentryOptions+HybridSDKs.h>
#import <Cordova/CDVAvailability.h>
@import Sentry;

Expand All @@ -25,8 +26,11 @@ - (void)startWithOptions:(CDVInvokedUrlCommand *)command {

NSError *error = nil;

SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:options
didFailWithError:&error];
SentryOptions* sentryOptions = [self createOptionsWithDictionary:options error:&error];
if (error != nil) {
NSLog(@"%@", error);
return;
}

CDVPluginResult *result =
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
Expand All @@ -35,7 +39,7 @@ - (void)startWithOptions:(CDVInvokedUrlCommand *)command {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
messageAsBool:NO];
} else {
[SentrySDK startWithOptionsObject:sentryOptions];
[SentrySDK startWithOptions:sentryOptions];

// If the app is active/in foreground, and we have not sent the
// SentryHybridSdkDidBecomeActive notification, send it.
Expand All @@ -54,6 +58,60 @@ - (void)startWithOptions:(CDVInvokedUrlCommand *)command {
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}

- (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)options
error: (NSError *_Nonnull *_Nonnull) errorPointer
{
SentryBeforeSendEventCallback beforeSend = ^SentryEvent*(SentryEvent *event) {
// We don't want to send an event after startup that came from a Unhandled JS Exception of Cordova
// Because we sent it already before the app crashed.
if (nil != event.exceptions.firstObject.type &&
[event.exceptions.firstObject.type rangeOfString:@"Unhandled JS Exception"].location != NSNotFound) {
NSLog(@"Unhandled JS Exception");
return nil;
}

[self setEventOriginTag:event];

return event;
};

NSMutableDictionary * mutableOptions =[options mutableCopy];
[mutableOptions setValue:beforeSend forKey:@"beforeSend"];

// remove performance traces sample rate and traces sampler since we don't want to synchronize these configurations
// to the Native SDKs.
// The user could tho initialize the SDK manually and set themselves.
[mutableOptions removeObjectForKey:@"tracesSampleRate"];
[mutableOptions removeObjectForKey:@"tracesSampler"];
[mutableOptions removeObjectForKey:@"enableTracing"];

SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions didFailWithError:errorPointer];
if (*errorPointer != nil) {
return nil;
}
lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved

if ([mutableOptions valueForKey:@"enableNativeCrashHandling"] != nil) {
BOOL enableNativeCrashHandling = [mutableOptions[@"enableNativeCrashHandling"] boolValue];

if (!enableNativeCrashHandling) {
NSMutableArray *integrations = sentryOptions.integrations.mutableCopy;
[integrations removeObject:@"SentryCrashIntegration"];
sentryOptions.integrations = integrations;
}
}

// Enable the App start and Frames tracking measurements
if ([mutableOptions valueForKey:@"enableAutoPerformanceTracing"] != nil) {
BOOL enableAutoPerformanceTracing = [mutableOptions[@"enableAutoPerformanceTracing"] boolValue];
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracing;
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracing;
#endif
}

return sentryOptions;
}

- (void)setEventOriginTag:(SentryEvent *)event {
if (event.sdk != nil) {
NSString *sdkName = event.sdk[@"name"];
Expand Down
10 changes: 10 additions & 0 deletions src/js/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,15 @@ export interface CordovaOptions
*
* @default true
* */
enableWatchdogTerminationTracking?: boolean;

/**
* Enables Out of Memory Tracking for iOS and macCatalyst.
* See the following link for more information and possible restrictions:
* https://docs.sentry.io/platforms/apple/guides/ios/configuration/out-of-memory/
*
* @default true
* @deprecated The method will be removed on a major update, instead, use enableWatchdogTerminationTracking for the same result.
* */
enableOutOfMemoryTracking?: boolean;
}
7 changes: 6 additions & 1 deletion src/js/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export function init(options: Partial<CordovaOptions>): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, deprecation/deprecation
const window = getGlobalObject<{ SENTRY_RELEASE?: { id?: string } }>();

if (options.enableWatchdogTerminationTracking !== null) {
// eslint-disable-next-line deprecation/deprecation
options.enableWatchdogTerminationTracking = options.enableOutOfMemoryTracking;
}

const finalOptions = {
enableAutoSessionTracking: true,
enableOutOfMemoryTracking: true,
enableWatchdogTerminationTracking: true,
...DEFAULT_OPTIONS,
release: window?.SENTRY_RELEASE?.id,
...options,
Expand Down
Loading