Skip to content

Commit

Permalink
[ONL-8253] feat: Added typings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcibique committed Feb 9, 2024
1 parent f5f52b9 commit 4c4c4cb
Show file tree
Hide file tree
Showing 5 changed files with 711 additions and 383 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*.{js,jsx,ts,tsx,vue,css,scss}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.5.0] - 2024-02-09
### Changed
- Added typings


## [3.4.3] - 2023-06-16
### Changed
- Removed legacy analytics.js commands for Google Analytics
Expand Down
107 changes: 107 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
export enum HuhaTaskStatus {
IN_PROGRESS = 'In progress',
COMPLETED = 'Completed',
ABANDONED = 'Abandoned',
}

export interface HuhaOptions {
trackOnGoogleAnalytics?: boolean,
trackOnIntercom?: boolean,
trackOnSegment?: boolean,
}

export interface HuhaTaskProps {
name: string,
label?: string,
category?: string,
value?: string,
parentTask?: HuhaTask | null,
execId?: string,
persistent?: boolean,
}

export class HuhaTask implements HuhaOptions {
name: string;
label?: string;
category?: string;
value?: string;
status: HuhaTaskStatus;
effort: number;
errors: number;
start: number;
end?: number;
execId: string;
persistent: boolean;
parentExecId?: string;
parentTask?: HuhaTask | null;
trackOnGoogleAnalytics?: boolean;
trackOnIntercom?: boolean;
trackOnSegment?: boolean;

constructor(props: HuhaTaskProps, options: HuhaOptions);

addInteraction(): void;
addError(): void;
finish(status: HuhaTaskStatus): void;
complete(): void;
abandon(): void;
track(): void;

get time(): number;

sendToGoogleAnalytics(): void;
sendToIntercom(): void;
sendToSegment(): void;

updateFromLocalStorage(): void;
removeFromLocalStorage(): void;
}

export interface HuhaEventProps {
name: string,
object?: string,
action?: string,
category?: string,
value?: string,
task?: string | HuhaTask | null,
eventGroup?: string,
}

export class HuhaEvent implements HuhaOptions {
name: string;
object?: string;
action?: string;
category?: string;
value?: string;
task?: string | HuhaTask | null;
eventGroup?: string;
trackOnGoogleAnalytics?: boolean;
trackOnIntercom?: boolean;
trackOnSegment?: boolean;

constructor(props: HuhaEventProps, options: HuhaOptions);

track(): void;
sendToGoogleAnalytics(): void;
sendToSegment(): void;
}

export class Huha implements HuhaOptions {
tasks: HuhaTask[];
events: HuhaEvent[];

trackOnGoogleAnalytics?: boolean;
trackOnIntercom?: boolean;
trackOnSegment?: boolean;

constructor(options: HuhaOptions);

createTask(properties: HuhaTaskProps): HuhaTask;
createEvent(properties: HuhaEventProps): HuhaEvent;
getTask(name: string): HuhaTask | null;

setUpEvents(): void;
registerEvent(capturedEvent: string, element: Element): void;

abandonInProgressTasks(): void;
}
Loading

0 comments on commit 4c4c4cb

Please sign in to comment.