-
Notifications
You must be signed in to change notification settings - Fork 170
[RUM-14619] Add addViewLoadingTime() public API #4180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ playwright-report/ | |
| # Claude Code local files | ||
| *.local.md | ||
| .claude/settings.local.json | ||
| .planning/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,7 @@ import { | |||||||||||||||||||||
| startBufferingData, | ||||||||||||||||||||||
| isExperimentalFeatureEnabled, | ||||||||||||||||||||||
| ExperimentalFeature, | ||||||||||||||||||||||
| timeStampNow, | ||||||||||||||||||||||
| } from '@datadog/browser-core' | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import type { LifeCycle } from '../domain/lifeCycle' | ||||||||||||||||||||||
|
|
@@ -215,6 +216,18 @@ export interface RumPublicApi extends PublicApi { | |||||||||||||||||||||
| */ | ||||||||||||||||||||||
| addTiming: (name: string, time?: number) => void | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Manually set the current view's loading time. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * Call this method when the view has finished loading. The loading time is computed as the | ||||||||||||||||||||||
| * elapsed time since the view started. By default, the first call sets the loading time and | ||||||||||||||||||||||
| * subsequent calls are no-ops. Use `{ overwrite: true }` to replace a previously set value. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @category Data Collection | ||||||||||||||||||||||
| * @param options - Options. Set `overwrite: true` to replace a previously set loading time. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| addViewLoadingTime: (options?: { overwrite?: boolean }) => void | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Set the global context information to all events, stored in `@context` | ||||||||||||||||||||||
| * See [Global context](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/#global-context) for further information. | ||||||||||||||||||||||
|
|
@@ -533,6 +546,7 @@ export interface Strategy { | |||||||||||||||||||||
| getInternalContext: StartRumResult['getInternalContext'] | ||||||||||||||||||||||
| stopSession: StartRumResult['stopSession'] | ||||||||||||||||||||||
| addTiming: StartRumResult['addTiming'] | ||||||||||||||||||||||
| addLoadingTime: StartRumResult['addLoadingTime'] | ||||||||||||||||||||||
| startView: StartRumResult['startView'] | ||||||||||||||||||||||
| setViewName: StartRumResult['setViewName'] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -727,6 +741,17 @@ export function makeRumPublicApi( | |||||||||||||||||||||
| strategy.addTiming(sanitize(name)!, time as RelativeTime | TimeStamp | undefined) | ||||||||||||||||||||||
| }), | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| addViewLoadingTime: monitor((options?: { overwrite?: boolean }) => { | ||||||||||||||||||||||
| const callTimestamp = timeStampNow() | ||||||||||||||||||||||
| const result = strategy.addLoadingTime(callTimestamp, options?.overwrite ?? false) | ||||||||||||||||||||||
| addTelemetryUsage({ | ||||||||||||||||||||||
| feature: 'addViewLoadingTime', | ||||||||||||||||||||||
| no_view: false, | ||||||||||||||||||||||
| no_active_view: result?.noActiveView ?? false, | ||||||||||||||||||||||
| overwritten: result?.overwritten ?? false, | ||||||||||||||||||||||
| }) | ||||||||||||||||||||||
|
Comment on lines
747
to
752
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ question: TelemetryUsage is meant to understand which API the customer are using and with which option when available. I don't think we should return run-time analysis like this.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I went a different direction though — I aligned the telemetry with the mobile SDK schema instead, which tracks runtime state ( |
||||||||||||||||||||||
| }), | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| setGlobalContext: defineContextMethod( | ||||||||||||||||||||||
| getStrategy, | ||||||||||||||||||||||
| CustomerContextKey.globalContext, | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.