Skip to content

Update client layout instrumentation - #1128

Open
shawj0 wants to merge 5 commits into
microsoft:masterfrom
shawj0:shawjames/client-signal-0870
Open

Update client layout instrumentation#1128
shawj0 wants to merge 5 commits into
microsoft:masterfrom
shawj0:shawjames/client-signal-0870

Conversation

@shawj0

@shawj0 shawj0 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add lightweight signal capture for a small set of exact client-control indicators.
  • Reuse the existing layout discovery and mutation traversal.
  • Emit newly observed values through typed client Dimension 39.
  • Publish the package as 0.8.70-beta for a beta rollout.

Why

Downstream processing needs a compact page-level indication when these controls are present. Capturing the values during the traversal that already processes layout changes avoids a second DOM scan.

The typed Dimension path provides a compact numeric wire contract and owns per-page deduplication. It avoids using customer events, click telemetry, or the generic system-variable namespace.

Behavior

Scenario Result
Indicator exists during initial discovery Dimension value emitted once
Indicator is added or updated later New Dimension value emitted
Short-lived indicator is removed before upload Value retained
Indicator appears in an open shadow root or same-origin iframe Value emitted
Same indicator is encountered again No duplicate value
Similar or unrelated IDs No value emitted
No indicators present Existing behavior unchanged

Not changed

  • No additional observer, polling loop, or selector scan.
  • No click, custom-event, or customer-variable changes.
  • No backend processing or routing changes in this repository.
  • Existing privacy, consent, and startup checks remain unchanged.

Validation

  • 8 focused marker scenarios passed.
  • Sparse-payload smoke passed: initial discovery emitted one value, quiet payloads emitted none, and a later mutation emitted only its new value.
  • Live-page local-bundle smoke passed on Microsoft, MSN, and Bing with Dimension 39 present once and no legacy ABS variable.
  • 28 clarity-js package tests passed when excluding the existing consent-cookie timing flake.
  • The unrelated masking input timing failures reproduced identically on untouched 0.8.69.
  • 208 paired performance measurements found no repeatable INP, PLT, long-task, discovery, or mutation-cost regression.
  • Bundle delta: +303 raw bytes and +112 gzip bytes.

Backend contract

Decode should add matching ClientDimension.AgenticBrowserSignal = 39 and route values 1-5 to the session classifier. Unknown Dimension 39 is safely ignored by older Decode builds during rolling deployment.

Risk and rollout

Risk is limited by exact matching, typed values, Dimension-level deduplication, and reuse of the current traversal. Publish 0.8.70-beta through the normal beta flight, monitor value distribution and client performance, and roll back by disabling the flight if needed.

Copilot AI review requested due to automatic review settings August 3, 2026 21:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds lightweight detection of a small set of exact “agentic browser” DOM markers during existing layout discovery/mutation processing, emitting a page-level variable signal (<!>ABS) once per detected marker. It also bumps the monorepo/package versions to 0.8.70 for beta rollout.

Changes:

  • Add layout/agent marker detection and wire it into the layout node traversal + layout startup.
  • Expose the new signal via types (AgenticBrowserSignal enum + Constant.AgenticBrowserSignal = "<!>ABS").
  • Add a Playwright test suite covering initial, dynamic, transient, shadow DOM, and iframe scenarios; bump package versions to 0.8.70.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/agentic-browser.test.ts Adds Playwright coverage for the new agentic marker variable emission behavior.
packages/clarity-visualize/package.json Bumps package and dependency versions to 0.8.70.
packages/clarity-js/types/data.d.ts Adds AgenticBrowserSignal enum and <!>ABS constant key to the public type surface.
packages/clarity-js/src/layout/node.ts Hooks marker detection into element processing during layout traversal.
packages/clarity-js/src/layout/index.ts Resets agentic marker state during layout startup.
packages/clarity-js/src/layout/agent.ts Implements exact-id marker identification and per-page deduped variable emission.
packages/clarity-js/src/core/version.ts Bumps clarity-js internal version string to 0.8.70.
packages/clarity-js/package.json Bumps package version to 0.8.70.
packages/clarity-devtools/static/manifest.json Bumps extension manifest version/version_name to 0.8.70.
packages/clarity-devtools/package.json Bumps package and dependency versions to 0.8.70.
packages/clarity-decode/package.json Bumps package and dependency versions to 0.8.70.
package.json Bumps root monorepo version to 0.8.70.
lerna.json Bumps Lerna version to 0.8.70.

clarity("start", {
delay: 50,
projectId: "test",
upload: (payload) => { window.payloads.push(payload); }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This callback runs inside an injected HTML <script> as plain JavaScript, so a TypeScript annotation would be invalid here. This matches existing test patterns; no change needed.

James Shaw added 4 commits August 3, 2026 14:19
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8b609ea0-752a-4773-927c-7d6515ff9c75
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8b609ea0-752a-4773-927c-7d6515ff9c75
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.

3 participants