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
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "node",
"request": "launch",
"runtimeArgs": ["--inspect-brk", "${workspaceRoot}/node_modules/jest/bin/jest.js"],
"args": ["--runInBand", "-t", "gesture cancel previous interaction transaction"],
"args": ["--runInBand", "-t", ""],
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"test:watch": "jest --watch",
"run-ios": "cd samples/react-native && yarn react-native run-ios",
"run-android": "cd samples/react-native && yarn react-native run-android",
"yalc:add:sentry-javascript": "yalc add @sentry/browser @sentry/core @sentry/hub @sentry/integrations @sentry/react @sentry/types @sentry/utils",
"yalc:add:sentry-javascript": "yalc add @sentry/browser @sentry/core @sentry/react @sentry/types @sentry/utils",
"set-version-samples": "bash scripts/set-version-samples.sh"
},
"bin": {
Expand All @@ -67,22 +67,20 @@
"react-native": ">=0.65.0"
},
"dependencies": {
"@sentry/browser": "7.113.0",
"@sentry/browser": "8.4.0",
"@sentry/cli": "2.31.2",
"@sentry/core": "7.113.0",
"@sentry/hub": "7.113.0",
"@sentry/integrations": "7.113.0",
"@sentry/react": "7.113.0",
"@sentry/types": "7.113.0",
"@sentry/utils": "7.113.0"
"@sentry/core": "8.4.0",
"@sentry/react": "8.4.0",
"@sentry/types": "8.4.0",
"@sentry/utils": "8.4.0"
},
"devDependencies": {
"@babel/core": "^7.23.5",
"@expo/metro-config": "0.17.5",
"@mswjs/interceptors": "^0.25.15",
"@sentry-internal/eslint-config-sdk": "7.113.0",
"@sentry-internal/eslint-plugin-sdk": "7.113.0",
"@sentry-internal/typescript": "7.113.0",
"@sentry-internal/eslint-config-sdk": "8.4.0",
"@sentry-internal/eslint-plugin-sdk": "8.4.0",
"@sentry-internal/typescript": "8.4.0",
"@sentry/wizard": "3.16.3",
"@types/jest": "^29.5.3",
"@types/node": "^20.9.3",
Expand Down
7 changes: 3 additions & 4 deletions samples/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { SplashScreen, Stack, useNavigationContainerRef } from 'expo-router';
import { useEffect } from 'react';

import { useColorScheme } from '@/components/useColorScheme';
import { HttpClient } from '@sentry/integrations';
import { SENTRY_INTERNAL_DSN } from '../utils/dsn';
import * as Sentry from '@sentry/react-native';
import { ErrorEvent } from '@sentry/types';
import { isExpoGo } from '../utils/isExpoGo';

export {
Expand All @@ -27,7 +27,7 @@ process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({
dsn: SENTRY_INTERNAL_DSN,
debug: true,
environment: 'dev',
beforeSend: (event: Sentry.Event) => {
beforeSend: (event: ErrorEvent) => {
console.log('Event beforeSend:', event.event_id);
return event;
},
Expand All @@ -41,7 +41,7 @@ process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({
},
integrations(integrations) {
integrations.push(
new HttpClient({
Sentry.httpClientIntegration({
// These options are effective only in JS.
// This array can contain tuples of `[begin, end]` (both inclusive),
// Single status codes, or a combinations of both.
Expand All @@ -51,7 +51,6 @@ process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({
// default: [/.*/]
failedRequestTargets: [/.*/],
}),
Sentry.metrics.metricsAggregatorIntegration(),
new Sentry.ReactNativeTracing({
routingInstrumentation,
}),
Expand Down
1 change: 0 additions & 1 deletion samples/expo/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ config.watchFolders.push(path.resolve(__dirname, '../../node_modules/@sentry'));
config.watchFolders.push(path.resolve(__dirname, '../../node_modules/@sentry-internal'));
config.watchFolders.push(path.resolve(__dirname, '../../node_modules/tslib'));
config.watchFolders.push(path.resolve(__dirname, '../../node_modules/hoist-non-react-statics'));
config.watchFolders.push(path.resolve(__dirname, '../../node_modules/localforage'));
config.watchFolders.push(path.resolve(__dirname, '../../node_modules/@react-native/js-polyfills'));
config.watchFolders.push(`${__dirname}/../../dist`);

Expand Down
15 changes: 3 additions & 12 deletions samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { store } from './reduxApp';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import GesturesTracingScreen from './Screens/GesturesTracingScreen';
import { Platform, StyleSheet } from 'react-native';
import { HttpClient } from '@sentry/integrations';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { ErrorEvent } from '@sentry/types';

const isMobileOs = Platform.OS === 'android' || Platform.OS === 'ios';

Expand All @@ -39,7 +39,7 @@ Sentry.init({
dsn: SENTRY_INTERNAL_DSN,
debug: true,
environment: 'dev',
beforeSend: (event: Sentry.Event) => {
beforeSend: (event: ErrorEvent) => {
console.log('Event beforeSend:', event.event_id);
return event;
},
Expand All @@ -59,16 +59,8 @@ Sentry.init({
routingInstrumentation: reactNavigationInstrumentation,
enableUserInteractionTracing: true,
ignoreEmptyBackNavigationTransactions: true,
beforeNavigate: (context: Sentry.ReactNavigationTransactionContext) => {
// Example of not sending a transaction for the screen with the name "Manual Tracker"
if (context.data.route.name === 'ManualTracker') {
context.sampled = false;
}

return context;
},
}),
new HttpClient({
Sentry.httpClientIntegration({
// These options are effective only in JS.
// This array can contain tuples of `[begin, end]` (both inclusive),
// Single status codes, or a combinations of both.
Expand All @@ -78,7 +70,6 @@ Sentry.init({
// default: [/.*/]
failedRequestTargets: [/.*/],
}),
Sentry.metrics.metricsAggregatorIntegration(),
);
return integrations.filter(i => i.name !== 'Dedupe');
},
Expand Down
8 changes: 4 additions & 4 deletions samples/react-native/src/Screens/GesturesTracingScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import { getCurrentHub, Scope, sentryTraceGesture } from '@sentry/react-native';
import { sentryTraceGesture, startSpanManual } from '@sentry/react-native';
import { Span } from '@sentry/types';

const GesturesTracingScreen = () => {
const gesture = Gesture.Pinch().onBegin(() => {
Expand All @@ -18,10 +19,9 @@ const GesturesTracingScreen = () => {
};

const startExampleSpan = () => {
getCurrentHub().withScope((scope: Scope) => {
const child = scope.getTransaction()?.startChild({ op: 'example' });
startSpanManual({ name: 'Example', op: 'example' }, (span: Span) => {
setTimeout(() => {
child?.finish();
span.end();
}, 1000);
});
};
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-javascript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

tagPrefix=''
repo="https://github.com/getsentry/sentry-javascript.git"
packages=('@sentry/browser' '@sentry/core' '@sentry/hub' '@sentry/integrations' '@sentry/react' '@sentry/types' '@sentry/utils' '@sentry-internal/typescript')
packages=('@sentry/browser' '@sentry/core' '@sentry/react' '@sentry/types' '@sentry/utils' '@sentry-internal/typescript')
packages+=('@sentry-internal/eslint-config-sdk' '@sentry-internal/eslint-plugin-sdk')

. $(dirname "$0")/update-package-json.sh
51 changes: 31 additions & 20 deletions src/js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
EventHint,
Outcome,
SeverityLevel,
TransportMakeRequestResponse,
UserFeedback,
} from '@sentry/types';
import { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';
Expand All @@ -16,7 +17,7 @@ import { Alert } from 'react-native';
import { createIntegration } from './integrations/factory';
import { defaultSdkInfo } from './integrations/sdkinfo';
import type { ReactNativeClientOptions } from './options';
import { ReactNativeTracing } from './tracing';
import type { ReactNativeTracing } from './tracing';
import { createUserFeedbackEnvelope, items } from './utils/envelope';
import { ignoreRequireCycleLogs } from './utils/ignorerequirecyclelogs';
import { mergeOutcomes } from './utils/outcome';
Expand All @@ -42,7 +43,6 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
super(options);

this._outcomesBuffer = [];
this._initNativeSdk();
}

/**
Expand Down Expand Up @@ -86,29 +86,14 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
dsn: this.getDsn(),
tunnel: undefined,
});
this._sendEnvelope(envelope);
}

/**
* Sets up the integrations
*/
public setupIntegrations(): void {
super.setupIntegrations();
const tracing = this.getIntegration(ReactNativeTracing);
const routingName = tracing?.options.routingInstrumentation?.name;
if (routingName) {
this.addIntegration(createIntegration(routingName));
}
const enableUserInteractionTracing = tracing?.options.enableUserInteractionTracing;
if (enableUserInteractionTracing) {
this.addIntegration(createIntegration('ReactNativeUserInteractionTracing'));
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.sendEnvelope(envelope);
}

/**
* @inheritdoc
*/
protected _sendEnvelope(envelope: Envelope): void {
public sendEnvelope(envelope: Envelope): PromiseLike<TransportMakeRequestResponse> {
const outcomes = this._clearOutcomes();
this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);

Expand Down Expand Up @@ -137,6 +122,32 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
if (shouldClearOutcomesBuffer) {
this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact
}

return Promise.resolve({});
}

/**
* @inheritDoc
*/
public init(): void {
this._initNativeSdk();
super.init();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Was it previously wrong and you fix it now or is it a change that was required for V8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init was added for V8, the native init needs to happen before the JS init, to avoid the native not available error log in Expo.

Before v8 the native init happened in constructor, which doesn't make sense with dedicate init method.

}

/**
* @inheritdoc
*/
protected _setupIntegrations(): void {
super._setupIntegrations();
const tracing = this.getIntegrationByName<ReactNativeTracing>('ReactNativeTracing');
const routingName = tracing?.options?.routingInstrumentation?.name;
if (routingName) {
this.addIntegration(createIntegration(routingName));
}
const enableUserInteractionTracing = tracing?.options.enableUserInteractionTracing;
if (enableUserInteractionTracing) {
this.addIntegration(createIntegration('ReactNativeUserInteractionTracing'));
}
}

/**
Expand Down
43 changes: 3 additions & 40 deletions src/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,34 @@ export type {
} from '@sentry/types';

export {
addGlobalEventProcessor,
addBreadcrumb,
captureException,
captureEvent,
captureMessage,
getHubFromCarrier,
getCurrentHub,
Hub,
Scope,
setContext,
setExtra,
setExtras,
setTag,
setTags,
setUser,
startTransaction,

// v8 spans
startInactiveSpan,
startSpan,
startSpanManual,
getActiveSpan,
spanToJSON,
spanIsSampled,
setMeasurement,

// v8 scopes
getCurrentScope,
getGlobalScope,
getIsolationScope,
getClient,
setCurrentClient,
addEventProcessor,
metrics,
metricsDefault as metrics,
} from '@sentry/core';

import { _addTracingExtensions } from './tracing/addTracingExtensions';
_addTracingExtensions();

export {
Integrations as BrowserIntegrations,
ErrorBoundary,
withErrorBoundary,
createReduxEnhancer,
Expand All @@ -61,36 +48,17 @@ export {
withProfiler,
} from '@sentry/react';

export { lastEventId } from '@sentry/browser';

import * as Integrations from './integrations';

export * from './integrations/exports';

export { SDK_NAME, SDK_VERSION } from './version';
export type { ReactNativeOptions } from './options';
export { ReactNativeClient } from './client';

export {
init,
wrap,
// eslint-disable-next-line deprecation/deprecation
setDist,
// eslint-disable-next-line deprecation/deprecation
setRelease,
nativeCrash,
flush,
close,
captureUserFeedback,
withScope,
configureScope,
} from './sdk';
export { init, wrap, nativeCrash, flush, close, captureUserFeedback, withScope } from './sdk';
export { TouchEventBoundary, withTouchEventBoundary } from './touchevents';

export {
ReactNativeTracing,
ReactNavigationV4Instrumentation,
// eslint-disable-next-line deprecation/deprecation
ReactNavigationV5Instrumentation,
ReactNavigationInstrumentation,
ReactNativeNavigationInstrumentation,
Expand All @@ -102,9 +70,4 @@ export {
startTimeToFullDisplaySpan,
} from './tracing';

export type { ReactNavigationTransactionContext, TimeToDisplayProps } from './tracing';

export {
/** @deprecated Import the integration function directly, e.g. `screenshotIntegration()` instead of `new Integrations.Screenshot(). */
Integrations,
};
export type { TimeToDisplayProps } from './tracing';
Loading