Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Oct 6, 2022
2 parents d27d9e0 + 5636309 commit c0d52bf
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 105 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/add-platform-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
permissions:
issues: write
steps:
- uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
- uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # pin@1.0.4
with:
add-labels: "Platform: React-Native"
add-labels: 'Platform: React-Native'
repo-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/buildandtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ jobs:
# we want that the matrix keeps running, default is to cancel them if it fails.
fail-fast: false
matrix:
platform: ["ios", "android"]
platform: ['ios', 'android']
dev: [true, false]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: '14'
- name: Cache Dependencies
uses: actions/cache@v3
id: cache
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
Expand All @@ -18,7 +18,7 @@ on:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: "27 16 * * 5"
- cron: '27 16 * * 5'

jobs:
analyze:
Expand All @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: ["javascript"]
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
Expand All @@ -39,7 +39,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -50,18 +50,15 @@ 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@v2
uses: github/codeql-action/autobuild@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ jobs:

# Wait until the Appium server starts.
- name: Check Appium Server
uses: nick-fields/retry@b4fa57557dda8c2f30bcb2d19372cc3237190f7f # v2.8.1
uses: nick-fields/retry@b4fa57557dda8c2f30bcb2d19372cc3237190f7f # pin@v2
with:
timeout_seconds: 60
max_attempts: 10
command: curl --output /dev/null --silent --head --fail http://127.0.0.1:4723/sessions

- name: Run tests on Android
if: ${{ matrix.platform == 'android' }}
uses: reactivecircus/android-emulator-runner@d7b53ddc6e44254e1f4cf4a6ad67345837027a66 # v2.26.0
uses: reactivecircus/android-emulator-runner@d7b53ddc6e44254e1f4cf4a6ad67345837027a66 # pin@v2
with:
api-level: 29
emulator-options: -accel on -no-snapshot -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none -timezone US/Pacific
Expand Down
25 changes: 22 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@

### Fixes

