[RUM-14619] Add setViewLoadingTime() public API#4180
[RUM-14619] Add setViewLoadingTime() public API#4180MaelNamNam wants to merge 2 commits intomainfrom
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 0188cfa | 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".
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
cc33dd8 to
c25c762
Compare
46d9511 to
7d86ef3
Compare
d7e5d0b to
9b2fd0e
Compare
9b2fd0e to
deca8c8
Compare
|
I have read the CLA Document and I hereby sign the CLA |
f6cdfbd to
44c3e11
Compare
712ed76 to
1d44d73
Compare
mormubis
left a comment
There was a problem hiding this comment.
Overall the implementation is clean and well-tested — moving the state into trackCommonViewMetrics was the right call. A few things worth addressing.
| @@ -948,21 +950,15 @@ export interface StopResource { | |||
| } | |||
| export interface AddViewLoadingTime { | |||
There was a problem hiding this comment.
Since you're already hand-editing this block under [MANUAL], worth renaming the interface to SetViewLoadingTime to match the feature string ('set-view-loading-time') and the public API (setViewLoadingTime). AddViewLoadingTime is a leftover from the old name.
There was a problem hiding this comment.
Woooooops, sorry, I missed this one. Thanks & renamed in 4bb65b3.
There was a problem hiding this comment.
Actually, I went too fast on this and I'm reverting it (cf 00a28dc): the telemetry event is called add-view-loading-time because it was define as such in the Mobile SDKs. As this setViewLoadingTime is an experimental API, I feel it's best to re-use already existing event names rather than add a new one just for Browser that might eventually get removed.
packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.spec.ts
Show resolved
Hide resolved
packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.spec.ts
Show resolved
Hide resolved
packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.spec.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.spec.ts
Outdated
Show resolved
Hide resolved
8c7198d to
320c8ea
Compare
320c8ea to
99b1b18
Compare
mormubis
left a comment
There was a problem hiding this comment.
setLoadingTime is only ever called from the public API — auto-detection writes directly to commonViewMetrics.loadingTime via its own callback and never touches this function. so by the time hasManualLoadingTime is true, the only way to get here again is the user explicitly calling setViewLoadingTime() a second time. that's already an unambiguous intent to update the value, which makes the overwrite param redundant.
the guard if (hasManualLoadingTime && !overwrite) only makes sense if some internal code path could also call setLoadingTime — but nothing does. the parameter exists because the no-op behavior was pushed down into trackCommonViewMetrics instead of being handled higher up where the intent is clear.
a cleaner design would be to remove overwrite entirely and just always apply the new value — or if first-call-wins is genuinely desired, enforce it at the rumPublicApi level where the user's options are already resolved, rather than leaking it down through the whole call chain as a boolean flag.
6142e5b to
0188cfa
Compare
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 experimental public API:
DD_RUM.setViewLoadingTime()[Experimental]via JSDoc annotation (no runtime feature flag required)init()are drained with preserved timestamps)startView()/manuallyTrackViews— timer resets for each new viewfeature: 'addViewLoadingTime'only (browser omitsoverwritten,no_view, andno_active_view— kept optional in schema for mobile compat)Note: The
enableExperimentalFeatures: ['set_view_loading_time']runtime gate has been removed. The API is available without any flag, consistent with other experimental APIs (startAction,stopAction,startResource,stopResource).Upstream dep: rum-events-format#352 has been merged, submodule updated to
5ddfd3b, types regenerated, and[MANUAL]annotation removed from this PR.AddViewLoadingTimeis now auto-generated from the schema.Test instructions
Checklist