Skip to content

Commit

Permalink
Merge branch 'master' into feat/extra-controller-breadcrumb-data
Browse files Browse the repository at this point in the history
* master:
  ref: Mark options.sdkInfo as deprecated (#1960)
  feat: Add extra app start span (#1952)
  • Loading branch information
kevinrenskers committed Jul 12, 2022
2 parents 476e262 + 0be48b6 commit beee960
Show file tree
Hide file tree
Showing 26 changed files with 315 additions and 116 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
### Features

- Enhance the UIViewController breadcrumbs with more data (#1945)
- feat: Add extra app start span (#1952)
- Add enableAutoBreadcrumbTracking option (#1958)

### Fixes

- Properly sanitize the event context and SDK information (#1943)
- Don't send error 429 as `network_error` (#1957)
- Deprecate not needed option `sdkInfo` (#1960)

## 7.20.0

Expand Down Expand Up @@ -41,7 +43,7 @@
## 7.18.0

### Features

- Replace tracestate header with baggage (#1867)

### Fixes
Expand Down
1 change: 1 addition & 0 deletions Samples/tvOS-Swift/tvOS-Swift/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct ContentView: View {
Button(action: captureMessageAction) {
Text("Capture Message")
}
.accessibility(identifier: "captureMessageButton")

Button(action: captureUserFeedbackAction) {
Text("Capture User Feedback")
Expand Down
20 changes: 18 additions & 2 deletions Samples/tvOS-Swift/tvOS-SwiftUITests/LaunchUITests.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import XCTest

class LaunchUITests: XCTestCase {

private let app: XCUIApplication = XCUIApplication()

override func setUpWithError() throws {
try super.setUpWithError()
continueAfterFailure = false

app.launch()
}

override func tearDown() {
app.terminate()
super.tearDown()
}

func testLaunch() throws {
let app = XCUIApplication()
app.launch()
XCTAssertTrue(app.buttons["captureMessageButton"].waitForExistence(), "Home Screen doesn't exist.")
}
}

extension XCUIElement {

@discardableResult
func waitForExistence() -> Bool {
self.waitForExistence(timeout: TimeInterval(10))
}
}
4 changes: 4 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
03F84D3727DD4191008FE43F /* SentrySamplingProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F84D3027DD4191008FE43F /* SentrySamplingProfiler.cpp */; };
03F84D3827DD4191008FE43F /* SentryBacktrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F84D3127DD4191008FE43F /* SentryBacktrace.cpp */; };
03F9D37C2819A65C00602916 /* SentryProfilerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */; };
0A1C3592287D7107007D01E3 /* SentryMetaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */; };
15360CCF2432777500112302 /* SentrySessionTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 15360CCE2432777400112302 /* SentrySessionTracker.m */; };
15360CD2243277A000112302 /* SentrySessionTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 15360CD12432779F00112302 /* SentrySessionTracker.h */; };
15360CD62432832400112302 /* SentryAutoSessionTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 15360CD52432832400112302 /* SentryAutoSessionTrackingIntegration.m */; };
Expand Down Expand Up @@ -704,6 +705,7 @@
03F84D3027DD4191008FE43F /* SentrySamplingProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SentrySamplingProfiler.cpp; path = Sources/Sentry/SentrySamplingProfiler.cpp; sourceTree = SOURCE_ROOT; };
03F84D3127DD4191008FE43F /* SentryBacktrace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SentryBacktrace.cpp; path = Sources/Sentry/SentryBacktrace.cpp; sourceTree = SOURCE_ROOT; };
03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfilerTests.mm; sourceTree = "<group>"; };
0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetaTests.swift; sourceTree = "<group>"; };
15360CCE2432777400112302 /* SentrySessionTracker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySessionTracker.m; sourceTree = "<group>"; };
15360CD12432779F00112302 /* SentrySessionTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentrySessionTracker.h; path = include/SentrySessionTracker.h; sourceTree = "<group>"; };
15360CD52432832400112302 /* SentryAutoSessionTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryAutoSessionTrackingIntegration.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1759,6 +1761,7 @@
630C01931EC3402C00C52CEF /* SentryKSCrashReportConverterTests.m */,
63B819131EC352A7002FDF4C /* SentryInterfacesTests.m */,
63EED6C22237989300E02400 /* SentryOptionsTest.m */,
0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */,
632331F52404FFA8008D91D6 /* SentryScopeTests.m */,
7B569DFE2590EEF600B653FC /* SentryScope+Equality.h */,
7B569DFF2590EEF600B653FC /* SentryScope+Equality.m */,
Expand Down Expand Up @@ -3381,6 +3384,7 @@
7BBD18992449DE9D00427C76 /* TestRateLimits.swift in Sources */,
8E4A038625F76A7600000D77 /* TypeMapping.swift in Sources */,
7B04A9AB24EA5F8D00E710B1 /* SentryUserTests.swift in Sources */,
0A1C3592287D7107007D01E3 /* SentryMetaTests.swift in Sources */,
7BA61CCF247EB59500C130A8 /* SentryCrashUUIDConversionTests.swift in Sources */,
7BBD188D2448453600427C76 /* SentryHttpDateParserTests.swift in Sources */,
7BBD18BB24530D2600427C76 /* SentryFileManagerTests.swift in Sources */,
Expand Down
7 changes: 7 additions & 0 deletions Sources/Sentry/PrivateSentrySDKOnly.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import "PrivateSentrySDKOnly.h"
#import "SentryDebugImageProvider.h"
#import "SentryInstallation.h"
#import "SentryMeta.h"
#import "SentrySDK+Private.h"
#import "SentrySerialization.h"
#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -66,6 +67,12 @@ + (void)setAppStartMeasurementHybridSDKMode:(BOOL)appStartMeasurementHybridSDKMo
_appStartMeasurementHybridSDKMode = appStartMeasurementHybridSDKMode;
}

+ (void)setSdkName:(NSString *)sdkName andVersionString:(NSString *)versionString
{
SentryMeta.sdkName = sdkName;
SentryMeta.versionString = versionString;
}

#if SENTRY_HAS_UIKIT

+ (BOOL)framesTrackingMeasurementHybridSDKMode
Expand Down
5 changes: 5 additions & 0 deletions Sources/Sentry/Public/PrivateSentrySDKOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ typedef void (^SentryOnAppStartMeasurementAvailable)(
*/
+ (NSArray<SentryDebugMeta *> *)getDebugImages;

/**
* Override SDK information.
*/
+ (void)setSdkName:(NSString *)sdkName andVersionString:(NSString *)versionString;

@property (class, nullable, nonatomic, copy)
SentryOnAppStartMeasurementAvailable onAppStartMeasurementAvailable;

Expand Down
20 changes: 19 additions & 1 deletion Sources/Sentry/Public/SentryAppStartMeasurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@ SENTRY_NO_INIT
appStartTimestamp:(NSDate *)appStartTimestamp
duration:(NSTimeInterval)duration
runtimeInitTimestamp:(NSDate *)runtimeInitTimestamp
didFinishLaunchingTimestamp:(NSDate *)didFinishLaunchingTimestamp;
didFinishLaunchingTimestamp:(NSDate *)didFinishLaunchingTimestamp
DEPRECATED_MSG_ATTRIBUTE("Use "
"initWithType:appStartTimestamp:duration:mainTimestamp:"
"runtimeInitTimestamp:didFinishLaunchingTimestamp instead.");

/**
* Initializes SentryAppStartMeasurement with the given parameters.
*/
- (instancetype)initWithType:(SentryAppStartType)type
appStartTimestamp:(NSDate *)appStartTimestamp
duration:(NSTimeInterval)duration
runtimeInitTimestamp:(NSDate *)runtimeInitTimestamp
moduleInitializationTimestamp:(NSDate *)moduleInitializationTimestamp
didFinishLaunchingTimestamp:(NSDate *)didFinishLaunchingTimestamp;

/**
* The type of the app start.
Expand All @@ -41,6 +54,11 @@ SENTRY_NO_INIT
*/
@property (readonly, nonatomic, strong) NSDate *runtimeInitTimestamp;

/**
* When application main function is called.
*/
@property (readonly, nonatomic, strong) NSDate *moduleInitializationTimestamp;

/**
* When OS posts UIApplicationDidFinishLaunchingNotification.
*/
Expand Down
4 changes: 3 additions & 1 deletion Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ NS_SWIFT_NAME(Options)

/**
* Describes the Sentry SDK and its configuration used to capture and transmit an event.
* This is reserved for internal use, and will be removed in a future version of the SDK.
*/
@property (nonatomic, readonly, strong) SentrySdkInfo *sdkInfo;
@property (nonatomic, readonly, strong) SentrySdkInfo *sdkInfo DEPRECATED_MSG_ATTRIBUTE(
"This property will be removed in a future version of the SDK");

/**
* The maximum size for each attachment in bytes. Default is 20 MiB / 20 * 1024 * 1024 bytes.
Expand Down
17 changes: 17 additions & 0 deletions Sources/Sentry/SentryAppStartMeasurement.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "SentryAppStartMeasurement.h"
#import "NSDate+SentryExtras.h"
#import <Foundation/Foundation.h>

@implementation SentryAppStartMeasurement
Expand All @@ -8,12 +9,28 @@ - (instancetype)initWithType:(SentryAppStartType)type
duration:(NSTimeInterval)duration
runtimeInitTimestamp:(NSDate *)runtimeInitTimestamp
didFinishLaunchingTimestamp:(NSDate *)didFinishLaunchingTimestamp
{
return [self initWithType:type
appStartTimestamp:appStartTimestamp
duration:duration
runtimeInitTimestamp:runtimeInitTimestamp
moduleInitializationTimestamp:[NSDate dateWithTimeIntervalSince1970:0]
didFinishLaunchingTimestamp:didFinishLaunchingTimestamp];
}

- (instancetype)initWithType:(SentryAppStartType)type
appStartTimestamp:(NSDate *)appStartTimestamp
duration:(NSTimeInterval)duration
runtimeInitTimestamp:(NSDate *)runtimeInitTimestamp
moduleInitializationTimestamp:(NSDate *)moduleInitializationTimestamp
didFinishLaunchingTimestamp:(NSDate *)didFinishLaunchingTimestamp
{
if (self = [super init]) {
_type = type;
_appStartTimestamp = appStartTimestamp;
_duration = duration;
_runtimeInitTimestamp = runtimeInitTimestamp;
_moduleInitializationTimestamp = moduleInitializationTimestamp;
_didFinishLaunchingTimestamp = didFinishLaunchingTimestamp;
}

Expand Down
13 changes: 7 additions & 6 deletions Sources/Sentry/SentryAppStartTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ - (void)buildAppStartMeasurement
appStartDuration = 0;
}

SentryAppStartMeasurement *appStartMeasurement =
[[SentryAppStartMeasurement alloc] initWithType:appStartType
appStartTimestamp:self.sysctl.processStartTimestamp
duration:appStartDuration
runtimeInitTimestamp:runtimeInit
didFinishLaunchingTimestamp:self.didFinishLaunchingTimestamp];
SentryAppStartMeasurement *appStartMeasurement = [[SentryAppStartMeasurement alloc]
initWithType:appStartType
appStartTimestamp:self.sysctl.processStartTimestamp
duration:appStartDuration
runtimeInitTimestamp:runtimeInit
moduleInitializationTimestamp:self.sysctl.moduleInitializationTimestamp
didFinishLaunchingTimestamp:self.didFinishLaunchingTimestamp];

SentrySDK.appStartMeasurement = appStartMeasurement;
};
Expand Down
8 changes: 4 additions & 4 deletions Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ - (void)captureSession:(SentrySession *)session
}

SentryEnvelopeItem *item = [[SentryEnvelopeItem alloc] initWithSession:session];
SentryEnvelopeHeader *envelopeHeader =
[[SentryEnvelopeHeader alloc] initWithId:nil sdkInfo:self.options.sdkInfo traceContext:nil];
SentryEnvelopeHeader *envelopeHeader = [[SentryEnvelopeHeader alloc] initWithId:nil
traceContext:nil];
SentryEnvelope *envelope = [[SentryEnvelope alloc] initWithHeader:envelopeHeader
singleItem:item];
[self captureEnvelope:envelope];
Expand Down Expand Up @@ -591,8 +591,8 @@ - (void)setSdk:(SentryEvent *)event
}

event.sdk = @{
@"name" : self.options.sdkInfo.name,
@"version" : self.options.sdkInfo.version,
@"name" : SentryMeta.sdkName,
@"version" : SentryMeta.versionString,
@"integrations" : integrations
};
}
Expand Down
13 changes: 1 addition & 12 deletions Sources/Sentry/SentryEnvelope.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,23 @@ @implementation SentryEnvelopeHeader
// id can be null if no event in the envelope or attachment related to event
- (instancetype)initWithId:(SentryId *_Nullable)eventId
{
SentrySdkInfo *sdkInfo = [[SentrySdkInfo alloc] initWithName:SentryMeta.sdkName
andVersion:SentryMeta.versionString];
self = [self initWithId:eventId andSdkInfo:sdkInfo];

self = [self initWithId:eventId traceContext:nil];
return self;
}

- (instancetype)initWithId:(SentryId *_Nullable)eventId andSdkInfo:(SentrySdkInfo *_Nullable)sdkInfo
{
return [self initWithId:eventId sdkInfo:sdkInfo traceContext:nil];
}

- (instancetype)initWithId:(nullable SentryId *)eventId
traceContext:(nullable SentryTraceContext *)traceContext
{
SentrySdkInfo *sdkInfo = [[SentrySdkInfo alloc] initWithName:SentryMeta.sdkName
andVersion:SentryMeta.versionString];

self = [self initWithId:eventId sdkInfo:sdkInfo traceContext:traceContext];

return self;
}

- (instancetype)initWithId:(nullable SentryId *)eventId
sdkInfo:(nullable SentrySdkInfo *)sdkInfo
traceContext:(nullable SentryTraceContext *)traceContext
{

if (self = [super init]) {
_eventId = eventId;
_sdkInfo = sdkInfo;
Expand Down
14 changes: 12 additions & 2 deletions Sources/Sentry/SentryMeta.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@ @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 *const versionString = @"7.20.0";
static NSString *const sdkName = @"sentry.cocoa";
static NSString *versionString = @"7.20.0";
static NSString *sdkName = @"sentry.cocoa";

+ (NSString *)versionString
{
return versionString;
}

+ (void)setVersionString:(NSString *)value
{
versionString = value;
}

+ (NSString *)sdkName
{
return sdkName;
}

+ (void)setSdkName:(NSString *)value
{
sdkName = value;
}

@end
14 changes: 11 additions & 3 deletions Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ - (instancetype)init
}

_inAppExcludes = [NSArray new];
_sdkInfo = [[SentrySdkInfo alloc] initWithName:SentryMeta.sdkName
andVersion:SentryMeta.versionString];

// Set default release name
if (nil != infoDict) {
Expand Down Expand Up @@ -303,8 +301,12 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options

// SentrySdkInfo already expects a dictionary with {"sdk": {"name": ..., "value": ...}}
// so we're passing the whole options object.
// Note: we should remove this code once the hybrid SDKs move over to the new
// PrivateSentrySDKOnly setter functions.
if ([options[@"sdk"] isKindOfClass:[NSDictionary class]]) {
_sdkInfo = [[SentrySdkInfo alloc] initWithDict:options orDefaults:_sdkInfo];
SentrySdkInfo *sdkInfo = [[SentrySdkInfo alloc] initWithDict:options];
SentryMeta.versionString = sdkInfo.version;
SentryMeta.sdkName = sdkInfo.name;
}

if (nil != error && nil != *error) {
Expand All @@ -314,6 +316,12 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
}
}

- (SentrySdkInfo *)sdkInfo
{
return [[SentrySdkInfo alloc] initWithName:SentryMeta.sdkName
andVersion:SentryMeta.versionString];
}

- (void)setBool:(id)value block:(void (^)(BOOL))block
{
// Entries in the dictionary can be NSNull. Especially, on React-Native, this can happen.
Expand Down

0 comments on commit beee960

Please sign in to comment.