Title: feat(o11y): stamp testhubBuildUuid + buildProductMap on cypress build caps [SDK-7285] by kamal-kaur04 · Pull Request #1180 · browserstack/browserstack-cypress-cli · GitHub
Open Graph Title: feat(o11y): stamp testhubBuildUuid + buildProductMap on cypress build caps [SDK-7285] by kamal-kaur04 · Pull Request #1180 · browserstack/browserstack-cypress-cli
X Title: feat(o11y): stamp testhubBuildUuid + buildProductMap on cypress build caps [SDK-7285] by kamal-kaur04 · Pull Request #1180 · browserstack/browserstack-cypress-cli
Description: What is this about? Two commits. ed3a58a adds the two capabilities; 5c9a9e0 makes buildProductMap.observability report actual state rather than requested state (product-owner requirement, 2026-09-10). Detail + the before/after toggle in this comment. Cypress is the only SDK line that stamps no TestHub capability at all — measured, 0 of 16,629 sessions carry one, across all 32 CLI versions present including the newest. bin/ has zero references to testhubBuildUuid, buildProductMap or a browserstackSDK cap; the build id goes to the in-browser reporter instead. That leaves cypress with a single route into Test Reporting & Analytics — the BTCER session_hashed_id fallback — where every other SDK line has two. That fallback misses ~32.5% of cypress sessions, and those sessions are then counted against ingestion stability with no build to attach to. Population: 2,917 orphaned sessions in the measured cohort · 0.5882 pp of instability · 76 accounts / 56 groups. Cypress is the only diffuse line in that bucket — top group 10.6%, 24 groups to reach 90%, where every other line is 83–100% a single customer. So this is a product gap affecting many customers a little, not a support case. This PR adds the missing surface. It does not on its own move the metric — see Dependent PRs / release order. Related Jira task/s SDK-7285 — item A1.1 of the approved orphan-bucket action-item ledger Dependent PRs / release order ⚠️ This PR is the last of three legs to become useful, and it is inert until the second one ships. Please do not expect a metric movement from merging it alone. Leg Where State A1.1 — send the two keys on the build-creation payload this PR ✅ here A1.1b — map both keys into the session capabilities hash automate rails ❌ not started, no owner A1.2 — extract instead of CAST(NULL AS STRING) zombies l4_metrics.yml:2081-2087 ❌ open Why A1.1b exists. The capabilities column the metric reads on automate.cypress_test_sessions_partitioned is not the payload the CLI sends — it is rebuilt server-side from an explicit key list. Measured over 3,782 cypress sessions (BQ job_5VlbncWZuByJPM9vetoSvqNYMkmK): CLI-sent key Appears in session capabilities run_settings (sent on every build) 0 / 3,782 — dropped cypress_cli_user_agent (sent on every build) 0 / 3,782 — dropped parallels 0 / 3,782 — dropped test_suite 3,782 — renamed to testSuite local_mode_inferred 3,782 — verbatim Three keys sent on every build never arrive; one is renamed while another is preserved verbatim. Mixed casing plus outright drops rules out a blanket transform. Automation cases to add None. The change adds two keys to an outbound payload; there is no user-visible behaviour to assert from a wrapper test, and the value is only observable in BigQuery. Covered by unit tests here + the end-to-end wire capture below. Code changes to check bin/helpers/capabilityHelper.js — the two new keys, and the new require of ../testhub/utils test/unit/bin/helpers/capabilityHelper.js — new context("testhub build attribution") The change obj.testhubBuildUuid = process.env.BROWSERSTACK_TESTHUB_UUID || ""; obj.buildProductMap = testhubUtils.getProductMap(bsConfig); Four things worth a reviewer's attention, all deliberate: No sequencing work was needed. runs.js:137 already awaits TestHubHandler.launchBuild, which sets BROWSERSTACK_TESTHUB_UUID at testhub/utils.js:236, before capabilityHelper.validate → build.createBuild → caps(). Confirmed on the wire below. getProductMap() is reused, not reimplemented (bin/testhub/utils.js:38) — same five-product shape the other SDK lines stamp. Calling it at caps-build time is deliberate: it reports the products still enabled after the accessibility/observability gates at runs.js:118-137, rather than the ones originally requested. No new require cycle. bin/helpers/utils.js:30 already top-level-requires ../testhub/utils, and capabilityHelper already requires ./utils, so the module was in the graph. getProductMap is reached through the module object (late-bound) rather than destructured at load time, so a partially-initialised export cannot bite. Both keys are written unconditionally (|| ""). The metric treats an absent key and '' identically, so the empty string costs nothing — and it preserves the distinction between a cap writer ran and had nothing to name and no cap writer ran at all, which for cypress is currently unobservable anywhere. Key names deliberately match the other five SDK lines so the A1.2 branch can reuse their existing REGEXP_EXTRACT verbatim. Second commit — the map must not lie about observability buildProductMap is stamped twice with two different meanings: on the build-start request it is intent, on the session caps it is outcome. Only the first was honest. extractDataFromResponse already clears BROWSERSTACK_TEST_OBSERVABILITY for a 2xx carrying observability.success = false, but launchBuild's catch — every non-2xx and every network error — only logged, leaving the flag true. The session then advertised observability with no build behind it. The collector rejects 7,442 × 400 + 442 × 403 build-starts per week, so this was the common path, not an edge case. Three coupled changes: handleErrorForObservability also clears the flag (one funnel, all failure paths agree); launchBuild's catch routes through it, before the error.success === false branch so network errors are covered too; and caps() no longer stamps the "null" sentinel as a uuid — which is required because of the second change, since that is what now causes the sentinel to be written on this path. An explicit testObservability: false in config already resolved correctly and was left alone; it is covered by a test purely as a regression guard. Verification Unit — 2 new tests; whole-suite comparison against a stashed baseline, so "no regressions" is measured rather than asserted: passing failing full unit suite with this change 691 16 full unit suite, change stashed (8731a23) 689 16 Same 16 failures either way — all pre-existing on master (runs ×7, fileHelpers ×2, readCypressConfigUtil ×3, syncSpecsLogs ×1, utils › getVideoConfig ×3). Heads-up that master's unit suite does not currently pass clean. End-to-end on production infra — patched CLI served from source, --cli-debug --sync, 1 spec / 2 tests, Chrome 136 / Windows 11. Total tests: 1, passed: 1, failed: 0, exit 0. TestHub build xcsouiygyettrxqdxyxmi18qnkyb6alfxqnj8x4z Automate build b1caa6889d0ce4122dd9c601374d9462e01f389b Session ecbded54b9f90a9a4dc9ebffdac03db3ae1d6e21 CLI debug, showing the value was in hand before caps were built: debug: TestHub build uuid stamped on caps: xcsouiygyettrxqdxyxmi18qnkyb6alfxqnj8x4z On the wire — captured by wrapping axios.post from outside the repo, so this is the request as sent rather than the CLI's own account of it: POST https://api.browserstack.com/automate/cypress/v1/builds/ → 201 keys sent: [buildProductMap, cache_dependencies, customBuildName, cypress_cli_user_agent, devices, local, parallels, project, run_settings, test_suite, testhubBuildUuid] "testhubBuildUuid": "xcsouiygyettrxqdxyxmi18qnkyb6alfxqnj8x4z" "buildProductMap": {"observability": true, "accessibility": false, "percy": false, "automate": true, "app_automate": false} response: {"message":"Success","build_id":"b1caa6889d0ce4122dd9c601374d9462e01f389b", ...} The uuid on the caps payload is byte-identical to the TestHub build the same run created, and the hub accepted the payload with both previously-unknown keys present (201) — which settles the open "confirm the hub tolerates an unknown cap key before rollout" question in the affirmative. What is NOT verified here: whether the keys survive into automate.cypress_test_sessions_partitioned.capabilities. That is leg A1.1b and is a property of the automate rails layer, not of this diff. The probe session's row had not landed at the time of writing; I will post the result as a comment either way. Note the metric excludes group_id IN (2, 1224686) and this run is group 2, so the probe is plumbing-only and never enters the stability numbers. Release Version bump: minor (backwards-compatible feature) patch (bug fix or other small change) Release notes type: Improvement Release notes (customer-facing): Cypress builds now report their Test Reporting & Analytics build id and enabled-product map with the session, so Cypress sessions can be attributed to the build that created them. When Test Observability is disabled or its build could not be started, the reported product map now correctly shows it as off. Release notes (internal): bin/helpers/capabilityHelper.js: caps() now stamps testhubBuildUuid (from BROWSERSTACK_TESTHUB_UUID, set by TestHubHandler.launchBuild before caps() runs) and buildProductMap (from the existing testhub/utils.js getProductMap()) on the build-creation payload. Cypress previously stamped no TestHub capability on any session (0 of 16,629 measured), leaving the BTCER session_hashed_id fallback as its only route into TRA; that fallback misses ~32.5%, worth 2,917 orphaned sessions / 0.5882 pp across 76 accounts. Both keys are written unconditionally so an empty uuid is distinguishable from an absent writer. Added test/unit/bin/helpers/capabilityHelper.js → context("testhub build attribution"). bin/testhub/utils.js + bin/testhub/testhubHandler.js: handleErrorForObservability now also clears BROWSERSTACK_TEST_OBSERVABILITY, and launchBuild's catch routes through it rather than only logging — so a non-2xx or network failure on build start no longer leaves buildProductMap.observability reporting true with no build behind it (verified against an injected collector 400: true before, false after). caps() additionally guards against stamping the "null" uuid sentinel that funnel writes. Also logBuildError treated only undefined as "no error object", so a null error logged the string "null" — this affected the accessibility no-response path as well. Inert until the automate rails layer maps both keys into the session capabilities hash (that column is rebuilt server-side from an explicit key list — three keys the CLI sends on every build appear 0/3,782 times), and until the zombies cypress branch extracts testhubBuildUuid instead of hardcoding CAST(NULL AS STRING). Checklist Ready to review Has it been approved by a member of your team? Verified end-to-end on BrowserStack infra (build links above) Payload verified on the wire, separately from the pass/fail result No-regression measured against a stashed baseline, not asserted Fix demonstrated by toggle (4 new tests fail on unfixed source, pass on fixed; plus a before/after production run) Downstream dependencies and release order stated Reviewer notes The one judgement call is point 4 above — writing "" rather than omitting the key when build start produced no uuid. The metric cannot tell the two apart today, so this is free on the measurement side; the reason to prefer the empty string is diagnostic, and it is the only thing that would let us separate build start failed from TestHub was never requested on a cypress session. Happy to guard it instead if you would rather the key never appear empty. 🤖 Generated with Claude Code
Open Graph Description: What is this about? Two commits. ed3a58a adds the two capabilities; 5c9a9e0 makes buildProductMap.observability report actual state rather than requested state (product-owner requirement, 2026-09-...
X Description: What is this about? Two commits. ed3a58a adds the two capabilities; 5c9a9e0 makes buildProductMap.observability report actual state rather than requested state (product-owner requirement, 2026-09-...
Opengraph URL: https://github.com/browserstack/browserstack-cypress-cli/pull/1180
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c542470d-3d75-ce9d-a39e-3dfe653f6a3c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8988:24E22D:763E09:9C9038:6B04E8AA |
| html-safe-nonce | b59d21386364eed673f1d2eccce9a1aa14c0a4a40babf04f31c7746ededbb14b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTg4OjI0RTIyRDo3NjNFMDk6OUM5MDM4OjZCMDRFOEFBIiwidmlzaXRvcl9pZCI6IjYxNjAwNTEyNTQwMzYwNjQ0MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0d589882f71476a2e8c044c48fc977d232544670b5ce9d72dceaeeca339b69b0 |
| hovercard-subject-tag | pull_request:4485760993 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/browserstack/browserstack-cypress-cli/pull/1180/files |
| twitter:image | https://avatars.githubusercontent.com/u/38219887?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/38219887?s=400&v=4 |
| og:image:alt | What is this about? Two commits. ed3a58a adds the two capabilities; 5c9a9e0 makes buildProductMap.observability report actual state rather than requested state (product-owner requirement, 2026-09-... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | f3851aad500d8e8dce736722ddc6fa9596e17d9fce3c53581eba968664c0bc32 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/browserstack/browserstack-cypress-cli git https://github.com/browserstack/browserstack-cypress-cli.git |
| octolytics-dimension-user_id | 1119453 |
| octolytics-dimension-user_login | browserstack |
| octolytics-dimension-repository_id | 242935045 |
| octolytics-dimension-repository_nwo | browserstack/browserstack-cypress-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 242935045 |
| octolytics-dimension-repository_network_root_nwo | browserstack/browserstack-cypress-cli |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e29c922455fd8137f27e1cfcdf6a1e8b920b1926 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width