Skip to content

Commit

Permalink
add ability to pass user distinct id
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroHryshyn committed Apr 15, 2024
1 parent 04bdf03 commit 6f409e7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/cli/src/executeMainThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { parseFlowSettings } from "./schemata/flowSettingsSchema.js";
import { parseRunSettings } from "./schemata/runArgvSettingsSchema.js";
import { TarService } from "./services/tarService.js";
import type { TelemetryEvent } from "./telemetry";
import { getCurrentUserData } from "./utils";

export const executeMainThread = async () => {
const slicedArgv = hideBin(process.argv);
Expand Down Expand Up @@ -136,6 +137,16 @@ export const executeMainThread = async () => {
? new NullSender()
: new PostHogSender({
cloudRole: "CLI",
getUserDistinctId: async () => {
const userData = await getCurrentUserData();

if (!userData) {
// @TODO create anonymous session
return "AnonymousUser";
}

return userData.user.userId;
},
});

let exit: () => void = () => {
Expand Down

0 comments on commit 6f409e7

Please sign in to comment.