Skip to content

Commit 1f7a544

Browse files
authored
🤖 feat: include workspaceId in message_sent telemetry payload (#938)
_Generated with `mux`_ Adds the workspace ID (already random/anonymous) to the `message_sent` telemetry event for per-workspace analytics. The workspace ID is randomly generated (e.g., UUID format) and contains no user information, so it's safe to include per the existing privacy guidelines in `payload.ts`.
1 parent 99759d1 commit 1f7a544

File tree

5 files changed

+9
-2
lines changed

5 files changed

+9
-2
lines changed

src/browser/components/ChatInput/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
10181018
} else {
10191019
// Track telemetry for successful message send
10201020
telemetry.messageSent(
1021+
props.workspaceId,
10211022
sendMessageOptions.model,
10221023
mode,
10231024
actualMessageText.length,

src/browser/hooks/useTelemetry.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import type {
2929
*
3030
* telemetry.workspaceSwitched(fromId, toId);
3131
* telemetry.workspaceCreated(workspaceId, runtimeType);
32-
* telemetry.messageSent(model, mode, messageLength, runtimeType, thinkingLevel);
32+
* telemetry.messageSent(workspaceId, model, mode, messageLength, runtimeType, thinkingLevel);
3333
* telemetry.streamCompleted(model, wasInterrupted, durationSecs, outputTokens);
3434
* telemetry.providerConfigured(provider, keyType);
3535
* telemetry.commandUsed(commandType);
@@ -48,13 +48,14 @@ export function useTelemetry() {
4848

4949
const messageSent = useCallback(
5050
(
51+
workspaceId: string,
5152
model: string,
5253
mode: string,
5354
messageLength: number,
5455
runtimeType: TelemetryRuntimeType,
5556
thinkingLevel: TelemetryThinkingLevel
5657
) => {
57-
trackMessageSent(model, mode, messageLength, runtimeType, thinkingLevel);
58+
trackMessageSent(workspaceId, model, mode, messageLength, runtimeType, thinkingLevel);
5859
},
5960
[]
6061
);

src/common/orpc/schemas/telemetry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const WorkspaceSwitchedPropertiesSchema = z.object({
6161
});
6262

6363
const MessageSentPropertiesSchema = z.object({
64+
workspaceId: z.string(),
6465
model: z.string(),
6566
mode: z.string(),
6667
message_length_b2: z.number(),

src/common/telemetry/payload.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ export type TelemetryThinkingLevel = "off" | "low" | "medium" | "high";
9292
* Chat/AI interaction events
9393
*/
9494
export interface MessageSentPayload {
95+
/** Workspace ID (randomly generated, safe to send) */
96+
workspaceId: string;
9597
/** Full model identifier (e.g., 'anthropic/claude-3-5-sonnet-20241022') */
9698
model: string;
9799
/** UI mode (e.g., 'plan', 'exec', 'edit') */

src/common/telemetry/tracking.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export function trackWorkspaceSwitched(fromWorkspaceId: string, toWorkspaceId: s
6565
* @param messageLength - Raw character count (will be rounded to base-2)
6666
*/
6767
export function trackMessageSent(
68+
workspaceId: string,
6869
model: string,
6970
mode: string,
7071
messageLength: number,
@@ -74,6 +75,7 @@ export function trackMessageSent(
7475
trackEvent({
7576
event: "message_sent",
7677
properties: {
78+
workspaceId,
7779
model,
7880
mode,
7981
message_length_b2: roundToBase2(messageLength),

0 commit comments

Comments
 (0)