From b5795a8b3f961926153d88641265a50cc5746938 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 6 Nov 2025 16:16:53 -0800 Subject: [PATCH 01/24] Fixed update notice. --- src/app/(main)/UpdateNotice.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/(main)/UpdateNotice.tsx b/src/app/(main)/UpdateNotice.tsx index 357287912..81e2ca3af 100644 --- a/src/app/(main)/UpdateNotice.tsx +++ b/src/app/(main)/UpdateNotice.tsx @@ -1,5 +1,5 @@ import { useEffect, useCallback, useState } from 'react'; -import { Button, AlertBanner, Flexbox } from '@umami/react-zen'; +import { Button, AlertBanner, Column, Row } from '@umami/react-zen'; import { setItem } from '@/lib/storage'; import { useVersion, checkVersion } from '@/store/version'; import { REPO_URL, VERSION_CHECK } from '@/lib/constants'; @@ -47,13 +47,15 @@ export function UpdateNotice({ user, config }) { } return ( - - - - - - + + + + + + + + ); } From 6135ef9dd218186ed663f89a511fa66bfecc6aec Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 6 Nov 2025 22:24:08 -0800 Subject: [PATCH 02/24] Fixed test. --- src/lib/__tests__/detect.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/__tests__/detect.test.ts b/src/lib/__tests__/detect.test.ts index fcf706af1..f02ac8392 100644 --- a/src/lib/__tests__/detect.test.ts +++ b/src/lib/__tests__/detect.test.ts @@ -1,4 +1,4 @@ -import * as detect from '../detect'; +import { getIpAddress } from '../ip'; const IP = '127.0.0.1'; const BAD_IP = '127.127.127.127'; @@ -6,23 +6,23 @@ const BAD_IP = '127.127.127.127'; test('getIpAddress: Custom header', () => { process.env.CLIENT_IP_HEADER = 'x-custom-ip-header'; - expect(detect.getIpAddress(new Headers({ 'x-custom-ip-header': IP }))).toEqual(IP); + expect(getIpAddress(new Headers({ 'x-custom-ip-header': IP }))).toEqual(IP); }); test('getIpAddress: CloudFlare header', () => { - expect(detect.getIpAddress(new Headers({ 'cf-connecting-ip': IP }))).toEqual(IP); + expect(getIpAddress(new Headers({ 'cf-connecting-ip': IP }))).toEqual(IP); }); test('getIpAddress: Standard header', () => { - expect(detect.getIpAddress(new Headers({ 'x-forwarded-for': IP }))).toEqual(IP); + expect(getIpAddress(new Headers({ 'x-forwarded-for': IP }))).toEqual(IP); }); test('getIpAddress: CloudFlare header is lower priority than standard header', () => { - expect( - detect.getIpAddress(new Headers({ 'cf-connecting-ip': BAD_IP, 'x-forwarded-for': IP })), - ).toEqual(IP); + expect(getIpAddress(new Headers({ 'cf-connecting-ip': BAD_IP, 'x-forwarded-for': IP }))).toEqual( + IP, + ); }); test('getIpAddress: No header', () => { - expect(detect.getIpAddress(new Headers())).toEqual(null); + expect(getIpAddress(new Headers())).toEqual(null); }); From 4272bb4c4d44aec362ecf0e1c16be61c5f053525 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 6 Nov 2025 22:48:34 -0800 Subject: [PATCH 03/24] Removed db types from docker build. --- .github/workflows/cd.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a02e9900c..1b9e8965b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -15,10 +15,6 @@ jobs: packages: write id-token: write - strategy: - matrix: - db-type: [postgresql] - steps: - uses: actions/checkout@v5 @@ -53,7 +49,6 @@ jobs: ghcr.io/${{ github.repository }} flavor: | latest=auto - prefix=${{ matrix.db-type }}- tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} @@ -65,7 +60,6 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64 - build-args: DATABASE_TYPE=${{ matrix.db-type }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 437c9603dbf9e2362c3a19fd4c5952592867708f Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 6 Nov 2025 22:58:26 -0800 Subject: [PATCH 04/24] Fixed build. --- .github/workflows/cd.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1b9e8965b..d3ee4ee2a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -53,6 +53,9 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + type=ref,event=branch + type=ref,event=pr + type=sha - name: Build and push Docker image id: build-and-push From 04a05bbf26b0855441b9c2cc4cfa1a4ad49efa9b Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 6 Nov 2025 23:35:14 -0800 Subject: [PATCH 05/24] Added workflow input. --- .github/workflows/cd.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d3ee4ee2a..1e070a7c2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,6 +5,11 @@ on: tags: - 'v*.*.*' workflow_dispatch: + inputs: + manual_tag: + description: 'Optional image tag (e.g. 1.2.3, beta, nightly)' + required: false + default: '' jobs: build: @@ -54,8 +59,7 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=ref,event=branch - type=ref,event=pr - type=sha + type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }} - name: Build and push Docker image id: build-and-push From dd6556968cfbf8d05b18e7e93e2f37963015958a Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 6 Nov 2025 23:58:12 -0800 Subject: [PATCH 06/24] Updated image tag. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7b51db66c..8c8a47a6e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ --- services: umami: - image: ghcr.io/umami-software/umami:postgresql-latest + image: ghcr.io/umami-software/umami:latest ports: - "3000:3000" environment: From a90b7881387ac54d745fd8c11325e312c0fcc0d8 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 00:09:53 -0800 Subject: [PATCH 07/24] Updated cd script. --- .github/workflows/cd.yml | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1e070a7c2..3098d314b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,8 +6,8 @@ on: - 'v*.*.*' workflow_dispatch: inputs: - manual_tag: - description: 'Optional image tag (e.g. 1.2.3, beta, nightly)' + version: + description: 'Optional image version (e.g. 3.0.0, beta)' required: false default: '' @@ -23,7 +23,6 @@ jobs: steps: - uses: actions/checkout@v5 - # Install cosign (for image signing) - name: Install cosign uses: sigstore/cosign-installer@v3 @@ -45,6 +44,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # Normalize manual input if provided + - name: Normalize manual version + id: normalize + run: | + INPUT="${{ github.event.inputs.version }}" + if [[ -n "$INPUT" ]]; then + # Strip leading v if present + VERSION="${INPUT#v}" + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + echo "version_tags=${VERSION},${MAJOR}.${MINOR},${MAJOR}" >> $GITHUB_ENV + else + echo "version_tags=" >> $GITHUB_ENV + fi + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 @@ -55,11 +69,18 @@ jobs: flavor: | latest=auto tags: | + # Semver tags from real Git tags type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + + # Manual input derived tags + type=raw,value=${{ env.version_tags }},enable=${{ env.version_tags != '' }} + + # Fallbacks for branches/PRs type=ref,event=branch - type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }} + type=ref,event=pr + type=sha - name: Build and push Docker image id: build-and-push @@ -73,7 +94,6 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - # Sign the published image digest - name: Sign the published Docker image env: TAGS: ${{ steps.meta.outputs.tags }} From df3ca02e8b0d8e9f4ba7027e43eb1d35e6f93b80 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 08:52:16 -0800 Subject: [PATCH 08/24] Always push latest for Docker. --- .github/workflows/cd.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3098d314b..515aa2aad 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -54,7 +54,8 @@ jobs: VERSION="${INPUT#v}" MAJOR=$(echo "$VERSION" | cut -d. -f1) MINOR=$(echo "$VERSION" | cut -d. -f2) - echo "version_tags=${VERSION},${MAJOR}.${MINOR},${MAJOR}" >> $GITHUB_ENV + # Include latest explicitly + echo "version_tags=${VERSION},${MAJOR}.${MINOR},${MAJOR},latest" >> $GITHUB_ENV else echo "version_tags=" >> $GITHUB_ENV fi @@ -69,17 +70,16 @@ jobs: flavor: | latest=auto tags: | - # Semver tags from real Git tags + # From real Git tags (v1.2.3) type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - # Manual input derived tags + # Manual input tags type=raw,value=${{ env.version_tags }},enable=${{ env.version_tags != '' }} - # Fallbacks for branches/PRs + # Fallbacks type=ref,event=branch - type=ref,event=pr type=sha - name: Build and push Docker image From d2f512cae7af0538fc67231404d9ed31ff2c3adb Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 09:14:19 -0800 Subject: [PATCH 09/24] Don't publish .sig files. --- .github/workflows/cd-manual.yml | 58 --------------------------------- .github/workflows/cd.yml | 21 +++++------- 2 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/cd-manual.yml diff --git a/.github/workflows/cd-manual.yml b/.github/workflows/cd-manual.yml deleted file mode 100644 index df6aa6289..000000000 --- a/.github/workflows/cd-manual.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Create docker images (manual) - -on: - workflow_dispatch: - inputs: - version: - type: string - description: Version - required: true - -jobs: - build: - name: Build, push, and deploy - runs-on: ubuntu-latest - - strategy: - matrix: - db-type: [postgresql] - - steps: - - uses: actions/checkout@v3 - - - name: Extract version parts from input - id: extract_version - run: | - echo "version=$(echo ${{ github.event.inputs.version }})" >> $GITHUB_ENV - echo "major=$(echo ${{ github.event.inputs.version }} | cut -d. -f1)" >> $GITHUB_ENV - echo "minor=$(echo ${{ github.event.inputs.version }} | cut -d. -f2)" >> $GITHUB_ENV - - - name: Generate tags - id: generate_tags - run: | - echo "tag_major=$(echo ${{ matrix.db-type }}-${{ env.major }})" >> $GITHUB_ENV - echo "tag_minor=$(echo ${{ matrix.db-type }}-${{ env.major }}.${{ env.minor }})" >> $GITHUB_ENV - echo "tag_patch=$(echo ${{ matrix.db-type }}-${{ env.version }})" >> $GITHUB_ENV - echo "tag_latest=$(echo ${{ matrix.db-type }}-latest)" >> $GITHUB_ENV - - - uses: mr-smithers-excellent/docker-build-push@v6 - name: Build & push Docker image to ghcr.io for ${{ matrix.db-type }} - with: - image: umami - tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }} - buildArgs: DATABASE_TYPE=${{ matrix.db-type }} - registry: ghcr.io - multiPlatform: true - platform: linux/amd64,linux/arm64 - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: mr-smithers-excellent/docker-build-push@v6 - name: Build & push Docker image to docker.io for ${{ matrix.db-type }} - with: - image: umamisoftware/umami - tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }} - buildArgs: DATABASE_TYPE=${{ matrix.db-type }} - registry: docker.io - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 515aa2aad..a4934e797 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -50,11 +50,9 @@ jobs: run: | INPUT="${{ github.event.inputs.version }}" if [[ -n "$INPUT" ]]; then - # Strip leading v if present VERSION="${INPUT#v}" MAJOR=$(echo "$VERSION" | cut -d. -f1) MINOR=$(echo "$VERSION" | cut -d. -f2) - # Include latest explicitly echo "version_tags=${VERSION},${MAJOR}.${MINOR},${MAJOR},latest" >> $GITHUB_ENV else echo "version_tags=" >> $GITHUB_ENV @@ -70,15 +68,10 @@ jobs: flavor: | latest=auto tags: | - # From real Git tags (v1.2.3) type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - - # Manual input tags type=raw,value=${{ env.version_tags }},enable=${{ env.version_tags != '' }} - - # Fallbacks type=ref,event=branch type=sha @@ -93,9 +86,13 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + provenance: false # disable automatic attestations + + # Generate a local provenance attestation instead of uploading signatures + - name: Generate provenance attestation + run: | + cosign attest --yes \ + --predicate <(echo '{"build":"github-actions","repo":"${{ github.repository }}","run_id":"${{ github.run_id }}"}') \ + --type slsaprovenance \ + ${{ steps.meta.outputs.tags }} - - name: Sign the published Docker image - env: - TAGS: ${{ steps.meta.outputs.tags }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - run: echo "${TAGS}" | xargs -I {} cosign sign --yes "{}@${DIGEST}" From 3e9ca8761ee4ae3dab686fd4fceea0f9aec29e20 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 09:15:01 -0800 Subject: [PATCH 10/24] Removed workflow script. --- .github/workflows/delete-untagged-images.yml | 22 -------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/delete-untagged-images.yml diff --git a/.github/workflows/delete-untagged-images.yml b/.github/workflows/delete-untagged-images.yml deleted file mode 100644 index a23a1bd27..000000000 --- a/.github/workflows/delete-untagged-images.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Delete untagged GHCR images - -on: - workflow_dispatch: # Run manually from the Actions tab - -jobs: - cleanup: - name: Delete all untagged images - runs-on: ubuntu-latest - - permissions: - packages: write - contents: read - - steps: - - name: Delete untagged GHCR images - uses: actions/delete-package-versions@v5 - with: - package-name: "umami" # 👈 change if your GHCR package name differs - package-type: "container" - delete-only-untagged-versions: true - min-versions-to-keep: 0 From 6ee93f7ac92a49ece115024e46d2dce51c963ebf Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 12:21:17 -0800 Subject: [PATCH 11/24] Updated README and cd.yml. --- .github/workflows/cd.yml | 59 ++++++++++++++++++++++------------------ README.md | 2 +- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a4934e797..534b23210 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: inputs: version: - description: 'Optional image version (e.g. 3.0.0, beta)' + description: 'Optional image version (e.g. 3.0.0, v3.0.0, or 3.0.0-beta.1)' required: false default: '' @@ -29,6 +29,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Log into GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Log into Docker Hub if: github.repository == 'umami-software/umami' uses: docker/login-action@v3 @@ -37,27 +44,29 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Log into GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Normalize manual input if provided - - name: Normalize manual version - id: normalize + # Compute tags for the image + - name: Compute version tags + id: compute run: | INPUT="${{ github.event.inputs.version }}" + TAGS="" + if [[ -n "$INPUT" ]]; then - VERSION="${INPUT#v}" + VERSION="${INPUT#v}" # strip leading v MAJOR=$(echo "$VERSION" | cut -d. -f1) MINOR=$(echo "$VERSION" | cut -d. -f2) - echo "version_tags=${VERSION},${MAJOR}.${MINOR},${MAJOR},latest" >> $GITHUB_ENV - else - echo "version_tags=" >> $GITHUB_ENV + + # prereleases (e.g., 3.0.0-beta) do NOT get 'latest' + if [[ "$VERSION" == *-* ]]; then + TAGS="${VERSION}" + else + TAGS="${VERSION},${MAJOR}.${MINOR},${MAJOR},latest" + fi fi + echo "tags=$TAGS" >> $GITHUB_OUTPUT + echo "Computed tags: $TAGS" + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 @@ -65,34 +74,32 @@ jobs: images: | umamisoftware/umami,enable=${{ github.repository == 'umami-software/umami' }} ghcr.io/${{ github.repository }} - flavor: | - latest=auto tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=raw,value=${{ env.version_tags }},enable=${{ env.version_tags != '' }} + type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }} + type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref_type == 'tag' }} + type=semver,pattern={{major}},enable=${{ github.ref_type == 'tag' }} + type=raw,value=${{ steps.compute.outputs.tags }},enable=${{ steps.compute.outputs.tags != '' }} type=ref,event=branch type=sha + # Build and push images - name: Build and push Docker image id: build-and-push uses: docker/build-push-action@v6 with: context: . - platforms: linux/amd64,linux/arm64 push: true + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - provenance: false # disable automatic attestations + provenance: false # disable automatic registry attestations - # Generate a local provenance attestation instead of uploading signatures - - name: Generate provenance attestation + # Generate a local provenance attestation (not uploaded) + - name: Generate local provenance attestation run: | cosign attest --yes \ --predicate <(echo '{"build":"github-actions","repo":"${{ github.repository }}","run_id":"${{ github.run_id }}"}') \ --type slsaprovenance \ ${{ steps.meta.outputs.tags }} - diff --git a/README.md b/README.md index 6d166d8c8..d3791e269 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ docker compose up -d Alternatively, to pull just the Umami Docker image with PostgreSQL support: ```bash -docker pull docker.umami.is/umami-software/umami:postgresql-latest +docker pull docker.umami.is/umami-software/umami:latest ``` --- From 8119dae3c3d951f9525c3d2e03587f451dd9dc14 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 13:59:50 -0800 Subject: [PATCH 12/24] Updated GH workflow. --- .github/workflows/cd.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 534b23210..f44d17689 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -23,9 +23,6 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Install cosign - uses: sigstore/cosign-installer@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -95,11 +92,3 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max provenance: false # disable automatic registry attestations - - # Generate a local provenance attestation (not uploaded) - - name: Generate local provenance attestation - run: | - cosign attest --yes \ - --predicate <(echo '{"build":"github-actions","repo":"${{ github.repository }}","run_id":"${{ github.run_id }}"}') \ - --type slsaprovenance \ - ${{ steps.meta.outputs.tags }} From e3ca002d77827430e7df155da31ffcc4b9c8aa13 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 14:35:05 -0800 Subject: [PATCH 13/24] Fixed tags in build. --- .github/workflows/cd.yml | 51 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f44d17689..f21f58aa1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -18,7 +18,6 @@ jobs: permissions: contents: read packages: write - id-token: write steps: - uses: actions/checkout@v5 @@ -41,54 +40,52 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - # Compute tags for the image - name: Compute version tags id: compute run: | INPUT="${{ github.event.inputs.version }}" + REF_TYPE="${{ github.ref_type }}" + REF_NAME="${{ github.ref_name }}" + + # Determine version source + if [[ -n "$INPUT" ]]; then + VERSION="${INPUT#v}" + elif [[ "$REF_TYPE" == "tag" ]]; then + VERSION="${REF_NAME#v}" + else + VERSION="" + fi + TAGS="" - if [[ -n "$INPUT" ]]; then - VERSION="${INPUT#v}" # strip leading v + if [[ -n "$VERSION" ]]; then MAJOR=$(echo "$VERSION" | cut -d. -f1) MINOR=$(echo "$VERSION" | cut -d. -f2) - # prereleases (e.g., 3.0.0-beta) do NOT get 'latest' if [[ "$VERSION" == *-* ]]; then - TAGS="${VERSION}" + # prerelease: only version tag + TAGS="$VERSION" else - TAGS="${VERSION},${MAJOR}.${MINOR},${MAJOR},latest" + # stable release: version + hierarchy + latest + TAGS="$VERSION,${MAJOR}.${MINOR},${MAJOR},latest" fi + else + # Non-tag build (e.g. from main branch) + TAGS="${REF_NAME}" fi echo "tags=$TAGS" >> $GITHUB_OUTPUT echo "Computed tags: $TAGS" - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: | - umamisoftware/umami,enable=${{ github.repository == 'umami-software/umami' }} - ghcr.io/${{ github.repository }} - tags: | - type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }} - type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref_type == 'tag' }} - type=semver,pattern={{major}},enable=${{ github.ref_type == 'tag' }} - type=raw,value=${{ steps.compute.outputs.tags }},enable=${{ steps.compute.outputs.tags != '' }} - type=ref,event=branch - type=sha - - # Build and push images - name: Build and push Docker image - id: build-and-push uses: docker/build-push-action@v6 with: context: . push: true platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + umamisoftware/umami:${{ steps.compute.outputs.tags }} + ghcr.io/${{ github.repository }}:${{ steps.compute.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max - provenance: false # disable automatic registry attestations + provenance: false From de6515139e5067375dc62601b5fb699846bfe161 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 18:17:51 -0800 Subject: [PATCH 14/24] Fixed Docker permissions. --- .github/workflows/cd.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f21f58aa1..6569954ea 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -67,7 +67,7 @@ jobs: TAGS="$VERSION" else # stable release: version + hierarchy + latest - TAGS="$VERSION,${MAJOR}.${MINOR},${MAJOR},latest" + TAGS="$VERSION,${MAJOR}.${MINOR},${MAJOR},postgresql-latest,latest" fi else # Non-tag build (e.g. from main branch) @@ -78,14 +78,15 @@ jobs: echo "Computed tags: $TAGS" - name: Build and push Docker image + id: build uses: docker/build-push-action@v6 with: context: . push: true platforms: linux/amd64,linux/arm64 - tags: | - umamisoftware/umami:${{ steps.compute.outputs.tags }} - ghcr.io/${{ github.repository }}:${{ steps.compute.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max provenance: false + tags: | + ghcr.io/${{ github.repository }}:${{ steps.compute.outputs.tags }} + ${{ github.repository == 'umami-software/umami' && format('umamisoftware/umami:{0}', steps.compute.outputs.tags) || '' }} From 6ba9c1c40c398020a9720a7d2ad4ecfa1c4639bc Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 22:41:10 -0800 Subject: [PATCH 15/24] New docker workflow. --- .github/workflows/cd.yml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6569954ea..a9509bce0 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -78,15 +78,23 @@ jobs: echo "Computed tags: $TAGS" - name: Build and push Docker image - id: build - uses: docker/build-push-action@v6 - with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - provenance: false - tags: | - ghcr.io/${{ github.repository }}:${{ steps.compute.outputs.tags }} - ${{ github.repository == 'umami-software/umami' && format('umamisoftware/umami:{0}', steps.compute.outputs.tags) || '' }} + run: | + TAGS="${{ steps.compute.outputs.tags }}" + + # Set image targets conditionally + if [[ "${{ github.repository }}" == "umami-software/umami" ]]; then + IMAGES=("umamisoftware/umami" "ghcr.io/${{ github.repository }}") + else + IMAGES=("ghcr.io/${{ github.repository }}") + fi + + for IMAGE in "${IMAGES[@]}"; do + echo "Building and pushing $IMAGE with tags: $TAGS" + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --push \ + $(echo "$TAGS" | tr ',' '\n' | sed "s|^|--tag ${IMAGE}:|") \ + --cache-from type=gha \ + --cache-to type=gha,mode=max \ + . + done From 1879c161eeba2591f72b4a9186d48f5836ca04a4 Mon Sep 17 00:00:00 2001 From: metaloozee Date: Sun, 9 Nov 2025 00:22:06 +0530 Subject: [PATCH 16/24] fix: Redirect loop on auth failure --- src/app/(main)/App.tsx | 8 ++------ src/app/logout/LogoutPage.tsx | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/app/(main)/App.tsx b/src/app/(main)/App.tsx index 32218d115..7700639da 100644 --- a/src/app/(main)/App.tsx +++ b/src/app/(main)/App.tsx @@ -9,18 +9,14 @@ import { MobileNav } from '@/app/(main)/MobileNav'; export function App({ children }) { const { user, isLoading, error } = useLoginQuery(); const config = useConfig(); - const { pathname, router } = useNavigation(); + const { pathname } = useNavigation(); if (isLoading || !config) { return ; } if (error) { - if (process.env.cloudMode) { - window.location.href = '/login'; - } else { - router.push('/login'); - } + window.location.href = '/login'; return null; } diff --git a/src/app/logout/LogoutPage.tsx b/src/app/logout/LogoutPage.tsx index 909f35de3..bd4717961 100644 --- a/src/app/logout/LogoutPage.tsx +++ b/src/app/logout/LogoutPage.tsx @@ -13,7 +13,7 @@ export function LogoutPage() { async function logout() { await post('/auth/logout'); - router.push('/login'); + window.location.href = '/login'; } removeClientAuthToken(); From bf548c5acae58cc1420d3ae7e79127f3db654e81 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Sun, 9 Nov 2025 21:19:38 -0800 Subject: [PATCH 17/24] Fix revenue bigInt but and case insensitive currency --- src/queries/sql/reports/getRevenue.ts | 38 +++++++++++---------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/queries/sql/reports/getRevenue.ts b/src/queries/sql/reports/getRevenue.ts index e13106ced..5771bdef0 100644 --- a/src/queries/sql/reports/getRevenue.ts +++ b/src/queries/sql/reports/getRevenue.ts @@ -41,6 +41,15 @@ async function relationalQuery( currency, }); + const joinQuery = filterQuery + ? `join website_event + on website_event.website_id = revenue.website_id + and website_event.session_id = revenue.session_id + and website_event.event_id = revenue.event_id + and website_event.website_id = {{websiteId::uuid}} + and website_event.created_at between {{startDate}} and {{endDate}}` + : ''; + const chart = await rawQuery( ` select @@ -48,17 +57,12 @@ async function relationalQuery( ${getDateSQL('revenue.created_at', unit, timezone)} t, sum(revenue.revenue) y from revenue - join website_event - on website_event.website_id = revenue.website_id - and website_event.session_id = revenue.session_id - and website_event.event_id = revenue.event_id - and website_event.website_id = {{websiteId::uuid}} - and website_event.created_at between {{startDate}} and {{endDate}} + ${joinQuery} ${cohortQuery} ${joinSessionQuery} where revenue.website_id = {{websiteId::uuid}} and revenue.created_at between {{startDate}} and {{endDate}} - and revenue.currency like {{currency}} + and revenue.currency ilike {{currency}} ${filterQuery} group by x, t order by t @@ -72,19 +76,14 @@ async function relationalQuery( session.country as name, sum(revenue) value from revenue - join website_event - on website_event.website_id = revenue.website_id - and website_event.session_id = revenue.session_id - and website_event.event_id = revenue.event_id - and website_event.website_id = {{websiteId::uuid}} - and website_event.created_at between {{startDate}} and {{endDate}} + ${joinQuery} join session on session.website_id = revenue.website_id and session.session_id = revenue.session_id ${cohortQuery} where revenue.website_id = {{websiteId::uuid}} and revenue.created_at between {{startDate}} and {{endDate}} - and revenue.currency = {{currency}} + and revenue.currency ilike {{currency}} ${filterQuery} group by session.country `, @@ -98,23 +97,18 @@ async function relationalQuery( count(distinct revenue.event_id) as count, count(distinct revenue.session_id) as unique_count from revenue - join website_event - on website_event.website_id = revenue.website_id - and website_event.session_id = revenue.session_id - and website_event.event_id = revenue.event_id - and website_event.website_id = {{websiteId::uuid}} - and website_event.created_at between {{startDate}} and {{endDate}} + ${joinQuery} ${cohortQuery} ${joinSessionQuery} where revenue.website_id = {{websiteId::uuid}} and revenue.created_at between {{startDate}} and {{endDate}} - and revenue.currency = {{currency}} + and revenue.currency ilike {{currency}} ${filterQuery} `, queryParams, ).then(result => result?.[0]); - total.average = total.count > 0 ? total.sum / total.count : 0; + total.average = total.count > 0 ? Number(total.sum) / Number(total.count) : 0; return { chart, country, total }; } From f30724629cb4a6b4c401c78e83085b7671e1fbe4 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Sun, 9 Nov 2025 21:37:35 -0800 Subject: [PATCH 18/24] Fix null and string return types from getWebsiteStats --- src/queries/sql/getWebsiteStats.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/queries/sql/getWebsiteStats.ts b/src/queries/sql/getWebsiteStats.ts index 391d22be2..4a4bef78b 100644 --- a/src/queries/sql/getWebsiteStats.ts +++ b/src/queries/sql/getWebsiteStats.ts @@ -36,11 +36,11 @@ async function relationalQuery( return rawQuery( ` select - sum(t.c) as "pageviews", + cast(coalesce(sum(t.c), 0) as bigint) as "pageviews", count(distinct t.session_id) as "visitors", count(distinct t.visit_id) as "visits", - sum(case when t.c = 1 then 1 else 0 end) as "bounces", - sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime" + coalesce(sum(case when t.c = 1 then 1 else 0 end), 0) as "bounces", + cast(coalesce(sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}), 0) as bigint) as "totaltime" from ( select website_event.session_id, From 9230f3cb7b18203614fe2856d216540916be785c Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Sun, 9 Nov 2025 22:03:06 -0800 Subject: [PATCH 19/24] manually include basePath --- src/app/(main)/App.tsx | 2 +- src/app/logout/LogoutPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/App.tsx b/src/app/(main)/App.tsx index 7700639da..ec08838d1 100644 --- a/src/app/(main)/App.tsx +++ b/src/app/(main)/App.tsx @@ -16,7 +16,7 @@ export function App({ children }) { } if (error) { - window.location.href = '/login'; + window.location.href = `${process.env.basePath || ''}/login`; return null; } diff --git a/src/app/logout/LogoutPage.tsx b/src/app/logout/LogoutPage.tsx index bd4717961..d66d62a98 100644 --- a/src/app/logout/LogoutPage.tsx +++ b/src/app/logout/LogoutPage.tsx @@ -13,7 +13,7 @@ export function LogoutPage() { async function logout() { await post('/auth/logout'); - window.location.href = '/login'; + window.location.href = `${process.env.basePath || ''}/login`; } removeClientAuthToken(); From f3e246c64bf75093664472d0cae32a6067089327 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Sun, 9 Nov 2025 23:58:20 -0800 Subject: [PATCH 20/24] fix hasdata queries, add hasData to website events, fix sessionactivity truncation, --- .../[websiteId]/events/EventsTable.tsx | 37 ++++++++++++++++++- .../[websiteId]/sessions/SessionActivity.tsx | 9 +++-- src/queries/sql/events/getEventData.ts | 28 +++++++------- src/queries/sql/events/getWebsiteEvents.ts | 6 ++- .../sql/sessions/getSessionActivity.ts | 4 +- 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/src/app/(main)/websites/[websiteId]/events/EventsTable.tsx b/src/app/(main)/websites/[websiteId]/events/EventsTable.tsx index e9e3e6a0c..ea0edde1b 100644 --- a/src/app/(main)/websites/[websiteId]/events/EventsTable.tsx +++ b/src/app/(main)/websites/[websiteId]/events/EventsTable.tsx @@ -1,11 +1,24 @@ -import { DataTable, DataColumn, Row, Text, DataTableProps, IconLabel } from '@umami/react-zen'; +import { + DataTable, + DataColumn, + Row, + Text, + DataTableProps, + IconLabel, + Button, + Dialog, + DialogTrigger, + Icon, + Popover, +} from '@umami/react-zen'; import { useFormat, useMessages, useNavigation } from '@/components/hooks'; import { Avatar } from '@/components/common/Avatar'; import Link from 'next/link'; -import { Eye } from '@/components/icons'; +import { Eye, FileText } from '@/components/icons'; import { Lightning } from '@/components/svg'; import { DateDistance } from '@/components/common/DateDistance'; import { TypeIcon } from '@/components/common/TypeIcon'; +import { EventData } from '@/components/metrics/EventData'; export function EventsTable(props: DataTableProps) { const { formatMessage, labels } = useMessages(); @@ -32,6 +45,7 @@ export function EventsTable(props: DataTableProps) { > {row.eventName || row.urlPath} + {row.hasData > 0 && } ); }} @@ -72,3 +86,22 @@ export function EventsTable(props: DataTableProps) { ); } + +const PropertiesButton = props => { + return ( + + + + + + + + + ); +}; diff --git a/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx b/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx index b9f34e485..7bcf1b760 100644 --- a/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx +++ b/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx @@ -14,7 +14,7 @@ import { import { LoadingPanel } from '@/components/common/LoadingPanel'; import { Eye, FileText } from '@/components/icons'; import { Lightning } from '@/components/svg'; -import { useMessages, useSessionActivityQuery, useTimezone } from '@/components/hooks'; +import { useMessages, useMobile, useSessionActivityQuery, useTimezone } from '@/components/hooks'; import { EventData } from '@/components/metrics/EventData'; export function SessionActivity({ @@ -36,6 +36,7 @@ export function SessionActivity({ startDate, endDate, ); + const { isMobile } = useMobile(); let lastDay = null; return ( @@ -50,16 +51,16 @@ export function SessionActivity({ {showHeader && {formatTimezoneDate(createdAt, 'PPPP')}} - {formatTimezoneDate(createdAt, 'pp')} + {formatTimezoneDate(createdAt, 'pp')} {eventName ? : } - + {eventName ? formatMessage(labels.triggeredEvent) : formatMessage(labels.viewedPage)} - + {eventName || urlPath} {hasData > 0 && } diff --git a/src/queries/sql/events/getEventData.ts b/src/queries/sql/events/getEventData.ts index 42dc2040b..269258a8d 100644 --- a/src/queries/sql/events/getEventData.ts +++ b/src/queries/sql/events/getEventData.ts @@ -19,20 +19,20 @@ async function relationalQuery(websiteId: string, eventId: string) { return rawQuery( ` - select website_id as "websiteId", - session_id as "sessionId", - event_id as "eventId", - url_path as "urlPath", - event_name as "eventName", - data_key as "dataKey", - string_value as "stringValue", - number_value as "numberValue", - date_value as "dateValue", - data_type as "dataType", - created_at as "createdAt" + select event_data.website_id as "websiteId", + event_data.website_event_id as "eventId", + website_event.event_name as "eventName", + event_data.data_key as "dataKey", + event_data.string_value as "stringValue", + event_data.number_value as "numberValue", + event_data.date_value as "dateValue", + event_data.data_type as "dataType", + event_data.created_at as "createdAt" from event_data - website_id = {{websiteId::uuid}} - event_id = {{eventId::uuid}} + join website_event on website_event.event_id = event_data.website_event_id + and website_event.website_id = {{websiteId::uuid}} + where event_data.website_id = {{websiteId::uuid}} + and event_data.website_event_id = {{eventId::uuid}} `, { websiteId, eventId }, FUNCTION_NAME, @@ -45,9 +45,7 @@ async function clickhouseQuery(websiteId: string, eventId: string): Promise Date: Mon, 10 Nov 2025 01:07:11 -0800 Subject: [PATCH 21/24] fix realtime logs for mobile --- .../[websiteId]/realtime/RealtimeLog.tsx | 38 ++++++++++++++----- .../[websiteId]/realtime/RealtimePage.tsx | 5 ++- src/components/metrics/ListTable.tsx | 6 +-- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx index 9ae19bf89..3dec340f2 100644 --- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx +++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx @@ -9,6 +9,7 @@ import { useCountryNames, useLocale, useMessages, + useMobile, useNavigation, useTimezone, useWebsite, @@ -40,6 +41,7 @@ export function RealtimeLog({ data }: { data: any }) { const { countryNames } = useCountryNames(locale); const [filter, setFilter] = useState(TYPE_ALL); const { updateParams } = useNavigation(); + const { isPhone } = useMobile(); const buttons = [ { @@ -123,12 +125,18 @@ export function RealtimeLog({ data }: { data: any }) { const row = logs[index]; return ( - - - - {getTime(row)} + + + + + + + {getTime(row)} + - {getDetail(row)} + + {getDetail(row)} + ); @@ -168,10 +176,22 @@ export function RealtimeLog({ data }: { data: any }) { return ( {formatMessage(labels.activity)} - - - - + {isPhone ? ( + <> + + + + + + + + ) : ( + + + + + )} + {logs?.length === 0 && } {logs?.length > 0 && ( diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimePage.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimePage.tsx index 7f9ab6085..0f9fa358b 100644 --- a/src/app/(main)/websites/[websiteId]/realtime/RealtimePage.tsx +++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimePage.tsx @@ -6,7 +6,7 @@ import { PageBody } from '@/components/common/PageBody'; import { Panel } from '@/components/common/Panel'; import { RealtimeChart } from '@/components/metrics/RealtimeChart'; import { WorldMap } from '@/components/metrics/WorldMap'; -import { useRealtimeQuery } from '@/components/hooks'; +import { useMobile, useRealtimeQuery } from '@/components/hooks'; import { RealtimeLog } from './RealtimeLog'; import { RealtimeHeader } from './RealtimeHeader'; import { RealtimePaths } from './RealtimePaths'; @@ -16,6 +16,7 @@ import { percentFilter } from '@/lib/filters'; export function RealtimePage({ websiteId }: { websiteId: string }) { const { data, isLoading, error } = useRealtimeQuery(websiteId); + const { isMobile } = useMobile(); if (isLoading || error) { return ; @@ -48,7 +49,7 @@ export function RealtimePage({ websiteId }: { websiteId: string }) { - + diff --git a/src/components/metrics/ListTable.tsx b/src/components/metrics/ListTable.tsx index 303556b01..e76e01745 100644 --- a/src/components/metrics/ListTable.tsx +++ b/src/components/metrics/ListTable.tsx @@ -57,7 +57,7 @@ export function ListTable({ showPercentage={showPercentage} change={renderChange ? renderChange(row, index) : null} currency={currency} - isMobile={isPhone} + isPhone={isPhone} /> ); }; @@ -101,7 +101,7 @@ const AnimatedRow = ({ animate, showPercentage = true, currency, - isMobile, + isPhone, }) => { const props = useSpring({ width: percent, @@ -120,7 +120,7 @@ const AnimatedRow = ({ gap > - + {label} From 49e1582c288bc5bc71f3f4e0482873b0930c1297 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Mon, 10 Nov 2025 15:36:43 -0800 Subject: [PATCH 22/24] implement generateTimeSeries for eventsChart --- src/components/metrics/EventsChart.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/metrics/EventsChart.tsx b/src/components/metrics/EventsChart.tsx index 7301faf44..246772b3e 100644 --- a/src/components/metrics/EventsChart.tsx +++ b/src/components/metrics/EventsChart.tsx @@ -1,10 +1,11 @@ -import { useMemo, useState, useEffect } from 'react'; -import { colord } from 'colord'; import { BarChart, BarChartProps } from '@/components/charts/BarChart'; +import { LoadingPanel } from '@/components/common/LoadingPanel'; import { useDateRange, useLocale, useWebsiteEventsSeriesQuery } from '@/components/hooks'; import { renderDateLabels } from '@/lib/charts'; import { CHART_COLORS } from '@/lib/constants'; -import { LoadingPanel } from '@/components/common/LoadingPanel'; +import { generateTimeSeries } from '@/lib/date'; +import { colord } from 'colord'; +import { useCallback, useEffect, useMemo, useState } from 'react'; export interface EventsChartProps extends BarChartProps { websiteId: string; @@ -15,7 +16,7 @@ export function EventsChart({ websiteId, focusLabel }: EventsChartProps) { const { dateRange: { startDate, endDate, unit }, } = useDateRange(); - const { locale } = useLocale(); + const { locale, dateLocale } = useLocale(); const { data, isLoading, error } = useWebsiteEventsSeriesQuery(websiteId); const [label, setLabel] = useState(focusLabel); @@ -37,7 +38,7 @@ export function EventsChart({ websiteId, focusLabel }: EventsChartProps) { const color = colord(CHART_COLORS[index % CHART_COLORS.length]); return { label: key, - data: map[key], + data: generateTimeSeries(map[key], startDate, endDate, unit, dateLocale), lineTension: 0, backgroundColor: color.alpha(0.6).toRgbString(), borderColor: color.alpha(0.7).toRgbString(), @@ -54,6 +55,8 @@ export function EventsChart({ websiteId, focusLabel }: EventsChartProps) { } }, [focusLabel]); + const renderXLabel = useCallback(renderDateLabels(unit, locale), [unit, locale]); + return ( {chartData && ( @@ -63,7 +66,7 @@ export function EventsChart({ websiteId, focusLabel }: EventsChartProps) { maxDate={endDate} unit={unit} stacked={true} - renderXLabel={renderDateLabels(unit, locale)} + renderXLabel={renderXLabel} height="400px" /> )} From a1d6204373b13bb4675de3aacc49a650b24318be Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Mon, 10 Nov 2025 17:24:51 -0800 Subject: [PATCH 23/24] add canonicalizeTimezone conversions Co-authored-by: Om Mishra --- src/components/hooks/useDateParameters.ts | 4 ++-- src/components/hooks/useTimezone.ts | 15 +++++++++++++-- src/lib/constants.ts | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/components/hooks/useDateParameters.ts b/src/components/hooks/useDateParameters.ts index 359bbc1fd..16e123142 100644 --- a/src/components/hooks/useDateParameters.ts +++ b/src/components/hooks/useDateParameters.ts @@ -5,7 +5,7 @@ export function useDateParameters() { const { dateRange: { startDate, endDate, unit }, } = useDateRange(); - const { timezone, toUtc } = useTimezone(); + const { timezone, toUtc, canonicalizeTimezone } = useTimezone(); return { startAt: +toUtc(startDate), @@ -13,6 +13,6 @@ export function useDateParameters() { startDate: toUtc(startDate).toISOString(), endDate: toUtc(endDate).toISOString(), unit, - timezone, + timezone: canonicalizeTimezone(timezone), }; } diff --git a/src/components/hooks/useTimezone.ts b/src/components/hooks/useTimezone.ts index 0e1fe6cd3..3770c26bd 100644 --- a/src/components/hooks/useTimezone.ts +++ b/src/components/hooks/useTimezone.ts @@ -1,5 +1,5 @@ import { setItem } from '@/lib/storage'; -import { TIMEZONE_CONFIG } from '@/lib/constants'; +import { TIMEZONE_CONFIG, TIMEZONE_LEGACY } from '@/lib/constants'; import { formatInTimeZone, zonedTimeToUtc, utcToZonedTime } from 'date-fns-tz'; import { useApp, setTimezone } from '@/store/app'; import { useLocale } from './useLocale'; @@ -34,5 +34,16 @@ export function useTimezone() { return utcToZonedTime(date, timezone); }; - return { timezone, saveTimezone, formatTimezoneDate, toUtc, fromUtc }; + const canonicalizeTimezone = (timezone: string): string => { + return TIMEZONE_LEGACY[timezone] ?? timezone; + }; + + return { + timezone, + saveTimezone, + formatTimezoneDate, + toUtc, + fromUtc, + canonicalizeTimezone, + }; } diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 50a25b8d8..195fe1be8 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -658,3 +658,24 @@ export const CURRENCIES = [ { id: 'OMR', name: 'Omani Rial' }, { id: 'GHS', name: 'Ghanaian Cedi' }, ]; + +export const TIMEZONE_LEGACY: Record = { + 'Asia/Batavia': 'Asia/Jakarta', + 'Asia/Calcutta': 'Asia/Kolkata', + 'Asia/Chongqing': 'Asia/Shanghai', + 'Asia/Harbin': 'Asia/Shanghai', + 'Asia/Jayapura': 'Asia/Pontianak', + 'Asia/Katmandu': 'Asia/Kathmandu', + 'Asia/Macao': 'Asia/Macau', + 'Asia/Rangoon': 'Asia/Yangon', + 'Asia/Saigon': 'Asia/Ho_Chi_Minh', + 'Europe/Kiev': 'Europe/Kyiv', + 'Europe/Zaporozhye': 'Europe/Kyiv', + 'Etc/UTC': 'UTC', + 'US/Arizona': 'America/Phoenix', + 'US/Central': 'America/Chicago', + 'US/Eastern': 'America/New_York', + 'US/Mountain': 'America/Denver', + 'US/Pacific': 'America/Los_Angeles', + 'US/Samoa': 'Pacific/Pago_Pago', +}; From 13ab84d50e7f8bfa4837ba8f7e48e97703b227dd Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Mon, 10 Nov 2025 17:26:06 -0800 Subject: [PATCH 24/24] Revert "add canonicalizeTimezone conversions" This reverts commit a1d6204373b13bb4675de3aacc49a650b24318be. --- src/components/hooks/useDateParameters.ts | 4 ++-- src/components/hooks/useTimezone.ts | 15 ++------------- src/lib/constants.ts | 21 --------------------- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/src/components/hooks/useDateParameters.ts b/src/components/hooks/useDateParameters.ts index 16e123142..359bbc1fd 100644 --- a/src/components/hooks/useDateParameters.ts +++ b/src/components/hooks/useDateParameters.ts @@ -5,7 +5,7 @@ export function useDateParameters() { const { dateRange: { startDate, endDate, unit }, } = useDateRange(); - const { timezone, toUtc, canonicalizeTimezone } = useTimezone(); + const { timezone, toUtc } = useTimezone(); return { startAt: +toUtc(startDate), @@ -13,6 +13,6 @@ export function useDateParameters() { startDate: toUtc(startDate).toISOString(), endDate: toUtc(endDate).toISOString(), unit, - timezone: canonicalizeTimezone(timezone), + timezone, }; } diff --git a/src/components/hooks/useTimezone.ts b/src/components/hooks/useTimezone.ts index 3770c26bd..0e1fe6cd3 100644 --- a/src/components/hooks/useTimezone.ts +++ b/src/components/hooks/useTimezone.ts @@ -1,5 +1,5 @@ import { setItem } from '@/lib/storage'; -import { TIMEZONE_CONFIG, TIMEZONE_LEGACY } from '@/lib/constants'; +import { TIMEZONE_CONFIG } from '@/lib/constants'; import { formatInTimeZone, zonedTimeToUtc, utcToZonedTime } from 'date-fns-tz'; import { useApp, setTimezone } from '@/store/app'; import { useLocale } from './useLocale'; @@ -34,16 +34,5 @@ export function useTimezone() { return utcToZonedTime(date, timezone); }; - const canonicalizeTimezone = (timezone: string): string => { - return TIMEZONE_LEGACY[timezone] ?? timezone; - }; - - return { - timezone, - saveTimezone, - formatTimezoneDate, - toUtc, - fromUtc, - canonicalizeTimezone, - }; + return { timezone, saveTimezone, formatTimezoneDate, toUtc, fromUtc }; } diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 195fe1be8..50a25b8d8 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -658,24 +658,3 @@ export const CURRENCIES = [ { id: 'OMR', name: 'Omani Rial' }, { id: 'GHS', name: 'Ghanaian Cedi' }, ]; - -export const TIMEZONE_LEGACY: Record = { - 'Asia/Batavia': 'Asia/Jakarta', - 'Asia/Calcutta': 'Asia/Kolkata', - 'Asia/Chongqing': 'Asia/Shanghai', - 'Asia/Harbin': 'Asia/Shanghai', - 'Asia/Jayapura': 'Asia/Pontianak', - 'Asia/Katmandu': 'Asia/Kathmandu', - 'Asia/Macao': 'Asia/Macau', - 'Asia/Rangoon': 'Asia/Yangon', - 'Asia/Saigon': 'Asia/Ho_Chi_Minh', - 'Europe/Kiev': 'Europe/Kyiv', - 'Europe/Zaporozhye': 'Europe/Kyiv', - 'Etc/UTC': 'UTC', - 'US/Arizona': 'America/Phoenix', - 'US/Central': 'America/Chicago', - 'US/Eastern': 'America/New_York', - 'US/Mountain': 'America/Denver', - 'US/Pacific': 'America/Los_Angeles', - 'US/Samoa': 'Pacific/Pago_Pago', -};