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

(6) fix(tracing): ReactNativeTracing and initial navigation spans have to be created after integrations setup #4000

Merged
merged 44 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 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
9dd899e
fix(tracing): ReactNativeTracing and initial navigation spans have to…
krystofwoldrich Aug 8, 2024
5d98ded
fix background test
krystofwoldrich Aug 9, 2024
ecd26ed
Merge branch 'v6' into kw/tracing-integrations-independent-order
krystofwoldrich Aug 14, 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
Prev Previous commit
Next Next commit
clean up integrations tests
  • Loading branch information
krystofwoldrich committed Aug 6, 2024
commit 91c1eb885dd2e99505f26a2ebf9698db327bfee6
2 changes: 1 addition & 1 deletion src/js/tracing/integrations/nativeFrames.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ const MARGIN_OF_ERROR_SECONDS = 0.05;
* Instrumentation to add native slow/frozen frames measurements onto transactions.
*/
export const nativeFramesIntegration = (): Integration => {
const name: string = 'NativeFramesInstrumentation';
const name: string = 'NativeFrames';

/** The native frames at the finish time of the most recent span. */
let _lastSpanFinishFrames:
170 changes: 66 additions & 104 deletions test/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -315,21 +315,15 @@ describe('Tests the SDK functionality', () => {
it('no http client integration by default', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name: 'HttpClient' })]));
expectNotIntegration('HttpClient');
});

it('adds http client integration', () => {
init({
enableCaptureFailedRequests: true,
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'HttpClient' })]));
expectIntegration('HttpClient');
});

it('user defined http client integration overwrites default', () => {
@@ -361,53 +355,35 @@ describe('Tests the SDK functionality', () => {
it('no screenshot integration by default', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name: 'Screenshot' })]));
expectNotIntegration('Screenshot');
});

it('adds screenshot integration', () => {
init({
attachScreenshot: true,
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'Screenshot' })]));
expectIntegration('Screenshot');
});

it('no view hierarchy integration by default', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(
expect.not.arrayContaining([expect.objectContaining({ name: 'ViewHierarchy' })]),
);
expectNotIntegration('ViewHierarchy');
});

it('adds view hierarchy integration', () => {
init({
attachViewHierarchy: true,
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'ViewHierarchy' })]));
expectIntegration('ViewHierarchy');
});

it('no profiling integration by default', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(
expect.not.arrayContaining([expect.objectContaining({ name: 'HermesProfiling' })]),
);
expectNotIntegration('HermesProfiling');
});

it('adds profiling integration', () => {
@@ -417,47 +393,35 @@ describe('Tests the SDK functionality', () => {
},
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(
expect.arrayContaining([expect.objectContaining({ name: 'HermesProfiling' })]),
);
expectIntegration('HermesProfiling');
});

it('no spotlight integration by default', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name: 'Spotlight' })]));
expectNotIntegration('Spotlight');
});

it('adds spotlight integration', () => {
init({
enableSpotlight: true,
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'Spotlight' })]));
expectIntegration('Spotlight');
});

it('no app start integration by default', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name: 'AppStart' })]));
expectNotIntegration('AppStart');
});

it('when tracing enabled app start integration added by default', () => {
init({
tracesSampleRate: 0.5,
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'AppStart' })]));
expectIntegration('AppStart');
});

it('when tracing enabled and app start disabled the integration is not added', () => {
@@ -466,9 +430,30 @@ describe('Tests the SDK functionality', () => {
enableAppStartTracking: false,
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name: 'AppStart' })]));
expectNotIntegration('AppStart');
});

it('no native frames integration by default', () => {
init({});

expectNotIntegration('NativeFrames');
});

it('when tracing enabled native frames integration added by default', () => {
init({
tracesSampleRate: 0.5,
});

expectIntegration('NativeFrames');
});

it('when tracing enabled and native frames disabled the integration is not added', () => {
init({
tracesSampleRate: 0.5,
enableNativeFramesTracking: false,
});

expectNotIntegration('NativeFrames');
});

it('no default integrations', () => {
@@ -561,50 +546,29 @@ describe('Tests the SDK functionality', () => {
it('adds react default integrations', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(
expect.arrayContaining([
expect.objectContaining({ name: 'InboundFilters' }),
expect.objectContaining({ name: 'FunctionToString' }),
expect.objectContaining({ name: 'Breadcrumbs' }),
expect.objectContaining({ name: 'Dedupe' }),
expect.objectContaining({ name: 'HttpContext' }),
]),
);
expectIntegration('InboundFilters');
expectIntegration('FunctionToString');
expectIntegration('Breadcrumbs');
expectIntegration('Dedupe');
expectIntegration('HttpContext');
});

it('adds all platform default integrations', () => {
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(
expect.arrayContaining([
expect.objectContaining({ name: 'Release' }),
expect.objectContaining({ name: 'EventOrigin' }),
expect.objectContaining({ name: 'SdkInfo' }),
expect.objectContaining({ name: 'ReactNativeInfo' }),
]),
);
expectIntegration('Release');
expectIntegration('EventOrigin');
expectIntegration('SdkInfo');
expectIntegration('ReactNativeInfo');
});

it('adds web platform specific default integrations', () => {
(notWeb as jest.Mock).mockImplementation(() => false);
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(
expect.arrayContaining([
expect.objectContaining({ name: 'BrowserApiErrors' }),
expect.objectContaining({ name: 'GlobalHandlers' }),
expect.objectContaining({ name: 'LinkedErrors' }),
]),
);
expectIntegration('BrowserApiErrors');
expectIntegration('GlobalHandlers');
expectIntegration('LinkedErrors');
});

it('does not add native integrations if native disabled', () => {
@@ -617,36 +581,34 @@ describe('Tests the SDK functionality', () => {
},
});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(
expect.not.arrayContaining([expect.objectContaining({ name: 'DeviceContext' })]),
);
expect(actualIntegrations).toEqual(
expect.not.arrayContaining([expect.objectContaining({ name: 'ModulesLoader' })]),
);
expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name: 'Screenshot' })]));
expect(actualIntegrations).toEqual(
expect.not.arrayContaining([expect.objectContaining({ name: 'ViewHierarchy' })]),
);
expect(actualIntegrations).toEqual(
expect.not.arrayContaining([expect.objectContaining({ name: 'HermesProfiling' })]),
);
expectNotIntegration('DeviceContext');
expectNotIntegration('ModulesLoader');
expectNotIntegration('Screenshot');
expectNotIntegration('ViewHierarchy');
expectNotIntegration('HermesProfiling');
});
});

it('adds expo context integration if expo go is detected', () => {
(isExpoGo as jest.Mock).mockImplementation(() => true);
init({});

const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;

expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'ExpoContext' })]));
expectIntegration('ExpoContext');
});
});

function expectIntegration(name: string): void {
const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name })]));
}

function expectNotIntegration(name: string): void {
const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name })]));
}

function createMockedIntegration({ name }: { name?: string } = {}): Integration {
return {
name: name ?? 'MockedIntegration',