Skip to content

Commit

Permalink
feat(onboarding): Add hapi, fastify and Nest.js (#70647)
Browse files Browse the repository at this point in the history
Will merge this after v8 is out for a while (like 1 week or so).

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and cmanallen committed May 21, 2024
1 parent 7c8a6ee commit 7029197
Show file tree
Hide file tree
Showing 26 changed files with 957 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"papaparse": "^5.3.2",
"pegjs": "^0.10.0",
"pegjs-loader": "^0.5.6",
"platformicons": "^5.10.6",
"platformicons": "^5.10.9",
"po-catalog-loader": "2.0.0",
"prettier": "3.2.5",
"prismjs": "^1.29.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const topPythonFrameworks: PlatformKey[] = [

const topNodeFrameworks: PlatformKey[] = [
'node-express',
'node-nestjs',
'node-awslambda',
'node-gcpfunctions',
'node-koa',
Expand Down
3 changes: 3 additions & 0 deletions static/app/components/onboarding/productSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ export const platformProductAvailability = {
'node-awslambda': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
'node-connect': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
'node-express': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
'node-fastify': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
'node-gcpfunctions': [
ProductSolution.PERFORMANCE_MONITORING,
ProductSolution.PROFILING,
],
'node-hapi': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
'node-koa': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
'node-nestjs': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
php: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
'php-laravel': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
['php-symfony']: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
Expand Down
4 changes: 4 additions & 0 deletions static/app/data/platformPickerCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const popularPlatformCategories: Set<PlatformKey> = new Set([
'javascript-vue',
'node',
'node-express',
'node-nestjs',
'php',
'php-laravel',
'python',
Expand Down Expand Up @@ -70,7 +71,10 @@ const server: Set<PlatformKey> = new Set([
'node',
'node-connect',
'node-express',
'node-fastify',
'node-hapi',
'node-koa',
'node-nestjs',
'php',
'php-laravel',
'php-symfony',
Expand Down
21 changes: 21 additions & 0 deletions static/app/data/platforms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,20 @@ export const platforms: PlatformIntegration[] = [
language: 'node',
link: 'https://docs.sentry.io/platforms/javascript/guides/express/',
},
{
id: 'node-fastify',
name: 'Fastify',
type: 'framework',
language: 'node',
link: 'https://docs.sentry.io/platforms/javascript/guides/fastify/',
},
{
id: 'node-hapi',
name: 'Hapi',
type: 'framework',
language: 'node',
link: 'https://docs.sentry.io/platforms/javascript/guides/hapi/',
},
{
id: 'node-gcpfunctions',
name: 'Google Cloud Functions (Node)',
Expand All @@ -417,6 +431,13 @@ export const platforms: PlatformIntegration[] = [
language: 'node',
link: 'https://docs.sentry.io/platforms/javascript/guides/koa/',
},
{
id: 'node-nestjs',
name: 'Nest.js',
type: 'framework',
language: 'node',
link: 'https://docs.sentry.io/platforms/javascript/guides/nestjs/',
},
{
id: 'php',
name: 'PHP',
Expand Down
7 changes: 7 additions & 0 deletions static/app/gettingStartedDocs/node/awslambda.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ describe('awslambda onboarding docs', function () {
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
});

expect(
screen.getByText(
textWithMarkupMatcher(
/const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
)
)
).toBeInTheDocument();
expect(
screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
).toBeInTheDocument();
Expand Down
7 changes: 7 additions & 0 deletions static/app/gettingStartedDocs/node/azurefunctions.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ describe('express onboarding docs', function () {
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
});

expect(
screen.getByText(
textWithMarkupMatcher(
/const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
)
)
).toBeInTheDocument();
expect(
screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
).toBeInTheDocument();
Expand Down
15 changes: 15 additions & 0 deletions static/app/gettingStartedDocs/node/connect.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ describe('connect onboarding docs', function () {
});
});

it('includes error handler', () => {
renderWithOnboardingLayout(docs);

expect(
screen.getByText(textWithMarkupMatcher(/Sentry\.setupConnectErrorHandler\(app\)/))
).toBeInTheDocument();
});

it('displays sample rates by default', () => {
renderWithOnboardingLayout(docs, {
selectedProducts: [
Expand Down Expand Up @@ -59,6 +67,13 @@ describe('connect onboarding docs', function () {
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
});

expect(
screen.getByText(
textWithMarkupMatcher(
/const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
)
)
).toBeInTheDocument();
expect(
screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
).toBeInTheDocument();
Expand Down
4 changes: 3 additions & 1 deletion static/app/gettingStartedDocs/node/connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Params = DocsParams;
const getSdkSetupSnippet = () => `
${getImportInstrumentSnippet()}
// All other imports below
${getSentryImportSnippet('node')}
const connect = require("connect");
Expand Down Expand Up @@ -69,7 +70,7 @@ const onboarding: OnboardingConfig = {
},
{
description: tct(
"Make sure to import [code1:instrument.js/mjs] at the top of your file. Set up the error handler after all controllers and before any other error middleware. This setup is typically done in your application's entry point file, which is usually [code2:index.(js|ts)]. If you are unable to import an external file, read about [docs:alternative installation methods in our docs].",
"Make sure to import [code1:instrument.js/mjs] at the top of your file. Set up the error handler after all controllers and before any other error middleware. This setup is typically done in your application's entry point file, which is usually [code2:index.(js|ts)]. If you're running your application in ESM mode, or looking for alternative ways to set up Sentry, read about [docs:installation methods in our docs].",
{
code1: <code />,
code2: <code />,
Expand All @@ -83,6 +84,7 @@ const onboarding: OnboardingConfig = {
label: 'JavaScript',
value: 'javascript',
language: 'javascript',
filename: 'index.(js|mjs)',
code: getSdkSetupSnippet(),
},
],
Expand Down
15 changes: 15 additions & 0 deletions static/app/gettingStartedDocs/node/express.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ describe('express onboarding docs', function () {
});
});

it('includes error handler', () => {
renderWithOnboardingLayout(docs);

expect(
screen.getByText(textWithMarkupMatcher(/Sentry\.setupExpressErrorHandler\(app\)/))
).toBeInTheDocument();
});

it('displays sample rates by default', () => {
renderWithOnboardingLayout(docs, {
selectedProducts: [
Expand Down Expand Up @@ -60,6 +68,13 @@ describe('express onboarding docs', function () {
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
});

expect(
screen.getByText(
textWithMarkupMatcher(
/const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
)
)
).toBeInTheDocument();
expect(
screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
).toBeInTheDocument();
Expand Down
4 changes: 3 additions & 1 deletion static/app/gettingStartedDocs/node/express.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Params = DocsParams;
const getSdkSetupSnippet = () => `
${getImportInstrumentSnippet()}
// All other imports below
${getSentryImportSnippet('node')}
const express = require("express");
Expand Down Expand Up @@ -83,7 +84,7 @@ const onboarding: OnboardingConfig = {
},
{
description: tct(
"Make sure to import [code1:instrument.js/mjs] at the top of your file. Set up the error handler after all controllers and before any other error middleware. This setup is typically done in your application's entry point file, which is usually [code2:index.(js|ts)]. If you are unable to import an external file, read about [docs:alternative installation methods in our docs].",
"Make sure to import [code1:instrument.js/mjs] at the top of your file. Set up the error handler after all controllers and before any other error middleware. This setup is typically done in your application's entry point file, which is usually [code2:index.(js|ts)]. If you're running your application in ESM mode, or looking for alternative ways to set up Sentry, read about [docs:installation methods in our docs].",
{
code1: <code />,
code2: <code />,
Expand All @@ -97,6 +98,7 @@ const onboarding: OnboardingConfig = {
label: 'JavaScript',
value: 'javascript',
language: 'javascript',
filename: 'index.(js|mjs)',
code: getSdkSetupSnippet(),
},
],
Expand Down
82 changes: 82 additions & 0 deletions static/app/gettingStartedDocs/node/fastify.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout';
import {screen} from 'sentry-test/reactTestingLibrary';
import {textWithMarkupMatcher} from 'sentry-test/utils';

import {ProductSolution} from 'sentry/components/onboarding/productSelection';

import docs from './fastify';

describe('fastify onboarding docs', function () {
it('renders onboarding docs correctly', () => {
renderWithOnboardingLayout(docs);

// Renders main headings
expect(screen.getByRole('heading', {name: 'Install'})).toBeInTheDocument();
expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
expect(screen.getByRole('heading', {name: 'Upload Source Maps'})).toBeInTheDocument();
expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument();

// Includes import statement
const allMatches = screen.getAllByText(
textWithMarkupMatcher(/import \* as Sentry from "@sentry\/node"/)
);
allMatches.forEach(match => {
expect(match).toBeInTheDocument();
});
});

it('includes error handler', () => {
renderWithOnboardingLayout(docs);

expect(
screen.getByText(textWithMarkupMatcher(/Sentry\.setupFastifyErrorHandler\(app\)/))
).toBeInTheDocument();
});

it('displays sample rates by default', () => {
renderWithOnboardingLayout(docs, {
selectedProducts: [
ProductSolution.ERROR_MONITORING,
ProductSolution.PERFORMANCE_MONITORING,
ProductSolution.PROFILING,
],
});

expect(
screen.queryByText(textWithMarkupMatcher(/tracesSampleRate/))
).toBeInTheDocument();
expect(
screen.queryByText(textWithMarkupMatcher(/profilesSampleRate/))
).toBeInTheDocument();
});

it('enables performance setting the tracesSampleRate to 1', () => {
renderWithOnboardingLayout(docs, {
selectedProducts: [
ProductSolution.ERROR_MONITORING,
ProductSolution.PERFORMANCE_MONITORING,
],
});

expect(
screen.getByText(textWithMarkupMatcher(/tracesSampleRate: 1\.0/))
).toBeInTheDocument();
});

it('enables profiling by setting profiling samplerates', () => {
renderWithOnboardingLayout(docs, {
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.PROFILING],
});

expect(
screen.getByText(
textWithMarkupMatcher(
/const { nodeProfilingIntegration } = require\("@sentry\/profiling-node"\)/
)
)
).toBeInTheDocument();
expect(
screen.getByText(textWithMarkupMatcher(/profilesSampleRate: 1\.0/))
).toBeInTheDocument();
});
});

0 comments on commit 7029197

Please sign in to comment.