[RUM-14619] Add addViewLoadingTime() public API#4180
[RUM-14619] Add addViewLoadingTime() public API#4180MaelNamNam wants to merge 11 commits intomainfrom
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 874630d | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4e10304d9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| no_active_view: isResult && 'no_active_view' in result, | ||
| overwritten: isResult && 'overwritten' in result && result.overwritten !== false, |
There was a problem hiding this comment.
Default telemetry flags to false for buffered calls
When addViewLoadingTime() is called before init, strategy.addLoadingTime(...) returns undefined, so isResult && ... evaluates to undefined for both no_active_view and overwritten. Those fields are then omitted from the telemetry payload instead of being sent as explicit booleans, which contradicts the AddViewLoadingTime usage schema and makes pre-start telemetry inaccurate. Please coerce these expressions to false when no result is available.
Useful? React with 👍 / 👎.
Add a new public API `DD_RUM.addViewLoadingTime(options?)` that allows
developers to manually report when a view has finished loading.
- Computes loading time as elapsed time since view start
- Suppresses auto-detected loading time on first manual call
- First-call-wins by default; `{ overwrite: true }` to replace
- Pre-start buffering with preserved call timestamps
- Telemetry usage tracking
- Gracefully no-ops on ended/expired views
- Unit tests + E2E test
f4e1030 to
169989b
Compare
packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.ts
Outdated
Show resolved
Hide resolved
| addTelemetryUsage({ | ||
| feature: 'addViewLoadingTime', | ||
| no_view: false, | ||
| no_active_view: isResult && 'no_active_view' in result, | ||
| overwritten: isResult && 'overwritten' in result && result.overwritten !== false, | ||
| }) |
There was a problem hiding this comment.
❓ 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.
| addTelemetryUsage({ | |
| feature: 'addViewLoadingTime', | |
| no_view: false, | |
| no_active_view: isResult && 'no_active_view' in result, | |
| overwritten: isResult && 'overwritten' in result && result.overwritten !== false, | |
| }) | |
| addTelemetryUsage({ | |
| feature: 'addViewLoadingTime', | |
| overwrite | |
| }) |
There was a problem hiding this comment.
Good point. I went a different direction though — I aligned the telemetry with the mobile SDK schema instead, which tracks runtime state (no_view, no_active_view, overwritten). This matches what iOS/Android already report for AddViewLoadingTime. See c25c762.
| const result = strategy.addLoadingTime(callTimestamp, options?.overwrite ?? false) | ||
|
|
||
| // For pre-start buffered calls, result is undefined so we emit best-guess default values. | ||
| const isResult = result && typeof result === 'object' |
There was a problem hiding this comment.
💬 suggestion: use Types to prevent runtime assertion
There was a problem hiding this comment.
Kept the runtime assertion — it feeds the no_active_view and overwritten telemetry fields that are now aligned with the mobile SDK schema. See c25c762.
…JSDoc link - Remove '(CONTEXT decision)' comment from trackCommonViewMetrics.ts - Remove 'Phase 2 telemetry' comment from trackCommonViewMetrics.ts - Remove broken JSDoc link to non-existent doc page from rumPublicApi.ts
cc33dd8 to
c25c762
Compare
- Refactor addLoadingTime to return void at newView and trackViews layers - Simplify telemetry to user intent, remove runtime assertion - Add unit and E2E tests for manual loading time coverage - Draft RFC for addViewLoadingTime() public API
46d9511 to
7d86ef3
Compare
…xperimental gate - Add SET_VIEW_LOADING_TIME enum member to ExperimentalFeature - Rename addViewLoadingTime to setViewLoadingTime on RumPublicApi interface and implementation - Add experimental feature guard that fires display.warn() when flag is disabled - Preserve telemetry wire format string 'addViewLoadingTime' unchanged - Import display from @datadog/browser-core for warning output
…e and experimental gate - Rename describe block from addViewLoadingTime to setViewLoadingTime - Add mockExperimentalFeatures([SET_VIEW_LOADING_TIME]) to existing working tests - Rename all rumPublicApi.addViewLoadingTime() calls to setViewLoadingTime() - Add no-op test verifying display.warn() fires when experimental flag is disabled - Update E2E tests to use setViewLoadingTime() with enableExperimentalFeatures config
…from browser payload - Mark no_view and no_active_view as optional in AddViewLoadingTime interface with [MANUAL] comments - Remove no_view and no_active_view from addTelemetryUsage call in setViewLoadingTime - Browser never meaningfully sent these mobile-only fields (always false)
…te experimental status in RFC - Rename all public API references from addViewLoadingTime to setViewLoadingTime - Preserve telemetry wire format string 'addViewLoadingTime' (backend contract) - Update Open Questions Q1 from Stable to Experimental with rationale - Add Constraint #7 documenting experimental gate and backend pipeline vision - Update Annex A browser row to Experimental stability - Add v1.2 changelog entry
…in RFC - Replace telemetry block to show only feature + overwritten (no no_view, no no_active_view) - Add three naming surfaces table (public API, wire format, TypeScript interface) - Add Constraint #8 documenting no auto-detection opt-out rationale - Update no_view/no_active_view note to explain browser omission - Update pre-start telemetry cons bullet to remove no_active_view reference
- Create 11-01-SUMMARY.md with execution results - Update STATE.md: Phase 11 complete, all v1.2 phases done, 100% progress - Update ROADMAP.md: Phase 11 plan progress - Mark RFC-01 through RFC-04 requirements complete in REQUIREMENTS.md
Motivation
Allow developers to manually report view loading time for complex async patterns (SPAs with deferred fetching, skeleton screens) where auto-detection is inaccurate.
Brings Browser SDK to parity with iOS/Android SDKs.
Changes
New public API:
DD_RUM.addViewLoadingTime(options?){ overwrite: true }to replaceinit()are drained with preserved timestamps)no_view,no_active_view,overwritten(aligned with mobile schema)Upstream dep: rum-events-format#352 — once merged, the manual type in
telemetryEvent.types.tscan be replaced by the generated one.Test instructions
Checklist