- Make `configureScope` callback safe [#2510](https://github.com/getsentry/sentry-react-native/pull/2510)

### Dependencies

- Bump JavaScript SDK from v7.14.0 to v7.14.1 ([#2511](https://github.com/getsentry/sentry-react-native/pull/2511))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7141)
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.0...7.14.1)
- Bump Cocoa SDK from v7.27.0 to v7.27.1 ([#2521](https://github.com/getsentry/sentry-react-native/pull/2521))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7271)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.0...7.27.1)
- Bump Android SDK from v6.4.2 to v6.4.3 ([#2520](https://github.com/getsentry/sentry-react-native/pull/2520))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#643)
- [diff](https://github.com/getsentry/sentry-java/compare/6.4.2...6.4.3)

## 4.6.0

### Fixes

- SDK Gracefully downgrades when callback throws an error ([#2502](https://github.com/getsentry/sentry-react-native/pull/2502))
- React Navigation v5 ignores when current route is undefined after state changed. ([#2484](https://github.com/getsentry/sentry-react-native/pull/2484))

### Features

Expand All @@ -16,9 +35,9 @@

### Dependencies

- Bump Cocoa SDK from v7.25.1 to v7.26.0 ([#2500](https://github.com/getsentry/sentry-react-native/pull/2500))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7260)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.25.1...7.26.0)
- Bump Cocoa SDK from v7.25.1 to v7.27.0 ([#2500](https://github.com/getsentry/sentry-react-native/pull/2500), [#2506](https://github.com/getsentry/sentry-react-native/pull/2506))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7270)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.25.1...7.27.0)
- Bump JavaScript SDK from v7.13.0 to v7.14.0 ([#2504](https://github.com/getsentry/sentry-react-native/pull/2504))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7140)
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.13.0...7.14.0)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This repository contains a sample project. It can be used to test the SDK as you

You need:

- nodejs 8 or higher
- nodejs 14 or higher
- yarn 1 or higher

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

s.dependency 'React-Core'
s.dependency 'Sentry', '7.26.0'
s.dependency 'Sentry', '7.27.1'

s.source_files = 'ios/RNSentry.{h,m}'
s.public_header_files = 'ios/RNSentry.h'
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ android {

dependencies {
implementation 'com.facebook.react:react-native:+'
api 'io.sentry:sentry-android:6.4.2'
api 'io.sentry:sentry-android:6.4.3'
}
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
"react-native": ">=0.56.0"
},
"dependencies": {
"@sentry/browser": "7.14.0",
"@sentry/browser": "7.14.1",
"@sentry/cli": "1.74.4",
"@sentry/core": "7.14.0",
"@sentry/hub": "7.14.0",
"@sentry/integrations": "7.14.0",
"@sentry/react": "7.14.0",
"@sentry/tracing": "7.14.0",
"@sentry/types": "7.14.0",
"@sentry/utils": "7.14.0"
"@sentry/core": "7.14.1",
"@sentry/hub": "7.14.1",
"@sentry/integrations": "7.14.1",
"@sentry/react": "7.14.1",
"@sentry/tracing": "7.14.1",
"@sentry/types": "7.14.1",
"@sentry/utils": "7.14.1"
},
"devDependencies": {
"@sentry-internal/eslint-config-sdk": "7.14.0",
"@sentry-internal/eslint-plugin-sdk": "7.14.0",
"@sentry-internal/eslint-config-sdk": "7.14.1",
"@sentry-internal/eslint-plugin-sdk": "7.14.1",
"@sentry/typescript": "^5.20.1",
"@sentry/wizard": "2.2.0",
"@types/jest": "^26.0.15",
Expand Down
2 changes: 1 addition & 1 deletion sample/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

const path = require('path');
const blacklist = require('metro-config/src/defaults/blacklist');
const blacklist = require('metro-config/src/defaults/exclusionList');
const resolve = require('metro-resolver/src/resolve');

const parentDir = path.resolve(__dirname, '..');
Expand Down
2 changes: 1 addition & 1 deletion src/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export {
captureException,
captureEvent,
captureMessage,
configureScope,
getHubFromCarrier,
getCurrentHub,
Hub,
Expand Down Expand Up @@ -66,6 +65,7 @@ export {
close,
captureUserFeedback,
withScope,
configureScope,
} from './sdk';
export { TouchEventBoundary, withTouchEventBoundary } from './touchevents';

Expand Down
15 changes: 15 additions & 0 deletions src/js/sdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,18 @@ export function withScope(callback: (scope: Scope) => void): ReturnType<Hub['wit
};
getCurrentHub().withScope(safeCallback);
}

/**
* Callback to set context information onto the scope.
* @param callback Callback function that receives Scope.
*/
export function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {
const safeCallback = (scope: Scope): void => {
try {
callback(scope);
} catch (e) {
logger.error('Error while running configureScope callback', e);
}
};
getCurrentHub().configureScope(safeCallback);
}
6 changes: 3 additions & 3 deletions src/js/tracing/reactnavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati

this._pushRecentRouteKey(route.key);
this._latestRoute = route;

// Clear the latest transaction as it has been handled.
this._latestTransaction = undefined;
}
}

// Clear the latest transaction as it has been handled.
this._latestTransaction = undefined;
}

/** Creates final transaction context before confirmation */
Expand Down
1 change: 0 additions & 1 deletion test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
envelopeItemPayload,
envelopeItems,
firstArg,
flushPromises,
getMockSession,
getMockUserFeedback,
getSyncPromiseRejectOnFirstCall,
Expand Down
18 changes: 17 additions & 1 deletion test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface MockedClient {
}

let mockedGetCurrentHubWithScope: jest.Mock;
let mockedGetCurrentHubConfigureScope: jest.Mock;

jest.mock('@sentry/react', () => {
const actualModule = jest.requireActual('@sentry/react');
Expand All @@ -17,10 +18,12 @@ jest.mock('@sentry/react', () => {
...actualModule,
getCurrentHub: jest.fn(() => {
mockedGetCurrentHubWithScope = jest.fn();
mockedGetCurrentHubConfigureScope = jest.fn();
return {
getClient: jest.fn(() => mockClient),
setTag: jest.fn(),
withScope: mockedGetCurrentHubWithScope,
configureScope: mockedGetCurrentHubConfigureScope,
};
}),
defaultIntegrations: [ { name: 'MockedDefaultReactIntegration', setupOnce: jest.fn() } ],
Expand Down Expand Up @@ -62,7 +65,7 @@ import { getCurrentHub } from '@sentry/react';
import { Integration, Scope } from '@sentry/types';

import { ReactNativeClientOptions } from '../src/js/options';
import { flush, init, withScope } from '../src/js/sdk';
import { configureScope,flush, init, withScope } from '../src/js/sdk';
import { ReactNativeTracing, ReactNavigationInstrumentation } from '../src/js/tracing';
import { firstArg, secondArg } from './testutils';

Expand Down Expand Up @@ -234,6 +237,19 @@ describe('Tests the SDK functionality', () => {
});
});

describe('configureScope', () => {
test('configureScope callback does not throw', () => {
const mockScopeCallback = jest.fn(() => { throw 'Test error' });

configureScope(mockScopeCallback);

expect(() => {
(mockedGetCurrentHubConfigureScope.mock.calls[0][firstArg] as (scope: Scope) => void)({} as any);
}).not.toThrow();
expect(mockScopeCallback).toBeCalledTimes(1);
});
});

describe('integrations', () => {
it('replaces default integrations', () => {
const mockDefaultIntegration = getMockedIntegration();
Expand Down
2 changes: 0 additions & 2 deletions test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,3 @@ export const getSyncPromiseRejectOnFirstCall = <Y extends any[]>(reason: unknown
}
});
};

export const flushPromises = (): Promise<void> => new Promise(setImmediate);
8 changes: 6 additions & 2 deletions test/tracing/reactnavigation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const dummyRoute = {
};

class MockNavigationContainer {
currentRoute: NavigationRoute = dummyRoute;
currentRoute: NavigationRoute | undefined = dummyRoute;
listeners: Record<string, (e: any) => void> = {};
addListener: any = jest.fn(
(eventType: string, listener: (e: any) => void): void => {
this.listeners[eventType] = listener;
}
);
getCurrentRoute(): NavigationRoute {
getCurrentRoute(): NavigationRoute | undefined {
return this.currentRoute;
}
}
Expand Down Expand Up @@ -120,6 +120,10 @@ describe('ReactNavigationInstrumentation', () => {
someParam: 42,
},
};
// If .getCurrentRoute() is undefined, ignore state change
mockNavigationContainerRef.current.currentRoute = undefined;
mockNavigationContainerRef.current.listeners['state']({});

mockNavigationContainerRef.current.currentRoute = route;
mockNavigationContainerRef.current.listeners['state']({});

Expand Down
Loading

0 comments on commit c0d52bf

Please sign in to comment.