feat(DXG-1408): add analytics headers - #495
Merged
Natalia Markitantova (markitosha) merged 7 commits intoAug 18, 2026
Merged
Conversation
Maksim Filipenka (mfilipenka)
force-pushed
the
corti-sdk-javascript-add-analytics-headers-dxg-1408
branch
from
August 17, 2026 10:34
598922c to
626b6b8
Compare
Maksim Filipenka (mfilipenka)
force-pushed
the
corti-sdk-javascript-add-analytics-headers-dxg-1408
branch
from
August 17, 2026 11:28
626b6b8 to
de1fc55
Compare
Copilot started reviewing on behalf of
Natalia Markitantova (markitosha)
August 17, 2026 12:37
View session
There was a problem hiding this comment.
Pull request overview
Adds SDK-managed analytics metadata propagation to Corti requests by introducing a standardized X-Corti-Analytics header for HTTP calls and an x-corti-analytics query parameter for WebSocket handshakes, enabling consistent downstream analytics attribution.
Changes:
- Introduces
src/custom/utils/analytics.tshelpers to build an SDK-owned analytics payload and merge it into headers/query params. - Wires analytics query parameters into Custom Stream/Transcribe WebSocket connection flows.
- Adds unit tests validating payload construction, reserved-key behavior, and merge semantics.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/utils/analytics.test.ts | Adds unit coverage for analytics payload building and header/query merging behavior. |
| src/custom/utils/sdkHeaderNames.ts | Registers X-Corti-Analytics as an SDK-managed header name. |
| src/custom/utils/analytics.ts | Implements analytics payload construction, serialization, and merge helpers. |
| src/custom/transcribe/CustomTranscribe.ts | Injects analytics into WebSocket handshake query parameters for transcribe flows. |
| src/custom/stream/CustomStream.ts | Injects analytics into WebSocket handshake query parameters for stream flows. |
| src/custom/CortiClient.ts | Adds analytics option and merges analytics header into client default headers. |
Suppressed comments (1)
tests/unit/utils/analytics.test.ts:51
- This assertion relies on a specific JSON string ordering inside the query parameter value. Consider parsing the JSON value and asserting the object contents to avoid order-dependent failures.
it("returns a single x-corti-analytics query parameter with a JSON value", () => {
expect(analyticsQueryParams({ source: "web" })).toEqual({
[X_CORTI_ANALYTICS_QUERY]: `{"sdk_version":"${SDK_VERSION}","sdk_type":"javascript","source":"web"}`,
});
});
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Maksim Filipenka (mfilipenka)
force-pushed
the
corti-sdk-javascript-add-analytics-headers-dxg-1408
branch
3 times, most recently
from
August 18, 2026 11:51
777dd34 to
e2974f0
Compare
Maksim Filipenka (mfilipenka)
force-pushed
the
corti-sdk-javascript-add-analytics-headers-dxg-1408
branch
from
August 18, 2026 12:13
e2974f0 to
1ff0a44
Compare
Keep Fern's last-write-wins merge as mergeHeadersOriginal and collapse X-Corti-Analytics in custom before delegating. Drop connect-level analytics so sockets only send the client constructor payload as a query param.
Use a single x-corti-analytics key and merge per-call overlays in withAnalytics so extra headers and query params stay intact beside the reserved SDK fields.
Store SDK_HEADER_NAMES in lowercase and compare against lowercased keys so x-corti-analytics is stripped from WS protocols after mergeHeaders.
Copilot started reviewing on behalf of
Natalia Markitantova (markitosha)
August 18, 2026 18:10
View session
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
Suppressed comments (2)
README.md:694
- This says analytics metadata is sent “with every request”, but the implementation only adds the X-Corti-Analytics/x-corti-analytics payload when analytics is provided (client-level analytics or a per-call header/query param). Either update the docs to match the current behavior, or change the code to always send the reserved keys even when analytics isn’t configured.
The SDK sends metadata about itself (`sdk_version`, `sdk_type`) with every request via the `X-Corti-Analytics` header (REST) or the `x-corti-analytics` query parameter (WebSocket). You can extend this payload with your own fields on the client constructor, and overlay extra fields on individual REST calls or WebSocket connections.
src/custom/overrides/headers.ts:26
- mergeHeaders strips the x-corti-analytics key from all input objects, which changes merge semantics for that key: passing a later
{ "x-corti-analytics": null }no longer deletes a previously-set analytics header (it gets ignored). This is inconsistent with mergeHeadersOriginal behavior (null deletes) and makes it impossible to explicitly clear analytics on a specific call.
if (key.toLowerCase() !== X_CORTI_ANALYTICS) {
cleaned[key] = value;
continue;
}
mergeHeaders now attaches sdk_version and sdk_type even when the caller did not provide analytics.
Natalia Markitantova (markitosha)
approved these changes
Aug 18, 2026
Natalia Markitantova (markitosha)
merged commit Aug 18, 2026
caeea6d
into
master
5 of 6 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.