Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/fix-emails-posthog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"lingo.dev": patch
"@lingo.dev/_compiler": patch
"@lingo.dev/compiler": patch
---

fix: hash emails before sending as PostHog distinct_id
4 changes: 3 additions & 1 deletion packages/cli/src/cli/utils/observability.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pkg from "node-machine-id";
const { machineIdSync } = pkg;
import https from "https";
import crypto from "crypto";
import { getOrgId } from "./org-id";

const POSTHOG_API_KEY = "phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk";
Expand All @@ -17,8 +18,9 @@ function determineDistinctId(email: string | null | undefined): {
const orgId = getOrgId();

if (email) {
const hashedEmail = crypto.createHash("sha256").update(email).digest("hex");
return {
distinct_id: email,
distinct_id: hashedEmail,
distinct_id_source: "email",
org_id: orgId,
};
Expand Down
4 changes: 3 additions & 1 deletion packages/compiler/src/utils/observability.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as machineIdLib from "node-machine-id";
import crypto from "crypto";
import { getRc } from "./rc";
import { getOrgId } from "./org-id";

Expand Down Expand Up @@ -64,8 +65,9 @@ async function getDistinctId(): Promise<{
const email = await tryGetEmail();

if (email) {
const hashedEmail = crypto.createHash("sha256").update(email).digest("hex");
return {
distinct_id: email,
distinct_id: hashedEmail,
distinct_id_source: "email",
org_id: orgId,
};
Expand Down
4 changes: 3 additions & 1 deletion packages/new-compiler/src/utils/observability.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as machineIdLib from "node-machine-id";
import crypto from "crypto";
import { getRc } from "./rc";
import { getOrgId } from "./org-id";
import { TRACKING_VERSION, COMPILER_PACKAGE } from "./tracking-events";
Expand Down Expand Up @@ -64,8 +65,9 @@ async function getDistinctId(): Promise<{
const email = await tryGetEmail();

if (email) {
const hashedEmail = crypto.createHash("sha256").update(email).digest("hex");
return {
distinct_id: email,
distinct_id: hashedEmail,
distinct_id_source: "email",
org_id: orgId,
};
Expand Down
Loading