Skip to content

Commit bbd6743

Browse files
authored
Merge branch 'develop' into sig/astro-waitUntil
2 parents d5c85cf + d2a9826 commit bbd6743

File tree

13 files changed

+730
-783
lines changed

13 files changed

+730
-783
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
// We mock this here to simulate a Chrome browser extension
6+
window.chrome = { runtime: { id: 'mock-extension-id' } };
7+
8+
Sentry.init({
9+
dsn: 'https://[email protected]/1337',
10+
skipBrowserExtensionCheck: true,
11+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from '@playwright/test';
2+
import { sentryTest } from '../../../utils/fixtures';
3+
4+
sentryTest(
5+
'initializes inside a Chrome browser extension if `skipBrowserExtensionCheck` is set',
6+
async ({ getLocalTestUrl, page }) => {
7+
const url = await getLocalTestUrl({ testDir: __dirname });
8+
await page.goto(url);
9+
10+
const isInitialized = await page.evaluate(() => {
11+
return !!(window as any).Sentry.isInitialized();
12+
});
13+
14+
expect(isInitialized).toBe(true);
15+
},
16+
);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
async function run() {
2+
Sentry.startSpan({ name: 'parent_span' }, () => {
3+
Sentry.startSpan({ name: 'child_span', attributes: { someAttribute: '' } }, () => {
4+
// whatever a user would do here
5+
});
6+
});
7+
}
8+
9+
(async () => {
10+
await run();
11+
})();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import {
5+
envelopeRequestParser,
6+
shouldSkipTracingTest,
7+
waitForTransactionRequestOnUrl,
8+
} from '../../../../utils/helpers';
9+
10+
sentryTest('sends an empty string attribute', async ({ getLocalTestPath, page }) => {
11+
if (shouldSkipTracingTest()) {
12+
sentryTest.skip();
13+
}
14+
15+
const url = await getLocalTestPath({ testDir: __dirname });
16+
const req = await waitForTransactionRequestOnUrl(page, url);
17+
const transaction = envelopeRequestParser(req);
18+
19+
const childSpan = transaction.spans?.[0];
20+
expect(childSpan?.data?.someAttribute).toBe('');
21+
});

packages/browser-utils/src/metrics/browserMetrics.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ export interface ResourceEntry extends Record<string, unknown> {
513513
encodedBodySize?: number;
514514
decodedBodySize?: number;
515515
renderBlockingStatus?: string;
516+
deliveryType?: string;
516517
}
517518

518519
/** Create resource-related spans */
@@ -539,6 +540,10 @@ export function _addResourceSpans(
539540
setResourceEntrySizeData(attributes, entry, 'encodedBodySize', 'http.response_content_length');
540541
setResourceEntrySizeData(attributes, entry, 'decodedBodySize', 'http.decoded_response_content_length');
541542

543+
if (entry.deliveryType != null) {
544+
attributes['http.response_delivery_type'] = entry.deliveryType;
545+
}
546+
542547
if ('renderBlockingStatus' in entry) {
543548
attributes['resource.render_blocking_status'] = entry.renderBlockingStatus;
544549
}

packages/browser-utils/test/browser/browserMetrics.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,32 @@ describe('_addResourceSpans', () => {
338338
}),
339339
);
340340
});
341+
342+
// resource delivery types: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/deliveryType
343+
// i.e. better but not yet widely supported way to check for browser cache hit
344+
it.each(['cache', 'navigational-prefetch', ''])(
345+
'attaches delivery type ("%s") to resource spans if available',
346+
deliveryType => {
347+
const spans: Span[] = [];
348+
349+
getClient()?.on('spanEnd', span => {
350+
spans.push(span);
351+
});
352+
353+
const entry: ResourceEntry = {
354+
initiatorType: 'css',
355+
transferSize: 0,
356+
encodedBodySize: 0,
357+
decodedBodySize: 0,
358+
deliveryType,
359+
};
360+
361+
_addResourceSpans(span, entry, resourceEntryName, 100, 23, 345);
362+
363+
expect(spans).toHaveLength(1);
364+
expect(spanToJSON(spans[0]!).data).toMatchObject({ 'http.response_delivery_type': deliveryType });
365+
},
366+
);
341367
});
342368

