Skip to content

Adding event name in tracking payload overrides all other properties #4

@Sov3rain

Description

@Sov3rain

Hi there!

Using this package with Fastify server in Node@20. I'm building all the parameters for tracking my user like this:

const umami = new Umami();

umami.init({
  hostUrl: process.env.UMAMI_HOST,
  websiteId: ...,
  userAgent: req.userAgent.source,
});

const url = new URL(req.url, `${req.protocol}://${req.hostname}`);
const { hostname, pathname } = url;
const language = req.headers["accept-language"];
const { referrer } = req.headers;

umami.track({
  hostname,
  screen: "1920x1080",
  language,
  title: `/Home`,
  url: pathname,
  referrer,
});

This is working just fine, I'm getting all the information in my dashboard. Unfortunately when I add a custom event name, suddenly all the other information are missing, and I get only the event tracking:

umami.track({
  hostname,
  screen: "1920x1080",
  language,
  title: `/Home`,
  url: pathname,
  referrer,
+ name: "My event"
});

I worked around this issue by calling track() twice: once with the generic tracking information and once with my custom event only:

umami.track({
  hostname,
  screen: "1920x1080",
  language,
  title: `/Home`,
  url: pathname,
  referrer,
  name: "Button clicked"
});
umami.track("My event");

I should not be forced to do that, right?
Thanks!

NOTE: I'm importing the Umami class instead of the default import because it doesn't work, I can open another issue if you wish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions