Skip to content

[RUM-14619] Add addViewLoadingTime() public API#4180

Draft
MaelNamNam wants to merge 3 commits intomainfrom
mael.lilensten/manually_report_view_loading_time
Draft

[RUM-14619] Add addViewLoadingTime() public API#4180
MaelNamNam wants to merge 3 commits intomainfrom
mael.lilensten/manually_report_view_loading_time

Conversation

@MaelNamNam
Copy link

@MaelNamNam MaelNamNam commented Feb 13, 2026

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?)

  • Loading time = elapsed since current view start
  • First call suppresses auto-detected loading time
  • First-call-wins by default; { overwrite: true } to replace
  • Pre-start buffering supported (calls before init() are drained with preserved timestamps)
  • Telemetry: no_view, no_active_view, overwritten (aligned with mobile schema)

Upstream dep: rum-events-format#352 — once merged, the manual type in telemetryEvent.types.ts can be replaced by the generated one.

Test instructions

yarn test:unit --spec packages/rum-core/src/domain/view/trackViews.spec.ts
yarn test:unit --spec packages/rum-core/src/boot/rumPublicApi.spec.ts
yarn test:unit --spec packages/rum-core/src/boot/preStartRum.spec.ts
yarn test:e2e:init && yarn test:e2e -g "manual loading time"

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@MaelNamNam MaelNamNam requested a review from a team as a code owner February 13, 2026 10:27
@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.

@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Feb 13, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 169.43 KiB 170.22 KiB +805 B +0.46%
Rum Profiler 4.29 KiB 4.29 KiB 0 B 0.00%
Rum Recorder 24.54 KiB 24.54 KiB 0 B 0.00%
Logs 56.72 KiB 56.72 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 126.26 KiB 127.01 KiB +768 B +0.59%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance

Pending...

🧠 Memory Performance

Pending...

🔗 RealWorld

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Feb 13, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 83.33%
Overall Coverage: 77.29% (+0.16%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7d86ef3 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@MaelNamNam MaelNamNam changed the title ✨ feat(rum): add addViewLoadingTime() public API Add addViewLoadingTime() public API Feb 13, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines 755 to 756
no_active_view: isResult && 'no_active_view' in result,
overwritten: isResult && 'overwritten' in result && result.overwritten !== false,

Choose a reason for hiding this comment

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

P2 Badge 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
@MaelNamNam MaelNamNam force-pushed the mael.lilensten/manually_report_view_loading_time branch from f4e1030 to 169989b Compare February 13, 2026 10:32
Comment on lines 752 to 757
addTelemetryUsage({
feature: 'addViewLoadingTime',
no_view: false,
no_active_view: isResult && 'no_active_view' in result,
overwritten: isResult && 'overwritten' in result && result.overwritten !== false,
})
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
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
})

Copy link
Author

Choose a reason for hiding this comment

The 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 (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'
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 suggestion: ‏use Types to prevent runtime assertion

Copy link
Author

Choose a reason for hiding this comment

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

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.

@MaelNamNam MaelNamNam marked this pull request as draft February 13, 2026 19:10
…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
@MaelNamNam MaelNamNam force-pushed the mael.lilensten/manually_report_view_loading_time branch from cc33dd8 to c25c762 Compare February 17, 2026 10:40
@MaelNamNam MaelNamNam changed the title Add addViewLoadingTime() public API [RUM-14619] Add addViewLoadingTime() public API Feb 17, 2026
- 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
@MaelNamNam MaelNamNam force-pushed the mael.lilensten/manually_report_view_loading_time branch from 46d9511 to 7d86ef3 Compare February 18, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments