umami-software / umami

Umami is a simple, fast, privacy-focused alternative to Google Analytics.
https://umami.is
MIT License
22.18k stars 4.14k forks source link

Version 2.6.0 cannot use custom `API endpoint` and custom `script name` #2240

Closed aaro-n closed 1 year ago

aaro-n commented 1 year ago

Describe the Bug

I don't know if it's because of the deployment of umami to fly.io, the custom interface and custom script name of the 2.6.0 version can't be used normally, but both of them can work normally in the 2.5.0 version.

Environment introduction:

umami access domain name: tg.123.cn
COLLECT_API_ENDPOINT = "/api/59qrTtdFFrV"
TRACKER_SCRIPT_NAME = "PGmXAF3tDjvN9"

Insert umami on the website to be counted

  src="//js.123.fun/um/PGmXAF3tDjvN9.js"
  data-website-id="ID"
  data-host-url="https://tg.123.cn"

It can be used normally in umami 2.5.0 version

Troubleshoot

Accessing https://tg.123.cn/script.js is normal, accessing https://tg.123.cn/PGmXAF3tDjvN9.js prompts 404, Visit the website with a browser (chrome F12-network), js.123.fun/um/PGmXAF3tDjvN9.js has been loaded normally, https://tg.123.cn/api/59qrTtdFFrV prompt 404

Back to version 2.5.0, except for visiting https://tg.123.cn/PGmXAF3tDjvN9.js404, umami can count normally.

Database

PostgreSQL

Relevant log output

2023-08-30T05:51:19.652 app[4d89440be57587] nrt [info] - ready started server on 0.0.0.0:8080, url: http://localhost:8080

2023-08-30T05:59:51.791 app[4d89440be57587] nrt [info] TypeError: Cannot destructure property 'url' of 'payload' as it is undefined.

2023-08-30T05:59:51.791 app[4d89440be57587] nrt [info] at __WEBPACK_DEFAULT_EXPORT__ (/app/.next/server/pages/api/send.js:502:13)

2023-08-30T05:59:51.791 app[4d89440be57587] nrt [info] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

2023-08-30T06:00:03.897 app[4d89440be57587] nrt [info] TypeError: Cannot destructure property 'url' of 'payload' as it is undefined.

2023-08-30T06:00:03.897 app[4d89440be57587] nrt [info] at __WEBPACK_DEFAULT_EXPORT__ (/app/.next/server/pages/api/send.js:502:13)

2023-08-30T06:00:03.897 app[4d89440be57587] nrt [info] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Which browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

Fly.io,Docker

ScottEAdams commented 1 year ago

Same issue, TRACKER_SCRIPT_NAME is ignored on ghcr.io/umami-software/umami:postgresql-v2.6.0. Reverted to 2.5.0.

appotry commented 1 year ago

+1

saschwarz commented 1 year ago

@aaro-n I might not be following exactly what is going on in your explanation. But I think the TRACKER_SCRIPT_NAME no longer automatically appends .js. So your website src should exactly match the TRACKER_SCRIPT_NAME.

e.g. TRACKER_SCRIPT_NAME = "PGmXAF3tDjvN9" src="//js.123.fun/um/PGmXAF3tDjvN9"

aaro-n commented 1 year ago

@saschwarz Remove .js from the src item, that is, src="//js.123.fun/um/PGmXAF3tDjvN9", access to https://tg.123.cn/api/59qrTtdFFrV will still result in 404, accesshttps://tg.123.cn/api/send displays Internal Server Error, log

2023-08-30T23:09:31.922 app[4d89440be57587] nrt [info] TypeError: Cannot destructure property 'url' of 'payload' as it is undefined.

2023-08-30T23:09:31.922 app[4d89440be57587] nrt [info] at __WEBPACK_DEFAULT_EXPORT__ (/app/.next/server/pages/api/send.js:502:13)

2023-08-30T23:09:31.922 app[4d89440be57587] nrt [info] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Umami returns to version 2.5.0, visit https://tg.123.cn/api/send and https://tg.123.cn/api/59qrTtdFFrV both show Invalid payload., no error log

aaro-n commented 1 year ago

2.6.0

2023-08-30T23:16:24.945 runner[4d89440be57587] nrt [info] Pulling container image ghcr.io/umami-software/umami:postgresql-latest

2023-08-30T23:16:25.574 runner[4d89440be57587] nrt [info] Successfully prepared image ghcr.io/umami-software/umami:postgresql-latest (628.847169ms)

2023-08-30T23:16:25.936 runner[4d89440be57587] nrt [info] Configuring firecracker

2023-08-30T23:16:26.112 app[4d89440be57587] nrt [info] INFO Sending signal SIGINT to main child process w/ PID 265

2023-08-30T23:16:26.771 app[4d89440be57587] nrt [info] INFO Main child exited with signal (with signal 'SIGINT', core dumped? false)

2023-08-30T23:16:26.771 app[4d89440be57587] nrt [info] INFO Starting clean up.

2023-08-30T23:16:26.771 app[4d89440be57587] nrt [info] WARN hallpass exited, pid: 266, status: signal: 15 (SIGTERM)

2023-08-30T23:16:26.772 app[4d89440be57587] nrt [info] 2023/08/30 23:16:26 listening on [fdaa:0:6f3f:a7b:d86c:69d9:3c7c:2]:22 (DNS: [fdaa::3]:53)

2023-08-30T23:16:27.761 app[4d89440be57587] nrt [info] [ 334.760070] reboot: Restarting system

2023-08-30T23:16:28.256 app[4d89440be57587] nrt [info] [ 0.041354] PCI: Fatal: No config space access function found

2023-08-30T23:16:28.471 app[4d89440be57587] nrt [info] INFO Starting init (commit: 5293a085)...

2023-08-30T23:16:28.546 app[4d89440be57587] nrt [info] INFO Preparing to run: `docker-entrypoint.sh yarn start-docker` as nextjs

2023-08-30T23:16:28.556 app[4d89440be57587] nrt [info] INFO [fly api proxy] listening at /.fly/api

2023-08-30T23:16:28.559 app[4d89440be57587] nrt [info] 2023/08/30 23:16:28 listening on [fdaa:0:6f3f:a7b:d86c:69d9:3c7c:2]:22 (DNS: [fdaa::3]:53)

2023-08-30T23:16:29.107 app[4d89440be57587] nrt [info] yarn run v1.22.19

2023-08-30T23:16:29.167 app[4d89440be57587] nrt [info] $ npm-run-all check-db update-tracker start-server

2023-08-30T23:16:29.866 app[4d89440be57587] nrt [info] $ node scripts/check-db.js

2023-08-30T23:16:29.996 app[4d89440be57587] nrt [info] ✓ DATABASE_URL is defined.

2023-08-30T23:16:30.209 app[4d89440be57587] nrt [info] ✓ Database connection successful.

2023-08-30T23:16:30.314 app[4d89440be57587] nrt [info] ✓ Database version check successful.

2023-08-30T23:16:31.507 app[4d89440be57587] nrt [info] Prisma schema loaded from prisma/schema.prisma

2023-08-30T23:16:31.507 app[4d89440be57587] nrt [info] Datasource "db": PostgreSQL database "postgres", schema "public" at "db.xxxxxx.supabase.co:6543"

2023-08-30T23:16:31.507 app[4d89440be57587] nrt [info] 3 migrations found in prisma/migrations

2023-08-30T23:16:31.507 app[4d89440be57587] nrt [info] No pending migrations to apply.

2023-08-30T23:16:31.507 app[4d89440be57587] nrt [info] ✓ Database is up to date.

2023-08-30T23:16:31.752 app[4d89440be57587] nrt [info] $ node scripts/update-tracker.js

2023-08-30T23:16:31.813 app[4d89440be57587] nrt [info] Updated tracker endpoint: /api/59qrTtdFFrV.

2023-08-30T23:16:32.096 app[4d89440be57587] nrt [info] $ node server.js

2023-08-30T23:16:32.543 app[4d89440be57587] nrt [info] - ready started server on 0.0.0.0:8080, url: http://localhost:8080

2.5.0

2023-08-30T23:18:44.427 runner[4d89440be57587] nrt [info] Pulling container image ghcr.io/umami-software/umami@sha256:5fc95115445ff5c5a16f86637f743b0b184fc9f4995381d75299ed92fe22328b

2023-08-30T23:18:45.132 runner[4d89440be57587] nrt [info] Successfully prepared image ghcr.io/umami-software/umami@sha256:5fc95115445ff5c5a16f86637f743b0b184fc9f4995381d75299ed92fe22328b (705.330921ms)

2023-08-30T23:18:45.475 runner[4d89440be57587] nrt [info] Configuring firecracker

