Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
04b6c06
bump SDKs
lucas-zimerman Feb 14, 2025
0dc4bca
bump SDKs
lucas-zimerman Feb 14, 2025
382fef6
fix build
lucas-zimerman Feb 14, 2025
33af36c
fix tests
lucas-zimerman Feb 19, 2025
ad6a76c
fix tests
lucas-zimerman Feb 19, 2025
15342a2
fix lint errors
lucas-zimerman Feb 19, 2025
c267f9b
test ts 5.0
lucas-zimerman Feb 19, 2025
efea84f
rollback
lucas-zimerman Feb 19, 2025
65a10d5
Merge branch 'v7' into lz/bump/jsv9
lucas-zimerman Feb 24, 2025
028dbf9
fix merge conflict with yarn
lucas-zimerman Feb 25, 2025
a57459a
fix new lint issue
lucas-zimerman Feb 25, 2025
5de9867
sync yarn.lock with V7 branch and install new packages
lucas-zimerman Feb 26, 2025
ae65521
ensure we are using the JS version from the default node resolution
lucas-zimerman Feb 26, 2025
bd64169
update changelog with javascript version bump
lucas-zimerman Feb 26, 2025
39a81c7
fix check type (#4587)
lucas-zimerman Feb 25, 2025
3a4fd4c
add major changes to the SDK
lucas-zimerman Feb 26, 2025
d8088ad
fix lint
lucas-zimerman Feb 26, 2025
6f71cda
review check: fix changelog PR number / Fix wrapper incorrect null c…
lucas-zimerman Feb 26, 2025
55c1961
fix incorrect cli version
lucas-zimerman Feb 26, 2025
97853c6
fix lint
lucas-zimerman Feb 26, 2025
dc2e123
Merge branch 'v7' into lz/bump/jsv9
lucas-zimerman Feb 25, 2025
9a0b21e
remove shutdowntimeout from android / use newer wizard version
lucas-zimerman Mar 3, 2025
45ee6fa
rollback feedback test change, rollback jest version, fix safe test
lucas-zimerman Mar 14, 2025
816b506
return shutdowntimeout
lucas-zimerman Mar 14, 2025
25bf147
explain tracing sample rate
lucas-zimerman Mar 14, 2025
8584214
fix tracing extension test
lucas-zimerman Mar 14, 2025
a26497e
Merge branch 'v7' into lz/bump/jsv9
lucas-zimerman Mar 14, 2025
499e5a3
lint fix
lucas-zimerman Mar 14, 2025
578ad2c
update changelog
lucas-zimerman Mar 15, 2025
d7fe6c6
merge v7
lucas-zimerman Apr 7, 2025
b08c54f
fix yarn lock merge/ fix ts-jest version no longer exists / fix cor…
lucas-zimerman Apr 7, 2025
19197f3
fix lint on addTimeToInitialDisplay
lucas-zimerman Apr 7, 2025
709697c
fix issue with UIManager test
lucas-zimerman Apr 7, 2025
a5ddcda
moved major changes to the correct spot
lucas-zimerman Apr 7, 2025
219a73a
adds test to wrap and use updateProps when not deifned
lucas-zimerman Apr 9, 2025
b3ba7a3
lint fix
lucas-zimerman Apr 9, 2025
9f16e0b
hide updateProps and children
lucas-zimerman Apr 9, 2025
ce42083
Merge branch 'v7' into lz/jsv9/fix-props
lucas-zimerman Apr 15, 2025
8e03349
Merge branch 'v7' into lz/jsv9/fix-props
lucas-zimerman Apr 15, 2025
a38cbcb
TESTS: removed tests that weren't validating relevant code/ remove e…
lucas-zimerman Apr 15, 2025
f56d96e
moved sdk.wrap.test to wrap.test.tsx / added tests for react native …
lucas-zimerman Apr 16, 2025
359153b
remove name option and add other defaults for testing
lucas-zimerman Apr 16, 2025
222077c
lets also remove removeUpdateProps
lucas-zimerman Apr 16, 2025
a5f021e
Merge branch 'v7' into lz/jsv9/fix-props
lucas-zimerman Apr 15, 2025
37e0c94
Apply suggestions from code review
lucas-zimerman Apr 16, 2025
517161c
fix updateProps as {}, removeUpdateProps flag, clear tests
lucas-zimerman Apr 16, 2025
11dfba7
Merge branch 'v7' into lz/jsv9/fix-props
lucas-zimerman Apr 16, 2025
883a831
Merge branch 'v7' into lz/jsv9/fix-props
lucas-zimerman Apr 28, 2025
415f623
do not affect test
lucas-zimerman Apr 29, 2025
4dc429f
checkpoint
lucas-zimerman Apr 29, 2025
8d9f65b
split mock/real tests
lucas-zimerman Apr 29, 2025
7c8c3d1
split mock/real tests
lucas-zimerman Apr 29, 2025
0eb0901
fix unused usings
lucas-zimerman Apr 29, 2025
0ad5d39
Merge branch 'v7' into lz/jsv9/fix-props
lucas-zimerman Apr 30, 2025
3fc3d9f
Merge branch 'v7' into lz/jsv9/fix-props
lucas-zimerman May 6, 2025
cb615e1
Apply suggestions from code review
lucas-zimerman May 8, 2025
cf5c90f
Remove removeUpdateProps
lucas-zimerman May 8, 2025
8b93d90
fix lint
lucas-zimerman May 8, 2025
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 packages/core/src/js/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export interface ReactNativeClientOptions

export interface ReactNativeWrapperOptions {
/** Props for the root React profiler */
profilerProps?: ProfilerProps;
profilerProps?: Omit<ProfilerProps, 'updateProps' | 'children' | 'name'>;

/** Props for the root touch event boundary */
touchEventBoundaryProps?: TouchEventBoundaryProps;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/sdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function wrap<P extends Record<string, unknown>>(
options?: ReactNativeWrapperOptions
): React.ComponentType<P> {
const profilerProps = {
...(options?.profilerProps ?? {}),
...(options?.profilerProps),
name: RootComponent.displayName ?? 'Root',
updateProps: {}
};
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/js/tracing/reactnativeprofiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const ReactNativeProfilerGlobalState = {
},
};

type ProfilerConstructorProps = ConstructorParameters<typeof Profiler>[0];

/**
* Custom profiler for the React Native app root.
*/
export class ReactNativeProfiler extends Profiler {
public readonly name: string = 'ReactNativeProfiler';

public constructor(props: ConstructorParameters<typeof Profiler>[0]) {
public constructor(props: ProfilerConstructorProps) {
_setRootComponentCreationTimestampMs(timestampInSeconds() * 1000);
super(props);
}
Expand Down
111 changes: 111 additions & 0 deletions packages/core/test/wrap.mocked.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// We can't test wrap with mock and non mocked components, otherwise it will break the RN testing library.
import { render } from '@testing-library/react-native';
import * as React from 'react';
import type { ReactNativeWrapperOptions } from 'src/js/options';

jest.doMock('../src/js/touchevents', () => {
return {
TouchEventBoundary: ({ children }: { children: React.ReactNode }) => (
// eslint-disable-next-line react/no-unknown-property
<div testID="touch-boundaryID">{children}</div>
),
}
});

jest.doMock('../src/js/tracing', () => {
return {
ReactNativeProfiler: jest.fn(({ children }: { children: React.ReactNode }) => (
// eslint-disable-next-line react/no-unknown-property
<div testID="profilerID">{children}</div>
)),
}
});

jest.doMock('../src/js/feedback/FeedbackWidgetManager', () => {
return {
FeedbackWidgetProvider: ({ children }: { children: React.ReactNode }) => (
// eslint-disable-next-line react/no-unknown-property
<div testID="feedback-widgetID">{children}</div>
),
};
});


import { wrap } from '../src/js/sdk';
import { ReactNativeProfiler } from '../src/js/tracing';

describe('Sentry.wrap', () => {

const DummyComponent: React.FC<{ value?: string }> = ({ value }) => <div>{value}</div>;

it('should not enforce any keys on the wrapped component', () => {
const Mock: React.FC<{ test: 23 }> = () => <></>;
const ActualWrapped = wrap(Mock);

expect(typeof ActualWrapped.defaultProps).toBe(typeof Mock.defaultProps);
});

it('wraps components with Sentry wrappers', () => {
const Wrapped = wrap(DummyComponent);
const renderResult = render(<Wrapped value="wrapped" />);

expect(renderResult.toJSON()).toMatchInlineSnapshot(`
<div
testID="touch-boundaryID"
>
<div
testID="profilerID"
>
<div
testID="feedback-widgetID"
>
<div>
wrapped
</div>
</div>
</div>
</div>
`);
});

describe('ReactNativeProfiler', () => {
it('uses given options when set', () => {
const options: ReactNativeWrapperOptions = {
profilerProps: { disabled: false, includeRender: true, includeUpdates: true },
};
const Wrapped = wrap(DummyComponent, options);
render(<Wrapped value="wrapped" />);

expect(ReactNativeProfiler).toHaveBeenCalledWith(
expect.objectContaining({
name: 'Root',
disabled: false,
includeRender: true,
includeUpdates: true
}),
expect.anything(),
);

expect(ReactNativeProfiler).not.toHaveBeenCalledWith(
expect.objectContaining({
updateProps: expect.anything(),
})
);
});

it('ignore updateProps when set', () => {
const { wrap } = jest.requireActual('../src/js/sdk');

const Wrapped = wrap(DummyComponent, { updateProps: ['prop'] });
render(<Wrapped value="wrapped" />);

expect(ReactNativeProfiler).toHaveBeenCalledWith(
expect.objectContaining({
name: 'Root',
updateProps: {},
}),
expect.anything(),
);
});
});
});
40 changes: 17 additions & 23 deletions packages/core/test/wrap.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// We can't test wrap with mock and non mocked components, otherwise it will break the RN testing library.
import { logger, setCurrentClient } from '@sentry/core';
import { render } from '@testing-library/react-native';
import * as React from 'react';
Expand All @@ -7,30 +8,23 @@ import * as AppRegistry from '../src/js/integrations/appRegistry';
import { wrap } from '../src/js/sdk';
import { getDefaultTestClientOptions, TestClient } from './mocks/client';

describe('Sentry.wrap', () => {
it('should not enforce any keys on the wrapped component', () => {
const Mock: React.FC<{ test: 23 }> = () => <></>;
const ActualWrapped = wrap(Mock);
describe('ReactNativeProfiler', () => {
it('should wrap the component and init with a warning when getAppRegistryIntegration returns undefined', () => {
logger.warn = jest.fn();
const getAppRegistryIntegration = jest.spyOn(AppRegistry, 'getAppRegistryIntegration').mockReturnValueOnce(undefined);
const Mock: React.FC = () => <Text>Test</Text>;
const client = new TestClient(
getDefaultTestClientOptions(),
);
setCurrentClient(client);

expect(typeof ActualWrapped.defaultProps).toBe(typeof Mock.defaultProps);
});

it('should wrap the component and init with a warning when getAppRegistryIntegration returns undefined', () => {
logger.warn = jest.fn();
const getAppRegistryIntegration = jest.spyOn(AppRegistry, 'getAppRegistryIntegration').mockReturnValueOnce(undefined);
const Mock: React.FC = () => <Text>Test</Text>;
const client = new TestClient(
getDefaultTestClientOptions(),
);
setCurrentClient(client);

client.init();
const ActualWrapped = wrap(Mock);
client.init();
const ActualWrapped = wrap(Mock);

const { getByText } = render(<ActualWrapped />);
const { getByText } = render(<ActualWrapped />);

expect(getAppRegistryIntegration).toHaveBeenCalled();
expect(logger.warn).toHaveBeenCalledWith('AppRegistryIntegration.onRunApplication not found or invalid.');
expect(getByText('Test')).toBeTruthy();
expect(getAppRegistryIntegration).toHaveBeenCalled();
expect(logger.warn).toHaveBeenCalledWith('AppRegistryIntegration.onRunApplication not found or invalid.');
expect(getByText('Test')).toBeTruthy();
});
});
});
Loading