-
Notifications
You must be signed in to change notification settings - Fork 57
refactor: migrate identity module to TS #1248
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
base: development
Are you sure you want to change the base?
Changes from all commits
1cdacb3
8f4c21b
85a0f3c
d408003
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { IdentityApiData, MPID, UserIdentities } from '@mparticle/web-sdk'; | ||
| import { Context } from '@mparticle/event-models'; | ||
| import AudienceManager from './audienceManager'; | ||
| import { ICachedIdentityCall, IKnownIdentities } from './identity-utils'; | ||
| import { BaseVault } from './vault'; | ||
|
|
@@ -18,6 +19,7 @@ | |
| export type IdentityPreProcessResult = { | ||
| valid: boolean; | ||
| error?: string; | ||
| cleanedIdentities?: IdentityApiData; | ||
| }; | ||
|
|
||
| export type IdentityAPIMethod = valueof<typeof Constants.IdentityMethods>; | ||
|
|
@@ -49,14 +51,14 @@ | |
|
|
||
| export interface IIdentityAPIRequestData { | ||
| client_sdk: { | ||
| platform: typeof platform; | ||
| sdk_vendor: typeof sdkVendor; | ||
| sdk_version: typeof sdkVersion; | ||
| platform: string; | ||
| sdk_vendor: string; | ||
| sdk_version: string; | ||
| }; | ||
| context: string | null; | ||
| context: Context | null; | ||
| environment: Environment; | ||
| request_id: string; | ||
| request_timestamp_unixtime_ms: number; | ||
| request_timestamp_ms: number; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we renaming this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's really a typo fix on the interface. The SDK has always been sending request_timestamp_ms, the interface was just declaring the different key name |
||
| previous_mpid: MPID | null; | ||
| known_identities: IKnownIdentities; | ||
| } | ||
|
|
@@ -86,7 +88,7 @@ | |
| sdkVendor: string, | ||
| sdkVersion: string, | ||
| deviceId: string, | ||
| context: string | null, | ||
| context: Context | null, | ||
| mpid: MPID | ||
| ): IIdentityAPIRequestData; | ||
| createModifyIdentityRequest( | ||
|
|
@@ -95,17 +97,20 @@ | |
| platform: string, | ||
| sdkVendor: string, | ||
| sdkVersion: string, | ||
| context: string | null | ||
| context: Context | null | ||
| ): IIdentityAPIModifyRequestData; | ||
| createIdentityChanges( | ||
| previousIdentities: UserIdentities, | ||
| newIdentitie: UserIdentities | ||
| ): IIdentityAPIIdentityChangeData; | ||
| newIdentities: UserIdentities | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How long has this typo been here? 😓 |
||
| ): IIdentityAPIIdentityChangeData[]; | ||
| preProcessIdentityRequest( | ||
| identityApiData: IdentityApiData, | ||
| callback: IdentityCallback, | ||
| method: IdentityAPIMethod | ||
| ): IdentityPreProcessResult; | ||
| createAliasNetworkRequest(aliasRequest: IAliasRequest): object; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tied to the earlier comment. These three methods all return If you do above for Happy to defer to a follow-up if you want to keep this PR scoped, but please file a ticket so it does not slip.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, object is barely better than any, and object | void is genuinely confusing semantics. |
||
| convertAliasToNative(aliasRequest: IAliasRequest): object; | ||
| convertToNative(identityApiData: IdentityApiData): object | void; | ||
| } | ||
|
|
||
| export type AliasRequestScope = 'device' | 'mpid'; | ||
|
|
@@ -150,7 +155,7 @@ | |
| getUsers?(): IMParticleUser[]; | ||
| aliasUsers?( | ||
| aliasRequest?: IAliasRequest, | ||
| callback?: IdentityCallback | ||
| callback?: IAliasCallback | ||
| ): void; | ||
| createAliasRequest?( | ||
| sourceUser: IMParticleUser, | ||
|
|
@@ -211,12 +216,12 @@ | |
| IdentityAPI: SDKIdentityApi; | ||
| IdentityRequest: IIdentityRequest; | ||
|
|
||
| mParticleUser(mpid: MPID, IsLoggedIn: boolean): IMParticleUser; | ||
| mParticleUser(mpid?: MPID, IsLoggedIn?: boolean): IMParticleUser; | ||
|
|
||
| createUserAttributeChange( | ||
| key: string, | ||
| newValue: string, | ||
| previousUserAttributeValue: string, | ||
| newValue: string | string[] | null, | ||
|
Check warning on line 223 in src/identity.interfaces.ts
|
||
| previousUserAttributeValue: string | string[] | null, | ||
| isNewAttribute: boolean, | ||
| deleted: boolean, | ||
| user: IMParticleUser | ||
|
|
@@ -234,13 +239,13 @@ | |
| callback: IdentityCallback, | ||
| identityApiData: IdentityApiData, | ||
| method: IdentityAPIMethod, | ||
| knownIdentities: UserIdentities, | ||
| knownIdentities: IKnownIdentities, | ||
| parsingCachedResponse: boolean | ||
| ): void; | ||
| sendUserAttributeChangeEvent( | ||
| attributeKey: string, | ||
| newUserAttributeValue: string, | ||
| previousUserAttributeValue: string, | ||
| newUserAttributeValue: string | string[] | null, | ||
| previousUserAttributeValue: string | string[] | null, | ||
| isNewAttribute: boolean, | ||
| deleted: boolean, | ||
| user: IMParticleUser | ||
|
|
@@ -251,6 +256,14 @@ | |
| mpid: MPID, | ||
| prevUserIdentities: UserIdentities | ||
| ): void; | ||
| reinitForwardersOnUserChange( | ||
| prevUser: IMParticleUser, | ||
| newUser: IMParticleUser | ||
| ): void; | ||
| setForwarderCallbacks( | ||
| user: IMParticleUser, | ||
| method: IdentityAPIMethod | ||
| ): void; | ||
|
|
||
| /** | ||
| * @deprecated | ||
|
|
||
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.
Clean up the imports
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.
done