Skip to content

Commit fff677e

Browse files
authored
Enable Sentry Console integration (#8112)
* Enable Sentry Console integration * Change message & fix tests * Change message & fix tests * Create few-bobcats-brake.md
1 parent d0fda3d commit fff677e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.changeset/few-bobcats-brake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
When reporting errors to Sentry, Wrangler will now include the console output as additional metadata

packages/wrangler/src/__tests__/sentry.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe("sentry", () => {
6464
"Getting User settings...
6565
6666
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
67-
? Would you like to report this error to Cloudflare?
67+
? Would you like to report this error to Cloudflare? Wrangler's output and the error details will be shared with the Wrangler team to help us diagnose and fix the issue.
6868
🤖 Using fallback value in non-interactive context: no"
6969
`);
7070
expect(sentryRequests?.length).toEqual(0);
@@ -103,7 +103,7 @@ describe("sentry", () => {
103103
)
104104
);
105105
mockConfirm({
106-
text: "Would you like to report this error to Cloudflare?",
106+
text: "Would you like to report this error to Cloudflare? Wrangler's output and the error details will be shared with the Wrangler team to help us diagnose and fix the issue.",
107107
result: false,
108108
});
109109
await expect(runWrangler("whoami")).rejects.toMatchInlineSnapshot(
@@ -129,7 +129,7 @@ describe("sentry", () => {
129129
)
130130
);
131131
mockConfirm({
132-
text: "Would you like to report this error to Cloudflare?",
132+
text: "Would you like to report this error to Cloudflare? Wrangler's output and the error details will be shared with the Wrangler team to help us diagnose and fix the issue.",
133133
result: true,
134134
});
135135
await expect(runWrangler("whoami")).rejects.toMatchInlineSnapshot(
@@ -381,6 +381,7 @@ describe("sentry", () => {
381381
"InboundFilters",
382382
"FunctionToString",
383383
"LinkedErrors",
384+
"Console",
384385
"OnUncaughtException",
385386
"OnUnhandledRejection",
386387
"ContextLines",

packages/wrangler/src/sentry/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ const makeSentry10Transport = (options: BaseTransportOptions) => {
1818
let eventQueue: [string, RequestInit][] = [];
1919

2020
const transportSentry10 = async (request: TransportRequest) => {
21-
/* Adds helpful properties to the request body before we send it to our
22-
proxy Worker. These properties can be parsed out from the NDJSON in
23-
`request.body`, but it's easier and safer to just attach them here. */
21+
/**
22+
* Adds helpful properties to the request body before we send it to our
23+
* proxy Worker. These properties can be parsed out from the NDJSON in
24+
* `request.body`, but it's easier and safer to just attach them here.
25+
*/
2426
const sentryWorkerPayload = {
2527
envelope: request.body,
2628
url: options.url,
@@ -84,7 +86,6 @@ const makeSentry10Transport = (options: BaseTransportOptions) => {
8486
};
8587

8688
const disabledDefaultIntegrations = [
87-
"Console", // Console logs may contain PII
8889
"LocalVariables", // Local variables may contain tokens and PII
8990
"Http", // Only captures method/URL/response status, but URL may contain PII
9091
"Undici", // Same as "Http"
@@ -150,7 +151,7 @@ export function addBreadcrumb(
150151
export async function captureGlobalException(e: unknown) {
151152
if (typeof SENTRY_DSN !== "undefined") {
152153
sentryReportingAllowed = await confirm(
153-
"Would you like to report this error to Cloudflare?",
154+
"Would you like to report this error to Cloudflare? Wrangler's output and the error details will be shared with the Wrangler team to help us diagnose and fix the issue.",
154155
{ fallbackValue: false }
155156
);
156157

0 commit comments

Comments
 (0)