Skip to content

Commit 5f7d0ee

Browse files
authored
feat(loader-settings): Add default configuration hint to "Enable Performance" toggle (#74550)
Add a hint to the default configuration of tracing/performance monitoring to the loader settings. It will appear when "Enable Performance Monitoring" is toggled. Also adds a test for the message.
1 parent 14d616f commit 5f7d0ee

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

static/app/views/settings/project/projectKeys/details/loaderSettings.spec.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,63 @@ describe('Loader Script Settings', function () {
302302
)
303303
).not.toBeInTheDocument();
304304
});
305+
306+
it('shows performance message when it is enabled', function () {
307+
const {organization, project} = initializeOrg();
308+
const params = {
309+
projectSlug: project.slug,
310+
keyId: '1',
311+
};
312+
313+
const data = {
314+
...(ProjectKeysFixture()[0] as ProjectKey),
315+
dynamicSdkLoaderOptions: fullDynamicSdkLoaderOptions,
316+
} as ProjectKey;
317+
318+
const {rerender} = render(
319+
<LoaderSettings
320+
updateData={jest.fn()}
321+
orgSlug={organization.slug}
322+
keyId={params.keyId}
323+
project={project}
324+
data={data}
325+
/>
326+
);
327+
328+
expect(
329+
screen.getByText('tracesSampleRate: 1.0', {
330+
exact: false,
331+
})
332+
).toBeInTheDocument();
333+
334+
expect(
335+
screen.getByText('distributed tracing to same-origin requests', {
336+
exact: false,
337+
})
338+
).toBeInTheDocument();
339+
340+
data.dynamicSdkLoaderOptions.hasPerformance = false;
341+
342+
rerender(
343+
<LoaderSettings
344+
updateData={jest.fn()}
345+
orgSlug={organization.slug}
346+
keyId={params.keyId}
347+
project={project}
348+
data={data}
349+
/>
350+
);
351+
352+
expect(
353+
screen.queryByText('tracesSampleRate: 1.0', {
354+
exact: false,
355+
})
356+
).not.toBeInTheDocument();
357+
358+
expect(
359+
screen.queryByText('distributed tracing to same-origin requests', {
360+
exact: false,
361+
})
362+
).not.toBeInTheDocument();
363+
});
305364
});

static/app/views/settings/project/projectKeys/details/loaderSettings.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,17 @@ export function LoaderSettings({keyId, orgSlug, project, data, updateData}: Prop
196196
help={
197197
!sdkVersionSupportsPerformanceAndReplay(data.browserSdkVersion)
198198
? t('Only available in SDK version 7.x and above')
199-
: undefined
199+
: data.dynamicSdkLoaderOptions.hasPerformance
200+
? tct(
201+
'The default configurations are [codeTracesSampleRate:tracesSampleRate: 1.0] and distributed tracing to same-origin requests. [configDocs:Read the docs] to learn how to configure this.',
202+
{
203+
codeTracesSampleRate: <code />,
204+
configDocs: (
205+
<ExternalLink href="https://docs.sentry.io/platforms/javascript/install/loader/#custom-configuration" />
206+
),
207+
}
208+
)
209+
: undefined
200210
}
201211
disabledReason={
202212
!hasAccess

0 commit comments

Comments
 (0)