Skip to content

Commit d1622d8

Browse files
priscilawebdevAhmed-Labs
authored andcommitted
ref(onboarding): Split cloudflare pages onboarding docs (#102656)
Contributes to https://linear.app/getsentry/issue/TET-864/introduce-folders-for-onboarding-platforms
1 parent b93087d commit d1622d8

File tree

7 files changed

+108
-96
lines changed

7 files changed

+108
-96
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {getNodeAgentMonitoringOnboarding} from 'sentry/gettingStartedDocs/node/node/utils';
2+
3+
export const agentMonitoring = getNodeAgentMonitoringOnboarding({
4+
packageName: '@sentry/cloudflare',
5+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
StepType,
3+
type OnboardingConfig,
4+
} from 'sentry/components/onboarding/gettingStartedDoc/types';
5+
import {
6+
getCrashReportJavaScriptInstallSteps,
7+
getCrashReportModalConfigDescription,
8+
getCrashReportModalIntroduction,
9+
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
10+
11+
export const crashReport: OnboardingConfig = {
12+
introduction: () => getCrashReportModalIntroduction(),
13+
install: params => getCrashReportJavaScriptInstallSteps(params),
14+
configure: () => [
15+
{
16+
type: StepType.CONFIGURE,
17+
content: [
18+
{
19+
type: 'text',
20+
text: getCrashReportModalConfigDescription({
21+
link: 'https://docs.sentry.io/platforms/javascript/guides/cloudflare/user-feedback/configuration/#crash-report-modal',
22+
}),
23+
},
24+
],
25+
},
26+
],
27+
verify: () => [],
28+
nextSteps: () => [],
29+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type {Docs} from 'sentry/components/onboarding/gettingStartedDoc/types';
2+
3+
import {agentMonitoring} from './agentMonitoring';
4+
import {crashReport} from './crashReport';
5+
import {logs} from './logs';
6+
import {mcp} from './mcp';
7+
import {onboarding} from './onboarding';
8+
9+
const docs: Docs = {
10+
onboarding,
11+
crashReportOnboarding: crashReport,
12+
logsOnboarding: logs,
13+
agentMonitoringOnboarding: agentMonitoring,
14+
mcpOnboarding: mcp,
15+
};
16+
17+
export default docs;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {getNodeLogsOnboarding} from 'sentry/gettingStartedDocs/node/node/utils';
2+
3+
export const logs = getNodeLogsOnboarding({
4+
docsPlatform: 'cloudflare',
5+
packageName: '@sentry/cloudflare',
6+
generateConfigureSnippet: (params, packageName) => ({
7+
type: 'code',
8+
language: 'javascript',
9+
code: `import * as Sentry from "${packageName}";
10+
11+
export const onRequest = [
12+
// Make sure Sentry is the first middleware
13+
Sentry.sentryPagesPlugin((context) => ({
14+
dsn: "${params.dsn.public}",
15+
integrations: [
16+
// send console.log, console.warn, and console.error calls as logs to Sentry
17+
Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
18+
],
19+
// Enable logs to be sent to Sentry
20+
enableLogs: true,
21+
})),
22+
// Add more middlewares here
23+
];`,
24+
}),
25+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {getNodeMcpOnboarding} from 'sentry/gettingStartedDocs/node/node/utils';
2+
3+
export const mcp = getNodeMcpOnboarding({
4+
packageName: '@sentry/cloudflare',
5+
});

static/app/gettingStartedDocs/node/cloudflare-pages.spec.tsx renamed to static/app/gettingStartedDocs/node/cloudflare-pages/onboarding.spec.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {textWithMarkupMatcher} from 'sentry-test/utils';
44

55
import {ProductSolution} from 'sentry/components/onboarding/gettingStartedDoc/types';
66

7-
import docs from './cloudflare-pages';
7+
import docs from '.';
88

9-
describe('express onboarding docs', () => {
9+
describe('cloudflare-pages onboarding docs', () => {
1010
it('renders onboarding docs correctly', () => {
1111
renderWithOnboardingLayout(docs);
1212

@@ -16,6 +16,7 @@ describe('express onboarding docs', () => {
1616
expect(
1717
screen.getByRole('heading', {name: /Upload Source Maps/i})
1818
).toBeInTheDocument();
19+
expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument();
1920

2021
// Includes import statement
2122
const allMatches = screen.getAllByText(
@@ -31,7 +32,6 @@ describe('express onboarding docs', () => {
3132
selectedProducts: [
3233
ProductSolution.ERROR_MONITORING,
3334
ProductSolution.PERFORMANCE_MONITORING,
34-
ProductSolution.PROFILING,
3535
],
3636
});
3737

@@ -40,7 +40,7 @@ describe('express onboarding docs', () => {
4040
).toBeInTheDocument();
4141
});
4242

43-
it('displays logs configuration when logs are selected', () => {
43+
it('enables logs by setting enableLogs to true', () => {
4444
renderWithOnboardingLayout(docs, {
4545
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
4646
});
@@ -50,33 +50,27 @@ describe('express onboarding docs', () => {
5050
).toBeInTheDocument();
5151
});
5252

53-
it('shows Logging Integrations in next steps when logs is selected', () => {
53+
it('does not enable logs when not selected', () => {
5454
renderWithOnboardingLayout(docs, {
55-
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
55+
selectedProducts: [ProductSolution.ERROR_MONITORING],
5656
});
5757

58-
expect(screen.getByText('Logging Integrations')).toBeInTheDocument();
58+
expect(
59+
screen.queryByText(textWithMarkupMatcher(/enableLogs: true/))
60+
).not.toBeInTheDocument();
5961
});
6062

61-
it('does not display logs configuration when logs are not selected', () => {
63+
it('displays logs integration next step when logs are selected', () => {
6264
renderWithOnboardingLayout(docs, {
63-
selectedProducts: [
64-
ProductSolution.ERROR_MONITORING,
65-
ProductSolution.PERFORMANCE_MONITORING,
66-
],
65+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
6766
});
6867

69-
expect(
70-
screen.queryByText(textWithMarkupMatcher(/enableLogs: true/))
71-
).not.toBeInTheDocument();
68+
expect(screen.getByText('Logging Integrations')).toBeInTheDocument();
7269
});
7370

74-
it('does not show Logging Integrations in next steps when logs is not selected', () => {
71+
it('does not display logs integration next step when logs are not selected', () => {
7572
renderWithOnboardingLayout(docs, {
76-
selectedProducts: [
77-
ProductSolution.ERROR_MONITORING,
78-
ProductSolution.PERFORMANCE_MONITORING,
79-
],
73+
selectedProducts: [ProductSolution.ERROR_MONITORING],
8074
});
8175

8276
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
@@ -105,4 +99,10 @@ describe('express onboarding docs', () => {
10599
)
106100
).not.toBeInTheDocument();
107101
});
102+
103+
it('displays cloudflare features next step', () => {
104+
renderWithOnboardingLayout(docs);
105+
106+
expect(screen.getByText('Cloudflare Features')).toBeInTheDocument();
107+
});
108108
});

static/app/gettingStartedDocs/node/cloudflare-pages.tsx renamed to static/app/gettingStartedDocs/node/cloudflare-pages/onboarding.tsx

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
11
import {ExternalLink} from 'sentry/components/core/link';
22
import type {
3-
Docs,
43
DocsParams,
54
OnboardingConfig,
65
} from 'sentry/components/onboarding/gettingStartedDoc/types';
76
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/types';
87
import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
9-
import {
10-
getCrashReportJavaScriptInstallSteps,
11-
getCrashReportModalConfigDescription,
12-
getCrashReportModalIntroduction,
13-
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
8+
import {getInstallCodeBlock} from 'sentry/gettingStartedDocs/node/node/utils';
149
import {t, tct} from 'sentry/locale';
15-
import {
16-
getInstallCodeBlock,
17-
getNodeAgentMonitoringOnboarding,
18-
getNodeLogsOnboarding,
19-
getNodeMcpOnboarding,
20-
} from 'sentry/utils/gettingStartedDocs/node';
21-
22-
type Params = DocsParams;
2310

2411
const getSdkConfigureSnippetToml = () => `
2512
compatibility_flags = ["nodejs_compat"]
@@ -35,7 +22,7 @@ const getSdkConfigureSnippetJson = () => `
3522
"compatibility_date": "2024-09-23"
3623
}`;
3724

38-
const getSdkSetupSnippet = (params: Params) => `
25+
const getSdkSetupSnippet = (params: DocsParams) => `
3926
import * as Sentry from "@sentry/cloudflare";
4027
4128
export const onRequest = [
@@ -65,7 +52,7 @@ export const onRequest = [
6552
// Add more middlewares here
6653
];`;
6754

68-
const getVerifySnippet = (params: Params) => `
55+
const getVerifySnippet = (params: DocsParams) => `
6956
export function onRequest(context) {${
7057
params.isLogsSelected
7158
? `
@@ -78,7 +65,7 @@ export function onRequest(context) {${
7865
throw new Error();
7966
}`;
8067

81-
const onboarding: OnboardingConfig = {
68+
export const onboarding: OnboardingConfig = {
8269
introduction: () =>
8370
tct(
8471
"In this quick guide, you'll set up and configure the Sentry Cloudflare SDK for use in your Cloudflare Pages application. This will enable Sentry for the backend part of your application: the functions. If you'd like to monitor the frontend as well, refer to the instrumentation guide for [platformLink:the framework of your choice].",
@@ -111,7 +98,7 @@ const onboarding: OnboardingConfig = {
11198
{
11299
type: 'text',
113100
text: tct(
114-
"To use the SDK, you'll need to set either the [code:nodejs_compat] or [code:nodejs_als] compatibility flags in your [code:wrangler.toml]. This is because the SDK needs access to the [code:AsyncLocalStorage] API to work correctly.",
101+
"To use the SDK, you'll need to set either the [code:nodejs_compat] or [code:nodejs_als] compatibility flags in your [code:wrangler.json]/[code:wrangler.toml]. This is because the SDK needs access to the [code:AsyncLocalStorage] API to work correctly.",
115102
{code: <code />}
116103
),
117104
},
@@ -163,7 +150,7 @@ const onboarding: OnboardingConfig = {
163150
...params,
164151
}),
165152
],
166-
verify: (params: Params) => [
153+
verify: (params: DocsParams) => [
167154
{
168155
type: StepType.VERIFY,
169156
content: [
@@ -183,7 +170,7 @@ const onboarding: OnboardingConfig = {
183170
],
184171
},
185172
],
186-
nextSteps: (params: Params) => {
173+
nextSteps: (params: DocsParams) => {
187174
const steps = [
188175
{
189176
id: 'cloudflare-features',
@@ -209,59 +196,3 @@ const onboarding: OnboardingConfig = {
209196
return steps;
210197
},
211198
};
212-
213-
const crashReportOnboarding: OnboardingConfig = {
214-
introduction: () => getCrashReportModalIntroduction(),
215-
install: (params: Params) => getCrashReportJavaScriptInstallSteps(params),
216-
configure: () => [
217-
{
218-
type: StepType.CONFIGURE,
219-
content: [
220-
{
221-
type: 'text',
222-
text: getCrashReportModalConfigDescription({
223-
link: 'https://docs.sentry.io/platforms/javascript/guides/cloudflare/user-feedback/configuration/#crash-report-modal',
224-
}),
225-
},
226-
],
227-
},
228-
],
229-
verify: () => [],
230-
nextSteps: () => [],
231-
};
232-
233-
const docs: Docs = {
234-
onboarding,
235-
crashReportOnboarding,
236-
logsOnboarding: getNodeLogsOnboarding({
237-
docsPlatform: 'cloudflare',
238-
packageName: '@sentry/cloudflare',
239-
generateConfigureSnippet: (params, packageName) => ({
240-
type: 'code',
241-
language: 'javascript',
242-
code: `import * as Sentry from "${packageName}";
243-
244-
export const onRequest = [
245-
// Make sure Sentry is the first middleware
246-
Sentry.sentryPagesPlugin((context) => ({
247-
dsn: "${params.dsn.public}",
248-
integrations: [
249-
// send console.log, console.warn, and console.error calls as logs to Sentry
250-
Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
251-
],
252-
// Enable logs to be sent to Sentry
253-
enableLogs: true,
254-
})),
255-
// Add more middlewares here
256-
];`,
257-
}),
258-
}),
259-
agentMonitoringOnboarding: getNodeAgentMonitoringOnboarding({
260-
packageName: '@sentry/cloudflare',
261-
}),
262-
mcpOnboarding: getNodeMcpOnboarding({
263-
packageName: '@sentry/cloudflare',
264-
}),
265-
};
266-
267-
export default docs;

0 commit comments

Comments
 (0)