Skip to content

Commit

Permalink
feat(onboarding) add profiling to onboarding docs (#75275)
Browse files Browse the repository at this point in the history
Add document header onboarding step and enable profiling onboarding for
js projects
  • Loading branch information
JonasBa authored Jul 30, 2024
1 parent a96cbb0 commit f0133a5
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {Fragment} from 'react';

import {
type StepProps,
TabbedCodeSnippet,
} from 'sentry/components/onboarding/gettingStartedDoc/step';
import {tct} from 'sentry/locale';

export function getProfilingDocumentHeaderConfigurationStep(): StepProps {
return {
title: 'Add Document-Policy: js-profiling header',
description: (
<Fragment>
<p>
{tct(
`For the JavaScript browser profiler to start, the document response header needs
to include a Document-Policy header key with the js-profiling value. How you do
this will depend on how your assets are served.
If you're using a server like Express, you'll be able to use the response.set function to set the header value.
`,
{}
)}
</p>
<TabbedCodeSnippet
tabs={[
{
code: `response.set('Document-Policy', 'js-profiling')`,
language: 'javascript',
value: 'javascript',
label: 'Express',
},
]}
/>
</Fragment>
),
};
}
17 changes: 11 additions & 6 deletions static/app/gettingStartedDocs/javascript/angular.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getFeedbackConfigureDescription,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand Down Expand Up @@ -46,6 +47,10 @@ const getNextStep = (
step => step.id !== ProductSolution.SESSION_REPLAY
);
}

if (params.isProfilingSelected) {
nextStepDocs = nextStepDocs.filter(step => step.id !== ProductSolution.PROFILING);
}
return nextStepDocs;
};

Expand Down Expand Up @@ -133,6 +138,9 @@ const onboarding: OnboardingConfig = {
},
],
},
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/guides/angular/sourcemaps/',
...params,
Expand Down Expand Up @@ -187,6 +195,7 @@ function getSdkSetupSnippet(params: Params) {
import * as Sentry from "@sentry/angular";
import { AppModule } from "./app/app.module";
import { getProfilingDocumentHeaderConfigurationStep } from '../../components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
Sentry.init({
dsn: "${params.dsn}",
Expand Down Expand Up @@ -232,12 +241,8 @@ ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}
});`;
Expand Down
13 changes: 7 additions & 6 deletions static/app/gettingStartedDocs/javascript/ember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getFeedbackConfigureDescription,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand All @@ -31,6 +32,7 @@ import loadInitializers from "ember-load-initializers";
import config from "./config/environment";
import * as Sentry from "@sentry/ember";
import { getProfilingDocumentHeaderConfigurationStep } from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
Sentry.init({
dsn: "${params.dsn}",
Expand Down Expand Up @@ -71,12 +73,8 @@ ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}
});
Expand Down Expand Up @@ -134,6 +132,9 @@ const onboarding: OnboardingConfig = {
},
],
},
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/guides/ember/sourcemaps/',
}),
Expand Down
13 changes: 7 additions & 6 deletions static/app/gettingStartedDocs/javascript/gatsby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getFeedbackConfigureDescription,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand All @@ -28,6 +29,7 @@ type Params = DocsParams;

const getSdkSetupSnippet = (params: Params) => `
import * as Sentry from "@sentry/gatsby";
import { getProfilingDocumentHeaderConfigurationStep } from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
Sentry.init({
dsn: "${params.dsn}",
Expand Down Expand Up @@ -73,12 +75,8 @@ ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}
});
Expand Down Expand Up @@ -166,6 +164,9 @@ const onboarding: OnboardingConfig = {
],
configure: (params: Params) => [
getConfigureStep(params),
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/guides/gatsby/sourcemaps//',
}),
Expand Down
12 changes: 6 additions & 6 deletions static/app/gettingStartedDocs/javascript/javascript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getFeedbackConfigureDescription,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand Down Expand Up @@ -72,12 +73,8 @@ ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}
});
Expand Down Expand Up @@ -135,6 +132,9 @@ const onboarding: OnboardingConfig = {
},
],
},
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/sourcemaps/',
}),
Expand Down
12 changes: 6 additions & 6 deletions static/app/gettingStartedDocs/javascript/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getFeedbackConfigureDescription,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand Down Expand Up @@ -65,12 +66,8 @@ ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}${
params.isReplaySelected
Expand Down Expand Up @@ -144,6 +141,9 @@ const onboarding: OnboardingConfig = {
},
],
},
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/guides/react/sourcemaps/',
}),
Expand Down
12 changes: 6 additions & 6 deletions static/app/gettingStartedDocs/javascript/solid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getFeedbackConfigureDescription,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand Down Expand Up @@ -73,12 +74,8 @@ ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}
});
Expand Down Expand Up @@ -154,6 +151,9 @@ const onboarding: OnboardingConfig = {
},
],
},
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/guides/solid/sourcemaps/',
}),
Expand Down
12 changes: 6 additions & 6 deletions static/app/gettingStartedDocs/javascript/svelte.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getFeedbackConfigureDescription,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand Down Expand Up @@ -74,12 +75,8 @@ ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}
});
Expand Down Expand Up @@ -149,6 +146,9 @@ const onboarding: OnboardingConfig = {
},
],
},
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/guides/svelte/sourcemaps/',
}),
Expand Down
12 changes: 6 additions & 6 deletions static/app/gettingStartedDocs/javascript/vue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getFeedbackSDKSetupSnippet,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
import {
getReplayConfigOptions,
getReplayConfigureDescription,
Expand Down Expand Up @@ -88,12 +89,8 @@ const getSentryInitLayout = (params: Params, siblingOption: string): string => {
}${
params.isProfilingSelected
? `
// Set profilesSampleRate to 1.0 to profile every transaction.
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
// results in 25% of transactions being profiled (0.5*0.5=0.25)
profilesSampleRate: 1.0,`
// Profiling
profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
: ''
}
});`;
Expand Down Expand Up @@ -169,6 +166,9 @@ const onboarding: OnboardingConfig<PlatformOptions> = {
),
configurations: getSetupConfiguration(params),
},
...(params.isProfilingSelected
? [getProfilingDocumentHeaderConfigurationStep()]
: []),
getUploadSourceMapsStep({
guideLink: 'https://docs.sentry.io/platforms/javascript/guides/vue/sourcemaps/',
...params,
Expand Down

0 comments on commit f0133a5

Please sign in to comment.