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

feat(ddm-onboarding): Serverless javascript instructions #64540

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 4 additions & 2 deletions static/app/data/platformCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,12 @@ const customMetricBackendPlatforms: readonly PlatformKey[] = [
'python-wsgi',
'rust',
'node',
'node-awslambda',
'node-azurefunctions',
'node-connect',
'node-express',
'node-gcpfunctions',
'node-koa',
'node-connect',
'node-azurefunctions',
];

const customMetricFrontendPlatforms: readonly PlatformKey[] = [
Expand Down
53 changes: 53 additions & 0 deletions static/app/gettingStartedDocs/node/awslambda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
OnboardingConfig,
} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
import {getJSServerMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {ProductSolution} from 'sentry/components/onboarding/productSelection';
import {t, tct} from 'sentry/locale';
import type {ProductSelectionMap} from 'sentry/utils/gettingStartedDocs/node';
Expand Down Expand Up @@ -59,6 +60,14 @@ exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
throw new Error("This should show up in Sentry!")
});`;

const getMetricsConfigureSnippet = (params: DocsParams) => `
Sentry.AWSLambda.init({
dsn: "${params.dsn}",
_experiments: {
metricsAggregator: true,
},
});`;

const onboarding: OnboardingConfig = {
install: params => [
{
Expand Down Expand Up @@ -106,8 +115,52 @@ const onboarding: OnboardingConfig = {
],
};

const customMetricsOnboarding: OnboardingConfig = {
install: params => [
{
type: StepType.INSTALL,
description: tct(
'You need a minimum version [codeVersion:7.91.0] of [codePackage:@sentry/serverless]:',
{
codeVersion: <code />,
codePackage: <code />,
}
),
configurations: getInstallConfig(params, {
basePackage: '@sentry/serverless',
}),
},
],
configure: params => [
{
type: StepType.CONFIGURE,
description: tct(
'To enable capturing metrics, you first need to add the [codeIntegration:metricsAggregator] experiment to your [codeNamespace:Sentry.init] call in your main process.',
{
codeIntegration: <code />,
codeNamespace: <code />,
}
),
configurations: [
{
code: [
{
label: 'JavaScript',
value: 'javascript',
language: 'javascript',
code: getMetricsConfigureSnippet(params),
},
],
},
],
},
],
verify: getJSServerMetricsOnboarding().verify,
};

const docs: Docs = {
onboarding,
customMetricsOnboarding,
};

export default docs;
51 changes: 51 additions & 0 deletions static/app/gettingStartedDocs/node/gcpfunctions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
OnboardingConfig,
} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
import {getJSServerMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {ProductSolution} from 'sentry/components/onboarding/productSelection';
import {t, tct} from 'sentry/locale';
import type {ProductSelectionMap} from 'sentry/utils/gettingStartedDocs/node';
Expand Down Expand Up @@ -83,6 +84,14 @@ exports.helloHttp = Sentry.GCPFunction.wrapHttpFunction((req, res) => {
throw new Error("oh, hello there!");
});`;

const getMetricsConfigureSnippet = (params: DocsParams) => `
Sentry.GCPFunction.init({
dsn: "${params.dsn}",
_experiments: {
metricsAggregator: true,
},
});`;

const onboarding: OnboardingConfig = {
install: params => [
{
Expand Down Expand Up @@ -133,8 +142,50 @@ const onboarding: OnboardingConfig = {
],
};

const customMetricsOnboarding: OnboardingConfig = {
install: params => [
{
type: StepType.INSTALL,
description: tct(
'You need a minimum version [codeVersion:7.91.0] of [codePackage:@sentry/serverless]:',
{
codeVersion: <code />,
codePackage: <code />,
}
),
configurations: [{language: 'json', code: getInstallSnippet(params)}],
},
],
configure: params => [
{
type: StepType.CONFIGURE,
description: tct(
'To enable capturing metrics, you first need to add the [codeIntegration:metricsAggregator] experiment to your [codeNamespace:Sentry.init] call in your main process.',
{
codeIntegration: <code />,
codeNamespace: <code />,
}
),
configurations: [
{
code: [
{
label: 'JavaScript',
value: 'javascript',
language: 'javascript',
code: getMetricsConfigureSnippet(params),
},
],
},
],
},
],
verify: getJSServerMetricsOnboarding().verify,
};

const docs: Docs = {
onboarding,
customMetricsOnboarding,
};

export default docs;
9 changes: 4 additions & 5 deletions static/app/views/ddm/ddmOnboarding/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ function MetricsOnboardingSidebar(props: CommonSidebarProps) {
const projectSelectOptions = useMemo(() => {
const supportedProjectItems: SelectValue<string>[] = supportedProjects
.sort((aProject, bProject) => {
// TODO(aknaus): Enable once we have thw hasCustomMetrics flag
// if we're comparing two projects w/ or w/o custom metrics alphabetical sort
// if (aProject.hasCustomMetrics === bProject.hasCustomMetrics) {
return aProject.slug.localeCompare(bProject.slug);
// }
if (aProject.hasCustomMetrics === bProject.hasCustomMetrics) {
return aProject.slug.localeCompare(bProject.slug);
}
// otherwise sort by whether or not they have custom metrics
// return aProject.hasCustomMetrics ? 1 : -1;
return aProject.hasCustomMetrics ? 1 : -1;
})
.map(project => {
return {
Expand Down
Loading