2023-08-30T23:18:45.658 app[4d89440be57587] nrt [info] INFO Sending signal SIGINT to main child process w/ PID 265

2023-08-30T23:18:45.732 app[4d89440be57587] nrt [info] INFO Main child exited with signal (with signal 'SIGINT', core dumped? false)

2023-08-30T23:18:45.732 app[4d89440be57587] nrt [info] INFO Starting clean up.

2023-08-30T23:18:45.742 app[4d89440be57587] nrt [info] WARN hallpass exited, pid: 266, status: signal: 15 (SIGTERM)

2023-08-30T23:18:45.748 app[4d89440be57587] nrt [info] 2023/08/30 23:18:45 listening on [fdaa:0:6f3f:a7b:d86c:69d9:3c7c:2]:22 (DNS: [fdaa::3]:53)

2023-08-30T23:18:46.735 app[4d89440be57587] nrt [info] [ 138.518250] reboot: Restarting system

2023-08-30T23:18:47.214 app[4d89440be57587] nrt [info] [ 0.039665] PCI: Fatal: No config space access function found

2023-08-30T23:18:47.431 app[4d89440be57587] nrt [info] INFO Starting init (commit: 5293a085)...

2023-08-30T23:18:47.495 app[4d89440be57587] nrt [info] INFO Preparing to run: `docker-entrypoint.sh yarn start-docker` as nextjs

2023-08-30T23:18:47.506 app[4d89440be57587] nrt [info] INFO [fly api proxy] listening at /.fly/api

2023-08-30T23:18:47.508 app[4d89440be57587] nrt [info] 2023/08/30 23:18:47 listening on [fdaa:0:6f3f:a7b:d86c:69d9:3c7c:2]:22 (DNS: [fdaa::3]:53)

2023-08-30T23:18:48.045 app[4d89440be57587] nrt [info] yarn run v1.22.19

2023-08-30T23:18:48.096 app[4d89440be57587] nrt [info] $ npm-run-all check-db update-tracker start-server

2023-08-30T23:18:48.760 app[4d89440be57587] nrt [info] $ node scripts/check-db.js

2023-08-30T23:18:48.886 app[4d89440be57587] nrt [info] ✓ DATABASE_URL is defined.

2023-08-30T23:18:49.047 app[4d89440be57587] nrt [info] ✓ Database connection successful.

2023-08-30T23:18:49.141 app[4d89440be57587] nrt [info] ✓ Database version check successful.

2023-08-30T23:18:50.222 app[4d89440be57587] nrt [info] Prisma schema loaded from prisma/schema.prisma

2023-08-30T23:18:50.222 app[4d89440be57587] nrt [info] Datasource "db": PostgreSQL database "postgres", schema "public" at "db.xxx.supabase.co:6543"

2023-08-30T23:18:50.222 app[4d89440be57587] nrt [info] 3 migrations found in prisma/migrations

2023-08-30T23:18:50.222 app[4d89440be57587] nrt [info] No pending migrations to apply.

2023-08-30T23:18:50.222 app[4d89440be57587] nrt [info] ✓ Database is up to date.

2023-08-30T23:18:50.486 app[4d89440be57587] nrt [info] $ node scripts/update-tracker.js

2023-08-30T23:18:50.547 app[4d89440be57587] nrt [info] Updated tracker endpoint: /api/59qrTtdFFrV.

2023-08-30T23:18:50.815 app[4d89440be57587] nrt [info] $ node server.js

2023-08-30T23:18:51.265 app[4d89440be57587] nrt [info] Listening on port 8080 url: http://0.0.0.0:8080

2.5 and 2.6 environment variables are the same

aaro-n commented 1 year ago

Environment variables:

  APP_SECRET = "xxxxxx"
  CLIENT_IP_HEADER = "x-forwarded-for"
  COLLECT_API_ENDPOINT = "/api/59qrTtdFFrV"
  DATABASE_URL = "postgres://postgres:xxxx@db.zzzzzz.supabase.co:6543/postgres?pgbouncer=true"
  DISABLE_UPDATES = "1"
  FORCE_SSL = "1"
  PORT = "8080"
  TRACKER_SCRIPT_NAME = "PGmXAF3tDjvN9"
  HOSTNAME = "0.0.0.0"

  DEFAULT_LOCALE = "zh-CN"
mikecao commented 1 year ago

Fixed in v2.6.2.

aaro-n commented 1 year ago

The 2.6.2 version has fixed the problem and the problem is closed