Skip to content

Commit 48636ec

Browse files
committed
update verify snippets
1 parent fd756db commit 48636ec

22 files changed

+411
-38
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,30 @@ describe('awslambda onboarding docs', () => {
8181
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
8282
});
8383

84+
it('displays logging code in verify section when logs are selected', () => {
85+
renderWithOnboardingLayout(docs, {
86+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
87+
});
88+
89+
expect(
90+
screen.getByText(
91+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
92+
)
93+
).toBeInTheDocument();
94+
});
95+
96+
it('does not display logging code in verify section when logs are not selected', () => {
97+
renderWithOnboardingLayout(docs, {
98+
selectedProducts: [ProductSolution.ERROR_MONITORING],
99+
});
100+
101+
expect(
102+
screen.queryByText(
103+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
104+
)
105+
).not.toBeInTheDocument();
106+
});
107+
84108
it('enables performance setting the sample rate set to 1', () => {
85109
renderWithOnboardingLayout(docs, {
86110
selectedProducts: [

static/app/gettingStartedDocs/node/awslambda.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const moduleFormatOnboarding: Record<ModuleFormat, OnboardingConfig<PlatformOpti
124124
...params,
125125
}),
126126
],
127-
verify: () => [
127+
verify: (params: Params) => [
128128
{
129129
type: StepType.VERIFY,
130130
description: t(
@@ -133,7 +133,16 @@ const moduleFormatOnboarding: Record<ModuleFormat, OnboardingConfig<PlatformOpti
133133
configurations: [
134134
{
135135
language: 'javascript',
136-
code: `throw new Error("This should show up in Sentry!");`,
136+
code: `${
137+
params.isLogsSelected
138+
? `
139+
// Send a log before throwing the error
140+
Sentry.logger.info('User triggered test error', {
141+
action: 'test_error_lambda',
142+
});`
143+
: ''
144+
}
145+
throw new Error("This should show up in Sentry!");`,
137146
},
138147
],
139148
},
@@ -176,7 +185,7 @@ const moduleFormatOnboarding: Record<ModuleFormat, OnboardingConfig<PlatformOpti
176185
],
177186
},
178187
],
179-
verify: () => [
188+
verify: (params: Params) => [
180189
{
181190
type: StepType.VERIFY,
182191
description: t(
@@ -186,7 +195,15 @@ const moduleFormatOnboarding: Record<ModuleFormat, OnboardingConfig<PlatformOpti
186195
{
187196
language: 'javascript',
188197
code: `
189-
export const handler = Sentry.wrapHandler(async (event, context) => {
198+
export const handler = Sentry.wrapHandler(async (event, context) => {${
199+
params.isLogsSelected
200+
? `
201+
// Send a log before throwing the error
202+
Sentry.logger.info('User triggered test error', {
203+
action: 'test_error_lambda',
204+
});`
205+
: ''
206+
}
190207
throw new Error("This should show up in Sentry!")
191208
});`,
192209
},

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,28 @@ describe('express onboarding docs', () => {
8181

8282
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
8383
});
84+
85+
it('displays logging code in verify section when logs are selected', () => {
86+
renderWithOnboardingLayout(docs, {
87+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
88+
});
89+
90+
expect(
91+
screen.getByText(
92+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
93+
)
94+
).toBeInTheDocument();
95+
});
96+
97+
it('does not display logging code in verify section when logs are not selected', () => {
98+
renderWithOnboardingLayout(docs, {
99+
selectedProducts: [ProductSolution.ERROR_MONITORING],
100+
});
101+
102+
expect(
103+
screen.queryByText(
104+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
105+
)
106+
).not.toBeInTheDocument();
107+
});
84108
});

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,16 @@ export const onRequest = [
6565
// Add more middlewares here
6666
];`;
6767

68-
const getVerifySnippet = () => `
69-
export function onRequest(context) {
68+
const getVerifySnippet = (params: Params) => `
69+
export function onRequest(context) {${
70+
params.isLogsSelected
71+
? `
72+
// Send a log before throwing the error
73+
Sentry.logger.info('User triggered test error', {
74+
action: 'test_error_function',
75+
});`
76+
: ''
77+
}
7078
throw new Error();
7179
}`;
7280

@@ -146,7 +154,7 @@ const onboarding: OnboardingConfig = {
146154
...params,
147155
}),
148156
],
149-
verify: () => [
157+
verify: (params: Params) => [
150158
{
151159
type: StepType.VERIFY,
152160
description: tct(
@@ -161,7 +169,7 @@ const onboarding: OnboardingConfig = {
161169
value: 'javascript',
162170
language: 'javascript',
163171
filename: 'functions/customerror.js',
164-
code: getVerifySnippet(),
172+
code: getVerifySnippet(params),
165173
},
166174
],
167175
},

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,28 @@ describe('express onboarding docs', () => {
9494

9595
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
9696
});
97+
98+
it('displays logging code in verify section when logs are selected', () => {
99+
renderWithOnboardingLayout(docs, {
100+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
101+
});
102+
103+
expect(
104+
screen.getByText(
105+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
106+
)
107+
).toBeInTheDocument();
108+
});
109+
110+
it('does not display logging code in verify section when logs are not selected', () => {
111+
renderWithOnboardingLayout(docs, {
112+
selectedProducts: [ProductSolution.ERROR_MONITORING],
113+
});
114+
115+
expect(
116+
screen.queryByText(
117+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
118+
)
119+
).not.toBeInTheDocument();
120+
});
97121
});

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ export default Sentry.withSentry(
6767
} satisfies ExportedHandler<Env>,
6868
);`;
6969

70-
const getVerifySnippet = () => `
70+
const getVerifySnippet = (params: Params) => `${
71+
params.isLogsSelected
72+
? `
73+
// Send a log before throwing the error
74+
Sentry.logger.info('User triggered test error', {
75+
action: 'test_error_worker',
76+
});`
77+
: ''
78+
}
7179
setTimeout(() => {
7280
throw new Error();
7381
});`;
@@ -144,7 +152,7 @@ const onboarding: OnboardingConfig = {
144152
...params,
145153
}),
146154
],
147-
verify: () => [
155+
verify: (params: Params) => [
148156
{
149157
type: StepType.VERIFY,
150158
description: t(
@@ -153,7 +161,7 @@ const onboarding: OnboardingConfig = {
153161
configurations: [
154162
{
155163
language: 'javascript',
156-
code: getVerifySnippet(),
164+
code: getVerifySnippet(params),
157165
},
158166
],
159167
},

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ describe('connect onboarding docs', () => {
8989
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
9090
});
9191

92+
it('displays logging code in verify section when logs are selected', () => {
93+
renderWithOnboardingLayout(docs, {
94+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
95+
});
96+
97+
expect(
98+
screen.getByText(
99+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
100+
)
101+
).toBeInTheDocument();
102+
});
103+
104+
it('does not display logging code in verify section when logs are not selected', () => {
105+
renderWithOnboardingLayout(docs, {
106+
selectedProducts: [ProductSolution.ERROR_MONITORING],
107+
});
108+
109+
expect(
110+
screen.queryByText(
111+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
112+
)
113+
).not.toBeInTheDocument();
114+
});
115+
92116
it('enables performance setting the tracesSampleRate to 1', () => {
93117
renderWithOnboardingLayout(docs, {
94118
selectedProducts: [

static/app/gettingStartedDocs/node/connect.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const onboarding: OnboardingConfig = {
102102
...params,
103103
}),
104104
],
105-
verify: () => [
105+
verify: (params: Params) => [
106106
{
107107
type: StepType.VERIFY,
108108
description: t(
@@ -111,7 +111,7 @@ const onboarding: OnboardingConfig = {
111111
configurations: [
112112
{
113113
language: 'javascript',
114-
code: getVerifySnippet(),
114+
code: getVerifySnippet(params),
115115
},
116116
],
117117
},
@@ -134,8 +134,16 @@ const onboarding: OnboardingConfig = {
134134
},
135135
};
136136

137-
const getVerifySnippet = () => `
138-
app.use(async function () {
137+
const getVerifySnippet = (params: Params) => `
138+
app.use(async function () {${
139+
params.isLogsSelected
140+
? `
141+
// Send a log before throwing the error
142+
Sentry.logger.info('User triggered test error', {
143+
action: 'test_error_middleware',
144+
});`
145+
: ''
146+
}
139147
throw new Error("My first Sentry error!");
140148
});
141149
`;

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,30 @@ describe('express onboarding docs', () => {
9090
expect(screen.queryByText('Logging Integrations')).not.toBeInTheDocument();
9191
});
9292

93+
it('displays logging code in verify section when logs are selected', () => {
94+
renderWithOnboardingLayout(docs, {
95+
selectedProducts: [ProductSolution.ERROR_MONITORING, ProductSolution.LOGS],
96+
});
97+
98+
expect(
99+
screen.getByText(
100+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
101+
)
102+
).toBeInTheDocument();
103+
});
104+
105+
it('does not display logging code in verify section when logs are not selected', () => {
106+
renderWithOnboardingLayout(docs, {
107+
selectedProducts: [ProductSolution.ERROR_MONITORING],
108+
});
109+
110+
expect(
111+
screen.queryByText(
112+
textWithMarkupMatcher(/Sentry\.logger\.info\('User triggered test error'/)
113+
)
114+
).not.toBeInTheDocument();
115+
});
116+
93117
it('enables performance setting the tracesSampleRate to 1', () => {
94118
renderWithOnboardingLayout(docs, {
95119
selectedProducts: [

static/app/gettingStartedDocs/node/express.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const onboarding: OnboardingConfig = {
122122
...params,
123123
}),
124124
],
125-
verify: () => [
125+
verify: (params: Params) => [
126126
{
127127
type: StepType.VERIFY,
128128
description: t(
@@ -132,7 +132,15 @@ const onboarding: OnboardingConfig = {
132132
{
133133
language: 'javascript',
134134
code: `
135-
app.get("/debug-sentry", function mainHandler(req, res) {
135+
app.get("/debug-sentry", function mainHandler(req, res) {${
136+
params.isLogsSelected
137+
? `
138+
// Send a log before throwing the error
139+
Sentry.logger.info('User triggered test error', {
140+
action: 'test_error_endpoint',
141+
});`
142+
: ''
143+
}
136144
throw new Error("My first Sentry error!");
137145
});
138146
`,

0 commit comments

Comments
 (0)