Skip to content

Commit

Permalink
Merge branch 'master' into feat/1777-no-session-update-for-dropped-ev…
Browse files Browse the repository at this point in the history
…ents

* master:
  Fix: Set the correct OOM event timestamp (#2394)
  test: Fix SentrySerializationTests.testSerializationFailsWithInvalidJSONObject (#2392)
  feat(hybrid-sdks): Add captureScreenshots to PrivateSDKOnly (#2384)
  ci: Increase test timeout for iOS 12 (#2391)
  test: Disable flaky testCrashReportCount1 (#2389)
  test: Disable flaky testSerializeWithUnderlyingNSException (#2387)
  • Loading branch information
kevinrenskers committed Nov 16, 2022
2 parents b124961 + 8442084 commit 8e09fec
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 4 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
unit-tests:
name: Unit ${{matrix.platform}} - Xcode ${{matrix.xcode}} - OS ${{matrix.test-destination-os}}
runs-on: ${{matrix.runs-on}}
timeout-minutes: 15
timeout-minutes: ${{matrix.timeout-minutes}}
needs: build-test-server

strategy:
Expand All @@ -69,42 +69,50 @@ jobs:
platform: 'iOS'
xcode: '13.2.1'
test-destination-os: '12.4'
# This job needs to install the simulator which can take a couple of minutes
timeout-minutes: 25

# iOS 13.7
- runs-on: macos-11
platform: 'iOS'
xcode: '13.2.1'
test-destination-os: '13.7'
timeout-minutes: 15

# iOS 14
- runs-on: macos-11
platform: 'iOS'
xcode: '12.5.1'
test-destination-os: 'latest'
timeout-minutes: 15

# iOS 15
- runs-on: macos-12
platform: 'iOS'
xcode: '13.4.1'
test-destination-os: 'latest'
timeout-minutes: 15

# iOS 16
- runs-on: macos-12
platform: 'iOS'
xcode: '14.0'
test-destination-os: 'latest'
timeout-minutes: 15

# macOS 11
- runs-on: macos-11
platform: 'macOS'
xcode: '12.5.1'
test-destination-os: 'latest'
timeout-minutes: 15

# macOS 12
- runs-on: macos-12
platform: 'macOS'
xcode: '13.4.1'
test-destination-os: 'latest'
timeout-minutes: 15

# Catalyst. We only test the latest version, as
# the risk something breaking on Catalyst and not
Expand All @@ -113,18 +121,21 @@ jobs:
platform: 'Catalyst'
xcode: '13.4.1'
test-destination-os: 'latest'
timeout-minutes: 15

# tvOS 14
- runs-on: macos-11
platform: 'tvOS'
xcode: '12.5.1'
test-destination-os: 'latest'
timeout-minutes: 15

# tvOS 15
- runs-on: macos-12
platform: 'tvOS'
xcode: '13.4.1'
test-destination-os: 'latest'
timeout-minutes: 15

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- Don't increase session's error count for dropped events (#2374)
- Set the correct OOM event timestamp (#2394)

## 7.31.0

Expand Down
6 changes: 6 additions & 0 deletions Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@
<Test
Identifier = "SentryCrashIntegrationTests/testStartUpCrash_CallsFlush_disabled()">
</Test>
<Test
Identifier = "SentryCrashReportStore_Tests/testCrashReportCount1_disabled">
</Test>
<Test
Identifier = "SentryFileIOTrackingIntegrationTests/test_DataConsistency_readPath_disabled()">
</Test>
<Test
Identifier = "SentryFileIOTrackingIntegrationTests/test_DataConsistency_readUrl_disabled()">
</Test>
<Test
Identifier = "SentryNSErrorTests/testSerializeWithUnderlyingNSException_disabled()">
</Test>
<Test
Identifier = "SentryNetworkTrackerIntegrationTests/testGetRequest_SpanCreatedAndBaggageHeaderAdded_disabled()">
</Test>
Expand Down
6 changes: 6 additions & 0 deletions Sources/Sentry/PrivateSentrySDKOnly.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import "SentrySerialization.h"
#import <SentryDependencyContainer.h>
#import <SentryFramesTracker.h>
#import <SentryScreenshot.h>

@implementation PrivateSentrySDKOnly

Expand Down Expand Up @@ -120,6 +121,11 @@ + (SentryScreenFrames *)currentScreenFrames
return [SentryFramesTracker sharedInstance].currentFrames;
}

+ (NSArray<NSData *> *)captureScreenshots
{
return [SentryDependencyContainer.sharedInstance.screenshot takeScreenshots];
}

#endif

@end
7 changes: 7 additions & 0 deletions Sources/Sentry/SentryOutOfMemoryTracker.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import "NSDate+SentryExtras.h"
#import "SentryEvent+Private.h"
#import "SentryFileManager.h"
#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -68,6 +69,12 @@ - (void)start
self.options.maxBreadcrumbs)];
}

NSDictionary *lastBreadcrumb = event.serializedBreadcrumbs.lastObject;
if (lastBreadcrumb && [lastBreadcrumb objectForKey:@"timestamp"]) {
NSString *timestampIso8601String = [lastBreadcrumb objectForKey:@"timestamp"];
event.timestamp = [NSDate sentry_fromIso8601String:timestampIso8601String];
}

SentryException *exception =
[[SentryException alloc] initWithValue:SentryOutOfMemoryExceptionValue
type:SentryOutOfMemoryExceptionType];
Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/include/PrivateSentrySDKOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ typedef void (^SentryOnAppStartMeasurementAvailable)(
@property (class, nonatomic, assign, readonly) BOOL isFramesTrackingRunning;

@property (class, nonatomic, assign, readonly) SentryScreenFrames *currentScreenFrames;

+ (NSArray<NSData *> *)captureScreenshots;
#endif

@end
Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/include/SentryScreenshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable NSArray<NSData *> *)appScreenshots;

- (void)saveScreenShots:(NSString *)path;

- (NSArray<NSData *> *)takeScreenshots;
@end

NS_ASSUME_NONNULL_END
Expand Down
4 changes: 3 additions & 1 deletion Tests/SentryTests/Helper/SentrySerializationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class SentrySerializationTests: XCTestCase {
data = try SentrySerialization.data(withJSONObject: json)
} catch {
exp.fulfill()
XCTAssertEqual(error.localizedDescription, "Event cannot be converted to JSON (Invalid type in JSON write (__NSTaggedDate))")
//Depending of the iOS version, the underlying type of NSDate may change.
//Knowing that we have an error is enough.
XCTAssertTrue(error.localizedDescription.starts(with: "Event cannot be converted to JSON (Invalid type in JSON write"))
}
waitForExpectations(timeout: 1)
XCTAssertNil(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase {
fixture.fileManager.moveBreadcrumbsToPreviousBreadcrumbs()
sut.start()
assertOOMEventSent(expectedBreadcrumbs: 2)

let crashEvent = fixture.client.captureCrashEventInvocations.first?.event
XCTAssertEqual(crashEvent?.timestamp, breadcrumb.timestamp)
}

func testAppOOM_WithOnlyHybridSdkDidBecomeActive() {
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/Protocol/SentryNSErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SentryNSErrorTests: XCTestCase {
XCTAssertEqual(actualUnderlyingError.domain, inputUnderlyingError.domain)
}

func testSerializeWithUnderlyingNSException() {
func testSerializeWithUnderlyingNSException_disabled() {
let inputExceptionName = NSExceptionName.decimalNumberDivideByZeroException
let inputExceptionReason = "test exception reason"
let inputUnderlyingException = NSException(name: inputExceptionName, reason: inputExceptionReason, userInfo: ["some userinfo key": "some userinfo value"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ - (void)testReportStorePathExists
XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:self.reportStorePath]);
}

- (void)testCrashReportCount1
- (void)testCrashReportCount1_disabled
{
[self prepareReportStoreWithPathEnd:@"testCrashReportCount1"];
NSString *reportContents = @"Testing";
Expand Down

0 comments on commit 8e09fec

Please sign in to comment.