Skip to content

Commit 72d7b60

Browse files
lucas-zimermanLucas Zimerman
andauthored
Logs: enable iOS feature (#5190)
* enable ios logs: * logs * changelog * Drop outdated clang-format from npm (#5191) * enable logs on expo sample * repro' * patch clang-format and run it * return flags * return original sample code * more rollback * print clang version * remove deprecated package, add clang-format setup * try setup clang21 * other strategy to update clang/ more changes for version * gh action name change * Update .github/workflows/buildandtest.yml --------- Co-authored-by: Lucas Zimerman <[email protected]>
1 parent bed3a45 commit 72d7b60

File tree

25 files changed

+182
-118
lines changed

25 files changed

+182
-118
lines changed

.github/workflows/buildandtest.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ jobs:
5151
cache-dependency-path: yarn.lock
5252
- name: Install Dependencies
5353
run: yarn install
54+
55+
# Default of ubuntu and apt packages are too old compared to macos packages.
56+
# This is required for using a newer version of clang-format.
57+
- name: Setup clang-format V20
58+
run: |
59+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" 20
60+
sudo apt-get install -y clang-20 clang-format-20 lld-20 lldb-20
61+
62+
- name: Set clang-format V20 as default
63+
run: |
64+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 200
65+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 200
66+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 200
67+
clang --version
68+
clang-format --version
69+
5470
- name: Lint
5571
run: yarn lint
5672

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- Enable logs on native side of iOS ([#5190](https://github.com/getsentry/sentry-react-native/pull/5190))
1314
- Add mobile replay attributes to logs ([#5165](https://github.com/getsentry/sentry-react-native/pull/5165))
1415

1516
### Fixes

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"@expo/swiftlint": "^0.57.1",
3232
"@naturalcycles/ktlint": "^1.13.0",
3333
"@sentry/cli": "2.53.0",
34-
"clang-format": "^1.8.0",
3534
"downlevel-dts": "^0.11.0",
3635
"google-java-format": "^1.4.0",
3736
"lerna": "^8.1.8",

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentry+Test.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#import <RNSentry/RNSentry.h>
22

3-
@interface
4-
RNSentry (RNSentryInternal)
3+
@interface RNSentry (RNSentryInternal)
54

65
+ (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
76
otherUserKeys:(NSDictionary *)userDataKeys;

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ - (void)testRNSentryDependencyContainerInitializesFrameTracker
2222
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
2323
.andReturn(frameTrackerMock);
2424

25-
RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) {};
25+
RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) { };
2626
[[RNSentryDependencyContainer sharedInstance]
2727
initializeFramesTrackerListenerWith:emitNewFrameEvent];
2828
XCTAssertNotNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ - (void)testRNSentryFramesTrackerIsOneTimeListener
4646
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
4747
.andReturn(frameTrackerMock);
4848

49-
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};
49+
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) { };
5050

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

69-
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};
69+
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) { };
7070

7171
RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
7272
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#import "RNSentryOnDrawReporter.h"
22
#import <Foundation/Foundation.h>
33

4-
@interface
5-
RNSentryOnDrawReporterView (Testing)
4+
@interface RNSentryOnDrawReporterView (Testing)
65

76
+ (instancetype)createWithMockedListener;
87
- (RNSentryEmitNewFrameEvent)createEmitNewFrameEvent;

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ - (void)framesTrackerHasNewFrame:(nonnull NSDate *)newFrameDate
2828

2929
@end
3030

31-
@implementation
32-
RNSentryOnDrawReporterView (Testing)
31+
@implementation RNSentryOnDrawReporterView (Testing)
3332

3433
+ (instancetype)createWithMockedListener
3534
{

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
@class SentryOptions;
55

6-
@interface
7-
SentrySDKInternal (PrivateTests)
6+
@interface SentrySDKInternal (PrivateTests)
87

98
+ (nullable SentryOptions *)options;
109
@end

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,50 @@ - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Default
316316
enableUnhandledCPPExceptions, @"enableUnhandledCPPExceptionsV2 should default to disabled");
317317
}
318318

319+
- (void)testCreateOptionsWithDictionaryEnableLogsEnabled
320+
{
321+
RNSentry *rnSentry = [[RNSentry alloc] init];
322+
NSError *error = nil;
323+
324+
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
325+
@"dsn" : @"https://[email protected]/123456",
326+
@"enableLogs" : @YES,
327+
};
328+
SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary
329+
error:&error];
330+
331+
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
332+
XCTAssertNil(error, @"Should not pass no error");
333+
334+
id experimentalOptions = [actualOptions valueForKey:@"experimental"];
335+
XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil");
336+
337+
BOOL enableLogs = [[experimentalOptions valueForKey:@"enableLogs"] boolValue];
338+
XCTAssertTrue(enableLogs, @"enableLogs should be enabled");
339+
}
340+
341+
- (void)testCreateOptionsWithDictionaryEnableLogsDisabled
342+
{
343+
RNSentry *rnSentry = [[RNSentry alloc] init];
344+
NSError *error = nil;
345+
346+
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
347+
@"dsn" : @"https://[email protected]/123456",
348+
@"enableLogs" : @NO,
349+
};
350+
SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary
351+
error:&error];
352+
353+
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
354+
XCTAssertNil(error, @"Should not pass no error");
355+
356+
id experimentalOptions = [actualOptions valueForKey:@"experimental"];
357+
XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil");
358+
359+
BOOL enableLogs = [[experimentalOptions valueForKey:@"enableLogs"] boolValue];
360+
XCTAssertFalse(enableLogs, @"enableLogs should be disabled");
361+
}
362+
319363
- (void)testPassesErrorOnWrongDsn
320364
{
321365
RNSentry *rnSentry = [[RNSentry alloc] init];

0 commit comments

Comments
 (0)