analytics/mix.exs
hq1 c81cb16933
Snippet integration verification (#4106)
* Allow running browserless.io locally

* Compile tailwind classes based on extra/ too

* Add browserless runtime configuration

* Ignore verification events on ingestion

* Improve extracting HTML text in tests

* Update dependencies

- Floki will be used on production to parse site contents
- Req will be used to handle redundant stuff like retrying etc.

* Add shuttle SVG to generic components

Later on we'll use it to indicate verification errors

* Connect live socket & allow skipping awaiting the first pageview

* Connect live socket in general settings

* Implement verification checks & diagnostics

* Stub remote services with Req for testing

* Change snippet screen copy

* Update tracker script, so that:

1. headless browsers aren't ignored if `window.__plausible` is defined
2. callback optionally supplies the event response HTTP status

This will be later used to check whether the server acknowledged
the verification event.

* Implement LiveView verification UI

* Embed the verification UIs into settings and onboarding

* Implement browserless puppeteer verification script

It:
 - tries to visit the site
 - defines window.__plausible, so the tracker doesn't ignore test events
 - sends a verification event and instruments the callback
 - awaits the callback to fire and returns the result

* Improve diagnostics for CSP

Only report CSP error if the snippet is already found

* Put verification behind a feature flag/env setting

* Contact Us hint only for Enterprise Edition

* For headless code, use JS context instead of EEx interpolation

* Update diagnostics test with WordPress scenarios

* Shorten exception/throw interception

* Rename test

* Tidy up

* Bust URL always on headless check

* Update moduledoc

* Detect official Plausible WordPress Plugin

and act accordingly on diagnostics interoperation

* Stop using 'rating' in favour of 'interpretation'

* Only report CSP error if no proxy is likely

* Update CHANGELOG

* Allow event-* attributes on snippet elements

* Improve naive GTM detection, not to confuse it with GA4

* Update lib/plausible/verification.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Update test/plausible/site/verification/checks_test.exs

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* s/perform_wrapped/perform_safe

* Update lib/plausible/verification/checks/installation.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Remove garbage

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-05-23 15:00:50 +02:00

191 lines
6.1 KiB
Elixir

defmodule Plausible.MixProject do
use Mix.Project
def project do
[
name: "Plausible",
source_url: "https://github.com/plausible/analytics",
docs: docs(),
app: :plausible,
version: System.get_env("APP_VERSION", "0.0.1"),
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() in [:prod, :ce],
aliases: aliases(),
deps: deps(),
test_coverage: [
tool: ExCoveralls
],
releases: [
plausible: [
include_executables_for: [:unix],
config_providers: [
{Config.Reader,
path: {:system, "RELEASE_ROOT", "/import_extra_config.exs"}, imports: []}
]
]
],
dialyzer: [
plt_file: {:no_warn, "priv/plts/dialyzer.plt"},
plt_add_apps: [:mix, :ex_unit]
]
]
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
[
mod: {Plausible.Application, []},
extra_applications: [
:logger,
:runtime_tools,
:tls_certificate_check,
:opentelemetry_exporter
]
]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(env) when env in [:test, :dev],
do: ["lib", "test/support", "extra/lib"]
defp elixirc_paths(env) when env in [:ce_test, :ce_dev],
do: ["lib", "test/support"]
defp elixirc_paths(:ce), do: ["lib"]
defp elixirc_paths(_), do: ["lib", "extra/lib"]
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[
{:bamboo, "~> 2.3", override: true},
{:bamboo_phoenix, "~> 1.0.0"},
{:bamboo_postmark, git: "https://github.com/plausible/bamboo_postmark.git", branch: "main"},
{:bamboo_smtp, "~> 4.1"},
{:bamboo_mua, "~> 0.1.4"},
{:bcrypt_elixir, "~> 3.0"},
{:bypass, "~> 2.1", only: [:dev, :test, :ce_test]},
{:ecto_ch, "~> 0.3.5"},
{:cloak, "~> 1.1"},
{:cloak_ecto, "~> 1.2"},
{:combination, "~> 0.0.3"},
{:cors_plug, "~> 3.0"},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:csv, "~> 2.3"},
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
{:double, "~> 0.8.0", only: [:test, :ce_test]},
{:ecto, "~> 3.11.0"},
{:ecto_sql, "~> 3.11.0"},
{:envy, "~> 1.1.1"},
{:eqrcode, "~> 0.1.10"},
{:ex_machina, "~> 2.3", only: [:dev, :test, :ce_dev, :ce_test]},
{:excoveralls, "~> 0.10", only: :test},
{:finch, "~> 0.17.0"},
{:floki, "~> 0.35.0"},
{:fun_with_flags, "~> 1.11.0"},
{:fun_with_flags_ui, "~> 1.0"},
{:locus, "~> 2.3"},
{:gen_cycle, "~> 1.0.4"},
{:hackney, "~> 1.8"},
{:jason, "~> 1.3"},
{:kaffy, "~> 0.10.2", only: [:dev, :test, :staging, :prod]},
{:location, git: "https://github.com/plausible/location.git"},
{:mox, "~> 1.0", only: [:test, :ce_test]},
{:nanoid, "~> 2.1.0"},
{:nimble_totp, "~> 1.0"},
{:oban, "~> 2.17.0"},
{:observer_cli, "~> 1.7"},
{:opentelemetry, "~> 1.1"},
{:opentelemetry_api, "~> 1.1"},
{:opentelemetry_ecto, "~> 1.1.0"},
{:opentelemetry_exporter, "~> 1.6.0"},
{:opentelemetry_phoenix, "~> 1.0"},
{:opentelemetry_oban, "~> 1.0.0"},
{:phoenix, "~> 1.7.0"},
{:phoenix_view, "~> 2.0"},
{:phoenix_ecto, "~> 4.0"},
{:phoenix_html, "~> 3.3", override: true},
{:phoenix_live_reload, "~> 1.2", only: [:dev, :ce_dev]},
{:phoenix_pubsub, "~> 2.0"},
{:phoenix_live_view, "~> 0.18"},
{:php_serializer, "~> 2.0"},
{:plug, "~> 1.13", override: true},
{:plug_cowboy, "~> 2.3"},
{:postgrex, "~> 0.17.0"},
{:prom_ex, "~> 1.8"},
{:public_suffix, git: "https://github.com/axelson/publicsuffix-elixir"},
{:ref_inspector, "~> 2.0"},
{:referrer_blocklist, git: "https://github.com/plausible/referrer-blocklist.git"},
{:sentry, "~> 10.0"},
{:siphash, "~> 3.2"},
{:timex, "~> 3.7"},
{:ua_inspector, "~> 3.0"},
{:ex_doc, "~> 0.28", only: :dev, runtime: false},
{:ex_money, "~> 5.12"},
{:mjml_eex, "~> 0.9.0"},
{:mjml, "~> 1.5.0"},
{:heroicons, "~> 0.5.0"},
{:zxcvbn, git: "https://github.com/techgaun/zxcvbn-elixir.git"},
{:open_api_spex, "~> 3.18"},
{:joken, "~> 2.5"},
{:paginator, git: "https://github.com/duffelhq/paginator.git"},
{:scrivener_ecto, "~> 2.0"},
{:esbuild, "~> 0.7", runtime: Mix.env() in [:dev, :ce_dev]},
{:tailwind, "~> 0.2.0", runtime: Mix.env() in [:dev, :ce_dev]},
{:ex_json_logger, "~> 1.4.0"},
{:ecto_network, "~> 1.5.0"},
{:ex_aws, "~> 2.5"},
{:ex_aws_s3, "~> 2.5"},
{:sweet_xml, "~> 0.7.4"},
{:zstream, "~> 0.6.4"},
{:con_cache, "~> 1.1.0"},
{:req, "~> 0.4.14"}
]
end
defp aliases do
[
setup: ["deps.get", "ecto.setup", "assets.setup", "assets.build"],
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate", "test", "clean_clickhouse"],
"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
"assets.build": [
"tailwind default",
"esbuild default"
],
"assets.deploy": ["tailwind default --minify", "esbuild default --minify", "phx.digest"]
]
end
defp docs do
[
main: "readme",
logo: "priv/static/images/ee/favicon-32x32.png",
extras:
Path.wildcard("guides/**/*.md") ++
[
"README.md": [filename: "readme", title: "Introduction"],
"CONTRIBUTING.md": [filename: "contributing", title: "Contributing"]
],
groups_for_extras: [
Features: Path.wildcard("guides/features/*.md")
],
before_closing_body_tag: fn
:html ->
"""
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>mermaid.initialize({startOnLoad: true})</script>
"""
_ ->
""
end
]
end
end