Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(5) ref(tracing): Remove ReactNativeTracing deprecated options and use new integrations style #3998

Merged
merged 42 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c3dcfd3
chore(tracing): extract app start to a standalone integration
krystofwoldrich Jun 3, 2024
88d6988
Merge branch 'v6' into kw/ref-app-start-integration
krystofwoldrich Jun 11, 2024
fe53af5
fix merge
krystofwoldrich Jun 11, 2024
d4ac89f
fix spans, app start is now reported to Sentry
krystofwoldrich Jun 11, 2024
7c5dcaa
fix uikit init and minimal instrumentation edge cases
krystofwoldrich Jun 12, 2024
0b42472
update js docs
krystofwoldrich Jun 12, 2024
9765eaf
Merge branch 'v6' into kw/ref-app-start-integration
krystofwoldrich Aug 4, 2024
b9e9e9a
Add App Start Integration tests
krystofwoldrich Aug 5, 2024
b334931
Remove app start test from react native tracing
krystofwoldrich Aug 5, 2024
4d16787
clean up app start tests
krystofwoldrich Aug 5, 2024
4d84922
fix test affected by the app start extraction
krystofwoldrich Aug 5, 2024
0ff2020
Add standalone app start
krystofwoldrich Aug 5, 2024
b1eab51
fix
krystofwoldrich Aug 5, 2024
6d1cd70
ref(tracing): Extract NativeFrames as standalone integration
krystofwoldrich Aug 5, 2024
5eaaad2
Add integration handling test
krystofwoldrich Aug 6, 2024
eba6820
Merge branch 'kw/ref-app-start-integration' into kw/ref-native-frames…
krystofwoldrich Aug 6, 2024
91c1eb8
clean up integrations tests
krystofwoldrich Aug 6, 2024
db70c09
move native frames tests
krystofwoldrich Aug 6, 2024
e199244
add changelog
krystofwoldrich Aug 6, 2024
2956344
Merge branch 'kw/ref-app-start-integration' into kw/ref-native-frames…
krystofwoldrich Aug 6, 2024
adb53fc
fix
krystofwoldrich Aug 6, 2024
699fda7
move the app start test to tracing
krystofwoldrich Aug 6, 2024
7a386ab
Merge branch 'kw/ref-app-start-integration' into kw/ref-native-frames…
krystofwoldrich Aug 6, 2024
ad98ac0
fix tests
krystofwoldrich Aug 6, 2024
f2b9abe
add changelog
krystofwoldrich Aug 6, 2024
89b2354
ref(tracing): Extract Stall Tracking to a standalone integration
krystofwoldrich Aug 6, 2024
4f3ca7b
misc(tracing): Remove ReactNativeTracing deprecated options
krystofwoldrich Aug 6, 2024
5c12e5c
fix changelog
krystofwoldrich Aug 6, 2024
a111bdf
ref(tracing): Extract UserInteractionTracing as standalone interaction
krystofwoldrich Aug 6, 2024
92e04ee
Apply suggestions from code review
krystofwoldrich Aug 7, 2024
1168d4e
Revert "fix changelog"
krystofwoldrich Aug 7, 2024
a21e83d
Revert "misc(tracing): Remove ReactNativeTracing deprecated options"
krystofwoldrich Aug 7, 2024
af4c453
tests
krystofwoldrich Aug 7, 2024
3d33c02
fix tests
krystofwoldrich Aug 7, 2024
c71b900
fix tests
krystofwoldrich Aug 7, 2024
e632d53
Merge commit 'c71b9003a8934eca268d524732ab337325bc238d' into kw/ref-u…
krystofwoldrich Aug 7, 2024
474ee37
misc(tracing): Remove ReactNativeTracing deprecated options
krystofwoldrich Aug 6, 2024
07d9f00
fix changelog
krystofwoldrich Aug 6, 2024
6386062
refactor react native tracing to new function style integration
krystofwoldrich Aug 7, 2024
3002393
update changelog
krystofwoldrich Aug 7, 2024
2bbb93a
fix test, changelog and samples
krystofwoldrich Aug 8, 2024
0fad381
Merge remote-tracking branch 'origin/v6' into kw/rn-tracing-removed-d…
krystofwoldrich Aug 13, 2024
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Changes

