-
Notifications
You must be signed in to change notification settings - Fork 73
chore(logging): move device_id into Segment identity traits MONGOSH-2234 #2450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
this.currentUserId = message.userId ?? message.anonymousId; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
this.currentUserId = message.userId ?? message.anonymousId!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately because of the more derivative type I think TypeScript can no longer correctly resolve this scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM, is there a ticket that should be attached to this?
163850a
to
66e1d89
Compare
export type MongoshAnalyticsIdentity = Omit< | ||
SegmentIdentity, | ||
'context' | 'traits' | 'timestamp' | ||
>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[2025/06/02 10:17:26.877] src/cli-repl.ts(646,11): error TS2322: Type 'Analytics | undefined' is not assignable to type 'MongoshAnalytics | undefined'.
[2025/06/02 10:17:26.877] Type 'Analytics' is not assignable to type 'MongoshAnalytics'.
[2025/06/02 10:17:26.877] Types of property 'identify' are incompatible.
[2025/06/02 10:17:26.877] Type '({ userId, anonymousId, traits, context, timestamp, integrations, }: IdentifyParams, callback?: Callback | undefined) => void' is not assignable to type '(message: AnalyticsIdentifyMessage) => void'.
[2025/06/02 10:17:26.877] Types of parameters '__0' and 'message' are incompatible.
[2025/06/02 10:17:26.877] Type 'AnalyticsIdentifyMessage' is not assignable to type 'IdentifyParams'.
[2025/06/02 10:17:26.877] Type 'AnalyticsIdentifyMessage' is not assignable to type '{ traits?: UserTraits | undefined; context?: ExtraContext | undefined; timestamp?: Timestamp | undefined; integrations?: Integrations | undefined; } & { ...; }'.
[2025/06/02 10:17:26.877] Type 'AnalyticsIdentifyMessage' is not assignable to type '{ userId?: string | undefined; anonymousId: string; }'.
[2025/06/02 10:17:26.877] Types of property 'anonymousId' are incompatible.
[2025/06/02 10:17:26.877] Type 'string | undefined' is not assignable to type 'string'.
[2025/06/02 10:17:26.877] Type 'undefined' is not assignable to type 'string'.
ae019cb
to
de74a6f
Compare
6a195a3
to
3788ddd
Compare
Our track function was misleadingly typed with regards to Segment SDK.
For device_id to actually be used by Segment we'd need it to be in
traits.device_id
in the identify function.This ties our types closer to the Segment SDK and moves the device ID to traits instead.