Skip to content

Commit

Permalink
Merge branch 'main' into feat/replay
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Jun 18, 2024
2 parents 41f816a + 148f924 commit 834780e
Show file tree
Hide file tree
Showing 31 changed files with 959 additions and 280 deletions.
58 changes: 56 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,59 @@

Access to Mobile Replay is limited to early access orgs on Sentry. If you're interested, [sign up for the waitlist](https://sentry.io/lp/mobile-replay-beta/)

## 5.24.1

### Fixes

- App Start Native Frames can start with zeroed values ([#3881](https://github.com/getsentry/sentry-react-native/pull/3881))

### Dependencies

- Bump Cocoa SDK from v8.28.0 to v8.29.1 ([#3890](https://github.com/getsentry/sentry-react-native/pull/3890))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8291)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.28.0...8.29.1)

## 5.24.0

### Features

- Add native application start spans ([#3855](https://github.com/getsentry/sentry-react-native/pull/3855), [#3884](https://github.com/getsentry/sentry-react-native/pull/3884))
- This doesn't change the app start measurement length, but add child spans (more detail) into the existing app start span
- Added JS Bundle Execution start information to the application start measurements ([#3857](https://github.com/getsentry/sentry-react-native/pull/3857))

### Fixes

- Add more expressive debug logs to Native Frames Integration ([#3880](https://github.com/getsentry/sentry-react-native/pull/3880))
- Add missing tracing integrations when using `client.init()` ([#3882](https://github.com/getsentry/sentry-react-native/pull/3882))
- Ensure `sentry-cli` doesn't trigger Xcode `error:` prefix ([#3887](https://github.com/getsentry/sentry-react-native/pull/3887))
- Fixes `--allow-failure` failing Xcode builds

### Dependencies

- Bump Cocoa SDK from v8.27.0 to v8.28.0 ([#3866](https://github.com/getsentry/sentry-react-native/pull/3866))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8280)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.27.0...8.28.0)
- Bump Android SDK from v7.8.0 to v7.10.0 ([#3805](https://github.com/getsentry/sentry-react-native/pull/3805))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7100)
- [diff](https://github.com/getsentry/sentry-java/compare/7.8.0...7.10.0)
- Bump JavaScript SDK from v7.113.0 to v7.117.0 ([#3806](https://github.com/getsentry/sentry-react-native/pull/3806))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/v7/CHANGELOG.md#71170)
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.113.0...7.117.0)

## 5.23.1

### Fixes

- Fix failing iOS builds due to missing SentryLevel ([#3854](https://github.com/getsentry/sentry-react-native/pull/3854))
- Add missing logs to dropped App Start spans ([#3861](https://github.com/getsentry/sentry-react-native/pull/3861))
- Make all options of `startTimeToInitialDisplaySpan` optional ([#3867](https://github.com/getsentry/sentry-react-native/pull/3867))
- Add Span IDs to Time to Display debug logs ([#3868](https://github.com/getsentry/sentry-react-native/pull/3868))
- Use TTID end timestamp when TTFD should be updated with an earlier timestamp ([#3869](https://github.com/getsentry/sentry-react-native/pull/3869))

## 5.23.0

This release does *not* build on iOS. Please use `5.23.1` or newer.

### Features

- Functional integrations ([#3814](https://github.com/getsentry/sentry-react-native/pull/3814))
Expand Down Expand Up @@ -638,7 +691,7 @@ This release is compatible with `[email protected]` and newer.
});
```

Read more at https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7690
Read more at <https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7690>

- Report current screen in `contexts.app.view_names` ([#3339](https://github.com/getsentry/sentry-react-native/pull/3339))

Expand Down Expand Up @@ -1029,6 +1082,7 @@ This has been fixed in [version `5.9.1`](https://github.com/getsentry/sentry-rea
## 5.4.0

### Features

- Add TS 4.1 typings ([#2995](https://github.com/getsentry/sentry-react-native/pull/2995))
- TS 3.8 are present and work automatically with older projects
- Add CPU Info to Device Context ([#2984](https://github.com/getsentry/sentry-react-native/pull/2984))
Expand Down Expand Up @@ -2676,7 +2730,7 @@ We are looking into ways making this more stable and plan to re-enable it again

## v0.23.2

- Fixed #228 again ¯\\_(ツ)_
- Fixed #228 again ¯\\*(ツ)*

## v0.23.1

Expand Down
2 changes: 1 addition & 1 deletion RNSentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pod::Spec.new do |s|
s.preserve_paths = '*.js'

s.dependency 'React-Core'
s.dependency 'Sentry/HybridSDK', '8.27.0'
s.dependency 'Sentry/HybridSDK', '8.29.1'

s.source_files = 'ios/**/*.{h,m,mm}'
s.public_header_files = 'ios/RNSentry.h'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
330F308C2C0F3840002A0D4E /* RNSentryBreadcrumbTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 330F308B2C0F3840002A0D4E /* RNSentryBreadcrumbTests.m */; };
33958C692BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33958C682BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m */; };
33AFDFED2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33AFDFEC2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m */; };
33AFDFF12B8D15E500AAB120 /* RNSentryDependencyContainerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33AFDFF02B8D15E500AAB120 /* RNSentryDependencyContainerTests.m */; };
Expand All @@ -16,6 +17,8 @@

/* Begin PBXFileReference section */
1482D5685A340AB93348A43D /* Pods-RNSentryCocoaTesterTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSentryCocoaTesterTests.release.xcconfig"; path = "Target Support Files/Pods-RNSentryCocoaTesterTests/Pods-RNSentryCocoaTesterTests.release.xcconfig"; sourceTree = "<group>"; };
330F308B2C0F3840002A0D4E /* RNSentryBreadcrumbTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNSentryBreadcrumbTests.m; sourceTree = "<group>"; };
330F308D2C0F385A002A0D4E /* RNSentryBreadcrumb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSentryBreadcrumb.h; path = ../ios/RNSentryBreadcrumb.h; sourceTree = "<group>"; };
3360898D29524164007C7730 /* RNSentryCocoaTesterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNSentryCocoaTesterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
338739072A7D7D2800950DDD /* RNSentryTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNSentryTests.h; sourceTree = "<group>"; };
33958C672BFCEF5A00AD1FB6 /* RNSentryOnDrawReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSentryOnDrawReporter.h; path = ../ios/RNSentryOnDrawReporter.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -80,13 +83,15 @@
33AFDFF02B8D15E500AAB120 /* RNSentryDependencyContainerTests.m */,
33AFDFF22B8D15F600AAB120 /* RNSentryDependencyContainerTests.h */,
33958C682BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m */,
330F308B2C0F3840002A0D4E /* RNSentryBreadcrumbTests.m */,
);
path = RNSentryCocoaTesterTests;
sourceTree = "<group>";
};
33AFE0122B8F319000AAB120 /* RNSentry */ = {
isa = PBXGroup;
children = (
330F308D2C0F385A002A0D4E /* RNSentryBreadcrumb.h */,
33958C672BFCEF5A00AD1FB6 /* RNSentryOnDrawReporter.h */,
33AFE0132B8F31AF00AAB120 /* RNSentryDependencyContainer.h */,
);
Expand Down Expand Up @@ -204,6 +209,7 @@
33AFDFF12B8D15E500AAB120 /* RNSentryDependencyContainerTests.m in Sources */,
33F58AD02977037D008F60EA /* RNSentryTests.mm in Sources */,
33958C692BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m in Sources */,
330F308C2C0F3840002A0D4E /* RNSentryBreadcrumbTests.m in Sources */,
33AFDFED2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#import <XCTest/XCTest.h>
#import "RNSentryBreadcrumb.h"
@import Sentry;

@interface RNSentryBreadcrumbTests : XCTestCase

@end

@implementation RNSentryBreadcrumbTests

- (void)testGeneratesSentryBreadcrumbFromNSDictionary
{
SentryBreadcrumb* actualCrumb = [RNSentryBreadcrumb from:@{
@"level": @"error",
@"category": @"testCategory",
@"type": @"testType",
@"message": @"testMessage",
@"data": @{
@"test": @"data"
}
}];

XCTAssertEqual(actualCrumb.level, kSentryLevelError);
XCTAssertEqual(actualCrumb.category, @"testCategory");
XCTAssertEqual(actualCrumb.type, @"testType");
XCTAssertEqual(actualCrumb.message, @"testMessage");
XCTAssertTrue([actualCrumb.data isKindOfClass:[NSDictionary class]]);
XCTAssertEqual(actualCrumb.data[@"test"], @"data");
}

- (void)testUsesInfoAsDefaultSentryLevel
{
SentryBreadcrumb* actualCrumb = [RNSentryBreadcrumb from:@{
@"message": @"testMessage",
}];

XCTAssertEqual(actualCrumb.level, kSentryLevelInfo);
}

@end
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ android {

dependencies {
implementation 'com.facebook.react:react-native:+'
api 'io.sentry:sentry-android:7.9.0-alpha.1'
api 'io.sentry:sentry-android:7.11.0-alpha.2'
}
30 changes: 7 additions & 23 deletions android/src/main/java/io/sentry/react/RNSentryModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class RNSentryModuleImpl {
private FrameMetricsAggregator frameMetricsAggregator = null;
private boolean androidXAvailable;

private static boolean didFetchAppStart;
private static boolean hasFetchedAppStart;

// 700ms to constitute frozen frames.
private static final int FROZEN_FRAME_THRESHOLD = 700;
Expand Down Expand Up @@ -369,28 +369,17 @@ public void fetchNativeRelease(Promise promise) {
}

public void fetchNativeAppStart(Promise promise) {
final AppStartMetrics appStartInstance = AppStartMetrics.getInstance();
final SentryDate appStartTime = appStartInstance.getAppStartTimeSpan().getStartTimestamp();
final boolean isColdStart = appStartInstance.getAppStartType() == AppStartMetrics.AppStartType.COLD;
final Map<String, Object> measurement = InternalSentrySdk.getAppStartMeasurement();

if (appStartTime == null) {
logger.log(SentryLevel.WARNING, "App start won't be sent due to missing appStartTime.");
promise.resolve(null);
} else {
final double appStartTimestampMs = DateUtils.nanosToMillis(appStartTime.nanoTimestamp());

WritableMap appStart = Arguments.createMap();

appStart.putDouble("appStartTime", appStartTimestampMs);
appStart.putBoolean("isColdStart", isColdStart);
appStart.putBoolean("didFetchAppStart", didFetchAppStart);
WritableMap mutableMeasurement = (WritableMap) RNSentryMapConverter.convertToWritable(measurement);
mutableMeasurement.putBoolean("has_fetched", hasFetchedAppStart);

promise.resolve(appStart);
}
// This is always set to true, as we would only allow an app start fetch to only
// happen once in the case of a JS bundle reload, we do not want it to be
// instrumented again.
didFetchAppStart = true;
hasFetchedAppStart = true;

promise.resolve(mutableMeasurement);
}

/**
Expand Down Expand Up @@ -427,11 +416,6 @@ public void fetchNativeFrames(Promise promise) {
}
}

if (totalFrames == 0 && slowFrames == 0 && frozenFrames == 0) {
promise.resolve(null);
return;
}

WritableMap map = Arguments.createMap();
map.putInt("totalFrames", totalFrames);
map.putInt("slowFrames", slowFrames);
Expand Down
58 changes: 12 additions & 46 deletions ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#import <Sentry/SentryFormatter.h>
#import <Sentry/SentryAppStartMeasurement.h>
#import "RNSentryId.h"
#import "RNSentryBreadcrumb.h"

// This guard prevents importing Hermes in JSC apps
#if SENTRY_PROFILING_ENABLED
Expand Down Expand Up @@ -54,7 +55,7 @@ + (void)storeEnvelope:(SentryEnvelope *)envelope;

@end

static bool didFetchAppStart;
static bool hasFetchedAppStart;

static NSString* const nativeSdkName = @"sentry.cocoa.react-native";

Expand Down Expand Up @@ -400,24 +401,20 @@ - (NSDictionary*) fetchNativeStackFramesBy: (NSArray<NSNumber*>*)instructionsAdd
rejecter:(RCTPromiseRejectBlock)reject)
{
#if SENTRY_HAS_UIKIT
SentryAppStartMeasurement *appStartMeasurement = PrivateSentrySDKOnly.appStartMeasurement;

if (appStartMeasurement == nil) {
NSDictionary<NSString *, id> *measurements = [PrivateSentrySDKOnly appStartMeasurementWithSpans];
if (measurements == nil) {
resolve(nil);
} else {
BOOL isColdStart = appStartMeasurement.type == SentryAppStartTypeCold;

resolve(@{
@"isColdStart": [NSNumber numberWithBool:isColdStart],
@"appStartTime": [NSNumber numberWithDouble:(appStartMeasurement.appStartTimestamp.timeIntervalSince1970 * 1000)],
@"didFetchAppStart": [NSNumber numberWithBool:didFetchAppStart],
});

return;
}

NSMutableDictionary<NSString *, id> *mutableMeasurements = [[NSMutableDictionary alloc] initWithDictionary:measurements];
[mutableMeasurements setValue:[NSNumber numberWithBool:hasFetchedAppStart] forKey:@"has_fetched"];

// This is always set to true, as we would only allow an app start fetch to only happen once
// in the case of a JS bundle reload, we do not want it to be instrumented again.
didFetchAppStart = true;
hasFetchedAppStart = true;

resolve(mutableMeasurements);
#else
resolve(nil);
#endif
Expand All @@ -439,12 +436,6 @@ - (NSDictionary*) fetchNativeStackFramesBy: (NSArray<NSNumber*>*)instructionsAdd
NSNumber *total = [NSNumber numberWithLong:frames.total];
NSNumber *frozen = [NSNumber numberWithLong:frames.frozen];
NSNumber *slow = [NSNumber numberWithLong:frames.slow];
NSNumber *zero = [NSNumber numberWithLong:0L];

if ([total isEqualToNumber:zero] && [frozen isEqualToNumber:zero] && [slow isEqualToNumber:zero]) {
resolve(nil);
return;
}

resolve(@{
@"totalFrames": total,
Expand Down Expand Up @@ -578,32 +569,7 @@ - (NSDictionary*) fetchNativeStackFramesBy: (NSArray<NSNumber*>*)instructionsAdd
RCT_EXPORT_METHOD(addBreadcrumb:(NSDictionary *)breadcrumb)
{
[SentrySDK configureScope:^(SentryScope * _Nonnull scope) {
SentryBreadcrumb* breadcrumbInstance = [[SentryBreadcrumb alloc] init];

NSString * levelString = breadcrumb[@"level"];
SentryLevel sentryLevel;
if ([levelString isEqualToString:@"fatal"]) {
sentryLevel = kSentryLevelFatal;
} else if ([levelString isEqualToString:@"warning"]) {
sentryLevel = kSentryLevelWarning;
} else if ([levelString isEqualToString:@"error"]) {
sentryLevel = kSentryLevelError;
} else if ([levelString isEqualToString:@"debug"]) {
sentryLevel = kSentryLevelDebug;
} else {
sentryLevel = kSentryLevelInfo;
}
[breadcrumbInstance setLevel:sentryLevel];

[breadcrumbInstance setCategory:breadcrumb[@"category"]];

[breadcrumbInstance setType:breadcrumb[@"type"]];

[breadcrumbInstance setMessage:breadcrumb[@"message"]];

[breadcrumbInstance setData:breadcrumb[@"data"]];

[scope addBreadcrumb:breadcrumbInstance];
[scope addBreadcrumb:[RNSentryBreadcrumb from:breadcrumb]];
}];
}

Expand Down
9 changes: 9 additions & 0 deletions ios/RNSentryBreadcrumb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import <Foundation/Foundation.h>

@class SentryBreadcrumb;

@interface RNSentryBreadcrumb : NSObject

+ (SentryBreadcrumb *)from: (NSDictionary *) dict;

@end
33 changes: 33 additions & 0 deletions ios/RNSentryBreadcrumb.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#import "RNSentryBreadcrumb.h"
@import Sentry;

@implementation RNSentryBreadcrumb

+(SentryBreadcrumb*) from: (NSDictionary *) dict
{
SentryBreadcrumb* crumb = [[SentryBreadcrumb alloc] init];

NSString * levelString = dict[@"level"];
SentryLevel sentryLevel;
if ([levelString isEqualToString:@"fatal"]) {
sentryLevel = kSentryLevelFatal;
} else if ([levelString isEqualToString:@"warning"]) {
sentryLevel = kSentryLevelWarning;
} else if ([levelString isEqualToString:@"error"]) {
sentryLevel = kSentryLevelError;
} else if ([levelString isEqualToString:@"debug"]) {
sentryLevel = kSentryLevelDebug;
} else {
sentryLevel = kSentryLevelInfo;
}

[crumb setLevel:sentryLevel];
[crumb setCategory:dict[@"category"]];
[crumb setType:dict[@"type"]];
[crumb setMessage:dict[@"message"]];
[crumb setData:dict[@"data"]];

return crumb;
}

@end
Loading

0 comments on commit 834780e

Please sign in to comment.