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
Add better assets compression to CE (#4476)
ruslandoga6c7f123d2c39
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ae0f96901a..212de3ab90 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -26,7 +26,6 @@ All notable changes to this project will be documented in this file.### Changed- Support Unix sockets in `DATABASE_URL` plausible/analytics#4202-- Realtime and hourly graphs now show visits lasting their whole duration instead when specific events occur- Increase hourly request limit for API keys in CE from 600 to 1000000 (practically removing the limit) plausible/analytics#4200- Make TCP connections try IPv6 first with IPv4 fallback in CE plausible/analytics#4245@@ -37,6 +36,7 @@ All notable changes to this project will be documented in this file.- `DATABASE_CACERTFILE` now forces TLS for PostgreSQL connections, so you don't need to add `?ssl=true` in `DATABASE_URL`- Change auth session cookies to token-based ones with server-side expiration management.- Improve Google error messages in CE plausible/analytics#4485+- Better compress static assets in CE plausible/analytics#4476### Fixeddiff --git a/Dockerfile b/Dockerfileindex 602fcfdbec..344a128228 100644--- a/Dockerfile+++ b/Dockerfile@@ -20,7 +20,7 @@ RUN mkdir /appWORKDIR /app# install build dependencies-RUN apk add --no-cache git nodejs yarn python3 npm ca-certificates wget gnupg make gcc libc-dev && \+RUN apk add --no-cache git nodejs yarn python3 npm ca-certificates wget gnupg make gcc libc-dev brotli && \npm install npm@latest -gCOPY mix.exs ./diff --git a/config/ce.exs b/config/ce.exsindex ff99c2fed0..6ebd95e0e3 100644--- a/config/ce.exs+++ b/config/ce.exs@@ -2,6 +2,12 @@ import Configimport_config "prod.exs"+config :phoenix,+ static_compressors: [+ PhoenixBakery.Gzip,+ PhoenixBakery.Brotli+ ]+config :esbuild,default: [args:diff --git a/lib/plausible_web/endpoint.ex b/lib/plausible_web/endpoint.exindex 7721b75668..bee4207b54 100644--- a/lib/plausible_web/endpoint.ex+++ b/lib/plausible_web/endpoint.ex@@ -43,11 +43,16 @@ defmodule PlausibleWeb.Endpoint dostatic_paths ++ ["robots.txt"]end- plug(Plug.Static,- at: "/",- from: :plausible,- gzip: false,- only: static_paths+ static_compression =+ if Plausible.ce?() do+ [brotli: true, gzip: true]+ else+ [gzip: false]+ end++ plug(+ Plug.Static,+ [at: "/", from: :plausible, only: static_paths] ++ static_compression)on_ee dodiff --git a/mix.exs b/mix.exsindex e03ef6da5f..ebe3ad6b68 100644--- a/mix.exs+++ b/mix.exs@@ -146,7 +146,8 @@ defmodule Plausible.MixProject do{:req, "~> 0.5.0"},{:happy_tcp, github: "ruslandoga/happy_tcp", only: [:ce, :ce_dev, :ce_test]},{:ex_json_schema, "~> 0.10.2"},- {:odgn_json_pointer, "~> 3.0.1"}+ {:odgn_json_pointer, "~> 3.0.1"},+ {:phoenix_bakery, "~> 0.1.2", only: [:ce, :ce_dev, :ce_test]}]enddiff --git a/mix.lock b/mix.lockindex b4bcbc9ba5..0d60746b62 100644--- a/mix.lock+++ b/mix.lock@@ -111,6 +111,7 @@"paginator": {:git, "https://github.com/duffelhq/paginator.git", "3508d6ad77a95ac1faf15d5fd7f959fab3e17da2", []},"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},"phoenix": {:hex, :phoenix, "1.7.10", "02189140a61b2ce85bb633a9b6fd02dff705a5f1596869547aeb2b2b95edd729", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "cf784932e010fd736d656d7fead6a584a4498efefe5b8227e9f383bf15bb79d0"},+ "phoenix_bakery": {:hex, :phoenix_bakery, "0.1.2", "ca57673caea1a98f1cc763f94032796a015774d27eaa3ce5feef172195470452", [:mix], [{:brotli, "~> 0.3.0", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "45cc8cecc5c3002b922447c16389761718c07c360432328b04680034e893ea5b"},"phoenix_ecto": {:hex, :phoenix_ecto, "4.4.3", "86e9878f833829c3f66da03d75254c155d91d72a201eb56ae83482328dc7ca93", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "d36c401206f3011fefd63d04e8ef626ec8791975d9d107f9a0817d426f61ac07"},"phoenix_html": {:hex, :phoenix_html, "3.3.4", "42a09fc443bbc1da37e372a5c8e6755d046f22b9b11343bf885067357da21cb3", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "0249d3abec3714aff3415e7ee3d9786cb325be3151e6c4b3021502c585bf53fb"},"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.4.1", "2aff698f5e47369decde4357ba91fc9c37c6487a512b41732818f2204a8ef1d3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "9bffb834e7ddf08467fe54ae58b5785507aaba6255568ae22b4d46e2bb3615ab"},