Skip to content

Commit 145086e

Browse files
committed
rename option, streamlie reportPageLoaded
1 parent c1762f1 commit 145086e

File tree

7 files changed

+16
-19
lines changed

7 files changed

+16
-19
lines changed

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/reportPageLoaded/default/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ window._testBaseTimestamp = performance.timeOrigin / 1000;
55

66
Sentry.init({
77
dsn: 'https://[email protected]/1337',
8-
integrations: [Sentry.browserTracingIntegration({ explicitPageloadEnd: true })],
8+
integrations: [Sentry.browserTracingIntegration({ enableReportPageLoaded: true })],
99
tracesSampleRate: 1,
1010
debug: true,
1111
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/reportPageLoaded/default/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { sentryTest } from '../../../../../utils/fixtures';
99
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../../utils/helpers';
1010

1111
sentryTest(
12-
'waits for Sentry.reportPageLoaded() to be called when `explicitPageloadEnd` is true',
12+
'waits for Sentry.reportPageLoaded() to be called when `enableReportPageLoaded` is true',
1313
async ({ getLocalTestUrl, page }) => {
1414
if (shouldSkipTracingTest()) {
1515
sentryTest.skip();

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/reportPageLoaded/finalTimeout/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ window._testBaseTimestamp = performance.timeOrigin / 1000;
55

66
Sentry.init({
77
dsn: 'https://[email protected]/1337',
8-
integrations: [Sentry.browserTracingIntegration({ explicitPageloadEnd: true, finalTimeout: 3000 })],
8+
integrations: [Sentry.browserTracingIntegration({ enableReportPageLoaded: true, finalTimeout: 3000 })],
99
tracesSampleRate: 1,
1010
debug: true,
1111
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/reportPageLoaded/finalTimeout/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { sentryTest } from '../../../../../utils/fixtures';
99
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../../utils/helpers';
1010

1111
sentryTest(
12-
'final timeout cancels the pageload span even if `explicitPageloadEnd` is true',
12+
'final timeout cancels the pageload span even if `enableReportPageLoaded` is true',
1313
async ({ getLocalTestUrl, page }) => {
1414
if (shouldSkipTracingTest()) {
1515
sentryTest.skip();

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/reportPageLoaded/navigation/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ window._testBaseTimestamp = performance.timeOrigin / 1000;
55

66
Sentry.init({
77
dsn: 'https://[email protected]/1337',
8-
integrations: [Sentry.browserTracingIntegration({ explicitPageloadEnd: true, instrumentNavigation: false })],
8+
integrations: [Sentry.browserTracingIntegration({ enableReportPageLoaded: true, instrumentNavigation: false })],
99
tracesSampleRate: 1,
1010
debug: true,
1111
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/reportPageLoaded/navigation/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { sentryTest } from '../../../../../utils/fixtures';
99
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../../utils/helpers';
1010

1111
sentryTest(
12-
'starting a navigation span cancels the pageload span even if `explicitPageloadEnd` is true',
12+
'starting a navigation span cancels the pageload span even if `enableReportPageLoaded` is true',
1313
async ({ getLocalTestUrl, page }) => {
1414
if (shouldSkipTracingTest()) {
1515
sentryTest.skip();

packages/browser/src/tracing/browserTracingIntegration.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export interface BrowserTracingOptions {
265265
* that the pageload duration can be arbitrary and might not be fully representative of a perceived
266266
* page load time.
267267
*/
268-
explicitPageloadEnd: boolean;
268+
enableReportPageLoaded: boolean;
269269

270270
/**
271271
* _experiments allows the user to send options to define how this integration works.
@@ -314,7 +314,7 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = {
314314
detectRedirects: true,
315315
linkPreviousTrace: 'in-memory',
316316
consistentTraceSampling: false,
317-
explicitPageloadEnd: false,
317+
enableReportPageLoaded: false,
318318
_experiments: {},
319319
...defaultRequestInstrumentationOptions,
320320
};
@@ -363,7 +363,7 @@ export const browserTracingIntegration = ((options: Partial<BrowserTracingOption
363363
detectRedirects,
364364
linkPreviousTrace,
365365
consistentTraceSampling,
366-
explicitPageloadEnd,
366+
enableReportPageLoaded,
367367
onRequestSpanStart,
368368
} = {
369369
...DEFAULT_BROWSER_TRACING_OPTIONS,
@@ -442,10 +442,10 @@ export const browserTracingIntegration = ((options: Partial<BrowserTracingOption
442442
_pageloadSpan = undefined;
443443
}
444444
},
445-
trimIdleSpanEndTimestamp: !explicitPageloadEnd,
445+
trimIdleSpanEndTimestamp: !enableReportPageLoaded,
446446
});
447447

448-
if (isPageloadSpan && explicitPageloadEnd) {
448+
if (isPageloadSpan && enableReportPageLoaded) {
449449
_pageloadSpan = idleSpan;
450450
}
451451

@@ -458,7 +458,7 @@ export const browserTracingIntegration = ((options: Partial<BrowserTracingOption
458458
}
459459

460460
// Enable auto finish of the pageload span if users are not explicitly ending it
461-
if (isPageloadSpan && !explicitPageloadEnd && optionalWindowDocument) {
461+
if (isPageloadSpan && !enableReportPageLoaded && optionalWindowDocument) {
462462
optionalWindowDocument.addEventListener('readystatechange', () => {
463463
emitFinish();
464464
});
@@ -607,7 +607,7 @@ export const browserTracingIntegration = ((options: Partial<BrowserTracingOption
607607
});
608608

609609
client.on('endPageloadSpan', () => {
610-
if (explicitPageloadEnd && _pageloadSpan) {
610+
if (enableReportPageLoaded && _pageloadSpan) {
611611
_pageloadSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, 'reportPageLoaded');
612612
_pageloadSpan.end();
613613
}
@@ -765,17 +765,14 @@ export function getMetaContent(metaName: string): string | undefined {
765765

766766
/**
767767
* Manually report the end of the page load, resulting in the SDK ending the pageload span.
768-
* This only works if {@link BrowserTracingOptions.explicitPageloadEnd} is set to `true`.
768+
* This only works if {@link BrowserTracingOptions.enableReportPageLoaded} is set to `true`.
769769
* Otherwise, the pageload span will end itself based on the {@link BrowserTracingOptions.finalTimeout},
770770
* {@link BrowserTracingOptions.idleTimeout} and {@link BrowserTracingOptions.childSpanTimeout}.
771771
*
772772
* @param client - The client to use. If not provided, the global client will be used.
773773
*/
774-
export function reportPageLoaded(client?: Client): void {
775-
const clientToUse = client ?? getClient();
776-
if (clientToUse) {
777-
clientToUse.emit('endPageloadSpan');
778-
}
774+
export function reportPageLoaded(client: Client | undefined = getClient()): void {
775+
client?.emit('endPageloadSpan');
779776
}
780777

781778
/** Start listener for interaction transactions */

0 commit comments

Comments
 (0)