[PR #21862] [CLOSED] feat: add Umami analytics integration #26310

Closed
opened 2026-04-20 06:26:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21862
Author: @TeenBiscuits
Created: 2/25/2026
Status: Closed

Base: devHead: main


📝 Commits (10+)

📊 Changes

13 files changed (+320 additions, -15 deletions)

View changed files

📝 .env.example (+7 -1)
📝 backend/open_webui/env.py (+12 -7)
📝 backend/open_webui/main.py (+16 -1)
📝 src/app.d.ts (+10 -0)
📝 src/lib/components/chat/Chat.svelte (+33 -0)
📝 src/lib/components/chat/MessageInput.svelte (+28 -0)
📝 src/lib/components/chat/ModelSelector/Selector.svelte (+19 -1)
📝 src/lib/components/chat/ShareChatModal.svelte (+6 -0)
📝 src/lib/components/layout/Navbar/Menu.svelte (+25 -0)
📝 src/lib/components/layout/Sidebar/UserMenu.svelte (+7 -0)
src/lib/utils/umami.ts (+45 -0)
📝 src/routes/+layout.svelte (+75 -0)
📝 src/routes/auth/+page.svelte (+37 -5)

📄 Description

Pull Request Checklist

This pull request addresses the feature request in the discussion on post #10203.

  • Target branch: Verify that the pull request targets the dev branch. PRs targeting main will be immediately closed.

  • Description: Provide a concise description of the changes made in this pull request down below.

  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.

  • Documentation: Add docs in Open WebUI Docs Repository. Document user-facing behavior, environment variables, public APIs/interfaces, or deployment steps.

    • Not yet submitted in docs repo.
  • Dependencies: Are there any new or upgraded dependencies? If so, explain why, update the changelog/docs, and include any compatibility notes. Actually run the code/function that uses updated library to ensure it doesn't crash.

    • No new/upgraded project dependencies were introduced by this feature.
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Include reproducible steps to demonstrate the issue before the fix. Test edge cases (URL encoding, HTML entities, types). Take this as an opportunity to make screenshots of the feature/fix and include them in the PR description.

    • Manual runtime verification completed in Docker demo container with Umami env vars.
  • Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.

  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?

  • Design & Architecture: Prefer smart defaults over adding new settings; use local state for ephemeral UI logic. Open a Discussion for major architectural or UX changes.

    • Implemented with minimal, opt-in env-based defaults and no major architectural churn.
  • Git Hygiene: Keep PRs atomic (one logical change). Clean up commits and rebase on dev to ensure no unrelated commits (e.g. from main) are included. Push updates to the existing PR branch instead of closing and reopening.

  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:

    • Recommended title: feat: add Umami analytics integration with env-gated script and P1 event tracking

Description

This PR adds Umami analytics integration to Open WebUI with runtime backend configuration and frontend script injection controlled by environment variables. Tracking is enabled only when UMAMI_WEBSITE_ID is set; UMAMI_DOMAIN defaults to https://cloud.umami.is when not provided. If UMAMI_WEBSITE_ID is missing/empty, Umami is not loaded.

The implementation includes:

  • Backend config exposure (/api/config) for Umami runtime values.
  • Frontend dynamic script injection in app layout.
  • Distinct user identification via umami.identify(user.id).
  • P1 product events for authentication and core chat usage.
  • Standardized payload keys across P1 events: flow, surface, trigger.

Testing

Before fix

  • No Umami script integration existed.
  • No runtime env-gated analytics loading.
  • No distinct ID/user-level Umami identification and no P1 event emission.

After fix (manual)

  1. Build and run container.
  2. Set Umami env vars.
  3. Open app at http://localhost:3000.
  4. Verify script is injected only when website ID is set.
  5. Verify login/session binds distinct id (user.id) and P1 events emit for auth/chat actions.

Commands used

docker build -t open-webui-umami-demo .
docker run -d --name open-webui-umami-demo-container -p 3000:8080 \
  -e UMAMI_WEBSITE_ID=xxx \
  -e UMAMI_DOMAIN=https://analytics.example.com \
  open-webui-umami-demo
curl -I http://localhost:3000

Changelog Entry

Description

  • Added Umami analytics integration with runtime config and env-based enablement.
  • Implemented distinct user identification with user.id.
  • Added standardized analytics events for auth and core chat actions.

Added

  • New env vars:
    • UMAMI_WEBSITE_ID (required to enable Umami)
    • UMAMI_DOMAIN (optional, defaults to https://cloud.umami.is)
  • Frontend helper utilities for Umami track/identify.
  • Runtime analytics config block in backend /api/config.

Changed

  • App layout now conditionally injects Umami script at runtime.
  • nalytics events now include standardized payload metadata:
    • flow
    • surface
    • trigger

Deprecated

  • None.

Removed

  • None.

Fixed

  • Enabled proper opt-in analytics behavior: script remains disabled when UMAMI_WEBSITE_ID is not configured.
  • Added user-level distinct tracking linkage through user.id.

Security

  • Analytics remains opt-in and environment-controlled.
  • Distinct ID uses internal user ID (not email), reducing PII exposure.

Breaking Changes

  • BREAKING CHANGE: None.

Additional Information

  • Related request: discussion post #10203.
  • Scope intentionally limited to user events only (auth + core chat), no workspace/admin.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21862 **Author:** [@TeenBiscuits](https://github.com/TeenBiscuits) **Created:** 2/25/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `main` --- ### 📝 Commits (10+) - [`fe6783c`](https://github.com/open-webui/open-webui/commit/fe6783c16699911c7be17392596d579333fb110c) Merge pull request #19030 from open-webui/dev - [`fc05e0a`](https://github.com/open-webui/open-webui/commit/fc05e0a6c5d39da60b603b4d520f800d6e36f748) Merge pull request #19405 from open-webui/dev - [`e3faec6`](https://github.com/open-webui/open-webui/commit/e3faec62c58e3a83d89aa3df539feacefa125e0c) Merge pull request #19416 from open-webui/dev - [`9899293`](https://github.com/open-webui/open-webui/commit/9899293f050ad50ae12024cbebee7e018acd851e) Merge pull request #19448 from open-webui/dev - [`140605e`](https://github.com/open-webui/open-webui/commit/140605e660b8186a7d5c79fb3be6ffb147a2f498) Merge pull request #19462 from open-webui/dev - [`6f1486f`](https://github.com/open-webui/open-webui/commit/6f1486ffd0cb288d0e21f41845361924e0d742b3) Merge pull request #19466 from open-webui/dev - [`d95f533`](https://github.com/open-webui/open-webui/commit/d95f533214e3fe5beb5e41ec1f349940bc4c7043) Merge pull request #19729 from open-webui/dev - [`a727153`](https://github.com/open-webui/open-webui/commit/a7271532f8a38da46785afcaa7e65f9a45e7d753) 0.6.43 (#20093) - [`6adde20`](https://github.com/open-webui/open-webui/commit/6adde203cd292a9e3af9c64a2ae36b603fed096a) Merge pull request #20394 from open-webui/dev - [`f9b0534`](https://github.com/open-webui/open-webui/commit/f9b0534e0c442631d1cb7205169588b9b6204179) Merge pull request #20522 from open-webui/dev ### 📊 Changes **13 files changed** (+320 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+7 -1) 📝 `backend/open_webui/env.py` (+12 -7) 📝 `backend/open_webui/main.py` (+16 -1) 📝 `src/app.d.ts` (+10 -0) 📝 `src/lib/components/chat/Chat.svelte` (+33 -0) 📝 `src/lib/components/chat/MessageInput.svelte` (+28 -0) 📝 `src/lib/components/chat/ModelSelector/Selector.svelte` (+19 -1) 📝 `src/lib/components/chat/ShareChatModal.svelte` (+6 -0) 📝 `src/lib/components/layout/Navbar/Menu.svelte` (+25 -0) 📝 `src/lib/components/layout/Sidebar/UserMenu.svelte` (+7 -0) ➕ `src/lib/utils/umami.ts` (+45 -0) 📝 `src/routes/+layout.svelte` (+75 -0) 📝 `src/routes/auth/+page.svelte` (+37 -5) </details> ### 📄 Description # Pull Request Checklist This pull request addresses the feature request in the discussion on post #10203. - [x] **Target branch:** Verify that the pull request targets the `dev` branch. **PRs targeting `main` will be immediately closed.** - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Add docs in [Open WebUI Docs Repository](https://github.com/open-webui/docs). Document user-facing behavior, environment variables, public APIs/interfaces, or deployment steps. - _Not yet submitted in docs repo._ - [ ] **Dependencies:** Are there any new or upgraded dependencies? If so, explain why, update the changelog/docs, and include any compatibility notes. Actually run the code/function that uses updated library to ensure it doesn't crash. - _No new/upgraded project dependencies were introduced by this feature._ - [x] **Testing:** Perform manual tests to **verify the implemented fix/feature works as intended AND does not break any other functionality**. Include reproducible steps to demonstrate the issue before the fix. Test edge cases (URL encoding, HTML entities, types). Take this as an opportunity to **make screenshots of the feature/fix and include them in the PR description**. - _Manual runtime verification completed in Docker demo container with Umami env vars._ - [x] **Agentic AI Code:** Confirm this Pull Request is **not written by any AI Agent** or has at least **gone through additional human review AND manual testing**. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Design & Architecture:** Prefer smart defaults over adding new settings; use local state for ephemeral UI logic. Open a Discussion for major architectural or UX changes. - _Implemented with minimal, opt-in env-based defaults and no major architectural churn._ - [x] **Git Hygiene:** Keep PRs atomic (one logical change). Clean up commits and rebase on `dev` to ensure no unrelated commits (e.g. from `main`) are included. Push updates to the existing PR branch instead of closing and reopening. - [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - _Recommended title:_ `feat: add Umami analytics integration with env-gated script and P1 event tracking` --- # Description This PR adds Umami analytics integration to Open WebUI with runtime backend configuration and frontend script injection controlled by environment variables. Tracking is enabled only when `UMAMI_WEBSITE_ID` is set; `UMAMI_DOMAIN` defaults to `https://cloud.umami.is` when not provided. If `UMAMI_WEBSITE_ID` is missing/empty, Umami is not loaded. The implementation includes: - Backend config exposure (`/api/config`) for Umami runtime values. - Frontend dynamic script injection in app layout. - Distinct user identification via `umami.identify(user.id)`. - P1 product events for authentication and core chat usage. - Standardized payload keys across P1 events: `flow`, `surface`, `trigger`. --- # Testing ## Before fix - No Umami script integration existed. - No runtime env-gated analytics loading. - No distinct ID/user-level Umami identification and no P1 event emission. ## After fix (manual) 1. Build and run container. 2. Set Umami env vars. 3. Open app at `http://localhost:3000`. 4. Verify script is injected only when website ID is set. 5. Verify login/session binds distinct id (`user.id`) and P1 events emit for auth/chat actions. ## Commands used ```bash docker build -t open-webui-umami-demo . docker run -d --name open-webui-umami-demo-container -p 3000:8080 \ -e UMAMI_WEBSITE_ID=xxx \ -e UMAMI_DOMAIN=https://analytics.example.com \ open-webui-umami-demo curl -I http://localhost:3000 ``` --- # Changelog Entry ### Description - Added Umami analytics integration with runtime config and env-based enablement. - Implemented distinct user identification with `user.id`. - Added standardized analytics events for auth and core chat actions. ### Added - New env vars: - `UMAMI_WEBSITE_ID` (required to enable Umami) - `UMAMI_DOMAIN` (optional, defaults to `https://cloud.umami.is`) - Frontend helper utilities for Umami track/identify. - Runtime analytics config block in backend `/api/config`. ### Changed - App layout now conditionally injects Umami script at runtime. - nalytics events now include standardized payload metadata: - `flow` - `surface` - `trigger` ### Deprecated - None. ### Removed - None. ### Fixed - Enabled proper opt-in analytics behavior: script remains disabled when `UMAMI_WEBSITE_ID` is not configured. - Added user-level distinct tracking linkage through `user.id`. ### Security - Analytics remains opt-in and environment-controlled. - Distinct ID uses internal user ID (not email), reducing PII exposure. ### Breaking Changes - **BREAKING CHANGE**: None. --- ### Additional Information - Related request: discussion post #10203. - Scope intentionally limited to user events only (auth + core chat), no workspace/admin. ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:26:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#26310