Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/buildandtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ jobs:
cache-dependency-path: yarn.lock
- name: Install Dependencies
run: yarn install

# Default of ubuntu and apt packages are too old compared to macos packages.
# This is required for using a newer version of clang-format.
- name: Setup clang-format V20
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" 20
sudo apt-get install -y clang-20 clang-format-20 lld-20 lldb-20

- name: Set clang-format V20 as default
run: |
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 200
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 200
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 200
clang --version
clang-format --version

- name: Lint
run: yarn lint

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@expo/swiftlint": "^0.57.1",
"@naturalcycles/ktlint": "^1.13.0",
"@sentry/cli": "2.53.0",
"clang-format": "^1.8.0",
"downlevel-dts": "^0.11.0",
"google-java-format": "^1.4.0",
"lerna": "^8.1.8",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import <RNSentry/RNSentry.h>

@interface
RNSentry (RNSentryInternal)
@interface RNSentry (RNSentryInternal)

+ (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
otherUserKeys:(NSDictionary *)userDataKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (void)testRNSentryDependencyContainerInitializesFrameTracker
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) {};
RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) { };
[[RNSentryDependencyContainer sharedInstance]
initializeFramesTrackerListenerWith:emitNewFrameEvent];
XCTAssertNotNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (void)testRNSentryFramesTrackerIsOneTimeListener
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) { };

RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
Expand All @@ -66,7 +66,7 @@ - (void)testRNSentryFramesTrackerAddsItselfAsListener
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) { };

RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#import "RNSentryOnDrawReporter.h"
#import <Foundation/Foundation.h>

@interface
RNSentryOnDrawReporterView (Testing)
@interface RNSentryOnDrawReporterView (Testing)

+ (instancetype)createWithMockedListener;
- (RNSentryEmitNewFrameEvent)createEmitNewFrameEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ - (void)framesTrackerHasNewFrame:(nonnull NSDate *)newFrameDate

@end

@implementation
RNSentryOnDrawReporterView (Testing)
@implementation RNSentryOnDrawReporterView (Testing)

+ (instancetype)createWithMockedListener
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

@class SentryOptions;

@interface
SentrySDKInternal (PrivateTests)
@interface SentrySDKInternal (PrivateTests)

+ (nullable SentryOptions *)options;
@end
3 changes: 1 addition & 2 deletions packages/core/ios/RNSentry+fetchNativeStack.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

// This method was moved to a new category so we can use `@import Sentry` to use Sentry's Swift
// classes
@implementation
RNSentry (fetchNativeStack)
@implementation RNSentry (fetchNativeStack)

- (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAddr
symbolicate:(SymbolicateCallbackType)symbolicate
Expand Down
3 changes: 1 addition & 2 deletions packages/core/ios/RNSentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ typedef int (*SymbolicateCallbackType)(const void *, Dl_info *);

@end

@interface
RNSentry (fetchNativeStack)
@interface RNSentry (fetchNativeStack)

- (NSDictionary *_Nonnull)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAddr
symbolicate:(SymbolicateCallbackType)symbolicate;
Expand Down
111 changes: 42 additions & 69 deletions packages/core/ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ - (instancetype)init
}

RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(initNativeSdk
: (NSDictionary *_Nonnull)options resolve
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(initNativeSdk : (NSDictionary *_Nonnull)options resolve : (
RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
NSError *error = nil;
SentryOptions *sentryOptions = [self createOptionsWithDictionary:options error:&error];
Expand Down Expand Up @@ -200,8 +198,7 @@ - (BOOL)shouldIgnoreError:(NSString *)message
- (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)options
error:(NSError *_Nonnull *_Nonnull)errorPointer
{
SentryBeforeSendEventCallback beforeSend = ^SentryEvent *(SentryEvent *event)
{
SentryBeforeSendEventCallback beforeSend = ^SentryEvent *(SentryEvent *event) {
// We don't want to send an event after startup that came from a Unhandled JS Exception of
// React Native because we sent it already before the app crashed.
if (nil != event.exceptions.firstObject.type &&
Expand Down Expand Up @@ -292,7 +289,7 @@ - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)
id enableLogsValue = [mutableOptions valueForKey:@"enableLogs"];
if ([enableLogsValue isKindOfClass:[NSNumber class]]) {
[RNSentryExperimentalOptions setEnableLogs:[enableLogsValue boolValue]
sentryOptions:sentryOptions];
sentryOptions:sentryOptions];
}
}
[self trySetIgnoreErrors:mutableOptions];
Expand Down Expand Up @@ -362,9 +359,8 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event
event.tags = newTags;
}

RCT_EXPORT_METHOD(initNativeReactNavigationNewFrameTracking
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(initNativeReactNavigationNewFrameTracking : (
RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
#if SENTRY_HAS_UIKIT
if ([[NSThread currentThread] isMainThread]) {
Expand Down Expand Up @@ -406,19 +402,17 @@ - (void)stopObserving
return @[ RNSentryNewFrameEvent ];
}

RCT_EXPORT_METHOD(fetchNativeSdkInfo
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
fetchNativeSdkInfo : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
resolve(@ {
@"name" : PrivateSentrySDKOnly.getSdkName,
@"version" : PrivateSentrySDKOnly.getSdkVersionString
});
}

RCT_EXPORT_METHOD(fetchModules
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
fetchModules : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"modules" ofType:@"json"];
NSString *modulesString = [NSString stringWithContentsOfFile:filePath
Expand All @@ -433,15 +427,14 @@ - (void)stopObserving
return packageName;
}

RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, fetchNativeStackFramesBy
: (NSArray *)instructionsAddr)
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(
NSDictionary *, fetchNativeStackFramesBy : (NSArray *)instructionsAddr)
{
return [self fetchNativeStackFramesBy:instructionsAddr symbolicate:dladdr];
}

RCT_EXPORT_METHOD(fetchNativeLogAttributes
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(fetchNativeLogAttributes : (RCTPromiseResolveBlock)resolve rejecter : (
RCTPromiseRejectBlock)reject)
{
__block NSMutableDictionary<NSString *, id> *result = [NSMutableDictionary new];

Expand Down Expand Up @@ -491,9 +484,8 @@ - (void)stopObserving
resolve(result);
}

RCT_EXPORT_METHOD(fetchNativeDeviceContexts
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(fetchNativeDeviceContexts : (RCTPromiseResolveBlock)resolve rejecter : (
RCTPromiseRejectBlock)reject)
{
if (PrivateSentrySDKOnly.options.debug) {
NSLog(@"Bridge call to: deviceContexts");
Expand Down Expand Up @@ -553,9 +545,8 @@ - (void)stopObserving
resolve(serializedScope);
}

RCT_EXPORT_METHOD(fetchNativeAppStart
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
fetchNativeAppStart : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
#if SENTRY_HAS_UIKIT
NSDictionary<NSString *, id> *measurements =
Expand All @@ -580,9 +571,8 @@ - (void)stopObserving
#endif
}

RCT_EXPORT_METHOD(fetchNativeFrames
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
fetchNativeFrames : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{

#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
Expand Down Expand Up @@ -611,9 +601,8 @@ - (void)stopObserving
#endif
}

RCT_EXPORT_METHOD(fetchNativeRelease
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
fetchNativeRelease : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
resolve(@ {
Expand All @@ -623,11 +612,8 @@ - (void)stopObserving
});
}

RCT_EXPORT_METHOD(captureEnvelope
: (NSString *_Nonnull)rawBytes options
: (NSDictionary *_Nonnull)options resolve
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(captureEnvelope : (NSString *_Nonnull)rawBytes options : (NSDictionary *_Nonnull)
options resolve : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
NSData *data = [[NSData alloc] initWithBase64EncodedString:rawBytes options:0];

Expand All @@ -650,9 +636,8 @@ - (void)stopObserving
resolve(@YES);
}

RCT_EXPORT_METHOD(captureScreenshot
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
captureScreenshot : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
NSArray<NSData *> *rawScreenshots = [PrivateSentrySDKOnly captureScreenshots];
Expand Down Expand Up @@ -684,9 +669,8 @@ - (void)stopObserving
#endif
}

RCT_EXPORT_METHOD(fetchViewHierarchy
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
fetchViewHierarchy : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
NSData *rawViewHierarchy = [PrivateSentrySDKOnly captureViewHierarchy];
Expand Down Expand Up @@ -800,9 +784,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys

RCT_EXPORT_METHOD(crash) { [SentrySDKWrapper crash]; }

RCT_EXPORT_METHOD(closeNativeSdk
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
closeNativeSdk : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
[SentrySDKWrapper close];
resolve(@YES);
Expand All @@ -821,10 +804,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
// the 'tracesSampleRate' or 'tracesSampler' option.
}

RCT_EXPORT_METHOD(captureReplay
: (BOOL)isHardCrash resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(captureReplay : (BOOL)isHardCrash resolver : (
RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
#if SENTRY_TARGET_REPLAY_SUPPORTED
[PrivateSentrySDKOnly captureReplay];
Expand All @@ -834,10 +815,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
#endif
}

RCT_EXPORT_METHOD(getDataFromUri
: (NSString *_Nonnull)uri resolve
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(getDataFromUri : (NSString *_Nonnull)uri resolve : (
RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
NSURL *fileURL = [NSURL URLWithString:uri];
Expand Down Expand Up @@ -1020,9 +999,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
#endif
}

RCT_EXPORT_METHOD(crashedLastRun
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(
crashedLastRun : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
resolve(@([SentrySDKWrapper crashedLastRun]));
}
Expand All @@ -1036,17 +1014,14 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
}
#endif

RCT_EXPORT_METHOD(getNewScreenTimeToDisplay
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(getNewScreenTimeToDisplay : (RCTPromiseResolveBlock)resolve rejecter : (
RCTPromiseRejectBlock)reject)
{
[_timeToDisplay getTimeToDisplay:resolve];
}

RCT_EXPORT_METHOD(popTimeToDisplayFor
: (NSString *)key resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(popTimeToDisplayFor : (NSString *)key resolver : (
RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
resolve([RNSentryTimeToDisplay popTimeToDisplayFor:key]);
}
Expand All @@ -1057,10 +1032,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
return @YES; // The return ensures that the method is synchronous
}

RCT_EXPORT_METHOD(encodeToBase64
: (NSArray *)array resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(encodeToBase64 : (NSArray *)array resolver : (
RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)
{
NSUInteger count = array.count;
uint8_t *bytes = (uint8_t *)malloc(count);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/ios/RNSentryExperimentalOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param sentryOptions The SentryOptions instance to configure
* @param enabled Whether logs from sentry Cocoa should be enabled
*/
+ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions;
+ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions;

@end

Expand Down
2 changes: 1 addition & 1 deletion packages/core/ios/RNSentryExperimentalOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ + (BOOL)getEnableUnhandledCPPExceptionsV2:(SentryOptions *)sentryOptions
return sentryOptions.experimental.enableUnhandledCPPExceptionsV2;
}

+ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions
+ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions
{
if (sentryOptions == nil) {
return;
Expand Down
Loading
Loading