Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/platforms/javascript/common/apis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,39 @@ See <PlatformLink to="/tracing/instrumentation/">Tracing Instrumentation</Platfo
`browserTracingIntegration` has not been enabled.
</SdkApi>

<SdkApi
name="reportPageLoaded"
signature="function reportPageLoaded(): void"
categorySupported={["browser"]}
availableSince="10.13.0"
>

Signals to the Sentry SDK that the initial page was fully loaded.
Requires the <PlatformLink to="/tracing/instrumentation/automatic-instrumentation/#enableReportPageLoaded">`enableReportPageLoaded` option</PlatformLink> in `browserTracingIntegration` to
be set to `true`. Once called, the SDK ends the pageload span automatically,

By default, the SDK takes care of ending the pageload span automatically, based on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default, the SDK takes care of ending the pageload span automatically, based on
based on

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fully sure I get this suggestion correctly because the goal here was to explain what the SDK does by default (i.e. when reportPageLoaded() is not used). I think though it's better to join this sentence with the paragraph below instead (see #15006 (comment))

a period of inactivity where no new child spans are added to the pageload trace.
You can alternatively use explicit pageload reporting if the inactivity heuristics of
`browserTracingIntegration` don't work well for your use case.
However, you must ensure that you call `reportPageLoaded` in every situation.
If `reportPageLoaded` is not called, the pageload span will be ended after 30 seconds
or whatever custom value is set on the <PlatformLink to="/tracing/instrumentation/automatic-instrumentation/#enableReportPageLoaded">`finalTimeout` option</PlatformLink>.


<Expandable title="Examples">
```javascript
Sentry.init({
// 1. Enable manual page load reporting:
integrations: [browserTracingIntegration({ enableReportPageLoaded: true })]
})

// 2. Whenever you consider the page loaded:
Sentry.reportPageLoaded();
```
</Expandable>
</SdkApi>

## Tracing Utilities

These utilities can be used for more advanced tracing use cases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ This flag enables or disables creation of `pageload` span on first pageload.

</SdkOption>


<SdkOption name="enableReportPageLoaded" type='boolean' defaultValue='false' availableSince='10.13.0'>

This option determines whether the <PlatformLink to="/apis/#reportPageLoaded">`Sentry.reportPageLoaded()` function</PlatformLink> is enabled.

</SdkOption>

<SdkOption name="markBackgroundSpans" type='boolean' defaultValue='true'>

This option flags pageload/navigation spans when tabs are moved to the background with "cancelled". Because browser background tab timing is not suited for precise measurements of operations and can affect your statistics in nondeterministic ways, we recommend that this option be enabled.
Expand Down
10 changes: 7 additions & 3 deletions src/components/sdkApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Props = {
name: string;
parameters: ParameterDef[];
signature: string;
availableSince?: string;
categorySupported?: PlatformCategory[];
children?: React.ReactNode;
language?: string;
Expand All @@ -35,6 +36,7 @@ export function SdkApi({
name,
children,
signature,
availableSince,
parameters = [],
language,
categorySupported = [],
Expand All @@ -51,9 +53,12 @@ export function SdkApi({
{showServerLikeOnly && (
<div className="italic text-sm">Only available on Server</div>
)}

<pre className="mt-2 mb-2 text-sm">{codeToJsx(signature, lang)}</pre>

{availableSince && (
<p className="italic">
Available Since: <code>{availableSince}</code>
</p>
)}
{parameters.length ? (
<Expandable title="Parameters">
<div className="space-y-3">
Expand All @@ -63,7 +68,6 @@ export function SdkApi({
</div>
</Expandable>
) : null}

{children}
</SdkDefinition>
);
Expand Down
Loading