Skip to content
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

refactor: refactor api type declarations #150

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 65 additions & 71 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,65 @@ export interface constructorOptions {
export type apiCallback = () => void;
export type FlushCallback = (error?: Error, data?: any) => void;

export type IdentifyParams = {
userId?: string;
anonymousId?: string;
saikumarrs marked this conversation as resolved.
Show resolved Hide resolved
context?: apiObject;
traits?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
};

export type PageParams = {
name: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
};

export type TrackParams = {
event: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
};

export type GroupParams = {
groupId: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
traits?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
};

export type ScreenParams = {
name: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
};

export type AliasParams = {
previousId: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
};

declare class Analytics {
/**
* Initialize a new `Analytics` with your RudderStack project's `writeKey` and an
Expand Down Expand Up @@ -145,17 +204,7 @@ declare class Analytics {
* @param {Function=} callback (optional)
* @return {Analytics}
*/
identify(
message: {
userId?: string;
anonymousId?: string;
context?: apiObject;
traits?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback,
): Analytics;
identify(message: IdentifyParams, callback?: apiCallback): Analytics;
/**
* Send a group `message`.
*
Expand All @@ -170,18 +219,7 @@ declare class Analytics {
* @param {Function=} callback (optional)
* @return {Analytics}
*/
group(
message: {
groupId: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
traits?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback,
): Analytics;
group(message: GroupParams, callback?: apiCallback): Analytics;
/**
* Send a track `message`.
*
Expand All @@ -196,18 +234,7 @@ declare class Analytics {
* @param {Function=} callback (optional)
* @return {Analytics}
*/
track(
message: {
event: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback,
): Analytics;
track(message: TrackParams, callback?: apiCallback): Analytics;

/**
* Send a page `message`.
Expand All @@ -223,18 +250,7 @@ declare class Analytics {
* @param {Function=} callback (optional)
* @return {Analytics}
*/
page(
message: {
name: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback,
): Analytics;
page(message: PageParams, callback?: apiCallback): Analytics;

/**
* Send a screen `message`.
Expand All @@ -250,18 +266,7 @@ declare class Analytics {
* @param {Function=} callback (optional)
* @return {Analytics}
*/
screen(
message: {
name: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback,
): Analytics;
screen(message: ScreenParams, callback?: apiCallback): Analytics;

/**
* Send an alias `message`.
Expand All @@ -277,18 +282,7 @@ declare class Analytics {
* @param {Function=} callback (optional)
* @return {Analytics}
*/
alias(
message: {
previousId: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback,
): Analytics;
alias(message: AliasParams, callback?: apiCallback): Analytics;

/**
* Flush the current queue
Expand Down
Loading
Loading