Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

## Fixes

- Remove the warning that used to indicate that Time To Initial Display and Time To Full Display are not supported ([#5081](https://github.com/getsentry/sentry-react-native/pull/5081))

## 6.20.0

### Features
Expand Down
16 changes: 1 addition & 15 deletions packages/core/src/js/tracing/timetodisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import { fill, getActiveSpan, getSpanDescendants, logger, SEMANTIC_ATTRIBUTE_SEN
import * as React from 'react';
import { useState } from 'react';

import { isTurboModuleEnabled } from '../utils/environment';
import { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from './origin';
import { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';
import { getRNSentryOnDrawReporter } from './timetodisplaynative';
import { setSpanDurationAsMeasurement, setSpanDurationAsMeasurementOnSpan } from './utils';

let nativeComponentMissingLogged = false;

/**
* Flags of active spans with manual initial display.
*/
Expand Down Expand Up @@ -62,17 +59,6 @@ function TimeToDisplay(props: {
parentSpanId?: string;
}): React.ReactElement {
const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();
const isNewArchitecture = isTurboModuleEnabled();

if (__DEV__ && (isNewArchitecture || (!nativeComponentExists && !nativeComponentMissingLogged))){
nativeComponentMissingLogged = true;
// Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.
setTimeout(() => {
logger.warn(
'TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');
}, 0);
}

return (
<>
<RNSentryOnDrawReporter
Expand Down
19 changes: 0 additions & 19 deletions packages/core/test/tracing/timetodisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jest.mock('../../src/js/wrapper', () => mockWrapper);
import * as mockedtimetodisplaynative from './mockedtimetodisplaynative';
jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative);

import { isTurboModuleEnabled } from '../../src/js/utils/environment';
jest.mock('../../src/js/utils/environment', () => ({
isWeb: jest.fn().mockReturnValue(false),
isTurboModuleEnabled: jest.fn().mockReturnValue(false),
Expand Down Expand Up @@ -290,24 +289,6 @@ describe('TimeToDisplay', () => {
expect(getInitialDisplaySpanJSON(client.event!.spans!)!.timestamp).toEqual(initialDisplayEndTimestampMs / 1_000);
expect(getFullDisplaySpanJSON(client.event!.spans!)!.timestamp).toEqual(initialDisplayEndTimestampMs / 1_000);
});

test('should not log a warning if native component exists and not in new architecture', async () => {
(isTurboModuleEnabled as jest.Mock).mockReturnValue(false);

TestRenderer.create(<TimeToInitialDisplay record={true} />);
await jest.runOnlyPendingTimersAsync(); // Flush setTimeout.

expect(logger.warn).not.toHaveBeenCalled();
});

test('should log a warning if in new architecture', async () => {
(isTurboModuleEnabled as jest.Mock).mockReturnValue(true);
TestRenderer.create(<TimeToInitialDisplay record={true} />);
await jest.runOnlyPendingTimersAsync(); // Flush setTimeout.

expect(logger.warn).toHaveBeenCalledWith(
'TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');
});
});

function getInitialDisplaySpanJSON(spans: SpanJSON[]) {
Expand Down
Loading