Skip to content

Commit

Permalink
Merge branch 'main' into antonis/4169-cocoa-DebugImagesFromCache
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.mm
#	packages/core/ios/RNSentry.h
#	packages/core/ios/RNSentry.mm
  • Loading branch information
antonis committed Nov 6, 2024
2 parents 94ef651 + 5f40a37 commit e641e2d
Show file tree
Hide file tree
Showing 69 changed files with 1,891 additions and 1,655 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BasedOnStyle: WebKit
IndentWidth: 4
IndentPPDirectives: AfterHash
ColumnLimit: 100
AlwaysBreakAfterDefinitionReturnType: All
PointerAlignment: Right
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # pin@v3.26.10
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # pin@v3.27.0
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -55,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # pin@v3.26.10
uses: github/codeql-action/autobuild@662472033e021d55d94146f66f6058822b0b39fd # pin@v3.27.0

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
Expand All @@ -66,4 +66,4 @@ jobs:
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # pin@v3.26.10
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # pin@v3.27.0
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
metrics:
runs-on: ${{ matrix.runs-on }}
needs: [diff_check]
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
if: ${{ needs.diff_check.outputs.skip_ci != 'true' && env.SENTRY_AUTH_TOKEN != null }}
env:
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
strategy:
Expand Down Expand Up @@ -404,7 +404,7 @@ jobs:
-timezone US/Pacific
script: ./dev-packages/e2e-tests/cli.mjs ${{ matrix.platform }} --test

- uses: futureware-tech/simulator-action@bfa03d93ec9de6dacb0c5553bbf8da8afc6c2ee9 # pin@v3
- uses: futureware-tech/simulator-action@dab10d813144ef59b48d401cd95da151222ef8cd # pin@v4
if: ${{ matrix.platform == 'ios' }}
with:
model: ${{ env.IOS_DEVICE }}
Expand Down
28 changes: 25 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@

## Unreleased

### Features

