Skip to content

Commit 0e9c0cf

Browse files
committed
Identify chameleon with hashed user id
1 parent 619cb14 commit 0e9c0cf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { resolveModule } from '@codesandbox/common/lib/sandbox/modules';
2+
import { getHashedUserId } from '@codesandbox/common/lib/utils/analytics';
23
import {
34
EnvironmentVariable,
45
ModuleCorrection,
@@ -122,7 +123,7 @@ export const sandboxChanged: AsyncAction<{ id: string }> = withLoadApp<{
122123

123124
state.editor.isLoading = false;
124125

125-
effects.chameleon.loadTour(state.user && state.user.id);
126+
effects.chameleon.loadTour(state.user && getHashedUserId(state.user.id));
126127
});
127128

128129
export const contentMounted: Action = ({ state, effects }) => {

packages/common/src/utils/analytics.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,15 @@ if (process.env.NODE_ENV === 'production') {
159159
}, 5000);
160160
}
161161

162+
export function getHashedUserId(userId: string) {
163+
return hash(userId);
164+
}
165+
162166
export async function setUserId(userId: string) {
163167
try {
164168
if (!DNT) {
165169
if (typeof global.amplitude !== 'undefined') {
166-
const hashedId = hash(userId);
170+
const hashedId = getHashedUserId(userId);
167171
debug('[Amplitude] Setting User ID', hashedId);
168172
identify('userId', hashedId);
169173

0 commit comments

Comments
 (0)