Browse Source

feat(onboarding): Add profiling to platform node-azurefunctions (#55533)

Add profiling product selection to platform `node-azurefunctions`.

Closes https://github.com/getsentry/sentry/issues/55443
ArthurKnaus 1 year ago
parent
commit
61041e7a14

+ 4 - 0
static/app/components/onboarding/productSelection.tsx

@@ -64,6 +64,10 @@ export const platformProductAvailability = {
     ProductSolution.SESSION_REPLAY,
   ],
   node: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
+  'node-azurefunctions': [
+    ProductSolution.PERFORMANCE_MONITORING,
+    ProductSolution.PROFILING,
+  ],
   'node-connect': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
   python: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
   'python-aiohttp': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],

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

@@ -9,7 +9,11 @@ describe('GettingStartedWithAzurefunctions', function () {
     const {container} = render(<GettingStartedWithAzurefunctions dsn="test-dsn" />);
 
     // Steps
-    for (const step of steps()) {
+    for (const step of steps({
+      installSnippet: 'test-install-snippet',
+      importContent: 'test-import-content',
+      initContent: 'test-init-content',
+    })) {
       expect(
         screen.getByRole('heading', {name: step.title ?? StepTitle[step.type]})
       ).toBeInTheDocument();

+ 42 - 31
static/app/gettingStartedDocs/node/azurefunctions.tsx

@@ -1,36 +1,35 @@
 import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
 import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
 import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
-import {PlatformKey} from 'sentry/data/platformCategories';
 import {t, tct} from 'sentry/locale';
-import type {Organization} from 'sentry/types';
+import {
+  getDefaultInitParams,
+  getDefaultNodeImports,
+  getInstallSnippet,
+  getProductInitParams,
+  getProductIntegrations,
+  getProductSelectionMap,
+  joinWithIndentation,
+} from 'sentry/utils/gettingStartedDocs/node';
 
-type StepProps = {
-  newOrg: boolean;
-  organization: Organization;
-  platformKey: PlatformKey;
-  projectId: string;
-  sentryInitContent: string;
-};
+interface StepProps {
+  importContent: string;
+  initContent: string;
+  installSnippet: string;
+}
 
 export const steps = ({
-  sentryInitContent,
-}: Partial<StepProps> = {}): LayoutProps['steps'] => [
+  installSnippet,
+  importContent,
+  initContent,
+}: StepProps): LayoutProps['steps'] => [
   {
     type: StepType.INSTALL,
-    description: (
-      <p>{tct('Add [code:@sentry/node] as a dependency:', {code: <code />})}</p>
-    ),
+    description: t('Add the Sentry Node SDK as a dependency:'),
     configurations: [
       {
         language: 'bash',
-        code: `
-# Using yarn
-yarn add @sentry/node
-
-# Using npm
-npm install --save @sentry/node
-        `,
+        code: installSnippet,
       },
     ],
   },
@@ -43,10 +42,10 @@ npm install --save @sentry/node
         code: `
         "use strict";
 
-const Sentry = require("@sentry/node");
+${importContent}
 
 Sentry.init({
-  ${sentryInitContent},
+${initContent}
 });
 
 module.exports = async function (context, req) {
@@ -81,21 +80,33 @@ module.exports = async function (context, req) {
 
 export function GettingStartedWithAzurefunctions({
   dsn,
-  organization,
   newOrg,
   platformKey,
-  projectId,
+  activeProductSelection = [],
 }: ModuleProps) {
-  const sentryInitContent: string[] = [`dsn: "${dsn}"`];
+  const productSelection = getProductSelectionMap(activeProductSelection);
+
+  const installSnippet = getInstallSnippet({productSelection});
+  const imports = getDefaultNodeImports({productSelection});
+  const integrations = getProductIntegrations({productSelection});
+
+  const integrationParam =
+    integrations.length > 0
+      ? `integrations: [\n${joinWithIndentation(integrations)}\n],`
+      : null;
+
+  const initContent = joinWithIndentation([
+    ...getDefaultInitParams({dsn}),
+    ...(integrationParam ? [integrationParam] : []),
+    ...getProductInitParams({productSelection}),
+  ]);
 
   return (
     <Layout
       steps={steps({
-        sentryInitContent: sentryInitContent.join('\n'),
-        organization,
-        newOrg,
-        platformKey,
-        projectId,
+        installSnippet,
+        importContent: imports.join('\n'),
+        initContent,
       })}
       newOrg={newOrg}
       platformKey={platformKey}

+ 3 - 5
static/app/gettingStartedDocs/node/connect.tsx

@@ -1,7 +1,7 @@
 import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
 import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
 import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
-import {t, tct} from 'sentry/locale';
+import {t} from 'sentry/locale';
 import {
   getDefaultInitParams,
   getDefaultNodeImports,
@@ -25,9 +25,7 @@ export const steps = ({
 }: StepProps): LayoutProps['steps'] => [
   {
     type: StepType.INSTALL,
-    description: (
-      <p>{tct('Add [code:@sentry/node] as a dependency:', {code: <code />})}</p>
-    ),
+    description: t('Add the Sentry Node SDK as a dependency:'),
     configurations: [
       {
         language: 'bash',
@@ -46,7 +44,7 @@ ${importContent}
 
 // Configure Sentry before doing anything else
 Sentry.init({
-${initContent},
+${initContent}
 });
 
 function mainHandler(req, res) {