- Add env flag `SENTRY_DISABLE_NATIVE_DEBUG_UPLOAD` to allow disabling the debug file upload ([#4223](https://github.com/getsentry/sentry-react-native/pull/4223))

How to use in Android project? It works by default, just set `export SENTRY_DISABLE_NATIVE_DEBUG_UPLOAD=true` in your build environment. For Sentry Android Gradle Plugin add the following to your `android/app/build.gradle`.

```gradle
apply from: "../../../sentry.gradle"

sentry {
autoUploadProguardMapping = shouldSentryAutoUpload()
uploadNativeSymbols = shouldSentryAutoUpload()
}
```

How to use in Xcode? Make sure you are using `scripts/sentry-xcode.sh` and `scripts/sentry-xcode-debug-files.sh` in your
build phases. And add the following to your `ios/.xcode.env.local` file.

```bash
export SENTRY_DISABLE_NATIVE_DEBUG_UPLOAD=true
```

### Fixes

- Skips ignoring require cycle logs for RN 0.70 or newer ([#4214](https://github.com/getsentry/sentry-react-native/pull/4214))
Expand All @@ -23,9 +45,9 @@
- Bump JavaScript SDK from v8.34.0 to v8.36.0 ([#4196](https://github.com/getsentry/sentry-react-native/pull/4196), [#4222](https://github.com/getsentry/sentry-react-native/pull/4222))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#8360)
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.34.0...8.36.0)
- Bump CLI from v2.37.0 to v2.38.1 ([#4200](https://github.com/getsentry/sentry-react-native/pull/4200), [#4220](https://github.com/getsentry/sentry-react-native/pull/4220))
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2381)
- [diff](https://github.com/getsentry/sentry-cli/compare/2.37.0...2.38.1)
- Bump CLI from v2.37.0 to v2.38.2 ([#4200](https://github.com/getsentry/sentry-react-native/pull/4200), [#4220](https://github.com/getsentry/sentry-react-native/pull/4220), [#4231](https://github.com/getsentry/sentry-react-native/pull/4231))
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2382)
- [diff](https://github.com/getsentry/sentry-cli/compare/2.37.0...2.38.2)
- Bump Android SDK from v7.15.0 to v7.16.0 ([#4202](https://github.com/getsentry/sentry-react-native/pull/4202))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7160)
- [diff](https://github.com/getsentry/sentry-java/compare/7.15.0...7.16.0)
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<picture>
<source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-white.png" media="(prefers-color-scheme: dark)" />
<source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" />
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" alt="Sentry" width="280">
</picture>
</a>
</p>
<div align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<img src="https://sentry-brand.storage.googleapis.com/github-banners/github-sdk-react.jpg" alt="Sentry for React Native">
</a>
</div>

_Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us [<kbd>**Check out our open positions**</kbd>](https://sentry.io/careers/)_

Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@
"clean": "lerna run clean",
"circularDepCheck": "lerna run circularDepCheck",
"test": "lerna run test",
"fix": "run-s fix:lerna fix:android",
"fix": "run-s fix:lerna fix:android fix:clang",
"fix:lerna": "lerna run fix",
"fix:android": "run-s 'java:format fix' java:pmd",
"lint": "run-s lint:lerna lint:android",
"fix:clang": "run-s 'clang:format fix'",
"lint": "run-s lint:lerna lint:android lint:clang",
"lint:lerna": "lerna run lint",
"lint:android": "run-s 'java:format lint' java:pmd",
"lint:clang": "run-s 'clang:format lint'",
"java:format": "./scripts/google-java-format.sh",
"java:pmd": "./scripts/pmd.sh",
"clang:format": "./scripts/clang-format.sh",
"run-ios": "cd samples/react-native && yarn react-native run-ios",
"run-android": "cd samples/react-native && yarn react-native run-android",
"set-version-samples": "lerna run set-version"
},
"devDependencies": {
"@sentry/cli": "2.38.1",
"@sentry/cli": "2.38.2",
"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
Expand Up @@ -2,5 +2,5 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "RNSentryReplayBreadcrumbConverter.h"
#import "RNSentryBreadcrumb.h"
#import "RNSentryReplayBreadcrumbConverter.h"
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import "SentryFramesTracker.h"
#import <Foundation/Foundation.h>
#import <RNSentry/RNSentry.h>
#import "SentryFramesTracker.h"

@interface
SentrySDK (PrivateTests)
- (nullable SentryOptions *) options;
- (nullable SentryOptions *)options;
@end

@interface SentryDependencyContainer : NSObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "RNSentryDependencyContainerTests.h"
#import "RNSentryDependencyContainer.h"
#import <OCMock/OCMock.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "RNSentryDependencyContainer.h"

@interface RNSentryDependencyContainerTests : XCTestCase

Expand All @@ -12,17 +12,20 @@ @implementation RNSentryDependencyContainerTests

- (void)testRNSentryDependencyContainerInitializesFrameTracker
{
XCTAssertNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);
XCTAssertNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);

id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) {};
[[RNSentryDependencyContainer sharedInstance] initializeFramesTrackerListenerWith: emitNewFrameEvent];
XCTAssertNotNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);
RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) {};
[[RNSentryDependencyContainer sharedInstance]
initializeFramesTrackerListenerWith:emitNewFrameEvent];
XCTAssertNotNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);
}

@end
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import "SentryFramesTracker.h"
#import <Foundation/Foundation.h>
#import <RNSentry/RNSentry.h>
#import "SentryFramesTracker.h"

@interface
SentrySDK (PrivateTests)
- (nullable SentryOptions *) options;
- (nullable SentryOptions *)options;
@end

@interface SentryDependencyContainer : NSObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "RNSentryFramesTrackerListenerTests.h"
#import "RNSentryDependencyContainer.h"
#import <OCMock/OCMock.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "RNSentryDependencyContainer.h"

@interface RNSentryFramesTrackerListenerTests : XCTestCase

Expand All @@ -12,58 +12,68 @@ @implementation RNSentryFramesTrackerListenerTests

- (void)testRNSentryFramesTrackerCallsGivenEventEmitterOnNewFrame
{
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

XCTestExpectation *blockExpectation = [self expectationWithDescription:@"Block Expectation"];
XCTestExpectation *blockExpectation = [self expectationWithDescription:@"Block Expectation"];

RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {
XCTAssertTrue([newFrameTimestampInSeconds isKindOfClass:[NSNumber class]], @"The variable should be of type NSNumber.");
[blockExpectation fulfill];
};
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {
XCTAssertTrue([newFrameTimestampInSeconds isKindOfClass:[NSNumber class]],
@"The variable should be of type NSNumber.");
[blockExpectation fulfill];
};

RNSentryFramesTrackerListener* actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter: mockEventEmitter];
RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter:mockEventEmitter];

[actualListener framesTrackerHasNewFrame: [NSDate date]];
[self waitForExpectationsWithTimeout:1.0 handler:nil];
[actualListener framesTrackerHasNewFrame:[NSDate date]];
[self waitForExpectationsWithTimeout:1.0 handler:nil];
}

- (void)testRNSentryFramesTrackerIsOneTimeListener
{
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

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

RNSentryFramesTrackerListener* actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter: mockEventEmitter];
RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter:mockEventEmitter];

[actualListener framesTrackerHasNewFrame: [NSDate date]];
OCMVerify([frameTrackerMock removeListener:actualListener]);
[actualListener framesTrackerHasNewFrame:[NSDate date]];
OCMVerify([frameTrackerMock removeListener:actualListener]);
}

- (void)testRNSentryFramesTrackerAddsItselfAsListener
{
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

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

RNSentryFramesTrackerListener* actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter: mockEventEmitter];
RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter:mockEventEmitter];

[actualListener startListening];
OCMVerify([frameTrackerMock addListener:actualListener]);
[actualListener startListening];
OCMVerify([frameTrackerMock addListener:actualListener]);
}

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import <XCTest/XCTest.h>
#import "RNSentryOnDrawReporter.h"
#import <XCTest/XCTest.h>

@interface RNSentryOnDrawReporterTests : XCTestCase

Expand All @@ -9,8 +9,8 @@ @implementation RNSentryOnDrawReporterTests

- (void)testRNSentryOnDrawReporterViewIsAvailableWhenUIKitIs
{
RNSentryOnDrawReporterView* view = [[RNSentryOnDrawReporterView alloc] init];
XCTAssertNotNil(view);
RNSentryOnDrawReporterView *view = [[RNSentryOnDrawReporterView alloc] init];
XCTAssertNotNil(view);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@interface
SentrySDK (PrivateTests)
- (nullable SentryOptions *) options;
- (nullable SentryOptions *)options;
@end

@interface SentryBinaryImageInfo : NSObject
Expand Down
Loading

0 comments on commit e641e2d

Please sign in to comment.