343369
const setGlobalLocation = (location: Location) => {

packages/browser/src/client.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,26 @@ import { createUserFeedbackEnvelope } from './userfeedback';
2626
*/
2727
export type BrowserOptions = Options<BrowserTransportOptions> &
2828
BrowserClientReplayOptions &
29-
BrowserClientProfilingOptions;
29+
BrowserClientProfilingOptions & {
30+
/**
31+
* Important: Only set this option if you know what you are doing!
32+
*
33+
* By default, the SDK will check if `Sentry.init` is called in a browser extension.
34+
* In case it is, it will stop initialization and log a warning
35+
* because browser extensions require a different Sentry initialization process:
36+
* https://docs.sentry.io/platforms/javascript/best-practices/shared-environments/
37+
*
38+
* Setting up the SDK in a browser extension with global error monitoring is not recommended
39+
* and will likely flood you with errors from other web sites or extensions. This can heavily
40+
* impact your quota and cause interference with your and other Sentry SDKs in shared environments.
41+
*
42+
* If this check wrongfully flags your setup as a browser extension, you can set this
43+
* option to `true` to skip the check.
44+
*
45+
* @default false
46+
*/
47+
skipBrowserExtensionCheck?: boolean;
48+
};
3049

3150
/**
3251
* Configuration options for the Sentry Browser SDK Client class

packages/browser/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ declare const __SENTRY_RELEASE__: string | undefined;
160160
export function init(browserOptions: BrowserOptions = {}): Client | undefined {
161161
const options = applyDefaultOptions(browserOptions);
162162

163-
if (shouldShowBrowserExtensionError()) {
163+
if (!options.skipBrowserExtensionCheck && shouldShowBrowserExtensionError()) {
164164
consoleSandbox(() => {
165165
// eslint-disable-next-line no-console
166166
console.error(

packages/ember/config/ember-try.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

packages/ember/package.json

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"lint:ts": "tsc",
2626
"fix": "eslint . --format stylish --fix",
2727
"start": "ember serve",
28-
"test": "ember b --prod && yarn ember test",
29-
"test:all": "ember try:each",
28+
"test": "ember b --prod && ember test",
3029
"prepack": "ember ts:precompile",
3130
"postpack": "ember ts:clean"
3231
},
@@ -44,42 +43,34 @@
4443
},
4544
"devDependencies": {
4645
"@ember/optional-features": "~1.3.0",
47-
"@ember/test-helpers": "2.9.4",
46+
"@ember/test-helpers": "4.0.4",
4847
"@embroider/test-setup": "~4.0.0",
4948
"@glimmer/component": "~1.1.2",
5049
"@glimmer/tracking": "~1.1.2",
5150
"@types/ember": "~3.16.5",
52-
"@types/ember-qunit": "~3.4.9",
5351
"@types/ember-resolver": "5.0.13",
5452
"@types/ember__debug": "^3.16.5",
55-
"@types/qunit": "~2.9.1",
53+
"@types/qunit": "~2.19.11",
5654
"@types/rsvp": "~4.0.3",
5755
"babel-eslint": "~10.1.0",
5856
"broccoli-asset-rev": "~3.0.0",
59-
"ember-cli": "~4.8.0",
60-
"ember-cli-dependency-checker": "~3.3.1",
57+
"ember-cli": "~4.12.3",
58+
"ember-cli-dependency-checker": "~3.3.2",
6159
"ember-cli-inject-live-reload": "~2.1.0",
62-
"ember-cli-sri": "~2.1.1",
6360
"ember-cli-terser": "~4.0.2",
64-
"ember-cli-typescript-blueprints": "~3.0.0",
65-
"ember-disable-prototype-extensions": "~1.1.3",
6661
"ember-load-initializers": "~2.1.1",
67-
"ember-maybe-import-regenerator": "1.0.0",
68-
"ember-qunit": "~6.0.0",
69-
"ember-resolver": "11.0.0",
70-
"ember-sinon-qunit": "7.1.4",
71-
"ember-source": "~4.8.0",
72-
"ember-source-channel-url": "~2.0.1",
62+
"ember-qunit": "~8.1.0",
63+
"ember-resolver": "13.0.2",
64+
"ember-sinon-qunit": "7.5.0",
65+
"ember-source": "~4.12.4",
7366
"ember-template-lint": "~4.16.1",
74-
"ember-try": "~2.0.0",
75-
"ember-window-mock": "~0.8.1",
7667
"eslint-plugin-ember": "11.9.0",
7768
"eslint-plugin-n": "16.0.1",
7869
"eslint-plugin-qunit": "8.0.0",
7970
"loader.js": "~4.7.0",
80-
"qunit": "~2.19.2",
81-
"qunit-dom": "~2.0.0",
82-
"sinon": "15.2.0",
71+
"qunit": "~2.22.0",
72+
"qunit-dom": "~3.2.1",
73+
"sinon": "19.0.2",
8374
"webpack": "~5.95.0"
8475
},
8576
"engines": {

0 commit comments

Comments
 (0)