- Removed deprecated ReactNativeTracing option `idleTimeout` use `idleTimeoutMs` instead ([#3998](https://github.com/getsentry/sentry-react-native/pull/3998))
- Removed deprecated ReactNativeTracing option `maxTransactionDuration` use `finalTimeoutMs` instead ([#3998](https://github.com/getsentry/sentry-react-native/pull/3998))
- Removed `beforeNavigate` use `beforeStartSpan` instead ([#3998](https://github.com/getsentry/sentry-react-native/pull/3998))
- `beforeStartSpan` is executed before the span start, compared to `beforeNavigate` which was executed before the navigation ended (after the span was created)
- New Native Frames Integration ([#3996](https://github.com/getsentry/sentry-react-native/pull/3996))
- New Stall Tracking Integration ([#3997](https://github.com/getsentry/sentry-react-native/pull/3997))
- New User Interaction Tracing Integration ([#3999](https://github.com/getsentry/sentry-react-native/pull/3999))
Expand All @@ -22,6 +26,12 @@
enableStallTracking: true, // default true
enableUserInteractionTracing: true, // default false
integrations: [
Sentry.reactNativeTracingIntegration({
beforeStartSpan: (startSpanOptions) => {
startSpanOptions.name = 'New Name';
return startSpanOptions;
},
}),
Sentry.appStartIntegration({
standalone: false, // default false
}),
Expand Down
2 changes: 1 addition & 1 deletion samples/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({
// default: [/.*/]
failedRequestTargets: [/.*/],
}),
new Sentry.ReactNativeTracing({
Sentry.reactNativeTracingIntegration({
routingInstrumentation,
}),
);
Expand Down
5 changes: 2 additions & 3 deletions samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ Sentry.init({
},
integrations(integrations) {
integrations.push(
new Sentry.ReactNativeTracing({
Sentry.reactNativeTracingIntegration({
// The time to wait in ms until the transaction will be finished, For testing, default is 1000 ms
idleTimeout: 5000,
idleTimeoutMs: 5_000,
routingInstrumentation: reactNavigationInstrumentation,
enableUserInteractionTracing: true,
ignoreEmptyBackNavigationTransactions: true,
}),
Sentry.httpClientIntegration({
Expand Down
4 changes: 2 additions & 2 deletions src/js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { defaultSdkInfo } from './integrations/sdkinfo';
import type { ReactNativeClientOptions } from './options';
import type { mobileReplayIntegration } from './replay/mobilereplay';
import { MOBILE_REPLAY_INTEGRATION_NAME } from './replay/mobilereplay';
import type { ReactNativeTracing } from './tracing';
import { getReactNativeTracingIntegration } from './tracing/reactnativetracing';
import { createUserFeedbackEnvelope, items } from './utils/envelope';
import { ignoreRequireCycleLogs } from './utils/ignorerequirecyclelogs';
import { mergeOutcomes } from './utils/outcome';
Expand Down Expand Up @@ -141,7 +141,7 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
*/
protected _setupIntegrations(): void {
super._setupIntegrations();
const tracing = this.getIntegrationByName<ReactNativeTracing>('ReactNativeTracing');
const tracing = getReactNativeTracingIntegration(this);
const routingName = tracing?.options?.routingInstrumentation?.name;
if (routingName) {
this.addIntegration(createIntegration(routingName));
Expand Down
2 changes: 1 addition & 1 deletion src/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export { init, wrap, nativeCrash, flush, close, captureUserFeedback, withScope }
export { TouchEventBoundary, withTouchEventBoundary } from './touchevents';

export {
ReactNativeTracing,
reactNativeTracingIntegration,
ReactNavigationV5Instrumentation,
ReactNavigationInstrumentation,
ReactNativeNavigationInstrumentation,
Expand Down
7 changes: 2 additions & 5 deletions src/js/integrations/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { BrowserOptions } from '@sentry/react';
import type { Integration } from '@sentry/types';

import type { ReactNativeClientOptions } from '../options';
import { ReactNativeTracing } from '../tracing';
import { reactNativeTracingIntegration } from '../tracing';
import { isExpoGo, notWeb } from '../utils/environment';
import {
appStartIntegration,
Expand Down Expand Up @@ -114,10 +114,7 @@ export function getDefaultIntegrations(options: ReactNativeClientOptions): Integ
integrations.push(userInteractionIntegration());
}
if (hasTracingEnabled && options.enableAutoPerformanceTracing) {
integrations.push(new ReactNativeTracing());
}
if (hasTracingEnabled && options.enableAppStartTracking) {
integrations.push(appStartIntegration());
integrations.push(reactNativeTracingIntegration());
}
if (options.enableCaptureFailedRequests) {
integrations.push(httpClientIntegration());
Expand Down
6 changes: 0 additions & 6 deletions src/js/touchevents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { GestureResponderEvent } from 'react-native';
import { StyleSheet, View } from 'react-native';

import { createIntegration } from './integrations/factory';
import type { ReactNativeTracing } from './tracing';
import { startUserInteractionSpan } from './tracing/integrations/userInteraction';
import { UI_ACTION_TOUCH } from './tracing/ops';

Expand Down Expand Up @@ -92,17 +91,12 @@ class TouchEventBoundary extends React.Component<TouchEventBoundaryProps> {

public readonly name: string = 'TouchEventBoundary';

private _tracingIntegration: ReactNativeTracing | null = null;

/**
* Registers the TouchEventBoundary as a Sentry Integration.
*/
public componentDidMount(): void {
const client = getClient();
client?.addIntegration?.(createIntegration(this.name));
if (!this._tracingIntegration && client) {
this._tracingIntegration = client.getIntegrationByName<ReactNativeTracing>('ReactNativeTracing') || null;
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/js/tracing/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export { ReactNativeTracing } from './reactnativetracing';
export {
reactNativeTracingIntegration,
INTEGRATION_NAME as REACT_NATIVE_TRACING_INTEGRATION_NAME,
} from './reactnativetracing';
export type { ReactNativeTracingIntegration } from './reactnativetracing';

export type { RoutingInstrumentationInstance } from './routingInstrumentation';
export { RoutingInstrumentation } from './routingInstrumentation';
Expand Down
5 changes: 2 additions & 3 deletions src/js/tracing/integrations/appStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
APP_START_WARM as APP_START_WARM_OP,
UI_LOAD as UI_LOAD_OP,
} from '../ops';
import { ReactNativeTracing } from '../reactnativetracing';
import { getReactNativeTracingIntegration } from '../reactnativetracing';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '../semanticAttributes';
import { createChildSpanJSON, createSpanJSON, getBundleStartTimestampMs } from '../utils';

Expand Down Expand Up @@ -126,8 +126,7 @@ export const appStartIntegration = ({
const afterAllSetup = (client: Client): void => {
if (standaloneUserOption === undefined) {
// If not user defined, set based on the routing instrumentation presence
standalone = !client.getIntegrationByName<ReactNativeTracing>(ReactNativeTracing.id)?.options
.routingInstrumentation;
standalone = !getReactNativeTracingIntegration(client)?.options.routingInstrumentation;
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/js/tracing/integrations/userInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const startUserInteractionSpan = (userInteractionId: {
logger.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction with undefined elementId.`);
return undefined;
}
if (!tracing.currentRoute) {
if (!tracing.state.currentRoute) {
logger.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction without a current route.`);
return undefined;
}
Expand All @@ -61,7 +61,7 @@ export const startUserInteractionSpan = (userInteractionId: {
return undefined;
}

const name = `${tracing.currentRoute}.${elementId}`;
const name = `${tracing.state.currentRoute}.${elementId}`;
if (
activeTransaction &&
spanToJSON(activeTransaction).description === name &&
Expand Down
14 changes: 11 additions & 3 deletions src/js/tracing/reactnativenavigation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { addBreadcrumb, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
import {
addBreadcrumb,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
spanToJSON,
} from '@sentry/core';
import type { Span } from '@sentry/types';

import type { EmitterSubscription } from '../utils/rnlibrariesinterface';
import { isSentrySpan } from '../utils/span';
import { DEFAULT_NAVIGATION_SPAN_NAME } from './reactnativetracing';
import type { OnConfirmRoute, TransactionCreator } from './routingInstrumentation';
import { InternalRoutingInstrumentation } from './routingInstrumentation';
import type { BeforeNavigate } from './types';
Expand Down Expand Up @@ -124,7 +130,7 @@ export class ReactNativeNavigationInstrumentation extends InternalRoutingInstrum
this._discardLatestTransaction();
}

this._latestTransaction = this.onRouteWillChange({ name: 'Route Change' });
this._latestTransaction = this.onRouteWillChange({ name: DEFAULT_NAVIGATION_SPAN_NAME });

this._stateChangeTimeout = setTimeout(
this._discardLatestTransaction.bind(this),
Expand All @@ -151,7 +157,9 @@ export class ReactNativeNavigationInstrumentation extends InternalRoutingInstrum

const routeHasBeenSeen = this._recentComponentIds.includes(event.componentId);

this._latestTransaction.updateName(event.componentName);
if (spanToJSON(this._latestTransaction).description === DEFAULT_NAVIGATION_SPAN_NAME) {
this._latestTransaction.updateName(event.componentName);
}
this._latestTransaction.setAttributes({
// TODO: Should we include pass props? I don't know exactly what it contains, cant find it in the RNavigation docs
'route.name': event.componentName,
Expand Down
Loading
Loading