Skip to content

Commit a249035

Browse files
committed
fix: rename organizationSlug to organizationId in telemetry and related files
1 parent 34519b0 commit a249035

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

cli/src/core/telemetry.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import crypto from 'node:crypto';
22
import os from 'node:os';
33
import { PostHog } from 'posthog-node';
44
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
5-
import { config, getBaseHeaders, getLoginDetails } from './config.js';
5+
import { config, getBaseHeaders } from './config.js';
66
import { CreateClient } from './client/client.js';
77

88
// Environment variables to allow opting out of telemetry
@@ -32,7 +32,7 @@ type PostHogFetchResponse = {
3232

3333
type TelemetryIdentity = {
3434
userEmail?: string;
35-
organizationSlug: string;
35+
organizationId: string;
3636
};
3737

3838
const buildPostHogOkResponse = () => ({
@@ -125,7 +125,7 @@ const getIdentity = async (): Promise<TelemetryIdentity> => {
125125
try {
126126
if (!apiClient) {
127127
return {
128-
organizationSlug: 'anonymous',
128+
organizationId: 'anonymous',
129129
};
130130
}
131131

@@ -138,7 +138,7 @@ const getIdentity = async (): Promise<TelemetryIdentity> => {
138138

139139
if (resp.response?.code === EnumStatusCode.OK) {
140140
return {
141-
organizationSlug: resp.organizationSlug,
141+
organizationId: resp.organizationId || 'anonymous',
142142
userEmail: resp.userEmail || undefined,
143143
};
144144
}
@@ -149,7 +149,7 @@ const getIdentity = async (): Promise<TelemetryIdentity> => {
149149
}
150150
}
151151
return {
152-
organizationSlug: 'anonymous',
152+
organizationId: 'anonymous',
153153
};
154154
};
155155

@@ -166,9 +166,9 @@ export const capture = async (eventName: string, properties: Record<string, any>
166166
const metadata = getMetadata();
167167

168168
client.capture({
169-
distinctId: identity.userEmail ?? identity.organizationSlug,
169+
distinctId: identity.userEmail ?? identity.organizationId,
170170
groups: {
171-
orgslug: identity.organizationSlug,
171+
cosmo_organization: identity.organizationId ?? '',
172172
},
173173
event: eventName,
174174
properties: {

connect/src/wg/cosmo/platform/v1/platform_pb.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9273,6 +9273,11 @@ export class WhoAmIResponse extends Message<WhoAmIResponse> {
92739273
*/
92749274
organizationSlug = "";
92759275

9276+
/**
9277+
* @generated from field: string organizationId = 5;
9278+
*/
9279+
organizationId = "";
9280+
92769281
constructor(data?: PartialMessage<WhoAmIResponse>) {
92779282
super();
92789283
proto3.util.initPartial(data, this);
@@ -9285,6 +9290,7 @@ export class WhoAmIResponse extends Message<WhoAmIResponse> {
92859290
{ no: 2, name: "organizationName", kind: "scalar", T: 9 /* ScalarType.STRING */ },
92869291
{ no: 3, name: "userEmail", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
92879292
{ no: 4, name: "organizationSlug", kind: "scalar", T: 9 /* ScalarType.STRING */ },
9293+
{ no: 5, name: "organizationId", kind: "scalar", T: 9 /* ScalarType.STRING */ },
92889294
]);
92899295

92909296
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): WhoAmIResponse {

controlplane/src/core/bufservices/organization/whoAmI.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ export function whoAmI(
2929
},
3030
organizationName: '',
3131
organizationSlug: '',
32+
organizationId: '',
3233
};
3334
}
3435

3536
return {
3637
response: {
3738
code: EnumStatusCode.OK,
3839
},
40+
organizationId: organization.id,
3941
organizationName: organization.name,
4042
organizationSlug: organization.slug,
4143
};

proto/wg/cosmo/platform/v1/platform.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,7 @@ message WhoAmIResponse {
12351235
string organizationName = 2;
12361236
optional string userEmail = 3;
12371237
string organizationSlug = 4;
1238+
string organizationId = 5;
12381239
}
12391240

12401241
message RouterToken {

studio/src/lib/track.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,19 @@ const identify = ({
6464
id: organizationId,
6565
slug: organizationSlug,
6666
name: organizationName,
67-
plan: plan
67+
plan: plan,
6868
});
6969
return;
7070
}
71-
71+
7272
posthog.identify(email, {
7373
id,
74-
email,
7574
});
7675
posthog.group('cosmo_organization', organizationId, {
7776
id: organizationId,
7877
slug: organizationSlug,
7978
name: organizationName,
80-
plan: plan
79+
plan: plan,
8180
});
8281
};
8382

0 commit comments

Comments
 (0)