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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

## Unreleased

### Changes

- New App Start Integration ([#3852](https://github.com/getsentry/sentry-react-native/pull/3852))

By default app start spans are attached to the first created transaction.
Standalone mode creates single root span (transaction) including only app start data.

```js
import Sentry from '@sentry/react-native';

Sentry.init({
tracesSampleRate: 1.0,
enableAppStartTracking: true, // default true
integrations: [
Sentry.appStartIntegration({
standalone: false, // default false
}),
],
});
```

### Fixes

- Pass `sampleRate` option to the Android SDK ([#3979](https://github.com/getsentry/sentry-react-native/pull/3979))
Expand Down
3 changes: 3 additions & 0 deletions samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Sentry.init({
maskAllVectors: true,
// maskAllText: false,
}),
Sentry.appStartIntegration({
standalone: false,
}),
);
return integrations.filter(i => i.name !== 'Dedupe');
},
Expand Down
4 changes: 4 additions & 0 deletions src/js/integrations/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { ReactNativeClientOptions } from '../options';
import { ReactNativeTracing } from '../tracing';
import { isExpoGo, notWeb } from '../utils/environment';
import {
appStartIntegration,
breadcrumbsIntegration,
browserApiErrorsIntegration,
browserGlobalHandlersIntegration,
Expand Down Expand Up @@ -100,6 +101,9 @@ export function getDefaultIntegrations(options: ReactNativeClientOptions): Integ
if (hasTracingEnabled && options.enableAutoPerformanceTracing) {
integrations.push(new ReactNativeTracing());
}
if (hasTracingEnabled && options.enableAppStartTracking) {
integrations.push(appStartIntegration());
}
if (options.enableCaptureFailedRequests) {
integrations.push(httpClientIntegration());
}
Expand Down
1 change: 1 addition & 0 deletions src/js/integrations/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export { viewHierarchyIntegration } from './viewhierarchy';
export { expoContextIntegration } from './expocontext';
export { spotlightIntegration } from './spotlight';
export { mobileReplayIntegration } from '../replay/mobilereplay';
export { appStartIntegration } from '../tracing/integrations/appStart';

export {
breadcrumbsIntegration,
Expand Down
10 changes: 10 additions & 0 deletions src/js/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ export interface BaseReactNativeOptions {
*/
beforeScreenshot?: (event: Event, hint: EventHint) => boolean;

/**
* Track the app start time by adding measurements to the first route transaction. If there is no routing instrumentation
* an app start transaction will be started.
*
* Requires performance monitoring to be enabled.
*
* Default: true
*/
enableAppStartTracking?: boolean;

/**
* Options which are in beta, or otherwise not guaranteed to be stable.
*/
Expand Down
7 changes: 1 addition & 6 deletions src/js/sdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOp
import { shouldEnableNativeNagger } from './options';
import { enableSyncToNative } from './scopeSync';
import { TouchEventBoundary } from './touchevents';
import type { ReactNativeTracing } from './tracing';
import { ReactNativeProfiler } from './tracing';
import { useEncodePolyfill } from './transports/encodePolyfill';
import { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';
Expand All @@ -34,6 +33,7 @@ const DEFAULT_OPTIONS: ReactNativeOptions = {
attachStacktrace: true,
enableCaptureFailedRequests: false,
enableNdk: true,
enableAppStartTracking: true,
};

/**
Expand Down Expand Up @@ -112,11 +112,6 @@ export function wrap<P extends Record<string, unknown>>(
RootComponent: React.ComponentType<P>,
options?: ReactNativeWrapperOptions
): React.ComponentType<P> {
const tracingIntegration = getClient()?.getIntegrationByName?.('ReactNativeTracing') as ReactNativeTracing | undefined;
if (tracingIntegration) {
tracingIntegration.useAppStartWithProfiler = true;
}

const profilerProps = {
...(options?.profilerProps ?? {}),
name: RootComponent.displayName ?? 'Root',
Expand Down
Loading