Skip to content

Commit 7b98893

Browse files
authored
ref(nuxt): Add and adjust mechanism.type in error events (#17599)
This PR adjusts/adds the `mechanism.type` field to errors caught from our Nuxt SDK. The name now follows the trace origin as well as possible.
1 parent 891d790 commit 7b98893

File tree

13 files changed

+198
-46
lines changed

13 files changed

+198
-46
lines changed

dev-packages/e2e-tests/test-applications/nuxt-3-dynamic-import/tests/errors.client.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test.describe('client-side errors', async () => {
2121
value: 'Error thrown from Nuxt-3 E2E test app',
2222
mechanism: {
2323
handled: false,
24+
type: 'auto.function.nuxt.vue-error',
2425
},
2526
},
2627
],
@@ -49,6 +50,7 @@ test.describe('client-side errors', async () => {
4950
value: 'Error thrown from Param Route Button',
5051
mechanism: {
5152
handled: false,
53+
type: 'auto.function.nuxt.vue-error',
5254
},
5355
},
5456
],
@@ -82,6 +84,7 @@ test.describe('client-side errors', async () => {
8284
value: 'Error thrown from Nuxt-3 E2E test app',
8385
mechanism: {
8486
handled: false,
87+
type: 'auto.function.nuxt.vue-error',
8588
},
8689
},
8790
],
@@ -96,6 +99,7 @@ test.describe('client-side errors', async () => {
9699
value: 'Another Error thrown from Nuxt-3 E2E test app',
97100
mechanism: {
98101
handled: false,
102+
type: 'auto.function.nuxt.vue-error',
99103
},
100104
},
101105
],

dev-packages/e2e-tests/test-applications/nuxt-3-dynamic-import/tests/errors.server.test.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@ test.describe('server-side errors', async () => {
1414

1515
expect(error.transaction).toEqual('GET /api/server-error');
1616

17-
const exception = error.exception.values[0];
18-
expect(exception.type).toEqual('Error');
19-
expect(exception.value).toEqual('Nuxt 3 Server error');
20-
expect(exception.mechanism.handled).toBe(false);
17+
const exception0 = error.exception.values[0];
18+
const exception1 = error.exception.values[1];
19+
20+
expect(exception0.type).toEqual('Error');
21+
expect(exception0.value).toEqual('Nuxt 3 Server error');
22+
expect(exception0.mechanism).toEqual({
23+
handled: false,
24+
type: 'auto.function.nuxt.nitro',
25+
exception_id: 1,
26+
parent_id: 0,
27+
source: 'cause',
28+
});
29+
30+
expect(exception1.type).toEqual('Error');
31+
expect(exception1.value).toEqual('Nuxt 3 Server error');
32+
// TODO: This isn't correct but requires adjustment in the core SDK
33+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
2134
});
2235

2336
test('captures api fetch error (fetched on click) with parametrized route', async ({ page }) => {
@@ -32,9 +45,22 @@ test.describe('server-side errors', async () => {
3245

3346
expect(error.transaction).toEqual('GET /api/param-error/1234');
3447

35-
const exception = error.exception.values[0];
36-
expect(exception.type).toEqual('Error');
37-
expect(exception.value).toEqual('Nuxt 3 Param Server error');
38-
expect(exception.mechanism.handled).toBe(false);
48+
const exception0 = error.exception.values[0];
49+
const exception1 = error.exception.values[1];
50+
51+
expect(exception0.type).toEqual('Error');
52+
expect(exception0.value).toEqual('Nuxt 3 Param Server error');
53+
expect(exception0.mechanism).toEqual({
54+
handled: false,
55+
type: 'auto.function.nuxt.nitro',
56+
exception_id: 1,
57+
parent_id: 0,
58+
source: 'cause',
59+
});
60+
61+
expect(exception1.type).toEqual('Error');
62+
expect(exception1.value).toEqual('Nuxt 3 Param Server error');
63+
// TODO: This isn't correct but requires adjustment in the core SDK
64+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
3965
});
4066
});

dev-packages/e2e-tests/test-applications/nuxt-3-min/tests/errors.client.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test.describe('client-side errors', async () => {
2121
value: 'Error thrown from Nuxt-3-min E2E test app',
2222
mechanism: {
2323
handled: false,
24+
type: 'auto.function.nuxt.vue-error',
2425
},
2526
},
2627
],
@@ -49,6 +50,7 @@ test.describe('client-side errors', async () => {
4950
value: 'Error thrown from Param Route Button',
5051
mechanism: {
5152
handled: false,
53+
type: 'auto.function.nuxt.vue-error',
5254
},
5355
},
5456
],
@@ -82,6 +84,7 @@ test.describe('client-side errors', async () => {
8284
value: 'Error thrown from Nuxt-3-min E2E test app',
8385
mechanism: {
8486
handled: false,
87+
type: 'auto.function.nuxt.vue-error',
8588
},
8689
},
8790
],
@@ -96,6 +99,7 @@ test.describe('client-side errors', async () => {
9699
value: 'Another Error thrown from Nuxt-3-min E2E test app',
97100
mechanism: {
98101
handled: false,
102+
type: 'auto.function.nuxt.vue-error',
99103
},
100104
},
101105
],

dev-packages/e2e-tests/test-applications/nuxt-3-min/tests/errors.server.test.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@ test.describe('server-side errors', async () => {
1414

1515
expect(error.transaction).toEqual('GET /api/server-error');
1616

17-
const exception = error.exception.values[0];
18-
expect(exception.type).toEqual('Error');
19-
expect(exception.value).toEqual('Nuxt 3 Server error');
20-
expect(exception.mechanism.handled).toBe(false);
17+
const exception0 = error.exception.values[0];
18+
const exception1 = error.exception.values[1];
19+
20+
expect(exception0.type).toEqual('Error');
21+
expect(exception0.value).toEqual('Nuxt 3 Server error');
22+
expect(exception0.mechanism).toEqual({
23+
handled: false,
24+
type: 'auto.function.nuxt.nitro',
25+
exception_id: 1,
26+
parent_id: 0,
27+
source: 'cause',
28+
});
29+
30+
// TODO: This isn't correct but requires adjustment in the core SDK
31+
expect(exception1.type).toEqual('Error');
32+
expect(exception1.value).toEqual('Nuxt 3 Server error');
33+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
2134
});
2235

2336
test('captures api fetch error (fetched on click) with parametrized route', async ({ page }) => {
@@ -32,9 +45,22 @@ test.describe('server-side errors', async () => {
3245

3346
expect(error.transaction).toEqual('GET /api/param-error/1234');
3447

35-
const exception = error.exception.values[0];
36-
expect(exception.type).toEqual('Error');
37-
expect(exception.value).toEqual('Nuxt 3 Param Server error');
38-
expect(exception.mechanism.handled).toBe(false);
48+
const exception0 = error.exception.values[0];
49+
const exception1 = error.exception.values[1];
50+
51+
expect(exception0.type).toEqual('Error');
52+
expect(exception0.value).toEqual('Nuxt 3 Param Server error');
53+
expect(exception0.mechanism).toEqual({
54+
handled: false,
55+
type: 'auto.function.nuxt.nitro',
56+
exception_id: 1,
57+
parent_id: 0,
58+
source: 'cause',
59+
});
60+
61+
// TODO: This isn't correct but requires adjustment in the core SDK
62+
expect(exception1.type).toEqual('Error');
63+
expect(exception1.value).toEqual('Nuxt 3 Param Server error');
64+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
3965
});
4066
});

dev-packages/e2e-tests/test-applications/nuxt-3-top-level-import/tests/errors.client.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test.describe('client-side errors', async () => {
2121
value: 'Error thrown from Nuxt-3 E2E test app',
2222
mechanism: {
2323
handled: false,
24+
type: 'auto.function.nuxt.vue-error',
2425
},
2526
},
2627
],
@@ -49,6 +50,7 @@ test.describe('client-side errors', async () => {
4950
value: 'Error thrown from Param Route Button',
5051
mechanism: {
5152
handled: false,
53+
type: 'auto.function.nuxt.vue-error',
5254
},
5355
},
5456
],
@@ -82,6 +84,7 @@ test.describe('client-side errors', async () => {
8284
value: 'Error thrown from Nuxt-3 E2E test app',
8385
mechanism: {
8486
handled: false,
87+
type: 'auto.function.nuxt.vue-error',
8588
},
8689
},
8790
],
@@ -96,6 +99,7 @@ test.describe('client-side errors', async () => {
9699
value: 'Another Error thrown from Nuxt-3 E2E test app',
97100
mechanism: {
98101
handled: false,
102+
type: 'auto.function.nuxt.vue-error',
99103
},
100104
},
101105
],

dev-packages/e2e-tests/test-applications/nuxt-3-top-level-import/tests/errors.server.test.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,23 @@ test.describe('server-side errors', async () => {
1919

2020
expect(error.transaction).toEqual('GET /api/server-error');
2121

22-
const exception = error.exception.values[0];
23-
expect(exception.type).toEqual('Error');
24-
expect(exception.value).toEqual('Nuxt 3 Server error');
25-
expect(exception.mechanism.handled).toBe(false);
22+
const exception0 = error.exception.values[0];
23+
const exception1 = error.exception.values[1];
24+
25+
expect(exception0.type).toEqual('Error');
26+
expect(exception0.value).toEqual('Nuxt 3 Server error');
27+
expect(exception0.mechanism).toEqual({
28+
handled: false,
29+
type: 'auto.function.nuxt.nitro',
30+
exception_id: 1,
31+
parent_id: 0,
32+
source: 'cause',
33+
});
34+
35+
expect(exception1.type).toEqual('Error');
36+
expect(exception1.value).toEqual('Nuxt 3 Server error');
37+
// TODO: This isn't correct but requires adjustment in the core SDK
38+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
2639

2740
expect(error.tags?.['my-isolated-tag']).toBe(true);
2841
expect(error.tags?.['my-global-scope-isolated-tag']).not.toBeDefined();
@@ -63,9 +76,22 @@ test.describe('server-side errors', async () => {
6376

6477
expect(error.transaction).toEqual('GET /api/param-error/1234');
6578

66-
const exception = error.exception.values[0];
67-
expect(exception.type).toEqual('Error');
68-
expect(exception.value).toEqual('Nuxt 3 Param Server error');
69-
expect(exception.mechanism.handled).toBe(false);
79+
const exception0 = error.exception.values[0];
80+
const exception1 = error.exception.values[1];
81+
82+
expect(exception0.type).toEqual('Error');
83+
expect(exception0.value).toEqual('Nuxt 3 Param Server error');
84+
expect(exception0.mechanism).toEqual({
85+
handled: false,
86+
type: 'auto.function.nuxt.nitro',
87+
exception_id: 1,
88+
parent_id: 0,
89+
source: 'cause',
90+
});
91+
92+
expect(exception1.type).toEqual('Error');
93+
expect(exception1.value).toEqual('Nuxt 3 Param Server error');
94+
// TODO: This isn't correct but requires adjustment in the core SDK
95+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
7096
});
7197
});

dev-packages/e2e-tests/test-applications/nuxt-3/tests/errors.client.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test.describe('client-side errors', async () => {
2121
value: 'Error thrown from Nuxt-3 E2E test app',
2222
mechanism: {
2323
handled: false,
24+
type: 'auto.function.nuxt.vue-error',
2425
},
2526
},
2627
],
@@ -62,6 +63,7 @@ test.describe('client-side errors', async () => {
6263
value: 'Error thrown in Error Boundary',
6364
mechanism: {
6465
handled: false,
66+
type: 'auto.function.nuxt.vue-error',
6567
},
6668
},
6769
],
@@ -90,6 +92,7 @@ test.describe('client-side errors', async () => {
9092
value: 'Error thrown from Param Route Button',
9193
mechanism: {
9294
handled: false,
95+
type: 'auto.function.nuxt.vue-error',
9396
},
9497
},
9598
],
@@ -123,6 +126,7 @@ test.describe('client-side errors', async () => {
123126
value: 'Error thrown from Nuxt-3 E2E test app',
124127
mechanism: {
125128
handled: false,
129+
type: 'auto.function.nuxt.vue-error',
126130
},
127131
},
128132
],
@@ -137,6 +141,7 @@ test.describe('client-side errors', async () => {
137141
value: 'Another Error thrown from Nuxt-3 E2E test app',
138142
mechanism: {
139143
handled: false,
144+
type: 'auto.function.nuxt.vue-error',
140145
},
141146
},
142147
],

dev-packages/e2e-tests/test-applications/nuxt-3/tests/errors.server.test.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@ test.describe('server-side errors', async () => {
1414

1515
expect(error.transaction).toEqual('GET /api/server-error');
1616

17-
const exception = error.exception.values[0];
18-
expect(exception.type).toEqual('Error');
19-
expect(exception.value).toEqual('Nuxt 3 Server error');
20-
expect(exception.mechanism.handled).toBe(false);
17+
const exception0 = error.exception.values[0];
18+
const exception1 = error.exception.values[1];
19+
20+
expect(exception0.type).toEqual('Error');
21+
expect(exception0.value).toEqual('Nuxt 3 Server error');
22+
expect(exception0.mechanism).toEqual({
23+
handled: false,
24+
type: 'chained',
25+
exception_id: 1,
26+
parent_id: 0,
27+
source: 'cause',
28+
});
29+
30+
expect(exception1.type).toEqual('Error');
31+
expect(exception1.value).toEqual('Nuxt 3 Server error');
32+
// TODO: This isn't correct but requires adjustment in the core SDK
33+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
2134
});
2235

2336
test('captures api fetch error (fetched on click) with parametrized route', async ({ page }) => {
@@ -32,9 +45,22 @@ test.describe('server-side errors', async () => {
3245

3346
expect(error.transaction).toEqual('GET /api/param-error/1234');
3447

35-
const exception = error.exception.values[0];
36-
expect(exception.type).toEqual('Error');
37-
expect(exception.value).toEqual('Nuxt 3 Param Server error');
38-
expect(exception.mechanism.handled).toBe(false);
48+
const exception0 = error.exception.values[0];
49+
const exception1 = error.exception.values[1];
50+
51+
expect(exception0.type).toEqual('Error');
52+
expect(exception0.value).toEqual('Nuxt 3 Param Server error');
53+
expect(exception0.mechanism).toEqual({
54+
handled: false,
55+
type: 'chained',
56+
exception_id: 1,
57+
parent_id: 0,
58+
source: 'cause',
59+
});
60+
61+
expect(exception1.type).toEqual('Error');
62+
expect(exception1.value).toEqual('Nuxt 3 Param Server error');
63+
// TODO: This isn't correct but requires adjustment in the core SDK
64+
expect(exception1.mechanism).toEqual({ handled: true, type: 'generic', exception_id: 0 });
3965
});
4066
});

dev-packages/e2e-tests/test-applications/nuxt-4/tests/errors.client.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test.describe('client-side errors', async () => {
2121
value: 'Error thrown from Nuxt-4 E2E test app',
2222
mechanism: {
2323
handled: false,
24+
type: 'auto.function.nuxt.vue-error',
2425
},
2526
},
2627
],
@@ -62,6 +63,7 @@ test.describe('client-side errors', async () => {
6263
value: 'Error thrown in Error Boundary',
6364
mechanism: {
6465
handled: false,
66+
type: 'auto.function.nuxt.vue-error',
6567
},
6668
},
6769
],
@@ -90,6 +92,7 @@ test.describe('client-side errors', async () => {
9092
value: 'Error thrown from Param Route Button',
9193
mechanism: {
9294
handled: false,
95+
type: 'auto.function.nuxt.vue-error',
9396
},
9497
},
9598
],
@@ -123,6 +126,7 @@ test.describe('client-side errors', async () => {
123126
value: 'Error thrown from Nuxt-4 E2E test app',
124127
mechanism: {
125128
handled: false,
129+
type: 'auto.function.nuxt.vue-error',
126130
},
127131
},
128132
],
@@ -137,6 +141,7 @@ test.describe('client-side errors', async () => {
137141
value: 'Another Error thrown from Nuxt-4 E2E test app',
138142
mechanism: {
139143
handled: false,
144+
type: 'auto.function.nuxt.vue-error',
140145
},
141146
},
142147
],

0 commit comments

Comments
 (0)