add thread id to tracking for asa - #482
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Tracker’s ASA/Agent tracking events to support an optional conversation “thread id”, allowing consumers to group related events across a single conversation thread.
Changes:
- Adds optional
threadIdto relevant Tracker method parameter typings (src/types/tracker.d.ts). - Includes
thread_idin the POST body for the affected tracking endpoints when provided (src/modules/tracker.js). - Updates tracker specs to assert
thread_idis sent through correctly (spec/src/modules/tracker.js).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/types/tracker.d.ts | Adds threadId to TypeScript declarations for ASA/Agent tracking methods. |
| src/modules/tracker.js | Passes threadId through as thread_id in request bodies for ASA/Agent tracking events. |
| spec/src/modules/tracker.js | Extends existing tests to validate thread_id is included in request params. |
Suppressed comments (5)
src/modules/tracker.js:2831
threadIdis optional, but guarding withif (threadId)changes behavior compared to other optional string params (e.g. empty string would be dropped). Since request bodies are JSON-stringified (undefined properties are omitted), you can assign unconditionally and avoid the branch.
if (threadId) {
bodyParams.thread_id = threadId;
}
src/modules/tracker.js:2897
threadIdis optional, but guarding withif (threadId)changes behavior compared to other optional string params (e.g. empty string would be dropped). Since request bodies are JSON-stringified (undefined properties are omitted), you can assign unconditionally and avoid the branch.
if (threadId) {
bodyParams.thread_id = threadId;
}
src/modules/tracker.js:2975
threadIdis optional, but guarding withif (threadId)changes behavior compared to other optional string params (e.g. empty string would be dropped). Since request bodies are JSON-stringified (undefined properties are omitted), you can assign unconditionally and avoid the branch.
if (threadId) {
bodyParams.thread_id = threadId;
}
src/modules/tracker.js:3049
threadIdis optional, but guarding withif (threadId)changes behavior compared to other optional string params (e.g. empty string would be dropped). Since request bodies are JSON-stringified (undefined properties are omitted), you can assign unconditionally and avoid the branch.
if (threadId) {
bodyParams.thread_id = threadId;
}
src/modules/tracker.js:3120
threadIdis optional, but guarding withif (threadId)changes behavior compared to other optional string params (e.g. empty string would be dropped). Since request bodies are JSON-stringified (undefined properties are omitted), you can assign unconditionally and avoid the branch.
if (threadId) {
bodyParams.thread_id = threadId;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (threadId) { | ||
| bodyParams.thread_id = threadId; | ||
| } |
Alexey-Pavlov
left a comment
There was a problem hiding this comment.
LGTM! Maybe it makes sense to add
@param {string} [parameters.threadId] - Thread ID for grouping events within a conversation
to the 6 deprecated trackAssistant* wrappers, but it's a nitpick
For this PR, we would need an additional approval from one of the shepherds
No description provided.