Skip to content

Commit ef297ee

Browse files
authored
fix: generating a UUID for anonymousID initial value, refactor userId replacement (#440)
1 parent 0318a96 commit ef297ee

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/core/src/analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ export class SegmentClient {
491491

492492
this.store.userInfo.set({
493493
...userInfo,
494-
...(userId !== undefined ? { userId } : {}),
494+
userId: userId ?? userInfo.userId,
495495
traits: mergedTraits,
496496
});
497497

packages/core/src/storage/sovranStorage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
Context,
88
UserInfoState,
99
} from '..';
10+
import { getUUID } from '../uuid';
1011
import type { Storage } from './types';
1112

1213
type Data = {
@@ -24,7 +25,7 @@ const INITIAL_VALUES: Data = {
2425
context: {},
2526
settings: {},
2627
userInfo: {
27-
anonymousId: 'anonymousId',
28+
anonymousId: getUUID(),
2829
userId: undefined,
2930
traits: undefined,
3031
},

0 commit comments

Comments
 (0)