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

Create Interface for Plausible instance #50

Open
alejandrocoding opened this issue Nov 15, 2022 · 1 comment
Open

Create Interface for Plausible instance #50

alejandrocoding opened this issue Nov 15, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@alejandrocoding
Copy link

Detailed Description

When creating an instance of Plausible, Typescript infer the typing, but there is not an explicit interface to import to use in our TS apps.

Context

When using this library in a class, like in Angular Services, you might want to declare the class property, give it a type and in the constructor or in the init() method of your class, you might want to create the instance. Because there is no interface, you might be forced to declare the property as any, which will make your instance untyped.

Possible Implementation

Extracting the type into an interface or type will allow devs to have an explicit type for the instance to get benefit of the strict typed system.

https://github.com/plausible/plausible-tracker/blob/master/src/lib/tracker.ts#L212-L217

It should be really easy to do and will be a great benefit, imo.
I can help with a PR if this FR makes sense.

@alejandrocoding alejandrocoding added the enhancement New feature or request label Nov 15, 2022
@sandstrom
Copy link

Somewhat related, it would also make sense to make a clear distinction between the tracker client, and the wrapper.

plausible/analytics#2414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants