Skip to content

Commit

Permalink
fix: fix UserTraits type in analytics
Browse files Browse the repository at this point in the history
This fixes the `UserTraits` type in analytics to allow the user to
specify properties that lives in either one of the types that
compose the union. For example, `countryCode` only exists in `User`
type but I cannot create a new variable typed `UserTraits` that
contains the `countryCode` property with the current type. This change
will allow that
  • Loading branch information
danielbento92 authored and boliveira committed May 23, 2023
1 parent ae91f5d commit aae0757
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/analytics/src/types/analytics.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export type ExtendedTrackTypes =
| typeof ON_SET_USER_TRACK_TYPE
| typeof LOAD_INTEGRATION_TRACK_TYPE;

export type UserTraits = Omit<User | UserLegacy, 'id'>;
export type UserTraits = Omit<User, 'id'> | Omit<UserLegacy, 'id'>;

export type UserData = {
id: number | null | undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/src/utils/hashUserData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const hashUserData = (userData: UserData): UserData => {
name: hashPlainTextString(traits.name) as string,
phoneNumber: hashPlainTextString(traits.phoneNumber),
username: hashPlainTextString(traits.username) as string,
},
} as UserTraits,
};
}

Expand Down

0 comments on commit aae0757

Please sign in to comment.