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

Publish the tracker as an npm package #2776

Open
Lehoczky opened this issue Jun 8, 2024 · 5 comments
Open

Publish the tracker as an npm package #2776

Lehoczky opened this issue Jun 8, 2024 · 5 comments

Comments

@Lehoczky
Copy link

Lehoczky commented Jun 8, 2024

Describe the feature or enhancement

Hi there 👋

Integrating umami with JS projects that use a bundler would be more convenient with a published library. Especially when using TypeScript, since the type declarations are lost from https://github.com/umami-software/umami/blob/master/src/tracker/index.d.ts when someone wants to use the tracker now.

Solution:

Publish the https://github.com/umami-software/umami/blob/master/src/tracker as an npm package called something like @umami/tracker with a small modification: have an init function that accepts a configuration object instead of using data-* attributes for configuration:

import {umami} from "@umami/tracker"

umami.init({
  website: "b59e9c65-ae32-47f1-8400-119fcf4861c4"
})

umami.track("event")
@mikecao
Copy link
Collaborator

mikecao commented Jun 8, 2024

@Lehoczky
Copy link
Author

Lehoczky commented Jun 9, 2024

Thank you! The name of the package is a bit misleading though, I would assume it only works in node, which is the server environment for JavaScript. For example nodemailer is using node in its name for this reason.

A better alternative would be @umami/js to know it works in browsers as well.

@Lehoczky
Copy link
Author

Upon some investigation, it look like https://github.com/umami-software/node is not identical to the tracker in this repository. I has different function signatures and does not support auto-inferring of the screen size, referer, etc.

@mikecao
Copy link
Collaborator

mikecao commented Jun 16, 2024

Because those things only exist on the client side. You would just use the tracker that comes with your installation in that case, since the functionality would be bound to whatever version you are running. It wouldn't make sense as a package.

@Lehoczky
Copy link
Author

A client side npm package would be great to have TypeScript support in our IDE, and to be able to initilaize the tracker without adding a <script> element to the HTML.

As an example Aptabase has a client side sdk as well: https://github.com/aptabase/aptabase-js/tree/main/packages/web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants