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

[ONL-8253] Added typings #73

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
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,
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might have an error with the value type in a couple of files in EBO, it's mostly string, but we do have numbers in confirmation.vue.

I have asked the data team about these and they told me that for the quote rate (for which we are sending a number) they only check if the value exists, they don't do any calculations with them, so we could just convert them to strings, or we could add number to value type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I have enabled numbers as value as well.

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 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
Loading