Skip to content

Commit

Permalink
Merge branch 'main' into fix/data-rate-report-fully-displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphofmann committed May 7, 2024
2 parents 345a565 + cbd7725 commit d308494
Show file tree
Hide file tree
Showing 54 changed files with 1,038 additions and 355 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}
path: Carthage/
- run: ./scripts/ci-select-xcode.sh 15.2
- run: make build-xcframework-sample
shell: sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ jobs:
# We don't upload codecov for scheduled runs as CodeCov only accepts a limited amount of uploads per commit.
- name: Push code coverage to codecov
id: codecov_1
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # [email protected].0
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # [email protected].1
if: ${{ contains(matrix.platform, 'iOS') && !contains(github.ref, 'release') && github.event.schedule == '' }}
with:
# Although public repos should not have to specify a token there seems to be a bug with the Codecov GH action, which can
Expand All @@ -250,7 +250,7 @@ jobs:
# Sometimes codecov uploads etc can fail. Retry one time to rule out e.g. intermittent network failures.
- name: Push code coverage to codecov
id: codecov_2
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # [email protected].0
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # [email protected].1
if: ${{ steps.codecov_1.outcome == 'failure' && contains(matrix.platform, 'iOS') && !contains(github.ref, 'release') && github.event.schedule == '' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@

## Unreleased

### Features

- Add option to use own NSURLSession for transport (#3811)
- Support sending GraphQL operation names in HTTP breadcrumbs (#3931)

### Fixes

- Ignore SentryFramesTracker thread sanitizer data races (#3922)
- Handle no releaseName in WatchDogTerminationLogic (#3919)
- Fix data race when calling reportFullyDisplayed from a background thread (#3926)
- Stop SessionReplay when closing SDK (#3941)

### Improvements

- Remove not needed lock for logging (#3934)
- Session replay Improvements (#3877)
- Use image average color and text font color to redact session replay
- Removed iOS 16 restriction from session replay
- Performance improvement

## 8.25.0

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Sentry
Copyright (c) 2015-2024 Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
options.debug = true

if #available(iOS 16.0, *) {
options.experimental.sessionReplay = SentryReplayOptions(sessionSampleRate: 0, errorSampleRate: 1, redactAllText: true, redactAllImages: true)
options.experimental.sessionReplay = SentryReplayOptions(sessionSampleRate: 1, errorSampleRate: 1, redactAllText: true, redactAllImages: true)
}

if #available(iOS 15.0, *) {
Expand Down
49 changes: 37 additions & 12 deletions Sentry.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Sources/Configuration/SDK.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ CLANG_CXX_LIBRARY = libc++
// leads to an error Module _SentryPrivate not found in the SentryTests-Swift.h header when import the
// SentryPrivate module with @import _SentryPrivate.
HEADER_SEARCH_PATHS = $(SRCROOT)/Sources/Sentry/include/**

SWIFT_ACTIVE_COMPILATION_CONDITIONS_Debug = DEBUG
SWIFT_ACTIVE_COMPILATION_CONDITIONS_Debug_without_UIKit = DEBUG
SWIFT_ACTIVE_COMPILATION_CONDITIONS_Test = TEST
SWIFT_ACTIVE_COMPILATION_CONDITIONS_TestCI = TESTCI
SWIFT_ACTIVE_COMPILATION_CONDITIONS_Release =
SWIFT_ACTIVE_COMPILATION_CONDITIONS_Release_without_UIKit =
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(SWIFT_ACTIVE_COMPILATION_CONDITIONS_$(CONFIGURATION))
19 changes: 19 additions & 0 deletions Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ NS_SWIFT_NAME(Options)
*/
@property (nonatomic, assign) BOOL enableAutoSessionTracking;

/**
* Whether to attach the top level `operationName` node of HTTP json requests to HTTP breadcrumbs
* @note Default is @c NO.
*/
@property (nonatomic, assign) BOOL enableGraphQLOperationTracking;

/**
* Whether to enable Watchdog Termination tracking or not.
* @note This feature requires the @c SentryCrashIntegration being enabled, otherwise it would
Expand Down Expand Up @@ -358,9 +364,22 @@ NS_SWIFT_NAME(Options)
/**
* Set as delegate on the @c NSURLSession used for all network data-transfer tasks performed by
* Sentry.
*
* @discussion The SDK ignores this option when using @c urlSession.
*/
@property (nullable, nonatomic, weak) id<NSURLSessionDelegate> urlSessionDelegate;

/**
* Use this property, so the transport uses this @c NSURLSession with your configuration for
* sending requests to Sentry.
*
* If not set, the SDK will create a new @c NSURLSession with @c [NSURLSessionConfiguration
* ephemeralSessionConfiguration].
*
* @note Default is @c nil.
*/
@property (nullable, nonatomic, strong) NSURLSession *urlSession;

/**
* Wether the SDK should use swizzling or not.
* @discussion When turned off the following features are disabled: breadcrumbs for touch events and
Expand Down
8 changes: 4 additions & 4 deletions Sources/Sentry/SentryAppStartTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ - (void)buildAppStartMeasurement:(NSDate *)appStartEnd
// With only running this once we know that the process is a new one when the following
// code is executed.
// We need to make sure the block runs on each test instead of only once
# if TEST
# if defined(TEST) || defined(TESTCI) || defined(DEBUG)
block();
# else
static dispatch_once_t once;
[self.dispatchQueue dispatchOnce:&once block:block];
# endif
# endif // defined(TEST) || defined(TESTCI) || defined(DEBUG)
}

/**
Expand Down Expand Up @@ -316,9 +316,9 @@ - (void)stop

[self.framesTracker removeListener:self];

# if TEST
# if defined(TEST) || defined(TESTCI) || defined(DEBUG)
self.isRunning = NO;
# endif
# endif // defined(TEST) || defined(TESTCI) || defined(DEBUG)
}

- (void)dealloc
Expand Down
18 changes: 0 additions & 18 deletions Sources/Sentry/SentryCoreGraphicsHelper.m

This file was deleted.

12 changes: 6 additions & 6 deletions Sources/Sentry/SentryHttpTransport.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueue;
@property (nonatomic, strong) dispatch_group_t dispatchGroup;

#if TEST || TESTCI
#if defined(TEST) || defined(TESTCI) || defined(DEBUG)
@property (nullable, nonatomic, strong) void (^startFlushCallback)(void);
#endif
#endif // defined(TEST) || defined(TESTCI) || defined(DEBUG)

/**
* Relay expects the discarded events split by data category and reason; see
Expand Down Expand Up @@ -161,12 +161,12 @@ - (void)recordLostEvent:(SentryDataCategory)category reason:(SentryDiscardReason
}
}

#if TEST || TESTCI
#if defined(TEST) || defined(TESTCI) || defined(DEBUG)
- (void)setStartFlushCallback:(void (^)(void))callback
{
_startFlushCallback = callback;
}
#endif
#endif // defined(TEST) || defined(TESTCI) || defined(DEBUG)

- (SentryFlushResult)flush:(NSTimeInterval)timeout
{
Expand All @@ -192,11 +192,11 @@ - (SentryFlushResult)flush:(NSTimeInterval)timeout

_isFlushing = YES;
dispatch_group_enter(self.dispatchGroup);
#if TEST || TESTCI
#if defined(TEST) || defined(TESTCI) || defined(DEBUG)
if (self.startFlushCallback != nil) {
self.startFlushCallback();
}
#endif
#endif // defined(TEST) || defined(TESTCI) || defined(DEBUG)
}

[self sendAllCachedEnvelopes];
Expand Down
9 changes: 6 additions & 3 deletions Sources/Sentry/SentryLog.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "SentryLog.h"
#import "SentryInternalCDefines.h"
#import "SentryLevelMapper.h"
#import "SentryLogOutput.h"

Expand Down Expand Up @@ -37,10 +38,12 @@ + (void)logWithMessage:(NSString *)message andLevel:(SentryLevel)level
}

+ (BOOL)willLogAtLevel:(SentryLevel)level
SENTRY_DISABLE_THREAD_SANITIZER(
"The SDK usually configures the log level and isDebug once when it starts. For tests, we "
"accept a data race causing some log messages of the wrong level over using a synchronized "
"block for this method, as it's called frequently in production.")
{
@synchronized(logConfigureLock) {
return isDebug && level != kSentryLevelNone && level >= diagnosticLevel;
}
return isDebug && level != kSentryLevelNone && level >= diagnosticLevel;
}

// Internal and only needed for testing.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryNSProcessInfoWrapper.mm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "SentryNSProcessInfoWrapper.h"

@implementation SentryNSProcessInfoWrapper {
#if TEST
#if defined(TEST) || defined(TESTCI) || defined(DEBUG)
NSString *_executablePath;
}
- (void)setProcessPath:(NSString *)path
Expand All @@ -20,7 +20,7 @@ - (instancetype)init
#else
}
# define SENTRY_BINARY_EXECUTABLE_PATH NSBundle.mainBundle.executablePath;
#endif
#endif // defined(TEST) || defined(TESTCI) || defined(DEBUG)

+ (SentryNSProcessInfoWrapper *)shared
{
Expand Down
19 changes: 19 additions & 0 deletions Sources/Sentry/SentryNetworkTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
@property (nonatomic, assign) BOOL isNetworkTrackingEnabled;
@property (nonatomic, assign) BOOL isNetworkBreadcrumbEnabled;
@property (nonatomic, assign) BOOL isCaptureFailedRequestsEnabled;
@property (nonatomic, assign) BOOL isGraphQLOperationTrackingEnabled;

@end

Expand All @@ -62,6 +63,7 @@ - (instancetype)init
_isNetworkTrackingEnabled = NO;
_isNetworkBreadcrumbEnabled = NO;
_isCaptureFailedRequestsEnabled = NO;
_isGraphQLOperationTrackingEnabled = NO;
}
return self;
}
Expand All @@ -87,12 +89,20 @@ - (void)enableCaptureFailedRequests
}
}

- (void)enableGraphQLOperationTracking
{
@synchronized(self) {
_isGraphQLOperationTrackingEnabled = YES;
}
}

- (void)disable
{
@synchronized(self) {
_isNetworkBreadcrumbEnabled = NO;
_isNetworkTrackingEnabled = NO;
_isCaptureFailedRequestsEnabled = NO;
_isGraphQLOperationTrackingEnabled = NO;
}
}

Expand Down Expand Up @@ -440,6 +450,11 @@ - (void)captureFailedRequests:(NSURLSessionTask *)sessionTask
}

context[@"response"] = response;

if (self.isGraphQLOperationTrackingEnabled) {
context[@"graphql_operation_name"] = [sessionTask getGraphQLOperationName];
}

event.context = context;

[SentrySDK captureEvent:event];
Expand Down Expand Up @@ -489,6 +504,10 @@ - (void)addBreadcrumbForSessionTask:(NSURLSessionTask *)sessionTask
breadcrumbData[@"status_code"] = statusCode;
breadcrumbData[@"reason"] =
[NSHTTPURLResponse localizedStringForStatusCode:responseStatusCode];

if (self.isGraphQLOperationTrackingEnabled) {
breadcrumbData[@"graphql_operation_name"] = [sessionTask getGraphQLOperationName];
}
}

if (urlComponents.query != nil) {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Sentry/SentryNetworkTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ - (BOOL)installWithOptions:(SentryOptions *)options
[SentryNetworkTracker.sharedInstance enableCaptureFailedRequests];
}

if (options.enableGraphQLOperationTracking) {
[SentryNetworkTracker.sharedInstance enableGraphQLOperationTracking];
}

if (shouldEnableNetworkTracking || options.enableNetworkBreadcrumbs
|| options.enableCaptureFailedRequests) {
[SentryNetworkTrackingIntegration swizzleURLSessionTask];
Expand Down
8 changes: 8 additions & 0 deletions Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ - (instancetype)init
_integrations = SentryOptions.defaultIntegrations;
self.sampleRate = SENTRY_DEFAULT_SAMPLE_RATE;
self.enableAutoSessionTracking = YES;
self.enableGraphQLOperationTracking = NO;
self.enableWatchdogTerminationTracking = YES;
self.sessionTrackingIntervalMillis = [@30000 unsignedIntValue];
self.attachStacktrace = YES;
Expand Down Expand Up @@ -353,6 +354,9 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
[self setBool:options[@"enableAutoSessionTracking"]
block:^(BOOL value) { self->_enableAutoSessionTracking = value; }];

[self setBool:options[@"enableGraphQLOperationTracking"]
block:^(BOOL value) { self->_enableGraphQLOperationTracking = value; }];

[self setBool:options[@"enableWatchdogTerminationTracking"]
block:^(BOOL value) { self->_enableWatchdogTerminationTracking = value; }];

Expand Down Expand Up @@ -446,6 +450,10 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
_inAppExcludes = [options[@"inAppExcludes"] filteredArrayUsingPredicate:isNSString];
}

if ([options[@"urlSession"] isKindOfClass:[NSURLSession class]]) {
self.urlSession = options[@"urlSession"];
}

if ([options[@"urlSessionDelegate"] conformsToProtocol:@protocol(NSURLSessionDelegate)]) {
self.urlSessionDelegate = options[@"urlSessionDelegate"];
}
Expand Down
Loading

0 comments on commit d308494

Please sign in to comment.