Skip to content

Commit 7f557f8

Browse files
author
Luca Forstner
committed
Merge remote-tracking branch 'origin/develop' into rm-browsertracing
2 parents cc9bf5d + 3e2c8f4 commit 7f557f8

File tree

257 files changed

+5522
-3581
lines changed

Some content is hidden

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

257 files changed

+5522
-3581
lines changed

MIGRATION.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Upgrading from 7.x to 8.x
22

3+
## Removal of the `MetricsAggregator` integration class and `metricsAggregatorIntegration`
4+
5+
The SDKs now support metrics features without any additional configuration.
6+
37
## Updated behaviour of `tracePropagationTargets` in the browser (HTTP tracing headers & CORS)
48

59
We updated the behaviour of the SDKs when no `tracePropagationTargets` option was defined. As a reminder, you can

dev-packages/browser-integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@sentry-internal/rrweb": "2.11.0",
5050
"@sentry/browser": "7.100.0",
5151
"@sentry/tracing": "7.100.0",
52-
"axios": "1.6.0",
52+
"axios": "1.6.7",
5353
"babel-loader": "^8.2.2",
5454
"html-webpack-plugin": "^5.5.0",
5555
"pako": "^2.1.0",

dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ sentryTest('should capture feedback (@sentry-internal/feedback import)', async (
4444
const feedbackEvent = envelopeRequestParser((await feedbackRequestPromise).request());
4545
expect(feedbackEvent).toEqual({
4646
type: 'feedback',
47+
breadcrumbs: expect.any(Array),
4748
contexts: {
4849
feedback: {
4950
contact_email: '[email protected]',

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ sentryTest('should capture feedback (@sentry-internal/feedback import)', async (
5050

5151
expect(breadcrumbs).toEqual(
5252
expect.arrayContaining([
53-
{
53+
expect.objectContaining({
5454
category: 'sentry.feedback',
5555
data: { feedbackId: expect.any(String) },
56-
},
56+
}),
5757
]),
5858
);
5959

6060
expect(feedbackEvent).toEqual({
6161
type: 'feedback',
62+
breadcrumbs: expect.any(Array),
6263
contexts: {
6364
feedback: {
6465
contact_email: '[email protected]',
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
});
8+
9+
Sentry.metrics.increment('increment');
10+
Sentry.metrics.increment('increment');
11+
Sentry.metrics.distribution('distribution', 42);
12+
Sentry.metrics.distribution('distribution', 45);
13+
Sentry.metrics.gauge('gauge', 5);
14+
Sentry.metrics.gauge('gauge', 15);
15+
Sentry.metrics.set('set', 'nope');
16+
Sentry.metrics.set('set', 'another');
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../utils/fixtures';
4+
import { getFirstSentryEnvelopeRequest, properEnvelopeRequestParser } from '../../utils/helpers';
5+
6+
sentryTest('collects metrics', async ({ getLocalTestUrl, page }) => {
7+
const url = await getLocalTestUrl({ testDir: __dirname });
8+
9+
const statsdBuffer = await getFirstSentryEnvelopeRequest<Uint8Array>(page, url, properEnvelopeRequestParser);
10+
const statsdString = new TextDecoder().decode(statsdBuffer);
11+
// Replace all the Txxxxxx to remove the timestamps
12+
const normalisedStatsdString = statsdString.replace(/T\d+\n?/g, 'T000000');
13+
14+
expect(normalisedStatsdString).toEqual(
15+
'increment@none:2|c|T000000distribution@none:42:45|d|T000000gauge@none:15:5:15:20:2|g|T000000set@none:3387254:3443787523|s|T000000',
16+
);
17+
});

dev-packages/browser-integration-tests/utils/helpers.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Page, Request } from '@playwright/test';
2-
import type { EnvelopeItemType, Event, EventEnvelopeHeaders } from '@sentry/types';
2+
import type { EnvelopeItem, EnvelopeItemType, Event, EventEnvelopeHeaders } from '@sentry/types';
3+
import { parseEnvelope } from '@sentry/utils';
34

45
export const envelopeUrlRegex = /\.sentry\.io\/api\/\d+\/envelope\//;
56

@@ -21,6 +22,27 @@ export const envelopeRequestParser = <T = Event>(request: Request | null, envelo
2122
return envelopeParser(request)[envelopeIndex] as T;
2223
};
2324

25+
/**
26+
* The above envelope parser does not follow the envelope spec...
27+
* ...but modifying it to follow the spec breaks a lot of the test which rely on the current indexing behavior.
28+
*
29+
* This parser is a temporary solution to allow us to test metrics with statsd envelopes.
30+
*
31+
* Eventually, all the tests should be migrated to use this 'proper' envelope parser!
32+
*/
33+
export const properEnvelopeParser = (request: Request | null): EnvelopeItem[] => {
34+
// https://develop.sentry.dev/sdk/envelopes/
35+
const envelope = request?.postData() || '';
36+
37+
const [, items] = parseEnvelope(envelope);
38+
39+
return items;
40+
};
41+
42+
export const properEnvelopeRequestParser = <T = Event>(request: Request | null, envelopeIndex = 1): T => {
43+
return properEnvelopeParser(request)[0][envelopeIndex] as T;
44+
};
45+
2446
export const envelopeHeaderRequestParser = (request: Request | null): EventEnvelopeHeaders => {
2547
// https://develop.sentry.dev/sdk/envelopes/
2648
const envelope = request?.postData() || '';

dev-packages/e2e-tests/test-applications/angular-17/event-proxy-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
7979
const rawSentryResponseBody = Buffer.concat(sentryResponseChunks).toString();
8080

8181
const data: SentryRequestCallbackData = {
82-
envelope: parseEnvelope(proxyRequestBody, new TextEncoder(), new TextDecoder()),
82+
envelope: parseEnvelope(proxyRequestBody),
8383
rawProxyRequestBody: proxyRequestBody,
8484
rawSentryResponseBody,
8585
sentryResponseStatusCode: sentryResponse.statusCode,

dev-packages/e2e-tests/test-applications/nextjs-14/event-proxy-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
7979
const rawSentryResponseBody = Buffer.concat(sentryResponseChunks).toString();
8080

8181
const data: SentryRequestCallbackData = {
82-
envelope: parseEnvelope(proxyRequestBody, new TextEncoder(), new TextDecoder()),
82+
envelope: parseEnvelope(proxyRequestBody),
8383
rawProxyRequestBody: proxyRequestBody,
8484
rawSentryResponseBody,
8585
sentryResponseStatusCode: sentryResponse.statusCode,

dev-packages/e2e-tests/test-applications/nextjs-app-dir/event-proxy-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
7979
const rawSentryResponseBody = Buffer.concat(sentryResponseChunks).toString();
8080

8181
const data: SentryRequestCallbackData = {
82-
envelope: parseEnvelope(proxyRequestBody, new TextEncoder(), new TextDecoder()),
82+
envelope: parseEnvelope(proxyRequestBody),
8383
rawProxyRequestBody: proxyRequestBody,
8484
rawSentryResponseBody,
8585
sentryResponseStatusCode: sentryResponse.statusCode,

0 commit comments

Comments
 (0)