Skip to content

Commit

Permalink
Merge branch '8.0.0' into fix/2463-increase-SentryCrashMAX_STRINGBUFF…
Browse files Browse the repository at this point in the history
…ERSIZE

* 8.0.0:
  fix: SentryAppStateManager should always stop when closing the SDK (#2460)
  Merge branch 'master' into 8.0.0
  release: 7.31.3
  fix: Reporting crashes when restarting the SDK (#2440)
  Update integration-tests.yml (#2461)
  fix: Core data span status with error (#2439)
  meta: disable swiftlint file length check in TBDBClient.swift (#2435)
  Revert "test: shorten some tests (#2422)" (#2427)
  test: shorten some tests (#2422)
  • Loading branch information
kevinrenskers committed Nov 29, 2022
2 parents e60b0a6 + 65910c9 commit 52f00b2
Show file tree
Hide file tree
Showing 51 changed files with 681 additions and 385 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ jobs:
- name: Download and Apply Patch
run: ./apply-patch.sh "${{ github.event.pull_request.head.sha }}" "${{ github.sha }}" add-sentry-to-alamofire

- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk
- name: Download Firewalk
run: curl "https://github.com/Alamofire/Firewalk/releases/download/0.8.1/firewalk.zip" --output firewalk.zip -L

- name: Unzip Firewalk
run: Unzip "firewalk.zip"

- name: Start Firewalk
run: firewalk &
run: ./firewalk &

- name: Validate Firewalk is running
run: curl http://localhost:8080/
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ This version adds a dependency on Swift.

### Fixes

- Errors shortly after SentrySDK.init now affect the session (#2430)
- Errors shortly after `SentrySDK.init` now affect the session (#2430)
- Use the same default environment for events and sessions (#2447)
- Increase `SentryCrashMAX_STRINGBUFFERSIZE` to reduce the instances where we're dropping a crash due to size limit (#2465)
- `SentryAppStateManager` correctly unsubscribes from `NSNotificationCenter` when closing the SDK (#2460)

### Breaking Changes

Expand Down Expand Up @@ -42,6 +43,13 @@ This version adds a dependency on Swift.
- Rename `SentryOptions.enablePreWarmedAppStartTracking` to `enablePreWarmedAppStartTracing`
- Rename `SentryOptions.enableFileIOTracking` to `enableFileIOTracing`
- Rename `SentryOptions.enableCoreDataTracking` to `enableCoreDataTracing`

## 7.31.3

### Fixes

- Reporting crashes when restarting the SDK (#2440)
- Core data span status with error (#2439)

## 7.31.2

Expand Down
8 changes: 4 additions & 4 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.31.2;
MARKETING_VERSION = 7.31.3;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift";
Expand Down Expand Up @@ -1140,7 +1140,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.31.2;
MARKETING_VERSION = 7.31.3;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift";
Expand Down Expand Up @@ -1785,7 +1785,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.31.2;
MARKETING_VERSION = 7.31.3;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift.Clip";
Expand Down Expand Up @@ -1820,7 +1820,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.31.2;
MARKETING_VERSION = 7.31.3;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift.Clip";
Expand Down
10 changes: 7 additions & 3 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

static let defaultDSN = "https://6cc9bae94def43cab8444a99e0031c28@o447951.ingest.sentry.io/5428557"

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {


static func startSentry() {
// For testing purposes, we want to be able to change the DSN and store it to disk. In a real app, you shouldn't need this behavior.
let dsn = DSNStorage.shared.getDSN() ?? AppDelegate.defaultDSN
DSNStorage.shared.saveDSN(dsn: dsn)
Expand Down Expand Up @@ -45,6 +44,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let httpStatusCodeRange = HttpStatusCodeRange(min: 400, max: 599)
options.failedRequestStatusCodes = [ httpStatusCodeRange ]
}
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

AppDelegate.startSentry()

if #available(iOS 14.0, *) {
metricKit.receiveReports()
Expand Down
62 changes: 38 additions & 24 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,11 @@ class ViewController: UIViewController {
SentrySDK.flush(timeout: 5)
}

@IBAction func close(_ sender: Any) {
SentrySDK.close()
}

@IBAction func startSDK(_ sender: Any) {
AppDelegate.startSentry()
}
}
38 changes: 21 additions & 17 deletions Samples/iOS-Swift/iOS13-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,30 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {

static let defaultDSN = "https://6cc9bae94def43cab8444a99e0031c28@o447951.ingest.sentry.io/5428557"

static func startSentry() {
// For testing purposes, we want to be able to change the DSN and store it to disk. In a real app, you shouldn't need this behavior.
let dsn = DSNStorage.shared.getDSN() ?? AppDelegate.defaultDSN
DSNStorage.shared.saveDSN(dsn: dsn)

SentrySDK.start { options in
options.dsn = dsn
options.beforeSend = { event in
return event
}
options.debug = true
// Sampling 100% - In Production you probably want to adjust this
options.tracesSampleRate = 1.0
options.sessionTrackingIntervalMillis = 5_000
if ProcessInfo.processInfo.arguments.contains("--io.sentry.profiling.enable") {
options.profilesSampleRate = 1
}
}
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// For testing purposes, we want to be able to change the DSN and store it to disk. In a real app, you shouldn't need this behavior.
let dsn = DSNStorage.shared.getDSN() ?? AppDelegate.defaultDSN
DSNStorage.shared.saveDSN(dsn: dsn)

SentrySDK.start { options in
options.dsn = dsn
options.beforeSend = { event in
return event
}
options.debug = true
// Sampling 100% - In Production you probably want to adjust this
options.tracesSampleRate = 1.0
options.sessionTrackingIntervalMillis = 5_000
if ProcessInfo.processInfo.arguments.contains("--io.sentry.profiling.enable") {
options.profilesSampleRate = 1
}
}
AppDelegate.startSentry()

return true
}
Expand Down
2 changes: 1 addition & 1 deletion Sentry.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sentry"
s.version = "7.31.2"
s.version = "7.31.3"
s.summary = "Sentry client for cocoa"
s.homepage = "https://github.com/getsentry/sentry-cocoa"
s.license = "mit"
Expand Down
4 changes: 4 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
7B6D98EB24C6E84F005502FA /* SentryCrashInstallationReporterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D98EA24C6E84F005502FA /* SentryCrashInstallationReporterTests.swift */; };
7B6D98ED24C703F8005502FA /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D98EC24C703F8005502FA /* Async.swift */; };
7B72D23A28D074BC0014798A /* TestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B72D23928D074BC0014798A /* TestExtensions.swift */; };
7B7725D8292F5DC20015BBF9 /* SentryCrashInstallationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7725D7292F5DC20015BBF9 /* SentryCrashInstallationTests.m */; };
7B77BE3527EC8445003C9020 /* SentryDiscardReasonMapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B77BE3427EC8445003C9020 /* SentryDiscardReasonMapper.h */; };
7B77BE3727EC8460003C9020 /* SentryDiscardReasonMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B77BE3627EC8460003C9020 /* SentryDiscardReasonMapper.m */; };
7B7A30C624B48321005A4C6E /* SentryCrashWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7A30C524B48321005A4C6E /* SentryCrashWrapper.h */; };
Expand Down Expand Up @@ -1147,6 +1148,7 @@
7B6D98EA24C6E84F005502FA /* SentryCrashInstallationReporterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashInstallationReporterTests.swift; sourceTree = "<group>"; };
7B6D98EC24C703F8005502FA /* Async.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Async.swift; sourceTree = "<group>"; };
7B72D23928D074BC0014798A /* TestExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestExtensions.swift; sourceTree = "<group>"; };
7B7725D7292F5DC20015BBF9 /* SentryCrashInstallationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashInstallationTests.m; sourceTree = "<group>"; };
7B77BE3427EC8445003C9020 /* SentryDiscardReasonMapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDiscardReasonMapper.h; path = include/SentryDiscardReasonMapper.h; sourceTree = "<group>"; };
7B77BE3627EC8460003C9020 /* SentryDiscardReasonMapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDiscardReasonMapper.m; sourceTree = "<group>"; };
7B7A30C524B48321005A4C6E /* SentryCrashWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryCrashWrapper.h; path = include/SentryCrashWrapper.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2234,6 +2236,7 @@
63FE71F120DA66EA00CDBAE8 /* Container+DeepSearch_Tests.m */,
63FE71F620DA66EB00CDBAE8 /* FileBasedTestCase.h */,
63FE71D920DA66E700CDBAE8 /* FileBasedTestCase.m */,
7B7725D7292F5DC20015BBF9 /* SentryCrashInstallationTests.m */,
D855AD61286ED6A4002573E1 /* SentryCrashTests.m */,
63FE71E220DA66E800CDBAE8 /* NSError+SimpleConstructor_Tests.m */,
63FE71D520DA66E600CDBAE8 /* RFC3339UTFString_Tests.m */,
Expand Down Expand Up @@ -3747,6 +3750,7 @@
7BED3576266F7BFF00EAA70D /* TestSentryCrashWrapper.m in Sources */,
7BC6EC18255C44540059822A /* SentryDebugMetaTests.swift in Sources */,
A811D867248E2770008A41EA /* SentrySystemEventBreadcrumbsTest.swift in Sources */,
7B7725D8292F5DC20015BBF9 /* SentryCrashInstallationTests.m in Sources */,
7B82D54924E2A2D400EE670F /* SentryIdTests.swift in Sources */,
7BD47B4E268F0B470076A663 /* ClearTestState.swift in Sources */,
7B6D98ED24C703F8005502FA /* Async.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Configuration/Sentry.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PRODUCT_NAME = Sentry
CURRENT_PROJECT_VERSION = 7.31.2
CURRENT_PROJECT_VERSION = 7.31.3
INFOPLIST_FILE = Sources/Sentry/Info.plist
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry

Expand Down
60 changes: 32 additions & 28 deletions Sources/Sentry/SentryAppStateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import <SentryCurrentDateProvider.h>
#import <SentryDispatchQueueWrapper.h>
#import <SentryFileManager.h>
#import <SentryNSNotificationCenterWrapper.h>
#import <SentryOptions.h>

#if SENTRY_HAS_UIKIT
Expand All @@ -24,6 +25,7 @@
@property (nonatomic, strong) id<SentryCurrentDateProvider> currentDate;
@property (nonatomic, strong) SentrySysctl *sysctl;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueue;
@property (nonatomic, strong) SentryNSNotificationCenterWrapper *notificationCenterWrapper;
@property (nonatomic) NSInteger startCount;

@end
Expand All @@ -36,6 +38,7 @@ - (instancetype)initWithOptions:(SentryOptions *)options
currentDateProvider:(id<SentryCurrentDateProvider>)currentDateProvider
sysctl:(SentrySysctl *)sysctl
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
notificationCenterWrapper:(SentryNSNotificationCenterWrapper *)notificationCenterWrapper
{
if (self = [super init]) {
self.options = options;
Expand All @@ -44,6 +47,7 @@ - (instancetype)initWithOptions:(SentryOptions *)options
self.currentDate = currentDateProvider;
self.sysctl = sysctl;
self.dispatchQueue = dispatchQueueWrapper;
self.notificationCenterWrapper = notificationCenterWrapper;
self.startCount = 0;
}
return self;
Expand All @@ -54,29 +58,24 @@ - (instancetype)initWithOptions:(SentryOptions *)options
- (void)start
{
if (self.startCount == 0) {
[NSNotificationCenter.defaultCenter
[self.notificationCenterWrapper
addObserver:self
selector:@selector(didBecomeActive)
name:SentryNSNotificationCenterWrapper.didBecomeActiveNotificationName
object:nil];
name:SentryNSNotificationCenterWrapper.didBecomeActiveNotificationName];

[NSNotificationCenter.defaultCenter
addObserver:self
selector:@selector(didBecomeActive)
name:SentryHybridSdkDidBecomeActiveNotificationName
object:nil];
[self.notificationCenterWrapper addObserver:self
selector:@selector(didBecomeActive)
name:SentryHybridSdkDidBecomeActiveNotificationName];

[NSNotificationCenter.defaultCenter
[self.notificationCenterWrapper
addObserver:self
selector:@selector(willResignActive)
name:SentryNSNotificationCenterWrapper.willResignActiveNotificationName
object:nil];
name:SentryNSNotificationCenterWrapper.willResignActiveNotificationName];

[NSNotificationCenter.defaultCenter
[self.notificationCenterWrapper
addObserver:self
selector:@selector(willTerminate)
name:SentryNSNotificationCenterWrapper.willTerminateNotificationName
object:nil];
name:SentryNSNotificationCenterWrapper.willTerminateNotificationName];

[self storeCurrentAppState];
}
Expand All @@ -85,43 +84,48 @@ - (void)start
}

- (void)stop
{
[self stopWithForce:NO];
}

- (void)stopWithForce:(BOOL)forceStop
{
if (self.startCount <= 0) {
return;
}

self.startCount -= 1;
if (forceStop) {
self.startCount = 0;
} else {
self.startCount -= 1;
}

if (self.startCount == 0) {
// Remove the observers with the most specific detail possible, see
// https://developer.apple.com/documentation/foundation/nsnotificationcenter/1413994-removeobserver
[NSNotificationCenter.defaultCenter
[self.notificationCenterWrapper
removeObserver:self
name:SentryNSNotificationCenterWrapper.didBecomeActiveNotificationName
object:nil];
name:SentryNSNotificationCenterWrapper.didBecomeActiveNotificationName];

[NSNotificationCenter.defaultCenter
[self.notificationCenterWrapper
removeObserver:self
name:SentryHybridSdkDidBecomeActiveNotificationName
object:nil];
name:SentryHybridSdkDidBecomeActiveNotificationName];

[NSNotificationCenter.defaultCenter
[self.notificationCenterWrapper
removeObserver:self
name:SentryNSNotificationCenterWrapper.willResignActiveNotificationName
object:nil];
name:SentryNSNotificationCenterWrapper.willResignActiveNotificationName];

[NSNotificationCenter.defaultCenter
[self.notificationCenterWrapper
removeObserver:self
name:SentryNSNotificationCenterWrapper.willTerminateNotificationName
object:nil];
name:SentryNSNotificationCenterWrapper.willTerminateNotificationName];
}
}

- (void)dealloc
{
// In dealloc it's safe to unsubscribe for all, see
// https://developer.apple.com/documentation/foundation/nsnotificationcenter/1413994-removeobserver
[NSNotificationCenter.defaultCenter removeObserver:self];
[self.notificationCenterWrapper removeObserver:self];
}

/**
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/SentryCoreDataTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context
[fetchSpan setDataValue:[NSNumber numberWithInteger:result.count] forKey:@"read_count"];

[fetchSpan
finishWithStatus:error != nil ? kSentrySpanStatusInternalError : kSentrySpanStatusOk];
finishWithStatus:result == nil ? kSentrySpanStatusInternalError : kSentrySpanStatusOk];

SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@",
error == nil ? @"ok" : @"error");
Expand Down Expand Up @@ -91,8 +91,7 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context
BOOL result = original(error);

if (fetchSpan) {
[fetchSpan
finishWithStatus:*error != nil ? kSentrySpanStatusInternalError : kSentrySpanStatusOk];
[fetchSpan finishWithStatus:result ? kSentrySpanStatusOk : kSentrySpanStatusInternalError];

SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@",
*error == nil ? @"ok" : @"error");
Expand Down
4 changes: 3 additions & 1 deletion Sources/Sentry/SentryCrashIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ + (void)sendAllSentryCrashReports
- (void)uninstall
{
if (nil != installation) {
[self.crashAdapter close];
[installation uninstall];
installationToken = 0;
}

[self.crashAdapter uninstallAsyncHooks];

[NSNotificationCenter.defaultCenter removeObserver:self
name:NSCurrentLocaleDidChangeNotification
object:nil];
Expand Down
9 changes: 1 addition & 8 deletions Sources/Sentry/SentryCrashWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,9 @@ - (void)installAsyncHooks
sentrycrash_install_async_hooks();
}

- (void)close
- (void)uninstallAsyncHooks
{
SentryCrash *handler = [SentryCrash sharedInstance];
@synchronized(handler) {
[handler setMonitoring:SentryCrashMonitorTypeNone];
handler.onCrash = NULL;
}

sentrycrash_deactivate_async_hooks();
sentrycrashccd_close();
}

- (NSDictionary *)systemInfo
Expand Down
Loading

0 comments on commit 52f00b2

Please sign in to comment.