mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 18:48:06 +03:00
517d4db262
* first commit with test and compile job Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * adding 'prepare' stage Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * updated ci script to include "test" compile phase Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * adding environment variables for connecting to postgresql Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * updated ci config for postgres Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * using non-alpine version of elixir Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * re-using the 'compile' artifacts and added explict env variables for testing Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * removing redundant deps fetching from common code Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * formatting using mix.format -- beware no-code changes! Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * added release config Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * adding consistent env variable for Database Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * more cleaning up of environment variables Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Adding releases config for enabling releases Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * cleaning up env configs Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Cleaned up config and prepared config for releases Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * updated CI script with new config for test Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Added Dockerfile for creating production docker image Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Adding "docker" build job yay! Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * using non-slim version of debian and installing webpack Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Adding overlays for migrations on releases Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * restricting the docker built to master branch only Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * typo fix Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * adding "Hosting.md" to explain hosting instructions Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * removed the default comments Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Added documentation related to env variables * updated documentation and fixed typo Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * updated documentation * Bumping up elixir version as `overlays` are only supported in latest version read release notes: https://github.com/elixir-lang/elixir/releases/tag/v1.10.0 Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Adding tarball assembly during release Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * updated HOSTING.md Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Added support for db migration Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * minor corrections Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * initializing admin user Admin user has been added in the "migration" phase. A default user is automatically created in the process. One can provide the related env variables, else a new one will be automatically created for you. Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Initial base domain update - phase#1 These changes are only meant for correct operating it under self-hosting. There are many other cosmetic changes, that require updates to email, site and other places where the original website and author is used. Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Using dedicated config variable `base_domain` instead Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * adding base_domain to releases config Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * removing the dedicated config "base_domain", relying on endpoint host Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Removed the usage of "Mix" in code! It is bad practice to use "mix" module inside the code as in actual release this module is unavailable. Replacing this with a config environment variable Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Added support for SMTP via Bamboo Smtp Adapter Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Capturing SMTP errors via Sentry Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Minor updates Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * Adding junit formatter -- useful for generating test reports Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * adding documentation for default user * Resolve "Gitlab Adoption: Add supported services in "Security & Compliance"" * bumping up the debian version to fix issues fixing some vulnerabilities identified by the scanning tools * More updates for self-hosting Changes in most of the places to suit self-hosting. Although, there are some which have been left-off. Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * quick-dirty-fix! * bumping up the db connect timeout Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * bumping up the db connect timeout Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * bumping up the db connect timeout Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * bumping up timeout - skipping MRs :-/ * removing restrictions on watching for changes this stuff isn't working * Update HOSTING.md * renamed the module name * reverting formatting-whitespace changes Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * reverting the name to release Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * adding docker-compose.yml and related instructions Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * using `plausible_url` instead of assuming `https` this is because, it is much to test in local dev machines and in most cases there's already a layer above which is capable for `https` termination and http -> https upgrade Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * WIP: merging changes from upstream Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * wip: more changes * Pushing in changes from upstream Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * changes to ci for testing Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * cleaning up and finishing clickhouse integration Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * updating readme with hosting details * removing deleted files from upstream * minor config adjustments Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * formatting changes Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * changing the connection strategy for clickhouse during release since clickhouse integration doesn't have an ecto support, we need to prepare the db _before_ the clickhouse migration. One workaround is to connect to a default db on init and then create a db Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * formatting * cleanup and added separated migration to setup * Big improvements to selfhosting - added ability for disabling - authentication completely - registration - landing page - formatting cleanups * Big improvements to selfhosting - added ability for disabling - authentication completely - registration - landing page - formatting cleanups * changing smtp auth to optional Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * removed stale templates and permanently removed landing page Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me> * removed stale templates and permanently removed landing page Signed-off-by: Chandra Tungathurthi <tckb@tgrthi.me>
156 lines
6.3 KiB
Elixir
156 lines
6.3 KiB
Elixir
defmodule PlausibleWeb.Router do
|
|
use PlausibleWeb, :router
|
|
use Plug.ErrorHandler
|
|
use Sentry.Plug
|
|
@two_weeks_in_seconds 60 * 60 * 24 * 14
|
|
|
|
pipeline :browser do
|
|
plug :accepts, ["html"]
|
|
plug :fetch_session
|
|
plug :fetch_flash
|
|
plug :put_secure_browser_headers
|
|
plug PlausibleWeb.SessionTimeoutPlug, timeout_after_seconds: @two_weeks_in_seconds
|
|
plug PlausibleWeb.AuthPlug
|
|
plug PlausibleWeb.LastSeenPlug
|
|
end
|
|
|
|
pipeline :csrf do
|
|
plug :protect_from_forgery
|
|
end
|
|
|
|
pipeline :api do
|
|
plug :accepts, ["json"]
|
|
plug :fetch_session
|
|
plug PlausibleWeb.AuthPlug
|
|
end
|
|
|
|
pipeline :stats_api do
|
|
plug :accepts, ["json"]
|
|
plug :fetch_session
|
|
end
|
|
|
|
if Application.get_env(:plausible, :environment) == "dev" do
|
|
forward "/sent-emails", Bamboo.SentEmailViewerPlug
|
|
end
|
|
|
|
get "/js/plausible.js", PlausibleWeb.TrackerController, :plausible
|
|
get "/js/analytics.js", PlausibleWeb.TrackerController, :plausible
|
|
get "/js/p.js", PlausibleWeb.TrackerController, :p
|
|
|
|
scope "/api/stats", PlausibleWeb.Api do
|
|
pipe_through :stats_api
|
|
|
|
get "/:domain/current-visitors", StatsController, :current_visitors
|
|
get "/:domain/main-graph", StatsController, :main_graph
|
|
get "/:domain/referrers", StatsController, :referrers
|
|
get "/:domain/goal/referrers", StatsController, :referrers_for_goal
|
|
get "/:domain/referrers/:referrer", StatsController, :referrer_drilldown
|
|
get "/:domain/goal/referrers/:referrer", StatsController, :referrer_drilldown_for_goal
|
|
get "/:domain/pages", StatsController, :pages
|
|
get "/:domain/countries", StatsController, :countries
|
|
get "/:domain/browsers", StatsController, :browsers
|
|
get "/:domain/operating-systems", StatsController, :operating_systems
|
|
get "/:domain/screen-sizes", StatsController, :screen_sizes
|
|
get "/:domain/conversions", StatsController, :conversions
|
|
end
|
|
|
|
scope "/api", PlausibleWeb do
|
|
pipe_through :api
|
|
|
|
post "/event", Api.ExternalController, :event
|
|
get "/error", Api.ExternalController, :error
|
|
|
|
post "/paddle/webhook", Api.PaddleController, :webhook
|
|
|
|
get "/:domain/status", Api.InternalController, :domain_status
|
|
end
|
|
|
|
scope "/", PlausibleWeb do
|
|
pipe_through :browser
|
|
|
|
get "/register", AuthController, :register_form
|
|
post "/register", AuthController, :register
|
|
get "/claim-activation", AuthController, :claim_activation_link
|
|
get "/login", AuthController, :login_form
|
|
post "/login", AuthController, :login
|
|
get "/password/request-reset", AuthController, :password_reset_request_form
|
|
post "/password/request-reset", AuthController, :password_reset_request
|
|
get "/password/reset", AuthController, :password_reset_form
|
|
post "/password/reset", AuthController, :password_reset
|
|
end
|
|
|
|
scope "/", PlausibleWeb do
|
|
pipe_through [:browser, :csrf]
|
|
|
|
get "/password", AuthController, :password_form
|
|
post "/password", AuthController, :set_password
|
|
post "/logout", AuthController, :logout
|
|
get "/settings", AuthController, :user_settings
|
|
put "/settings", AuthController, :save_settings
|
|
delete "/me", AuthController, :delete_me
|
|
|
|
get "/auth/google/callback", AuthController, :google_auth_callback
|
|
|
|
get "/", PageController, :index
|
|
|
|
get "/billing/change-plan", BillingController, :change_plan_form
|
|
get "/billing/change-plan/preview/:plan_id", BillingController, :change_plan_preview
|
|
post "/billing/change-plan/:new_plan_id", BillingController, :change_plan
|
|
get "/billing/upgrade", BillingController, :upgrade
|
|
get "/billing/success", BillingController, :success
|
|
|
|
get "/sites", SiteController, :index
|
|
get "/sites/new", SiteController, :new
|
|
post "/sites", SiteController, :create_site
|
|
post "/sites/:website/make-public", SiteController, :make_public
|
|
post "/sites/:website/make-private", SiteController, :make_private
|
|
post "/sites/:website/weekly-report/enable", SiteController, :enable_weekly_report
|
|
post "/sites/:website/weekly-report/disable", SiteController, :disable_weekly_report
|
|
post "/sites/:website/weekly-report/recipients", SiteController, :add_weekly_report_recipient
|
|
|
|
delete "/sites/:website/weekly-report/recipients/:recipient",
|
|
SiteController,
|
|
:remove_weekly_report_recipient
|
|
|
|
post "/sites/:website/monthly-report/enable", SiteController, :enable_monthly_report
|
|
post "/sites/:website/monthly-report/disable", SiteController, :disable_monthly_report
|
|
|
|
post "/sites/:website/monthly-report/recipients",
|
|
SiteController,
|
|
:add_monthly_report_recipient
|
|
|
|
delete "/sites/:website/monthly-report/recipients/:recipient",
|
|
SiteController,
|
|
:remove_monthly_report_recipient
|
|
|
|
get "/sites/:website/shared-links/new", SiteController, :new_shared_link
|
|
post "/sites/:website/shared-links", SiteController, :create_shared_link
|
|
delete "/sites/:website/shared-links/:slug", SiteController, :delete_shared_link
|
|
|
|
get "/sites/:website/custom-domains/new", SiteController, :new_custom_domain
|
|
get "/sites/:website/custom-domains/dns-setup", SiteController, :custom_domain_dns_setup
|
|
get "/sites/:website/custom-domains/snippet", SiteController, :custom_domain_snippet
|
|
post "/sites/:website/custom-domains", SiteController, :add_custom_domain
|
|
delete "/sites/:website/custom-domains/:id", SiteController, :delete_custom_domain
|
|
|
|
get "/sites/:website/weekly-report/unsubscribe", UnsubscribeController, :weekly_report
|
|
get "/sites/:website/monthly-report/unsubscribe", UnsubscribeController, :monthly_report
|
|
|
|
get "/:website/snippet", SiteController, :add_snippet
|
|
get "/:website/settings", SiteController, :settings
|
|
get "/:website/goals", SiteController, :goals
|
|
get "/:website/goals/new", SiteController, :new_goal
|
|
post "/:website/goals", SiteController, :create_goal
|
|
delete "/:website/goals/:id", SiteController, :delete_goal
|
|
put "/:website/settings", SiteController, :update_settings
|
|
put "/:website/settings/google", SiteController, :update_google_auth
|
|
delete "/:website/settings/google", SiteController, :delete_google_auth
|
|
delete "/:website", SiteController, :delete_site
|
|
|
|
get "/share/:slug", StatsController, :shared_link
|
|
post "/share/:slug/authenticate", StatsController, :authenticate_shared_link
|
|
get "/:domain/visitors.csv", StatsController, :csv_export
|
|
get "/:domain/*path", StatsController, :stats
|
|
end
|
|
end
|