File tree Expand file tree Collapse file tree 4 files changed +16
-3
lines changed
Expand file tree Collapse file tree 4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " lingo.dev " : patch
3+ " @lingo.dev/_compiler " : patch
4+ " @lingo.dev/compiler " : patch
5+ ---
6+
7+ fix: hash emails before sending as PostHog distinct_id
Original file line number Diff line number Diff line change 11import pkg from "node-machine-id" ;
22const { machineIdSync } = pkg ;
33import https from "https" ;
4+ import crypto from "crypto" ;
45import { getOrgId } from "./org-id" ;
56
67const POSTHOG_API_KEY = "phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk" ;
@@ -17,8 +18,9 @@ function determineDistinctId(email: string | null | undefined): {
1718 const orgId = getOrgId ( ) ;
1819
1920 if ( email ) {
21+ const hashedEmail = crypto . createHash ( "sha256" ) . update ( email ) . digest ( "hex" ) ;
2022 return {
21- distinct_id : email ,
23+ distinct_id : hashedEmail ,
2224 distinct_id_source : "email" ,
2325 org_id : orgId ,
2426 } ;
Original file line number Diff line number Diff line change 11import * as machineIdLib from "node-machine-id" ;
2+ import crypto from "crypto" ;
23import { getRc } from "./rc" ;
34import { getOrgId } from "./org-id" ;
45
@@ -64,8 +65,9 @@ async function getDistinctId(): Promise<{
6465 const email = await tryGetEmail ( ) ;
6566
6667 if ( email ) {
68+ const hashedEmail = crypto . createHash ( "sha256" ) . update ( email ) . digest ( "hex" ) ;
6769 return {
68- distinct_id : email ,
70+ distinct_id : hashedEmail ,
6971 distinct_id_source : "email" ,
7072 org_id : orgId ,
7173 } ;
Original file line number Diff line number Diff line change 11import * as machineIdLib from "node-machine-id" ;
2+ import crypto from "crypto" ;
23import { getRc } from "./rc" ;
34import { getOrgId } from "./org-id" ;
45import { TRACKING_VERSION , COMPILER_PACKAGE } from "./tracking-events" ;
@@ -64,8 +65,9 @@ async function getDistinctId(): Promise<{
6465 const email = await tryGetEmail ( ) ;
6566
6667 if ( email ) {
68+ const hashedEmail = crypto . createHash ( "sha256" ) . update ( email ) . digest ( "hex" ) ;
6769 return {
68- distinct_id : email ,
70+ distinct_id : hashedEmail ,
6971 distinct_id_source : "email" ,
7072 org_id : orgId ,
7173 } ;
You can’t perform that action at this time.
0 commit comments