Skip to content

Commit

Permalink
Merge branch '8.0.0' into fix/2455-appstatemanager-stop
Browse files Browse the repository at this point in the history
* 8.0.0:
  Merge branch 'master' into 8.0.0
  release: 7.31.3
  revert rename of sentryuser (#2462)
  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)

# Conflicts:
#	Tests/SentryTests/Helper/TestNSNotificationCenterWrapper.swift
  • Loading branch information
kevinrenskers committed Nov 29, 2022
2 parents 51f6f0e + 37d8e33 commit 0c82ab9
Show file tree
Hide file tree
Showing 50 changed files with 568 additions and 362 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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ This version adds a dependency on Swift.
- Rename `SentryScope.add(_ crumb:)` to `SentryScope.addBreadcrumb(_ crumb:)` (#2416)
- Rename `SentryScope.add(_ attachment:)` to `SentryScope.addAttachment(_ attachment:)` (#2416)
- Rename `Client` to `SentryClient` (#2403)
- Rename `User` to `SentryUser` (#2403)
- Remove public APIs
- Remove `SentryScope.apply(to:)` (#2416)
- Remove `SentryScope.apply(to:maxBreadcrumb:)` (#2416)
Expand All @@ -43,6 +42,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.

11 changes: 9 additions & 2 deletions Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ViewController: UIViewController {
scope.setTag(value: "swift", key: "language")
scope.setExtra(value: String(describing: self), key: "currentViewController")

let user = SentryUser(userId: "1")
let user = User(userId: "1")
user.email = "tony@example.com"
scope.setUser(user)

Expand All @@ -33,7 +33,7 @@ class ViewController: UIViewController {
}

// Also works
let user = SentryUser(userId: "1")
let user = User(userId: "1")
user.email = "tony1@example.com"
SentrySDK.setUser(user)

Expand Down 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
1 change: 1 addition & 0 deletions Sources/Sentry/Public/SentryUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

NS_ASSUME_NONNULL_BEGIN

NS_SWIFT_NAME(User)
@interface SentryUser : NSObject <SentrySerializable, NSCopying>

/**
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
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryMeta.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ @implementation SentryMeta
// Don't remove the static keyword. If you do the compiler adds the constant name to the global
// symbol table and it might clash with other constants. When keeping the static keyword the
// compiler replaces all occurrences with the value.
static NSString *versionString = @"7.31.2";
static NSString *versionString = @"7.31.3";
static NSString *sdkName = @"sentry.cocoa";

+ (NSString *)versionString
Expand Down
6 changes: 1 addition & 5 deletions Sources/Sentry/include/SentryCrashWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ SENTRY_NO_INIT

- (void)installAsyncHooks;

/**
* It's not really possible to close SentryCrash. Best we can do is to deactivate all the monitors,
* clear the `onCrash` callback installed on the global handler, and a few more minor things.
*/
- (void)close;
- (void)uninstallAsyncHooks;

- (NSDictionary *)systemInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@
IMPLEMENT_REPORT_VALUE_PROPERTY(NAME, NAMEUPPER, TYPE) \
IMPLEMENT_REPORT_KEY_PROPERTY(NAME, NAMEUPPER)

typedef struct {
const char *key;
const char *value;
} ReportField;

typedef struct {
SentryCrashReportWriteCallback userCrashCallback;
int reportFieldsCount;
ReportField *reportFields[0];
} CrashHandlerData;

@interface
SentryCrashInstallation ()

Expand Down Expand Up @@ -84,4 +95,7 @@ SentryCrashInstallation ()
/** Make an absolute key paths from the specified paths. */
- (NSArray *)makeKeyPaths:(NSArray *)keyPaths;

/** Only needed for testing */
- (CrashHandlerData *)g_crashHandlerData;

@end
5 changes: 5 additions & 0 deletions Sources/SentryCrash/Installations/SentryCrashInstallation.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
*/
- (void)install;

/**
* Call this instead of `-[SentryCrash uninstall]`.
*/
- (void)uninstall;

/** Convenience method to call -[SentryCrash sendAllReportsWithCompletion:].
* This method will set the SentryCrash sink and then send all outstanding
* reports.
Expand Down
28 changes: 17 additions & 11 deletions Sources/SentryCrash/Installations/SentryCrashInstallation.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@
/** Max number of properties that can be defined for writing to the report */
#define kMaxProperties 500

typedef struct {
const char *key;
const char *value;
} ReportField;

typedef struct {
SentryCrashReportWriteCallback userCrashCallback;
int reportFieldsCount;
ReportField *reportFields[0];
} CrashHandlerData;

static CrashHandlerData *g_crashHandlerData;

static void
Expand Down Expand Up @@ -199,6 +188,11 @@ - (CrashHandlerData *)crashHandlerData
return (CrashHandlerData *)self.crashHandlerDataBacking.mutableBytes;
}

- (CrashHandlerData *)g_crashHandlerData
{
return g_crashHandlerData;
}

- (SentryCrashInstReportField *)reportFieldForProperty:(NSString *)propertyName
{
SentryCrashInstReportField *field = [self.fields objectForKey:propertyName];
Expand Down Expand Up @@ -298,6 +292,18 @@ - (void)install
}
}

- (void)uninstall
{
SentryCrash *handler = [SentryCrash sharedInstance];
@synchronized(handler) {
if (g_crashHandlerData == self.crashHandlerData) {
g_crashHandlerData = NULL;
handler.onCrash = NULL;
}
[handler uninstall];
}
}

- (void)sendAllReportsWithCompletion:(SentryCrashReportFilterCompletion)onCompletion
{
NSError *error = [self validateProperties];
Expand Down
Loading

0 comments on commit 0c82ab9

Please sign in to comment.