2019-09-02 14:29:19 +03:00
|
|
|
defmodule PlausibleWeb.Router do
|
|
|
|
use PlausibleWeb, :router
|
|
|
|
@two_weeks_in_seconds 60 * 60 * 24 * 14
|
|
|
|
|
|
|
|
pipeline :browser do
|
|
|
|
plug :accepts, ["html"]
|
2020-08-11 11:04:26 +03:00
|
|
|
plug PlausibleWeb.Firewall
|
2019-09-02 14:29:19 +03:00
|
|
|
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
|
|
|
|
|
2021-03-02 12:15:43 +03:00
|
|
|
pipeline :shared_link do
|
|
|
|
plug :accepts, ["html"]
|
|
|
|
plug :put_secure_browser_headers
|
|
|
|
end
|
|
|
|
|
2020-04-14 14:04:35 +03:00
|
|
|
pipeline :csrf do
|
|
|
|
plug :protect_from_forgery
|
|
|
|
end
|
|
|
|
|
2019-09-02 14:29:19 +03:00
|
|
|
pipeline :api do
|
2019-12-03 12:42:17 +03:00
|
|
|
plug :accepts, ["json"]
|
2020-08-11 11:04:26 +03:00
|
|
|
plug PlausibleWeb.Firewall
|
2019-09-02 14:29:19 +03:00
|
|
|
plug :fetch_session
|
|
|
|
plug PlausibleWeb.AuthPlug
|
|
|
|
end
|
|
|
|
|
2021-02-05 12:23:30 +03:00
|
|
|
pipeline :internal_stats_api do
|
2019-11-19 07:30:42 +03:00
|
|
|
plug :accepts, ["json"]
|
2020-08-11 11:04:26 +03:00
|
|
|
plug PlausibleWeb.Firewall
|
2019-11-19 07:30:42 +03:00
|
|
|
plug :fetch_session
|
2021-02-05 12:23:30 +03:00
|
|
|
plug PlausibleWeb.AuthorizeStatsPlug
|
|
|
|
end
|
|
|
|
|
2021-04-09 10:30:51 +03:00
|
|
|
pipeline :public_api do
|
2021-02-05 12:23:30 +03:00
|
|
|
plug :accepts, ["json"]
|
|
|
|
plug PlausibleWeb.Firewall
|
2019-11-19 07:30:42 +03:00
|
|
|
end
|
|
|
|
|
2020-05-26 16:09:34 +03:00
|
|
|
if Application.get_env(:plausible, :environment) == "dev" do
|
2019-09-02 14:29:19 +03:00
|
|
|
forward "/sent-emails", Bamboo.SentEmailViewerPlug
|
|
|
|
end
|
|
|
|
|
2021-01-07 11:42:45 +03:00
|
|
|
use Kaffy.Routes, scope: "/crm", pipe_through: [PlausibleWeb.CRMAuthPlug]
|
|
|
|
|
2019-11-19 07:30:42 +03:00
|
|
|
scope "/api/stats", PlausibleWeb.Api do
|
2021-02-05 12:23:30 +03:00
|
|
|
pipe_through :internal_stats_api
|
2019-11-19 07:30:42 +03:00
|
|
|
|
|
|
|
get "/:domain/current-visitors", StatsController, :current_visitors
|
|
|
|
get "/:domain/main-graph", StatsController, :main_graph
|
2020-09-28 11:29:24 +03:00
|
|
|
get "/:domain/sources", StatsController, :sources
|
|
|
|
get "/:domain/utm_mediums", StatsController, :utm_mediums
|
|
|
|
get "/:domain/utm_sources", StatsController, :utm_sources
|
|
|
|
get "/:domain/utm_campaigns", StatsController, :utm_campaigns
|
2019-11-19 07:30:42 +03:00
|
|
|
get "/:domain/referrers/:referrer", StatsController, :referrer_drilldown
|
2020-01-16 16:40:06 +03:00
|
|
|
get "/:domain/goal/referrers/:referrer", StatsController, :referrer_drilldown_for_goal
|
2019-11-19 07:30:42 +03:00
|
|
|
get "/:domain/pages", StatsController, :pages
|
2020-07-30 11:18:28 +03:00
|
|
|
get "/:domain/entry-pages", StatsController, :entry_pages
|
Adds entry and exit pages to Top Pages module (#712)
* Initial Pass
* Adds support for page visits counting by referrer
* Includes goal selection in entry and exit computation
* Adds goal-based entry and exit page stats, formatting, code cleanup
* Changelog
* Format
* Exit rate, visit duration, updated tests
* I keep forgetting to format :/
* Tests, last time
* Fixes double counting, exit rate >100%, relevant tests
* Fixes exit pages on filter and goal states
* Adds entry and exit filters, fixes various bugs
* Fixes discussed issues
* Format
* Fixes impossible case in tests
Originally, there were only 2 pageviews for `test-site.com`,`/` on `2019-01-01`, but that doesn't make sense when there were 3 sessions that exited on the same site/date.
* Format
* Removes boolean function parameter in favor of separate function
* Adds support for queries that use `page` filter as `entry-page`
* Format
* Makes loader/title interaction in sources report consistent
2021-02-26 12:02:37 +03:00
|
|
|
get "/:domain/exit-pages", StatsController, :exit_pages
|
2019-11-19 07:30:42 +03:00
|
|
|
get "/:domain/countries", StatsController, :countries
|
|
|
|
get "/:domain/browsers", StatsController, :browsers
|
2020-11-10 16:18:59 +03:00
|
|
|
get "/:domain/browser-versions", StatsController, :browser_versions
|
2019-11-19 07:30:42 +03:00
|
|
|
get "/:domain/operating-systems", StatsController, :operating_systems
|
2020-11-10 16:18:59 +03:00
|
|
|
get "/:domain/operating-system-versions", StatsController, :operating_system_versions
|
2019-11-19 07:30:42 +03:00
|
|
|
get "/:domain/screen-sizes", StatsController, :screen_sizes
|
|
|
|
get "/:domain/conversions", StatsController, :conversions
|
2020-10-30 11:49:41 +03:00
|
|
|
get "/:domain/property/:prop_name", StatsController, :prop_breakdown
|
2019-11-19 07:30:42 +03:00
|
|
|
end
|
|
|
|
|
2021-02-05 12:23:30 +03:00
|
|
|
scope "/api/v1/stats", PlausibleWeb.Api do
|
2021-04-09 10:30:51 +03:00
|
|
|
pipe_through [:public_api, PlausibleWeb.AuthorizeStatsApiPlug]
|
2021-02-05 12:23:30 +03:00
|
|
|
|
|
|
|
get "/realtime/visitors", ExternalStatsController, :realtime_visitors
|
|
|
|
get "/aggregate", ExternalStatsController, :aggregate
|
2021-02-22 11:21:25 +03:00
|
|
|
get "/breakdown", ExternalStatsController, :breakdown
|
2021-02-05 12:23:30 +03:00
|
|
|
get "/timeseries", ExternalStatsController, :timeseries
|
|
|
|
end
|
|
|
|
|
2021-04-09 10:30:51 +03:00
|
|
|
scope "/api/v1/sites", PlausibleWeb.Api do
|
|
|
|
pipe_through [:public_api, PlausibleWeb.AuthorizeSitesApiPlug]
|
|
|
|
|
|
|
|
post "/", ExternalSitesController, :create_site
|
2021-04-15 11:38:44 +03:00
|
|
|
put "/shared-links", ExternalSitesController, :find_or_create_shared_link
|
2021-04-09 10:30:51 +03:00
|
|
|
end
|
|
|
|
|
2019-09-02 14:29:19 +03:00
|
|
|
scope "/api", PlausibleWeb do
|
|
|
|
pipe_through :api
|
|
|
|
|
2019-10-31 06:49:46 +03:00
|
|
|
post "/event", Api.ExternalController, :event
|
2019-09-02 14:29:19 +03:00
|
|
|
get "/error", Api.ExternalController, :error
|
2020-07-20 10:34:35 +03:00
|
|
|
get "/health", Api.ExternalController, :health
|
2019-09-02 14:29:19 +03:00
|
|
|
|
|
|
|
post "/paddle/webhook", Api.PaddleController, :webhook
|
|
|
|
|
|
|
|
get "/:domain/status", Api.InternalController, :domain_status
|
2020-08-13 13:45:18 +03:00
|
|
|
get "/sites", Api.InternalController, :sites
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
scope "/", PlausibleWeb do
|
2021-04-01 10:43:32 +03:00
|
|
|
pipe_through [:browser, :csrf]
|
2019-09-02 14:29:19 +03:00
|
|
|
|
|
|
|
get "/register", AuthController, :register_form
|
|
|
|
post "/register", AuthController, :register
|
2020-12-15 12:30:45 +03:00
|
|
|
get "/activate", AuthController, :activate_form
|
|
|
|
post "/activate/request-code", AuthController, :request_activation_code
|
|
|
|
post "/activate", AuthController, :activate
|
2019-09-02 14:29:19 +03:00
|
|
|
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
|
2020-04-14 14:04:35 +03:00
|
|
|
end
|
|
|
|
|
2021-03-02 12:15:43 +03:00
|
|
|
scope "/", PlausibleWeb do
|
|
|
|
pipe_through [:shared_link]
|
|
|
|
|
|
|
|
get "/share/:slug", StatsController, :shared_link
|
|
|
|
post "/share/:slug/authenticate", StatsController, :authenticate_shared_link
|
|
|
|
end
|
|
|
|
|
2020-04-14 14:04:35 +03:00
|
|
|
scope "/", PlausibleWeb do
|
|
|
|
pipe_through [:browser, :csrf]
|
|
|
|
|
2019-09-02 14:29:19 +03:00
|
|
|
get "/password", AuthController, :password_form
|
|
|
|
post "/password", AuthController, :set_password
|
2021-03-31 16:48:56 +03:00
|
|
|
get "/logout", AuthController, :logout
|
2019-09-02 14:29:19 +03:00
|
|
|
get "/settings", AuthController, :user_settings
|
|
|
|
put "/settings", AuthController, :save_settings
|
|
|
|
delete "/me", AuthController, :delete_me
|
2021-02-05 12:23:30 +03:00
|
|
|
get "/settings/api-keys/new", AuthController, :new_api_key
|
|
|
|
post "/settings/api-keys", AuthController, :create_api_key
|
|
|
|
delete "/settings/api-keys/:id", AuthController, :delete_api_key
|
2019-09-02 14:29:19 +03:00
|
|
|
|
|
|
|
get "/auth/google/callback", AuthController, :google_auth_callback
|
|
|
|
|
|
|
|
get "/", PageController, :index
|
|
|
|
|
|
|
|
get "/billing/change-plan", BillingController, :change_plan_form
|
2020-04-21 14:11:38 +03:00
|
|
|
get "/billing/change-plan/preview/:plan_id", BillingController, :change_plan_preview
|
|
|
|
post "/billing/change-plan/:new_plan_id", BillingController, :change_plan
|
2019-09-02 14:29:19 +03:00
|
|
|
get "/billing/upgrade", BillingController, :upgrade
|
2021-03-16 13:03:50 +03:00
|
|
|
get "/billing/upgrade/:plan_id", BillingController, :upgrade_to_plan
|
2020-08-18 12:48:01 +03:00
|
|
|
get "/billing/upgrade-success", BillingController, :upgrade_success
|
2019-09-02 14:29:19 +03:00
|
|
|
|
2020-03-31 16:16:21 +03:00
|
|
|
get "/sites", SiteController, :index
|
2019-09-02 14:29:19 +03:00
|
|
|
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
|
2019-09-09 14:37:57 +03:00
|
|
|
post "/sites/:website/weekly-report/enable", SiteController, :enable_weekly_report
|
|
|
|
post "/sites/:website/weekly-report/disable", SiteController, :disable_weekly_report
|
2020-01-22 12:16:53 +03:00
|
|
|
post "/sites/:website/weekly-report/recipients", SiteController, :add_weekly_report_recipient
|
2020-06-08 10:35:13 +03:00
|
|
|
|
|
|
|
delete "/sites/:website/weekly-report/recipients/:recipient",
|
|
|
|
SiteController,
|
|
|
|
:remove_weekly_report_recipient
|
|
|
|
|
2019-09-09 14:37:57 +03:00
|
|
|
post "/sites/:website/monthly-report/enable", SiteController, :enable_monthly_report
|
|
|
|
post "/sites/:website/monthly-report/disable", SiteController, :disable_monthly_report
|
2020-06-08 10:35:13 +03:00
|
|
|
|
|
|
|
post "/sites/:website/monthly-report/recipients",
|
|
|
|
SiteController,
|
|
|
|
:add_monthly_report_recipient
|
|
|
|
|
|
|
|
delete "/sites/:website/monthly-report/recipients/:recipient",
|
|
|
|
SiteController,
|
|
|
|
:remove_monthly_report_recipient
|
2020-01-22 12:16:53 +03:00
|
|
|
|
2020-12-09 16:59:41 +03:00
|
|
|
post "/sites/:website/spike-notification/enable", SiteController, :enable_spike_notification
|
|
|
|
post "/sites/:website/spike-notification/disable", SiteController, :disable_spike_notification
|
|
|
|
put "/sites/:website/spike-notification", SiteController, :update_spike_notification
|
2020-12-29 16:17:27 +03:00
|
|
|
|
2020-12-09 16:59:41 +03:00
|
|
|
post "/sites/:website/spike-notification/recipients",
|
|
|
|
SiteController,
|
|
|
|
:add_spike_notification_recipient
|
|
|
|
|
|
|
|
delete "/sites/:website/spike-notification/recipients/:recipient",
|
|
|
|
SiteController,
|
|
|
|
:remove_spike_notification_recipient
|
|
|
|
|
2020-01-29 12:29:11 +03:00
|
|
|
get "/sites/:website/shared-links/new", SiteController, :new_shared_link
|
|
|
|
post "/sites/:website/shared-links", SiteController, :create_shared_link
|
2021-04-06 14:32:38 +03:00
|
|
|
get "/sites/:website/shared-links/:slug/edit", SiteController, :edit_shared_link
|
|
|
|
put "/sites/:website/shared-links/:slug", SiteController, :update_shared_link
|
2020-01-29 12:29:11 +03:00
|
|
|
delete "/sites/:website/shared-links/:slug", SiteController, :delete_shared_link
|
|
|
|
|
2020-02-26 11:54:21 +03:00
|
|
|
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
|
2020-06-30 11:00:19 +03:00
|
|
|
delete "/sites/:website/custom-domains/:id", SiteController, :delete_custom_domain
|
2020-02-26 11:54:21 +03:00
|
|
|
|
2020-01-22 12:16:53 +03:00
|
|
|
get "/sites/:website/weekly-report/unsubscribe", UnsubscribeController, :weekly_report
|
|
|
|
get "/sites/:website/monthly-report/unsubscribe", UnsubscribeController, :monthly_report
|
|
|
|
|
2019-09-02 14:29:19 +03:00
|
|
|
get "/:website/snippet", SiteController, :add_snippet
|
|
|
|
get "/:website/settings", SiteController, :settings
|
2020-11-06 14:30:38 +03:00
|
|
|
get "/:website/settings/general", SiteController, :settings_general
|
2020-11-19 15:57:55 +03:00
|
|
|
get "/:website/settings/visibility", SiteController, :settings_visibility
|
2020-11-06 14:30:38 +03:00
|
|
|
get "/:website/settings/goals", SiteController, :settings_goals
|
2020-11-16 16:38:44 +03:00
|
|
|
get "/:website/settings/search-console", SiteController, :settings_search_console
|
|
|
|
get "/:website/settings/email-reports", SiteController, :settings_email_reports
|
|
|
|
get "/:website/settings/custom-domain", SiteController, :settings_custom_domain
|
2020-11-19 15:57:55 +03:00
|
|
|
get "/:website/settings/danger-zone", SiteController, :settings_danger_zone
|
2019-10-31 08:39:51 +03:00
|
|
|
get "/:website/goals/new", SiteController, :new_goal
|
|
|
|
post "/:website/goals", SiteController, :create_goal
|
2019-10-31 09:20:45 +03:00
|
|
|
delete "/:website/goals/:id", SiteController, :delete_goal
|
2019-09-02 14:29:19 +03:00
|
|
|
put "/:website/settings", SiteController, :update_settings
|
2019-10-10 07:12:15 +03:00
|
|
|
put "/:website/settings/google", SiteController, :update_google_auth
|
2020-06-30 11:11:47 +03:00
|
|
|
delete "/:website/settings/google", SiteController, :delete_google_auth
|
2019-09-02 14:29:19 +03:00
|
|
|
delete "/:website", SiteController, :delete_site
|
2020-07-16 13:07:45 +03:00
|
|
|
delete "/:website/stats", SiteController, :reset_stats
|
2019-09-02 14:29:19 +03:00
|
|
|
|
2020-04-14 14:04:35 +03:00
|
|
|
get "/:domain/visitors.csv", StatsController, :csv_export
|
|
|
|
get "/:domain/*path", StatsController, :stats
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|
|
|
|
end
|