Browse Source

feat(onboarding): Simplify multi snippet docs javascript [part2] (#57200)

Simplify multi snippet docs for the platforms `node`, `node-awslambda`,
`node-azurefunctions`, `node-connect`, `node-express`, `node-koa`

Closes https://github.com/getsentry/sentry/issues/56839
ArthurKnaus 1 year ago
parent
commit
f98f700be9

+ 2 - 1
static/app/gettingStartedDocs/node/awslambda.spec.tsx

@@ -10,7 +10,8 @@ describe('GettingStartedWithAwsLambda', function () {
 
 
     // Steps
     // Steps
     for (const step of steps({
     for (const step of steps({
-      installSnippet: 'test-install-snippet',
+      installSnippetYarn: 'test-install-snippet-yarn',
+      installSnippetNpm: 'test-install-snippet-npm',
       importContent: 'test-import-content',
       importContent: 'test-import-content',
       initContent: 'test-init-content',
       initContent: 'test-init-content',
       sourceMapStep: {
       sourceMapStep: {

+ 28 - 9
static/app/gettingStartedDocs/node/awslambda.tsx

@@ -16,12 +16,14 @@ import {
 interface StepsParams {
 interface StepsParams {
   importContent: string;
   importContent: string;
   initContent: string;
   initContent: string;
-  installSnippet: string;
+  installSnippetNpm: string;
+  installSnippetYarn: string;
   sourceMapStep: StepProps;
   sourceMapStep: StepProps;
 }
 }
 
 
 export const steps = ({
 export const steps = ({
-  installSnippet,
+  installSnippetYarn,
+  installSnippetNpm,
   importContent,
   importContent,
   initContent,
   initContent,
   sourceMapStep,
   sourceMapStep,
@@ -31,8 +33,20 @@ export const steps = ({
     description: t('Add the Sentry Serverless SDK as a dependency:'),
     description: t('Add the Sentry Serverless SDK as a dependency:'),
     configurations: [
     configurations: [
       {
       {
-        language: 'bash',
-        code: installSnippet,
+        code: [
+          {
+            label: 'npm',
+            value: 'npm',
+            language: 'bash',
+            code: installSnippetNpm,
+          },
+          {
+            label: 'yarn',
+            value: 'yarn',
+            language: 'bash',
+            code: installSnippetYarn,
+          },
+        ],
       },
       },
     ],
     ],
   },
   },
@@ -92,10 +106,6 @@ export function GettingStartedWithAwsLambda({
 }: ModuleProps) {
 }: ModuleProps) {
   const productSelection = getProductSelectionMap(activeProductSelection);
   const productSelection = getProductSelectionMap(activeProductSelection);
 
 
-  const installSnippet = getInstallSnippet({
-    productSelection,
-    basePackage: '@sentry/serverless',
-  });
   const imports = getDefaulServerlessImports({productSelection});
   const imports = getDefaulServerlessImports({productSelection});
   const integrations = getProductIntegrations({productSelection});
   const integrations = getProductIntegrations({productSelection});
 
 
@@ -113,7 +123,16 @@ export function GettingStartedWithAwsLambda({
   return (
   return (
     <Layout
     <Layout
       steps={steps({
       steps={steps({
-        installSnippet,
+        installSnippetNpm: getInstallSnippet({
+          basePackage: '@sentry/serverless',
+          productSelection,
+          packageManager: 'npm',
+        }),
+        installSnippetYarn: getInstallSnippet({
+          basePackage: '@sentry/serverless',
+          productSelection,
+          packageManager: 'yarn',
+        }),
         importContent: imports.join('\n'),
         importContent: imports.join('\n'),
         initContent,
         initContent,
         sourceMapStep: getUploadSourceMapsStep({
         sourceMapStep: getUploadSourceMapsStep({

+ 2 - 1
static/app/gettingStartedDocs/node/azurefunctions.spec.tsx

@@ -12,7 +12,8 @@ describe('GettingStartedWithAzurefunctions', function () {
 
 
     // Steps
     // Steps
     for (const step of steps({
     for (const step of steps({
-      installSnippet: 'test-install-snippet',
+      installSnippetYarn: 'test-install-snippet-yarn',
+      installSnippetNpm: 'test-install-snippet-npm',
       importContent: 'test-import-content',
       importContent: 'test-import-content',
       initContent: 'test-init-content',
       initContent: 'test-init-content',
       sourceMapStep: {
       sourceMapStep: {

+ 20 - 6
static/app/gettingStartedDocs/node/azurefunctions.tsx

@@ -16,12 +16,14 @@ import {
 interface StepsParams {
 interface StepsParams {
   importContent: string;
   importContent: string;
   initContent: string;
   initContent: string;
-  installSnippet: string;
+  installSnippetNpm: string;
+  installSnippetYarn: string;
   sourceMapStep: StepProps;
   sourceMapStep: StepProps;
 }
 }
 
 
 export const steps = ({
 export const steps = ({
-  installSnippet,
+  installSnippetYarn,
+  installSnippetNpm,
   importContent,
   importContent,
   initContent,
   initContent,
   sourceMapStep,
   sourceMapStep,
@@ -31,8 +33,20 @@ export const steps = ({
     description: t('Add the Sentry Node SDK as a dependency:'),
     description: t('Add the Sentry Node SDK as a dependency:'),
     configurations: [
     configurations: [
       {
       {
-        language: 'bash',
-        code: installSnippet,
+        code: [
+          {
+            label: 'npm',
+            value: 'npm',
+            language: 'bash',
+            code: installSnippetNpm,
+          },
+          {
+            label: 'yarn',
+            value: 'yarn',
+            language: 'bash',
+            code: installSnippetYarn,
+          },
+        ],
       },
       },
     ],
     ],
   },
   },
@@ -93,7 +107,6 @@ export function GettingStartedWithAzurefunctions({
 }: ModuleProps) {
 }: ModuleProps) {
   const productSelection = getProductSelectionMap(activeProductSelection);
   const productSelection = getProductSelectionMap(activeProductSelection);
 
 
-  const installSnippet = getInstallSnippet({productSelection});
   const imports = getDefaultNodeImports({productSelection});
   const imports = getDefaultNodeImports({productSelection});
   const integrations = getProductIntegrations({productSelection});
   const integrations = getProductIntegrations({productSelection});
 
 
@@ -111,7 +124,8 @@ export function GettingStartedWithAzurefunctions({
   return (
   return (
     <Layout
     <Layout
       steps={steps({
       steps={steps({
-        installSnippet,
+        installSnippetNpm: getInstallSnippet({productSelection, packageManager: 'npm'}),
+        installSnippetYarn: getInstallSnippet({productSelection, packageManager: 'yarn'}),
         importContent: imports.join('\n'),
         importContent: imports.join('\n'),
         initContent,
         initContent,
         sourceMapStep: getUploadSourceMapsStep({
         sourceMapStep: getUploadSourceMapsStep({

+ 2 - 1
static/app/gettingStartedDocs/node/connect.spec.tsx

@@ -10,7 +10,8 @@ describe('GettingStartedWithConnect', function () {
 
 
     // Steps
     // Steps
     for (const step of steps({
     for (const step of steps({
-      installSnippet: 'test-install-snippet',
+      installSnippetYarn: 'test-install-snippet-yarn',
+      installSnippetNpm: 'test-install-snippet-npm',
       importContent: 'test-import-content',
       importContent: 'test-import-content',
       initContent: 'test-init-content',
       initContent: 'test-init-content',
       sourceMapStep: {
       sourceMapStep: {

+ 20 - 6
static/app/gettingStartedDocs/node/connect.tsx

@@ -16,12 +16,14 @@ import {
 interface StepsParams {
 interface StepsParams {
   importContent: string;
   importContent: string;
   initContent: string;
   initContent: string;
-  installSnippet: string;
+  installSnippetNpm: string;
+  installSnippetYarn: string;
   sourceMapStep: StepProps;
   sourceMapStep: StepProps;
 }
 }
 
 
 export const steps = ({
 export const steps = ({
-  installSnippet,
+  installSnippetYarn,
+  installSnippetNpm,
   importContent,
   importContent,
   initContent,
   initContent,
   sourceMapStep,
   sourceMapStep,
@@ -31,8 +33,20 @@ export const steps = ({
     description: t('Add the Sentry Node SDK as a dependency:'),
     description: t('Add the Sentry Node SDK as a dependency:'),
     configurations: [
     configurations: [
       {
       {
-        language: 'bash',
-        code: installSnippet,
+        code: [
+          {
+            label: 'npm',
+            value: 'npm',
+            language: 'bash',
+            code: installSnippetNpm,
+          },
+          {
+            label: 'yarn',
+            value: 'yarn',
+            language: 'bash',
+            code: installSnippetYarn,
+          },
+        ],
       },
       },
     ],
     ],
   },
   },
@@ -93,7 +107,6 @@ export function GettingStartedWithConnect({
 }: ModuleProps) {
 }: ModuleProps) {
   const productSelection = getProductSelectionMap(activeProductSelection);
   const productSelection = getProductSelectionMap(activeProductSelection);
 
 
-  const installSnippet = getInstallSnippet({productSelection});
   const imports = getDefaultNodeImports({productSelection});
   const imports = getDefaultNodeImports({productSelection});
   imports.push('import connect from "connect";');
   imports.push('import connect from "connect";');
 
 
@@ -112,7 +125,8 @@ export function GettingStartedWithConnect({
   return (
   return (
     <Layout
     <Layout
       steps={steps({
       steps={steps({
-        installSnippet,
+        installSnippetNpm: getInstallSnippet({productSelection, packageManager: 'npm'}),
+        installSnippetYarn: getInstallSnippet({productSelection, packageManager: 'yarn'}),
         importContent: imports.join('\n'),
         importContent: imports.join('\n'),
         initContent,
         initContent,
         sourceMapStep: getUploadSourceMapsStep({
         sourceMapStep: getUploadSourceMapsStep({

+ 2 - 1
static/app/gettingStartedDocs/node/express.spec.tsx

@@ -10,7 +10,8 @@ describe('GettingStartedWithExpress', function () {
 
 
     // Steps
     // Steps
     for (const step of steps({
     for (const step of steps({
-      installSnippet: 'test-install-snippet',
+      installSnippetYarn: 'test-install-snippet-yarn',
+      installSnippetNpm: 'test-install-snippet-npm',
       importContent: 'test-import-content',
       importContent: 'test-import-content',
       initContent: 'test-init-content',
       initContent: 'test-init-content',
       hasPerformanceMonitoring: true,
       hasPerformanceMonitoring: true,

+ 20 - 6
static/app/gettingStartedDocs/node/express.tsx

@@ -17,7 +17,8 @@ interface StepsParams {
   hasPerformanceMonitoring: boolean;
   hasPerformanceMonitoring: boolean;
   importContent: string;
   importContent: string;
   initContent: string;
   initContent: string;
-  installSnippet: string;
+  installSnippetNpm: string;
+  installSnippetYarn: string;
   sourceMapStep: StepProps;
   sourceMapStep: StepProps;
 }
 }
 
 
@@ -29,7 +30,8 @@ const performanceIntegrations: string[] = [
 ];
 ];
 
 
 export const steps = ({
 export const steps = ({
-  installSnippet,
+  installSnippetYarn,
+  installSnippetNpm,
   importContent,
   importContent,
   initContent,
   initContent,
   hasPerformanceMonitoring,
   hasPerformanceMonitoring,
@@ -40,8 +42,20 @@ export const steps = ({
     description: t('Add the Sentry Node SDK as a dependency:'),
     description: t('Add the Sentry Node SDK as a dependency:'),
     configurations: [
     configurations: [
       {
       {
-        language: 'bash',
-        code: installSnippet,
+        code: [
+          {
+            label: 'npm',
+            value: 'npm',
+            language: 'bash',
+            code: installSnippetNpm,
+          },
+          {
+            label: 'yarn',
+            value: 'yarn',
+            language: 'bash',
+            code: installSnippetYarn,
+          },
+        ],
       },
       },
     ],
     ],
   },
   },
@@ -128,7 +142,6 @@ export function GettingStartedWithExpress({
 }: ModuleProps) {
 }: ModuleProps) {
   const productSelection = getProductSelectionMap(activeProductSelection);
   const productSelection = getProductSelectionMap(activeProductSelection);
 
 
-  const installSnippet = getInstallSnippet({productSelection});
   const imports = getDefaultNodeImports({productSelection});
   const imports = getDefaultNodeImports({productSelection});
   imports.push('import express from "express";');
   imports.push('import express from "express";');
 
 
@@ -151,7 +164,8 @@ export function GettingStartedWithExpress({
   return (
   return (
     <Layout
     <Layout
       steps={steps({
       steps={steps({
-        installSnippet,
+        installSnippetNpm: getInstallSnippet({productSelection, packageManager: 'npm'}),
+        installSnippetYarn: getInstallSnippet({productSelection, packageManager: 'yarn'}),
         importContent: imports.join('\n'),
         importContent: imports.join('\n'),
         initContent,
         initContent,
         hasPerformanceMonitoring: productSelection['performance-monitoring'],
         hasPerformanceMonitoring: productSelection['performance-monitoring'],

+ 2 - 1
static/app/gettingStartedDocs/node/koa.spec.tsx

@@ -10,7 +10,8 @@ describe('GettingStartedWithKoa', function () {
 
 
     // Steps
     // Steps
     for (const step of steps({
     for (const step of steps({
-      installSnippet: 'test-install-snippet',
+      installSnippetYarn: 'test-install-snippet-yarn',
+      installSnippetNpm: 'test-install-snippet-npm',
       importContent: 'test-import-content',
       importContent: 'test-import-content',
       initContent: 'test-init-content',
       initContent: 'test-init-content',
       hasPerformanceMonitoring: true,
       hasPerformanceMonitoring: true,

+ 29 - 6
static/app/gettingStartedDocs/node/koa.tsx

@@ -17,7 +17,8 @@ interface StepsParams {
   hasPerformanceMonitoring: boolean;
   hasPerformanceMonitoring: boolean;
   importContent: string;
   importContent: string;
   initContent: string;
   initContent: string;
-  installSnippet: string;
+  installSnippetNpm: string;
+  installSnippetYarn: string;
   sourceMapStep: StepProps;
   sourceMapStep: StepProps;
 }
 }
 
 
@@ -27,7 +28,8 @@ const performanceIntegrations: string[] = [
 ];
 ];
 
 
 export const steps = ({
 export const steps = ({
-  installSnippet,
+  installSnippetYarn,
+  installSnippetNpm,
   importContent,
   importContent,
   initContent,
   initContent,
   hasPerformanceMonitoring,
   hasPerformanceMonitoring,
@@ -38,8 +40,20 @@ export const steps = ({
     description: t('Add the Sentry Node SDK as a dependency:'),
     description: t('Add the Sentry Node SDK as a dependency:'),
     configurations: [
     configurations: [
       {
       {
-        language: 'bash',
-        code: installSnippet,
+        code: [
+          {
+            label: 'npm',
+            value: 'npm',
+            language: 'bash',
+            code: installSnippetNpm,
+          },
+          {
+            label: 'yarn',
+            value: 'yarn',
+            language: 'bash',
+            code: installSnippetYarn,
+          },
+        ],
       },
       },
     ],
     ],
   },
   },
@@ -186,7 +200,7 @@ export function GettingStartedWithKoa({
   const additionalPackages = productSelection['performance-monitoring']
   const additionalPackages = productSelection['performance-monitoring']
     ? ['@sentry/utils']
     ? ['@sentry/utils']
     : [];
     : [];
-  const installSnippet = getInstallSnippet({productSelection, additionalPackages});
+
   let imports = getDefaultNodeImports({productSelection});
   let imports = getDefaultNodeImports({productSelection});
   imports = imports.concat([
   imports = imports.concat([
     'import { stripUrlQueryAndFragment } from "@sentry/utils";',
     'import { stripUrlQueryAndFragment } from "@sentry/utils";',
@@ -212,7 +226,16 @@ export function GettingStartedWithKoa({
   return (
   return (
     <Layout
     <Layout
       steps={steps({
       steps={steps({
-        installSnippet,
+        installSnippetNpm: getInstallSnippet({
+          additionalPackages,
+          productSelection,
+          packageManager: 'npm',
+        }),
+        installSnippetYarn: getInstallSnippet({
+          additionalPackages,
+          productSelection,
+          packageManager: 'yarn',
+        }),
         importContent: imports.join('\n'),
         importContent: imports.join('\n'),
         initContent,
         initContent,
         hasPerformanceMonitoring: productSelection['performance-monitoring'],
         hasPerformanceMonitoring: productSelection['performance-monitoring'],

Some files were not shown because too many files changed in this diff