Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Optimization: only request top sources if notification is to be sent
Uku Taht42d70bf4ea37
diff --git a/.backup-env b/.backup-envnew file mode 100644index 0000000000..44eb6e496a--- /dev/null+++ b/.backup-env@@ -0,0 +1,6 @@+CLICKHOUSE_PASSWORD=+S3_BUCKET=plausible-backups-test+S3_ACCESS_KEY=3KBJJYJN29XWX0R8D59M+S3_SECRET_KEY=WVIqTPPu76ZDMW7XlLeAVgU0FkNZeCwzapBN9slq+S3_ENDPOINT=s3.eu-central-1.wasabisys.com+REMOTE_STORAGE=s3diff --git a/backup-config.yml b/backup-config.ymlnew file mode 100644index 0000000000..e525c88aa3--- /dev/null+++ b/backup-config.yml@@ -0,0 +1,10 @@+general:+ remote_storage: s3+clickhouse:+ username: default+ password: ""+s3:+ access_key: "3KBJJYJN29XWX0R8D59M"+ secret_key: "WVIqTPPu76ZDMW7XlLeAVgU0FkNZeCwzapBN9slq"+ bucket: "plausible-backups-test"+ endpoint: "s3.eu-central-1.wasabisys.com"diff --git a/lib/workers/spike_notifier.ex b/lib/workers/spike_notifier.exindex bac715adf0..4582536156 100644--- a/lib/workers/spike_notifier.ex+++ b/lib/workers/spike_notifier.ex@@ -21,23 +21,24 @@ defmodule Plausible.Workers.SpikeNotifier dofor notification <- notifications doquery = Query.from(notification.site.timezone, %{"period" => "realtime"})current_visitors = clickhouse.current_visitors(notification.site, query)- sources = clickhouse.top_sources(notification.site, query, 3, 1, true)- notify(notification, current_visitors, sources)++ if current_visitors >= notification.threshold do+ sources = clickhouse.top_sources(notification.site, query, 3, 1, true)+ notify(notification, current_visitors, sources)+ endend:okenddef notify(notification, current_visitors, sources) do- if current_visitors >= notification.threshold do- for recipient <- notification.recipients do- send_notification(recipient, notification.site, current_visitors, sources)- end-- notification- |> SpikeNotification.was_sent()- |> Repo.update()+ for recipient <- notification.recipients do+ send_notification(recipient, notification.site, current_visitors, sources)end++ notification+ |> SpikeNotification.was_sent()+ |> Repo.update()enddefp send_notification(recipient, site, current_visitors, sources) dodiff --git a/pluralkit.me.events.ch b/pluralkit.me.events.chnew file mode 100644index 0000000000..438b6558d2Binary files /dev/null and b/pluralkit.me.events.ch differdiff --git a/pluralkit.me.sessions.ch b/pluralkit.me.sessions.chnew file mode 100644index 0000000000..01c4c6662dBinary files /dev/null and b/pluralkit.me.sessions.ch differ