Skip to content

Commit fd756db

Browse files
committed
feat(onboarding): Add logs empty state onboarding for node sdks
1 parent 9ed4ed8 commit fd756db

21 files changed

+447
-8
lines changed

static/app/gettingStartedDocs/node/awslambda.spec.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,42 @@ describe('awslambda onboarding docs', () => {
4545
).toBeInTheDocument();
4646
});
4747

48-
it('enables logs', () => {
48+
it('enables logs by setting enableLogs to true', () => {
49+
renderWithOnboardingLayout(docs, {
50+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
51+
});
52+
53+
expect(
54+
screen.getByText(textWithMarkupMatcher(/enableLogs: true/))
55+
).toBeInTheDocument();
56+
});
57+
58+
it('does not enable logs when not selected', () => {
59+
renderWithOnboardingLayout(docs, {
60+
selectedProducts: [ProductSolution.ERROR_MONITORING],
61+
});
62+
63+
expect(
64+
screen.queryByText(textWithMarkupMatcher(/enableLogs: true/))
65+
).not.toBeInTheDocument();
66+
});
67+
68+
it('displays logs integration next step when logs are selected', () => {
4969
renderWithOnboardingLayout(docs, {
5070
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
5171
});
5272

5373
expect(screen.getByText('Logging Integrations')).toBeInTheDocument();
5474
});
5575

76+
it('does not display logs integration next step when logs are not selected', () => {
77+
renderWithOnboardingLayout(docs, {
78+
selectedProducts: [ProductSolution.ERROR_MONITORING],
79+
});
80+
81+
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
82+
});
83+
5684
it('enables performance setting the sample rate set to 1', () => {
5785
renderWithOnboardingLayout(docs, {
5886
selectedProducts: [

static/app/gettingStartedDocs/node/awslambda.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {t, tct} from 'sentry/locale';
1717
import {
1818
getInstallConfig,
1919
getNodeAgentMonitoringOnboarding,
20+
getNodeLogsOnboarding,
2021
getNodeMcpOnboarding,
2122
getNodeProfilingOnboarding,
2223
getSdkInitSnippet,
@@ -242,6 +243,10 @@ const docs: Docs<PlatformOptions> = {
242243
profilingOnboarding: getNodeProfilingOnboarding({
243244
basePackage: '@sentry/aws-serverless',
244245
}),
246+
logsOnboarding: getNodeLogsOnboarding({
247+
docsPlatform: 'aws-lambda',
248+
sdkPackage: '@sentry/aws-serverless',
249+
}),
245250
agentMonitoringOnboarding: getNodeAgentMonitoringOnboarding({
246251
basePackage: 'aws-serverless',
247252
}),

static/app/gettingStartedDocs/node/azurefunctions.spec.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,42 @@ describe('express onboarding docs', () => {
4545
).toBeInTheDocument();
4646
});
4747

48-
it('enables logs', () => {
48+
it('enables logs by setting enableLogs to true', () => {
49+
renderWithOnboardingLayout(docs, {
50+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
51+
});
52+
53+
expect(
54+
screen.getByText(textWithMarkupMatcher(/enableLogs: true/))
55+
).toBeInTheDocument();
56+
});
57+
58+
it('does not enable logs when not selected', () => {
59+
renderWithOnboardingLayout(docs, {
60+
selectedProducts: [ProductSolution.ERROR_MONITORING],
61+
});
62+
63+
expect(
64+
screen.queryByText(textWithMarkupMatcher(/enableLogs: true/))
65+
).not.toBeInTheDocument();
66+
});
67+
68+
it('displays logs integration next step when logs are selected', () => {
4969
renderWithOnboardingLayout(docs, {
5070
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
5171
});
5272

5373
expect(screen.getByText('Logging Integrations')).toBeInTheDocument();
5474
});
5575

76+
it('does not display logs integration next step when logs are not selected', () => {
77+
renderWithOnboardingLayout(docs, {
78+
selectedProducts: [ProductSolution.ERROR_MONITORING],
79+
});
80+
81+
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
82+
});
83+
5684
it('enables performance setting the tracesSampleRate to 1', () => {
5785
renderWithOnboardingLayout(docs, {
5886
selectedProducts: [

static/app/gettingStartedDocs/node/azurefunctions.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {t, tct} from 'sentry/locale';
1414
import {
1515
getInstallConfig,
1616
getNodeAgentMonitoringOnboarding,
17+
getNodeLogsOnboarding,
1718
getNodeMcpOnboarding,
1819
getNodeProfilingOnboarding,
1920
getSdkInitSnippet,
@@ -119,6 +120,10 @@ const docs: Docs = {
119120
onboarding,
120121
crashReportOnboarding,
121122
profilingOnboarding: getNodeProfilingOnboarding(),
123+
logsOnboarding: getNodeLogsOnboarding({
124+
docsPlatform: 'azure-functions',
125+
sdkPackage: '@sentry/node',
126+
}),
122127
agentMonitoringOnboarding: getNodeAgentMonitoringOnboarding(),
123128
mcpOnboarding: getNodeMcpOnboarding(),
124129
};

static/app/gettingStartedDocs/node/cloudflare-pages.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {t, tct} from 'sentry/locale';
1515
import {
1616
getInstallConfig,
1717
getNodeAgentMonitoringOnboarding,
18+
getNodeLogsOnboarding,
1819
getNodeMcpOnboarding,
1920
} from 'sentry/utils/gettingStartedDocs/node';
2021

@@ -210,6 +211,29 @@ const crashReportOnboarding: OnboardingConfig = {
210211
const docs: Docs = {
211212
onboarding,
212213
crashReportOnboarding,
214+
logsOnboarding: getNodeLogsOnboarding({
215+
docsPlatform: 'cloudflare',
216+
sdkPackage: '@sentry/cloudflare',
217+
generateConfigureSnippet: (params, sdkPackage) => ({
218+
type: 'code',
219+
language: 'javascript',
220+
code: `import * as Sentry from "${sdkPackage}";
221+
222+
export const onRequest = [
223+
// Make sure Sentry is the first middleware
224+
Sentry.sentryPagesPlugin((context) => ({
225+
dsn: "${params.dsn.public}",
226+
integrations: [
227+
// send console.log, console.warn, and console.error calls as logs to Sentry
228+
Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
229+
],
230+
// Enable logs to be sent to Sentry
231+
enableLogs: true,
232+
})),
233+
// Add more middlewares here
234+
];`,
235+
}),
236+
}),
213237
agentMonitoringOnboarding: getNodeAgentMonitoringOnboarding({
214238
basePackage: 'cloudflare',
215239
}),

static/app/gettingStartedDocs/node/cloudflare-workers.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {t, tct} from 'sentry/locale';
1515
import {
1616
getInstallConfig,
1717
getNodeAgentMonitoringOnboarding,
18+
getNodeLogsOnboarding,
1819
getNodeMcpOnboarding,
1920
} from 'sentry/utils/gettingStartedDocs/node';
2021

@@ -202,6 +203,33 @@ const crashReportOnboarding: OnboardingConfig = {
202203
const docs: Docs = {
203204
onboarding,
204205
crashReportOnboarding,
206+
logsOnboarding: getNodeLogsOnboarding({
207+
docsPlatform: 'cloudflare',
208+
sdkPackage: '@sentry/cloudflare',
209+
generateConfigureSnippet: (params, sdkPackage) => ({
210+
type: 'code',
211+
language: 'javascript',
212+
code: `import * as Sentry from "${sdkPackage}";
213+
214+
export default Sentry.withSentry(
215+
env => ({
216+
dsn: "${params.dsn.public}",
217+
integrations: [
218+
// send console.log, console.warn, and console.error calls as logs to Sentry
219+
Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
220+
],
221+
// Enable logs to be sent to Sentry
222+
enableLogs: true,
223+
}),
224+
{
225+
async fetch(request, env, ctx) {
226+
return new Response('Hello World!');
227+
},
228+
} satisfies ExportedHandler<Env>,
229+
);
230+
`,
231+
}),
232+
}),
205233
agentMonitoringOnboarding: getNodeAgentMonitoringOnboarding({
206234
basePackage: 'cloudflare',
207235
}),

static/app/gettingStartedDocs/node/connect.spec.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,42 @@ describe('connect onboarding docs', () => {
5353
).toBeInTheDocument();
5454
});
5555

56-
it('enables logs', () => {
56+
it('enables logs by setting enableLogs to true', () => {
57+
renderWithOnboardingLayout(docs, {
58+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
59+
});
60+
61+
expect(
62+
screen.getByText(textWithMarkupMatcher(/enableLogs: true/))
63+
).toBeInTheDocument();
64+
});
65+
66+
it('does not enable logs when not selected', () => {
67+
renderWithOnboardingLayout(docs, {
68+
selectedProducts: [ProductSolution.ERROR_MONITORING],
69+
});
70+
71+
expect(
72+
screen.queryByText(textWithMarkupMatcher(/enableLogs: true/))
73+
).not.toBeInTheDocument();
74+
});
75+
76+
it('displays logs integration next step when logs are selected', () => {
5777
renderWithOnboardingLayout(docs, {
5878
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
5979
});
6080

6181
expect(screen.getByText('Logging Integrations')).toBeInTheDocument();
6282
});
6383

84+
it('does not display logs integration next step when logs are not selected', () => {
85+
renderWithOnboardingLayout(docs, {
86+
selectedProducts: [ProductSolution.ERROR_MONITORING],
87+
});
88+
89+
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
90+
});
91+
6492
it('enables performance setting the tracesSampleRate to 1', () => {
6593
renderWithOnboardingLayout(docs, {
6694
selectedProducts: [

static/app/gettingStartedDocs/node/connect.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getImportInstrumentSnippet,
1717
getInstallConfig,
1818
getNodeAgentMonitoringOnboarding,
19+
getNodeLogsOnboarding,
1920
getNodeMcpOnboarding,
2021
getNodeProfilingOnboarding,
2122
getSdkInitSnippet,
@@ -158,6 +159,10 @@ const docs: Docs = {
158159
onboarding,
159160
crashReportOnboarding,
160161
profilingOnboarding: getNodeProfilingOnboarding(),
162+
logsOnboarding: getNodeLogsOnboarding({
163+
docsPlatform: 'connect',
164+
sdkPackage: '@sentry/node',
165+
}),
161166
agentMonitoringOnboarding: getNodeAgentMonitoringOnboarding(),
162167
mcpOnboarding: getNodeMcpOnboarding(),
163168
};

static/app/gettingStartedDocs/node/express.spec.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,42 @@ describe('express onboarding docs', () => {
5454
).toBeInTheDocument();
5555
});
5656

57-
it('enables logs', () => {
57+
it('enables logs by setting enableLogs to true', () => {
58+
renderWithOnboardingLayout(docs, {
59+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
60+
});
61+
62+
expect(
63+
screen.getByText(textWithMarkupMatcher(/enableLogs: true/))
64+
).toBeInTheDocument();
65+
});
66+
67+
it('does not enable logs when not selected', () => {
68+
renderWithOnboardingLayout(docs, {
69+
selectedProducts: [ProductSolution.ERROR_MONITORING],
70+
});
71+
72+
expect(
73+
screen.queryByText(textWithMarkupMatcher(/enableLogs: true/))
74+
).not.toBeInTheDocument();
75+
});
76+
77+
it('displays logs integration next step when logs are selected', () => {
5878
renderWithOnboardingLayout(docs, {
5979
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
6080
});
6181

6282
expect(screen.getByText('Logging Integrations')).toBeInTheDocument();
6383
});
6484

85+
it('does not display logs integration next step when logs are not selected', () => {
86+
renderWithOnboardingLayout(docs, {
87+
selectedProducts: [ProductSolution.ERROR_MONITORING],
88+
});
89+
90+
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
91+
});
92+
6593
it('enables performance setting the tracesSampleRate to 1', () => {
6694
renderWithOnboardingLayout(docs, {
6795
selectedProducts: [

static/app/gettingStartedDocs/node/express.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
getImportInstrumentSnippet,
2121
getInstallConfig,
2222
getNodeAgentMonitoringOnboarding,
23+
getNodeLogsOnboarding,
2324
getNodeMcpOnboarding,
2425
getNodeProfilingOnboarding,
2526
getSdkInitSnippet,
@@ -177,6 +178,10 @@ const docs: Docs = {
177178
replayOnboardingJsLoader,
178179
crashReportOnboarding,
179180
feedbackOnboardingJsLoader,
181+
logsOnboarding: getNodeLogsOnboarding({
182+
docsPlatform: 'express',
183+
sdkPackage: '@sentry/node',
184+
}),
180185
profilingOnboarding: getNodeProfilingOnboarding(),
181186
agentMonitoringOnboarding: getNodeAgentMonitoringOnboarding(),
182187
mcpOnboarding: getNodeMcpOnboarding(),

0 commit comments

Comments
 (0)