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

Allow API to set browser, os, device, country, etc. #3120

Open
blanchardjeremy opened this issue Dec 18, 2024 · 3 comments
Open

Allow API to set browser, os, device, country, etc. #3120

blanchardjeremy opened this issue Dec 18, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@blanchardjeremy
Copy link

blanchardjeremy commented Dec 18, 2024

Describe the feature or enhancement

Currently, the following items are set only when a JS request is made from a user's machine to the Umami's servers.

See code here: https://github.com/umami-software/umami/blob/bce70c1034c6668255261c26093a35900b869566/src/lib/session.ts#L39C3-L40C30

const { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device } =
    await getClientInfo(req);

Many data points can be set via the API directly by POSTing an event: hostname, language, referrer, screen, title, url, website, name, data

Proposed Change

The following items should be something we can set through the API:

  • userAgent
  • browser
  • os
  • ip
  • country
  • device

The appropriate values would need to be documented.

Reason

My use case is that I want to only send server side requests to log page views. This gives me complete control over what data my users expose. And also allows me to make sure their IP address never hits any server other than mine.

As a privacy-focused solution, I think these are in line with your values!

Thanks!

@blanchardjeremy
Copy link
Author

Okay while investigating this, I realized there is a workaround.

The API requires you to post a user-agent header. So that allows you to specify browser, device, and operating system. (screen payload value also factors into device as well)

So I'm adjusting my request to be: Please document this behavior more clearly rather than just saying that user agent is required. If I'm sending a server side request, I thought I just needed to fake a user agent. I didn't realize it was meant to be part of the data you're receiving.

There's also still no way to manually set the IP address, but that doesn't actually matter to me (it's the whole reason why I'm doing this server side!)

@mikecao
Copy link
Collaborator

mikecao commented Dec 26, 2024

It's undocumented but you can send ip with the payload and it will accept it. As for the other properties, I think it makes sense to allow you to override the defaults. I don't think you should have to fake a user agent.

@mikecao mikecao added the enhancement New feature or request label Dec 26, 2024
@blanchardjeremy
Copy link
Author

Thanks for the reply @mikecao!

Regarding user agent: Well since i was doing a server side request, faking a user request seemed necessary. The API seems to be built to assume its always a client side request. The docs are pretty clear about a user agent being required. It just took me a few extra beats to understand why: its assuming that all calls come from the client.

Would love to see the IP param documented while we're at it. :)

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