Skip to content

Commit

Permalink
[ONL-8253] Added typings (#73)
Browse files Browse the repository at this point in the history
* [ONL-8253] feat: Added typings.

* [ONL-8253] chore: Stop building node v16.

* [ONL-8253] chore: Fixed default export.

* 3.5.0

* [ONL-8253] pr: Addressed comments.
  • Loading branch information
mcibique authored Feb 12, 2024
1 parent f5f52b9 commit 43c2f07
Show file tree
Hide file tree
Showing 6 changed files with 715 additions and 387 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- name: Checkout
Expand Down
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 | number,
parentTask?: HuhaTask | null,
execId?: string,
persistent?: boolean,
}

export class HuhaTask implements HuhaOptions {
name: string;
label?: string;
category?: string;
value?: string | number;
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 | number,
task?: string | HuhaTask | null,
eventGroup?: string,
}

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

constructor(props: HuhaEventProps, options: HuhaOptions);

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

export default 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 43c2f07

Please sign in to comment.