Skip to content

feat(umami): send a configurable event data key as distinct ID - #170

Open
loeffert wants to merge 1 commit into
foomo:mainfrom
airtime-sw-ag:feature/umami-distinct-id
Open

loeffert wants to merge 1 commit into
foomo:mainfrom
airtime-sw-ag:feature/umami-distinct-id

Conversation

@loeffert

@loeffert loeffert commented Nov 6, 2026

Copy link
Copy Markdown
Member

Description

The Umami tag sends a configurable event data value as the Umami distinct ID (payload.id).

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactoring
  • 🏃‍➡️ Performance
  • ✅ Tests
  • 🔐 Security
  • 🔧 Build/CI

Related Issues

Follow-up of #165.

Changes

  • New setting umami.distinctIdParameter: the event data key whose value the tag sends as payload.id. Empty (default) keeps the current behavior.
  • tag.NewUmami adds the template parameter distinctIdParameter when the setting is set. The signature does not change.
  • The template gets an optional text field distinctIdParameter. The JS reads that key from the event data and sets payload.id only for a non-empty value.
  • sesamy.schema.json, sesamy.yaml and docs/providers/umami.md describe the setting.

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.

Notes

Why: Umami v3.4.0 adds the distinct ID to the session hash (uuid(website, ip, userAgent, salt, distinctId ?? '')). Server-side tracking sends the visitor IP since #165, but visitors behind one corporate IP with the same browser still share one Umami session. A first-party session ID as distinct ID separates them. It does not join sessions across IP addresses, user agents or salt rotations; the docs say so.

Compatibility:

  • Without the setting, the tag and the template behave as before.
  • Umami before v3.4.0 stores payload.id as the session's distinct ID but does not use it for the session hash.
  • Umami truncates the distinct ID to 50 characters.
  • read_event_data already allows any key, so the permissions do not change.
  • Sites with a custom tag template (templates.tag) keep their template; it ignores the new parameter.

How tested:

  • New unit test TestNewUmami_DistinctIDParameter (parameter present with the setting, absent without it). TestConfig regenerated sesamy.schema.json.
  • golangci-lint run: 0 issues. go test -tags=safe ./...: pass.
  • The template parameters still parse as JSON.
  • A local Node harness ran the sandboxed JS with mocked GTM APIs: setting session_id with a value gives payload.id; no setting gives no id; an empty value gives no id.

The new setting umami.distinctIdParameter names the event data key whose value the tag sends as payload.id. Umami v3.4.0 and later add the distinct ID to the session hash, so visitors behind one IP with the same user agent get separate sessions. Empty (default) keeps the current behavior.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 4.75%. Comparing base (cddb6e4) to head (9a7b0b8).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##            main    #170      +/-   ##
========================================
+ Coverage   4.62%   4.75%   +0.13%     
========================================
  Files        138     138              
  Lines       4302    4308       +6     
========================================
+ Hits         199     205       +6     
  Misses      4103    4103              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants