Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
chore(cli): drop explanatory comments in dispatch.ts
Strip the review-round comments per feedback; rationale for the non-obvious ones lives in the fix commits (c22c7b32 post-alias fallback, b9740b8c credential ordering). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Kshitij Jhunjhunwala committed
Jul 24, 2026 at 10:57 UTC
f051e7701c19dbcf399fca0ad7784829b852c733
1 file changed
-21
ts/packages/cli/src/analytics/dispatch.ts
-21
@@ -172,12 +172,7 @@ const readOptionalJson = <A>(filePath: string) =>
172
type AnalyticsState = {
173
readonly install_id?: string;
174
readonly apollo_user_id?: string;
175
- // Tracked separately from apollo_user_id so an alias that was never enqueued
176
- // (no project key, telemetry off) is retried instead of blocked forever.
175
readonly aliased_apollo_user_id?: string;
178
- // Fingerprint of the credential that apollo_user_id was resolved from. The id
179
- // is only trusted while the active credential still matches, so an env-var key
180
- // override can never attribute one user's events to another.
176
readonly api_key_fingerprint?: string;
177
readonly created_at?: string;
178
};
@@ -279,10 +274,6 @@ const getDistinctId = (installId: string) =>
274
return apolloUserId;
275
}
276
282
- // Once the install has been aliased, PostHog has permanently merged the bare
283
- // install_id into that Apollo person — reusing it here would attribute these
284
- // events to the previous user rather than to nobody. Fall back to an id that
285
- // was never merged: pseudonymous per credential, or per device when signed out.
277
if (typeof state?.aliased_apollo_user_id !== 'string') {
278
return installId;
279
}
@@ -589,7 +580,6 @@ export const emitPostHogAlias = (installId: string, apolloUserId: string) =>
580
const envelope: AnalyticsEnvelope = {
581
event: POSTHOG_ALIAS_EVENT,
582
properties: {
592
- // PostHog merges `alias` into `distinct_id`.
583
distinct_id: apolloUserId,
584
alias: installId,
585
cli_version: constants.APP_VERSION,
@@ -602,11 +592,6 @@ export const emitPostHogAlias = (installId: string, apolloUserId: string) =>
592
return yield* enqueuePostHogEnvelope(envelope);
593
}).pipe(Effect.catchAllCause(() => Effect.succeed(false)));
594
605
-/**
606
- * Records the Apollo `org_member.id` as the analytics identity and stitches the
607
- * anonymous install into it. Safe to call from any command that already resolved
608
- * a session, which is how already-authenticated installs get backfilled.
609
- */
595
export const linkApolloIdentityForAnalytics = (apolloUserId: string, apiKey?: string) =>
596
Effect.gen(function* () {
597
const resolved = typeof apolloUserId === 'string' ? apolloUserId.trim() : '';
@@ -622,9 +607,6 @@ export const linkApolloIdentityForAnalytics = (apolloUserId: string, apiKey?: st
607
608
const state = yield* readAnalyticsState;
609
const installId = yield* getOrCreateInstallId;
625
- // Callers pass the credential they just validated: login resolves identity
626
- // before persisting it, so reading it back here would fingerprint the
627
- // previous key and never match.
610
const fingerprint =
611
typeof apiKey === 'string' && apiKey.length > 0
612
? fingerprintApiKey(apiKey)
@@ -636,8 +618,6 @@ export const linkApolloIdentityForAnalytics = (apolloUserId: string, apiKey?: st
618
});
619
}
620
639
- // PostHog refuses to merge an install that is already identified, so alias
640
- // an install at most once — a second user on this device stays unaliased.
621
if (typeof state?.aliased_apollo_user_id === 'string') {
622
return;
623
}
@@ -646,7 +626,6 @@ export const linkApolloIdentityForAnalytics = (apolloUserId: string, apiKey?: st
626
}
627
}).pipe(Effect.catchAllCause(() => Effect.void));
628
649
-/** Drops the Apollo identity on logout so later events revert to `install_id`. */
629
export const clearApolloIdentityForAnalytics = Effect.gen(function* () {
630
const state = yield* readAnalyticsState;
631
if (!state?.install_id || !state.apollo_user_id) {