Skip to content

Commit c587947

Browse files
authored
ref(astro): Adjust mechanism on error events captured by astro middleware (#17613)
mechanism type now follows the trace origin naming scheme closes #17612
1 parent e1c4367 commit c587947

File tree

4 files changed

+7
-22
lines changed

4 files changed

+7
-22
lines changed

dev-packages/e2e-tests/test-applications/astro-4/tests/errors.server.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ test.describe('server-side errors', () => {
4747
values: [
4848
{
4949
mechanism: {
50-
data: {
51-
function: 'astroMiddleware',
52-
},
5350
handled: false,
54-
type: 'astro',
51+
type: 'auto.middleware.astro',
5552
},
5653
stacktrace: expect.any(Object),
5754
type: 'TypeError',
@@ -136,11 +133,8 @@ test.describe('server-side errors', () => {
136133
values: [
137134
{
138135
mechanism: {
139-
data: {
140-
function: 'astroMiddleware',
141-
},
142136
handled: false,
143-
type: 'astro',
137+
type: 'auto.middleware.astro',
144138
},
145139
stacktrace: expect.any(Object),
146140
type: 'Error',

dev-packages/e2e-tests/test-applications/astro-5/tests/errors.server.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ test.describe('server-side errors', () => {
4747
values: [
4848
{
4949
mechanism: {
50-
data: {
51-
function: 'astroMiddleware',
52-
},
5350
handled: false,
54-
type: 'astro',
51+
type: 'auto.middleware.astro',
5552
},
5653
stacktrace: expect.any(Object),
5754
type: 'TypeError',
@@ -136,11 +133,8 @@ test.describe('server-side errors', () => {
136133
values: [
137134
{
138135
mechanism: {
139-
data: {
140-
function: 'astroMiddleware',
141-
},
142136
handled: false,
143-
type: 'astro',
137+
type: 'auto.middleware.astro',
144138
},
145139
stacktrace: expect.any(Object),
146140
type: 'Error',

packages/astro/src/server/middleware.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ function sendErrorToSentry(e: unknown): unknown {
5050

5151
captureException(objectifiedErr, {
5252
mechanism: {
53-
type: 'astro',
53+
type: 'auto.middleware.astro',
5454
handled: false,
55-
data: {
56-
function: 'astroMiddleware',
57-
},
5855
},
5956
});
6057

packages/astro/test/server/middleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('sentryMiddleware', () => {
168168
await expect(async () => middleware(ctx, next)).rejects.toThrowError();
169169

170170
expect(captureExceptionSpy).toHaveBeenCalledWith(error, {
171-
mechanism: { handled: false, type: 'astro', data: { function: 'astroMiddleware' } },
171+
mechanism: { handled: false, type: 'auto.middleware.astro' },
172172
});
173173
});
174174

@@ -205,7 +205,7 @@ describe('sentryMiddleware', () => {
205205
await expect(() => resultFromNext!.text()).rejects.toThrowError();
206206

207207
expect(captureExceptionSpy).toHaveBeenCalledWith(error, {
208-
mechanism: { handled: false, type: 'astro', data: { function: 'astroMiddleware' } },
208+
mechanism: { handled: false, type: 'auto.middleware.astro' },
209209
});
210210
});
211211

0 commit comments

Comments
 (0)