Skip to content

Commit ffc8f61

Browse files
committed
Merge remote-tracking branch 'origin/feat/local-variables-async-inspector' into feat/local-variables-async-inspector
2 parents e4c1246 + 693731e commit ffc8f61

File tree

71 files changed

+717
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+717
-217
lines changed

biome.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"suspicious": {
2121
"all": false,
2222
"noControlCharactersInRegex": "error"
23+
},
24+
"nursery": {
25+
"noUnusedImports": "error"
2326
}
2427
},
2528
"ignore": [".vscode/*", "**/*.json"]

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
1919
"clean:all": "run-s clean:build clean:caches clean:deps",
2020
"codecov": "codecov",
21-
"fix": "run-s fix:lerna fix:biome",
21+
"fix": "run-p fix:lerna fix:biome",
2222
"fix:lerna": "lerna run fix",
23-
"fix:biome": "biome check --apply-unsafe .",
23+
"fix:biome": "biome check --apply .",
2424
"changelog": "ts-node ./scripts/get-commit-list.ts",
2525
"link:yarn": "lerna exec yarn link",
26-
"lint": "run-s lint:lerna lint:biome",
26+
"lint": "run-p lint:lerna lint:biome",
2727
"lint:lerna": "lerna run lint",
2828
"lint:biome": "biome check .",
2929
"validate:es5": "lerna run validate:es5",

packages/angular/test/tracing.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Component } from '@angular/core';
22
import type { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
3-
import type { Hub } from '@sentry/types';
43

54
import { TraceClassDecorator, TraceDirective, TraceMethodDecorator, instrumentAngularRouting } from '../src';
65
import { getParameterizedRouteFromSnapshot } from '../src/tracing';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as SentryNode from '@sentry/node';
22
import type { Client } from '@sentry/types';
3-
import { SpyInstance, vi } from 'vitest';
3+
import { vi } from 'vitest';
44

55
import { handleRequest, interpolateRouteFromUrlAndParams } from '../../src/server/middleware';
66

packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<body>
88
<button id="button1" type="button">Button 1</button>
99
<button id="button2" type="button">Button 2</button>
10+
<button id="annotated-button" type="button" data-sentry-component="AnnotatedButton">Button 3</button>
1011
</body>
1112
</html>

packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,39 @@ sentryTest('captures Breadcrumb for clicks & debounces them for a second', async
5555
},
5656
]);
5757
});
58+
59+
sentryTest(
60+
'uses the annotated component name in the breadcrumb messages and adds it to the data object',
61+
async ({ getLocalTestUrl, page }) => {
62+
const url = await getLocalTestUrl({ testDir: __dirname });
63+
64+
await page.route('**/foo', route => {
65+
return route.fulfill({
66+
status: 200,
67+
body: JSON.stringify({
68+
userNames: ['John', 'Jane'],
69+
}),
70+
headers: {
71+
'Content-Type': 'application/json',
72+
},
73+
});
74+
});
75+
76+
const promise = getFirstSentryEnvelopeRequest<Event>(page);
77+
78+
await page.goto(url);
79+
await page.click('#annotated-button');
80+
await page.evaluate('Sentry.captureException("test exception")');
81+
82+
const eventData = await promise;
83+
84+
expect(eventData.breadcrumbs).toEqual([
85+
{
86+
timestamp: expect.any(Number),
87+
category: 'ui.click',
88+
message: 'body > AnnotatedButton',
89+
data: { 'ui.component_name': 'AnnotatedButton' },
90+
},
91+
]);
92+
},
93+
);

packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<body>
88
<input id="input1" type="text" />
99
<input id="input2" type="text" />
10+
<input id="annotated-input" data-sentry-component="AnnotatedInput" type="text" />
1011
</body>
1112
</html>

packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,48 @@ sentryTest('captures Breadcrumb for events on inputs & debounced them', async ({
6464
},
6565
]);
6666
});
67+
68+
sentryTest(
69+
'includes the annotated component name within the breadcrumb message and data',
70+
async ({ getLocalTestUrl, page }) => {
71+
const url = await getLocalTestUrl({ testDir: __dirname });
72+
73+
await page.route('**/foo', route => {
74+
return route.fulfill({
75+
status: 200,
76+
body: JSON.stringify({
77+
userNames: ['John', 'Jane'],
78+
}),
79+
headers: {
80+
'Content-Type': 'application/json',
81+
},
82+
});
83+
});
84+
85+
const promise = getFirstSentryEnvelopeRequest<Event>(page);
86+
87+
await page.goto(url);
88+
89+
await page.click('#annotated-input');
90+
await page.type('#annotated-input', 'John', { delay: 1 });
91+
92+
await page.evaluate('Sentry.captureException("test exception")');
93+
const eventData = await promise;
94+
expect(eventData.exception?.values).toHaveLength(1);
95+
96+
expect(eventData.breadcrumbs).toEqual([
97+
{
98+
timestamp: expect.any(Number),
99+
category: 'ui.click',
100+
message: 'body > AnnotatedInput',
101+
data: { 'ui.component_name': 'AnnotatedInput' },
102+
},
103+
{
104+
timestamp: expect.any(Number),
105+
category: 'ui.input',
106+
message: 'body > AnnotatedInput',
107+
data: { 'ui.component_name': 'AnnotatedInput' },
108+
},
109+
]);
110+
},
111+
);

packages/browser-integration-tests/suites/public-api/startTransaction/init.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/* eslint-disable no-unused-vars */
12
import * as Sentry from '@sentry/browser';
2-
// eslint-disable-next-line no-unused-vars
3+
// biome-ignore lint/nursery/noUnusedImports: Need to import tracing for side effect
34
import * as _ from '@sentry/tracing';
45

56
window.Sentry = Sentry;

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { get } from 'http';
21
/* eslint-disable max-lines */
32
import { addBreadcrumb, convertIntegrationFnToClass, getClient } from '@sentry/core';
43
import type {
@@ -12,6 +11,7 @@ import type {
1211
IntegrationFn,
1312
} from '@sentry/types';
1413
import type {
14+
Breadcrumb,
1515
FetchBreadcrumbData,
1616
FetchBreadcrumbHint,
1717
XhrBreadcrumbData,
@@ -24,6 +24,7 @@ import {
2424
addFetchInstrumentationHandler,
2525
addHistoryInstrumentationHandler,
2626
addXhrInstrumentationHandler,
27+
getComponentName,
2728
getEventDescription,
2829
htmlTreeAsString,
2930
logger,
@@ -133,6 +134,7 @@ function _getDomBreadcrumbHandler(
133134
}
134135

135136
let target;
137+
let componentName;
136138
let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;
137139

138140
let maxStringLength =
@@ -152,9 +154,10 @@ function _getDomBreadcrumbHandler(
152154
// Accessing event.target can throw (see getsentry/raven-js#838, #768)
153155
try {
154156
const event = handlerData.event as Event | Node;
155-
target = _isEvent(event)
156-
? htmlTreeAsString(event.target, { keyAttrs, maxStringLength })
157-
: htmlTreeAsString(event, { keyAttrs, maxStringLength });
157+
const element = _isEvent(event) ? event.target : event;
158+
159+
target = htmlTreeAsString(element, { keyAttrs, maxStringLength });
160+
componentName = getComponentName(element);
158161
} catch (e) {
159162
target = '<unknown>';
160163
}
@@ -163,17 +166,20 @@ function _getDomBreadcrumbHandler(
163166
return;
164167
}
165168

166-
addBreadcrumb(
167-
{
168-
category: `ui.${handlerData.name}`,
169-
message: target,
170-
},
171-
{
172-
event: handlerData.event,
173-
name: handlerData.name,
174-
global: handlerData.global,
175-
},
176-
);
169+
const breadcrumb: Breadcrumb = {
170+
category: `ui.${handlerData.name}`,
171+
message: target,
172+
};
173+
174+
if (componentName) {
175+
breadcrumb.data = { 'ui.component_name': componentName };
176+
}
177+
178+
addBreadcrumb(breadcrumb, {
179+
event: handlerData.event,
180+
name: handlerData.name,
181+
global: handlerData.global,
182+
});
177183
};
178184
}
179185

0 commit comments

Comments
 (0)