Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telemetry: add request_id field for code block actions #1586

Merged
merged 8 commits into from
Nov 2, 2023

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Nov 1, 2023

Context: https://sourcegraph.slack.com/archives/C05AGQYD528/p1698355247771849?thread_ts=1697738493.299929&cid=C05AGQYD528

From @chenkc805

For a "chatID", I'd like to be able to link specific chain of events together:
chat/command executed --> chat/command response --> code copied --> code pasted

This PR adds request_id to each Interaction so that when we display the code block in the UI, we will be able to refer back to the request when the code was generated:

  • add requestID parameter to copy and insert callback functions

Test plan

Ask Cody a question that generates a code block, and then copy the code. they should have the same request id as the request that generated the code

█ logEvent (telemetry disabled): CodyVSCodeExtension:recipe:chat-question:executed {"properties":{"embeddings":15,"local":1,"request_id":"2c951818-f4fe-4105-9113-0c055d8b264c"},"opts":{"hasV2Event":true}}
█ logEvent (telemetry disabled): CodyVSCodeExtension:chatResponse:hasCode {"properties":{"lineCount":1,"charCount":25,"source":"chat-question","request_id":"2c951818-f4fe-4105-9113-0c055d8b264c"},"opts":{"hasV2Event":true}}
█ logEvent (telemetry disabled): CodyVSCodeExtension:insertButton:clicked {"properties":{"op":"insert","charCount":25,"lineCount":1,"source":"chat-question","request_id":"2c951818-f4fe-4105-9113-0c055d8b264c"}}
█ logEvent (telemetry disabled): CodyVSCodeExtension:copyButton:clicked {"properties":{"op":"copy","charCount":25,"lineCount":1,"source":"chat-question","request_id":"2c951818-f4fe-4105-9113-0c055d8b264c"}}
█ logEvent (telemetry disabled): CodyVSCodeExtension:keyDown:Paste:clicked {"properties":{"op":"paste","lineCount":1,"charCount":25,"source":"chat-question","request_id":"2c951818-f4fe-4105-9113-0c055d8b264c"}}

@abeatrix abeatrix changed the title telemetry: add request_id field for tracing code telemetry: add request_id field for code block actions Nov 1, 2023
Copy link
Member

@valerybugakov valerybugakov left a comment

Choose a reason for hiding this comment

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

Preventive approval with a couple of inline comments.
It would be great to add/update a couple of unit tests to test this change in a follow-up PR.

@@ -57,6 +57,7 @@ export interface MyPromptsJSON {

// The blueprint of a Cody Command
export interface CodyPrompt {
request_id?: string
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to use camel-case everywhere in the PR?

Suggested change
request_id?: string
requestID?: string

Comment on lines +88 to +89
// chat id is used to identify chat session
public sessionID = new Date(Date.now()).toUTCString()
Copy link
Member

Choose a reason for hiding this comment

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

Why date instead of uuid.v4() that we used in other similar places? By clicking twice on the new chat button, I can create two sessions with the same ID.

@abeatrix abeatrix merged commit 604a4bf into main Nov 2, 2023
14 checks passed
@abeatrix abeatrix deleted the bee/link-code-block branch November 2, 2023 17:00
@abeatrix abeatrix added the chat/commands Chat and Commands label Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat/commands Chat and Commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants