From 514e568741856a4df3576505a28e960c88eb2465 Mon Sep 17 00:00:00 2001 From: MoumitaM Date: Fri, 6 Sep 2024 15:19:15 +0530 Subject: [PATCH] refactor: refactor api type declarations --- index.d.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/index.d.ts b/index.d.ts index 59b0415..14c7bc6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -57,64 +57,56 @@ export interface constructorOptions { export type apiCallback = () => void; export type FlushCallback = (error?: Error, data?: any) => void; +type IdentityOptions = + | { userId: string; anonymousId?: string } + | { userId?: string; anonymousId: string }; + export type IdentifyParams = { - userId?: string; - anonymousId?: string; context?: apiObject; traits?: apiObject; integrations?: integrationOptions; timestamp?: Date; -}; +} & IdentityOptions; export type PageParams = { name: string; - userId?: string; - anonymousId?: string; context?: apiObject; properties?: apiObject; integrations?: integrationOptions; timestamp?: Date; -}; +} & IdentityOptions; export type TrackParams = { event: string; - userId?: string; - anonymousId?: string; context?: apiObject; properties?: apiObject; integrations?: integrationOptions; timestamp?: Date; -}; +} & IdentityOptions; export type GroupParams = { groupId: string; - userId?: string; - anonymousId?: string; context?: apiObject; traits?: apiObject; integrations?: integrationOptions; timestamp?: Date; -}; +} & IdentityOptions; export type ScreenParams = { name: string; - userId?: string; - anonymousId?: string; context?: apiObject; properties?: apiObject; integrations?: integrationOptions; timestamp?: Date; -}; +} & IdentityOptions; export type AliasParams = { previousId: string; - userId?: string; - anonymousId?: string; context?: apiObject; properties?: apiObject; integrations?: integrationOptions; timestamp?: Date; -}; +} & IdentityOptions; declare class Analytics { /**