Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions extra/lib/plausible/auth/sso/domain/verification.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ defmodule Plausible.Auth.SSO.Domain.Verification do
@moduledoc """
SSO domain ownership verification chain

1. DNS TXT `{domain}` record lookup.
1. DNS TXT `{domain}` record lookup.
Successful expectation contains `plausible-sso-verification={domain-identifier}` record.

2. HTTP GET lookup at `https://{domain}/plausible-sso-verification`
2. HTTP GET lookup at `https://{domain}/plausible-sso-verification`
Successful expectation contains `{domain-identifier}` in the body.

3. META tag lookup at `https://{domain}`
Successful expectation contains:

```html
<meta name="plausible-sso-verification" content="{domain-identifier}">
<meta name="plausible-sso-verification" content="{domain-identifier}">
```

in the body of `text/html` type.
Expand Down Expand Up @@ -60,8 +60,10 @@ defmodule Plausible.Auth.SSO.Domain.Verification do
with %Req.Response{body: body} = response when is_binary(body) <-
run_request(url_override || "https://#{sso_domain}"),
true <- html?(response),
{:ok, html} <- Floki.parse_document(body),
[_ | _] <- Floki.find(html, ~s|meta[name="#{@prefix}"][content="#{domain_identifier}"]|) do
html <- LazyHTML.from_document(body),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passes tests. It's the only production code where I've migrated from Floki -> LazyHTML in this PR.

[_ | _] <-
LazyHTML.query(html, ~s|meta[name="#{@prefix}"][content="#{domain_identifier}"]|)
|> Enum.into([]) do
true
else
_ ->
Expand Down
3 changes: 1 addition & 2 deletions extra/lib/plausible_web/live/sso_management.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ defmodule PlausibleWeb.Live.SSOManagement do
~H"""
<form id="sso-init" for={} phx-submit="init-sso">
<p class="text-sm">
Single Sign-On (SSO) enables team members to sign in without having to register an account. For more details,
<.styled_link href="https://plausible.io/docs/sso">see our documentation</.styled_link>.
Single Sign-On (SSO) enables team members to sign in without having to register an account. For more details, <.styled_link href="https://plausible.io/docs/sso">see our documentation</.styled_link>.
</p>

<.button type="submit">Start Configuring SSO</.button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
</:subtitle>

<p class="text-sm">
To access this team, you must first
<.styled_link href="/logout">log out</.styled_link>
To access this team, you must first <.styled_link href="/logout">log out</.styled_link>
and log in as SSO user.
</p>
</.focus_box>
14 changes: 5 additions & 9 deletions lib/plausible_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule PlausibleWeb do

def controller do
quote do
use Phoenix.Controller, namespace: PlausibleWeb
use Phoenix.Controller, formats: [html: "View", json: "View"]

import Plug.Conn
import PlausibleWeb.ControllerHelpers
Expand All @@ -58,8 +58,7 @@ defmodule PlausibleWeb do
def view do
quote do
use Phoenix.View,
root: "lib/plausible_web/templates",
namespace: PlausibleWeb
root: "lib/plausible_web/templates"

# Import convenience functions from controllers
import Phoenix.Controller, only: [view_module: 1]
Expand All @@ -76,8 +75,7 @@ defmodule PlausibleWeb do
def extra_view do
quote do
use Phoenix.View,
root: "extra/lib/plausible_web/templates",
namespace: PlausibleWeb
root: "extra/lib/plausible_web/templates"

# Import convenience functions from controllers
import Phoenix.Controller, only: [view_module: 1]
Expand Down Expand Up @@ -107,7 +105,7 @@ defmodule PlausibleWeb do

def plugins_api_controller do
quote do
use Phoenix.Controller, namespace: PlausibleWeb.Plugins.API
use Phoenix.Controller, formats: [:json]
import Plug.Conn
import PlausibleWeb.Router.Helpers

Expand All @@ -124,9 +122,7 @@ defmodule PlausibleWeb do

def plugins_api_view do
quote do
use Phoenix.View,
namespace: PlausibleWeb.Plugins.API,
root: ""
use Phoenix.View, root: ""

alias PlausibleWeb.Router.Helpers
import PlausibleWeb.Plugins.API.Views.Pagination, only: [render_metadata_links: 4]
Expand Down
5 changes: 3 additions & 2 deletions lib/plausible_web/components/team/notice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ defmodule PlausibleWeb.Team.Notice do
>
<p>
You can also create a team and assign different roles to team members, such as admin,
editor, viewer or billing. Team members will gain access to all your sites.
<.styled_link href={Routes.team_setup_path(PlausibleWeb.Endpoint, :setup)}>
editor, viewer or billing. Team members will gain access to all your sites. <.styled_link href={
Routes.team_setup_path(PlausibleWeb.Endpoint, :setup)
}>
Create your team here
</.styled_link>.
</p>
Expand Down
6 changes: 4 additions & 2 deletions lib/plausible_web/live/choose_plan.ex
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ defmodule PlausibleWeb.Live.ChoosePlan do
~H"""
You have used
<span :if={@pageview_usage[:last_30_days]} class="inline">
<b><%= PlausibleWeb.AuthView.delimit_integer(@pageview_usage.last_30_days.total) %></b> billable pageviews in the last 30 days.
<b>{PlausibleWeb.AuthView.delimit_integer(@pageview_usage.last_30_days.total)}</b>
billable pageviews in the last 30 days.
</span>
<span :if={@pageview_usage[:last_cycle]} class="inline">
<b>{PlausibleWeb.AuthView.delimit_integer(@pageview_usage.last_cycle.total)}</b>
Expand All @@ -261,7 +262,8 @@ defmodule PlausibleWeb.Live.ChoosePlan do
href={Routes.settings_path(PlausibleWeb.Endpoint, :subscription)}
>
"Subscription" section
</a> in your account settings.
</a>
in your account settings.
"""
end

Expand Down
18 changes: 12 additions & 6 deletions lib/plausible_web/live/goal_settings/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
~H"""
<div id="pageviews-form" class="py-2" {@rest}>
<div class="text-sm pb-6 text-gray-500 dark:text-gray-400 text-justify rounded-md">
Pageview goals allow you to measure how many people visit a specific page or section of your site. Learn more in
<.styled_link href="https://plausible.io/docs/pageview-goals" new_tab={true}>
Pageview goals allow you to measure how many people visit a specific page or section of your site. Learn more in <.styled_link
href="https://plausible.io/docs/pageview-goals"
new_tab={true}
>
our docs
</.styled_link>.
</div>
Expand Down Expand Up @@ -257,8 +259,10 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
~H"""
<div id="scroll-form" class="py-2" x-data={@js} {@rest}>
<div class="text-sm pb-6 text-gray-500 dark:text-gray-400 text-justify rounded-md">
Scroll Depth goals allow you to see how many people scroll beyond your desired scroll depth percentage threshold. Learn more in
<.styled_link href="https://plausible.io/docs/scroll-depth" new_tab={true}>
Scroll Depth goals allow you to see how many people scroll beyond your desired scroll depth percentage threshold. Learn more in <.styled_link
href="https://plausible.io/docs/scroll-depth"
new_tab={true}
>
our docs
</.styled_link>.
</div>
Expand Down Expand Up @@ -330,8 +334,10 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
<div id="custom-events-form" class="py-2" {@rest}>
<div id="event-fields">
<div class="text-sm pb-6 text-gray-500 dark:text-gray-400 text-justify rounded-md">
Custom Events are not tracked by default - you have to configure them on your site to be sent to Plausible. See examples and learn more in
<.styled_link href="https://plausible.io/docs/custom-event-goals" new_tab={true}>
Custom Events are not tracked by default - you have to configure them on your site to be sent to Plausible. See examples and learn more in <.styled_link
href="https://plausible.io/docs/custom-event-goals"
new_tab={true}
>
our docs
</.styled_link>.
</div>
Expand Down
4 changes: 1 addition & 3 deletions lib/plausible_web/live/reset_password_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ defmodule PlausibleWeb.Live.ResetPasswordForm do
Set password →
</.button>
<p class="text-center text-gray-500 text-xs mt-4">
Don't have an account?
<.styled_link href="/register">Register</.styled_link>
instead.
Don't have an account? <.styled_link href="/register">Register</.styled_link> instead.
</p>
</.form>
"""
Expand Down
3 changes: 1 addition & 2 deletions lib/plausible_web/live/sites.ex
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,7 @@ defmodule PlausibleWeb.Live.Sites do
<p>
The site uses <span x-text="selectedInvitation && selectedInvitation.missing_features"></span>,
which your current subscription does not support. After accepting ownership of this site,
you will not be able to access them unless you
<.styled_link
you will not be able to access them unless you <.styled_link
class="inline-block"
href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
>
Expand Down
3 changes: 3 additions & 0 deletions lib/plausible_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defmodule PlausibleWeb.Router do
on_ee(do: plug(Plausible.Plugs.HandleExpiredSession))
on_ee(do: plug(Plausible.Plugs.SSOTeamAccess))
plug PlausibleWeb.Plugs.UserSessionTouch
plug :put_root_layout, html: {PlausibleWeb.LayoutView, :app}
end

on_ee do
Expand All @@ -28,13 +29,15 @@ defmodule PlausibleWeb.Router do
plug PlausibleWeb.AuthPlug
on_ee(do: plug(Plausible.Plugs.HandleExpiredSession))
plug PlausibleWeb.Plugs.UserSessionTouch
plug :put_root_layout, html: {PlausibleWeb.LayoutView, :app}
end
end

pipeline :shared_link do
plug :accepts, ["html"]
plug :put_secure_browser_headers
plug PlausibleWeb.Plugs.NoRobots
plug :put_root_layout, html: {PlausibleWeb.LayoutView, :app}
end

pipeline :csrf do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
</div>

<div class="text-center mt-8 dark:text-gray-100">
Questions?
<.styled_link href="https://plausible.io/contact">Contact us</.styled_link>
Questions? <.styled_link href="https://plausible.io/contact">Contact us</.styled_link>
</div>
</.focus_box>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ You used to have an active account with {Plausible.product_name()}, a simple, li
<br /><br />
We've noticed that you're still sending us stats so we're writing to inform you that we'll stop accepting stats from your sites {@time}. We're an independent, bootstrapped service and we don't sell your data, so this will reduce our server costs and help keep us sustainable.
<br /><br /> If you'd like to continue counting your site stats in a privacy-friendly way, please
<a href={plausible_url() <> "?__team=#{@team.identifier}"}>login to your Plausible account</a> and start a subscription.
<br /><br />
<a href={plausible_url() <> "?__team=#{@team.identifier}"}>login to your Plausible account</a>
and start a subscription. <br /><br />
Do you have any questions or need help with anything? Just reply to this email and we'll gladly help.
15 changes: 9 additions & 6 deletions lib/plausible_web/templates/email/check_stats_email.html.heex
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
Plausible is tracking your website stats without compromising the user experience and the privacy of your visitors.
<br /><br /> Here's how to get even more out of your Plausible experience: <br /><br /> *
<a href="https://plausible.io/docs/custom-event-goals">Set up custom events</a> and
<a href="https://plausible.io/docs/pageview-goals">pageview goals</a> to count actions you want your visitors to take<br />
<a href="https://plausible.io/docs/custom-event-goals">Set up custom events</a>
and <a href="https://plausible.io/docs/pageview-goals">pageview goals</a>
to count actions you want your visitors to take<br />
* Running an ecommerce? Assign monetary values to custom events to track
<a href="https://plausible.io/docs/ecommerce-revenue-tracking">revenue attribution</a>
<br /> * Follow the journey from a landing page to conversion with
<a href="https://plausible.io/docs/funnel-analysis">funnel analysis</a>
<br /> *
<a href="https://plausible.io/docs/manual-link-tagging">
Tag your social media, email and paid links
</a> to see which campaigns are responsible for most conversions<br />
* <a href="https://plausible.io/docs/custom-props/introduction">Send custom properties</a>
</a>
to see which campaigns are responsible for most conversions<br /> *
<a href="https://plausible.io/docs/custom-props/introduction">Send custom properties</a>
to collect data that we don't track automatically <br /> * Explore our
<a href="https://plausible.io/docs/stats-api">stats API</a> to retrieve your stats and our
<a href="https://plausible.io/docs/sites-api">sites API</a> to create and manage sites programmatically<br />
<a href="https://plausible.io/docs/stats-api">stats API</a>
to retrieve your stats and our <a href="https://plausible.io/docs/sites-api">sites API</a>
to create and manage sites programmatically<br />
<br /><br />
<a href={plausible_url()}>View your Plausible dashboard now</a>
for the most valuable traffic insights at a glance. <br /><br />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
We've recorded {@current_visitors} visitors on
<a href={"https://" <> @site.domain}><%= @site.domain %></a> in the last 12 hours.
<a href={"https://" <> @site.domain}>{@site.domain}</a>
in the last 12 hours.
<%= if @dashboard_link do %>
<br /><br /> View dashboard: <a href={@dashboard_link}>{@dashboard_link}</a>
<br /><br /> Something looks off? Please
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{@inviter.email} has invited you to the {@site.domain} site on {Plausible.product_name()}.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=none"}>Click here</a> to view and respond to the invitation. The invitation
<a href={Routes.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=none"}>Click here</a>
to view and respond to the invitation. The invitation
will expire 48 hours after this email is sent.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{@inviter.email} has invited you to the "{@team.name}" team on {Plausible.product_name()}.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :index)}>Click here</a> to view and respond to the invitation. The invitation
<a href={Routes.site_url(PlausibleWeb.Endpoint, :index)}>Click here</a>
to view and respond to the invitation. The invitation
will expire 48 hours after this email is sent.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{@invitee_email} has accepted your invitation to {@site.domain}.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site.domain) <> "?__team=#{@team.identifier}"}>Click here</a> to view site settings.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site.domain) <> "?__team=#{@team.identifier}"}>
Click here
</a>
to view site settings.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{@guest_invitation.team_invitation.email} has rejected your invitation to {@guest_invitation.site.domain}.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @guest_invitation.site.domain) <> "?__team=#{@team.identifier}"}>Click here</a> to view site settings.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @guest_invitation.site.domain) <> "?__team=#{@team.identifier}"}>
Click here
</a>
to view site settings.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{@inviter.email} has promoted you to a team member in the "{@team.name}" team on {Plausible.product_name()}.
<a href={PlausibleWeb.Router.Helpers.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=#{@team.identifier}"}>Click here</a> to view sites managed by the team.
<a href={PlausibleWeb.Router.Helpers.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=#{@team.identifier}"}>
Click here
</a>
to view sites managed by the team.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
:register_from_invitation_form,
@invitation_id
)
}>Click here</a> to create your account. The link is valid for 48 hours after this email is sent.
<br /><br />
}>
Click here
</a>
to create your account. The link is valid for 48 hours after this email is sent. <br /><br />
Plausible is a lightweight and open-source website analytics tool. We hope you like our simple and ethical approach to tracking website visitors.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
:register_from_invitation_form,
@invitation_id
)
}>Click here</a> to create your account. The link is valid for 48 hours after this email is sent.
<br /><br />
}>
Click here
</a>
to create your account. The link is valid for 48 hours after this email is sent. <br /><br />
Plausible is a lightweight and open-source website analytics tool. We hope you like our simple and ethical approach to tracking website visitors.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{@site_transfer.email} has rejected the ownership transfer of {@site_transfer.site.domain}.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site_transfer.site.domain) <> "?__team=#{@team.identifier}"}>Click here</a> to view site settings.
<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site_transfer.site.domain) <> "?__team=#{@team.identifier}"}>
Click here
</a>
to view site settings.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
<br /><br />
<% end %>
To finish your setup for {@site.domain}, review
<a href={"#{plausible_url()}/#{URI.encode_www_form(@site.domain)}/installation?__team=#{@site_team.identifier}"}>your installation</a> and start collecting visitor statistics.
<br /><br />
<a href={"#{plausible_url()}/#{URI.encode_www_form(@site.domain)}/installation?__team=#{@site_team.identifier}"}>
your installation
</a>
and start collecting visitor statistics. <br /><br />
This Plausible script is 45 times smaller than Google Analytics script so you’ll have a fast loading site while getting all the important traffic insights on one single page.
<br /><br /> On WordPress? We have a
<a href="https://plausible.io/wordpress-analytics-plugin">WordPress plugin</a> that makes the process simpler. We also have
<a href="https://plausible.io/docs/integration-guides">integration guides</a> for different site builders to help you start counting stats in no time.
<a href="https://plausible.io/wordpress-analytics-plugin">WordPress plugin</a>
that makes the process simpler. We also have
<a href="https://plausible.io/docs/integration-guides">integration guides</a>
for different site builders to help you start counting stats in no time.
<%= if ee?() do %>
<br /><br /> Do reply back to this email if you have any questions or need some guidance.
<% end %>
5 changes: 4 additions & 1 deletion lib/plausible_web/templates/email/team_changed.html.heex
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{@user.email} has transferred {@site.domain} to the "{@team.name}" team on Plausible Analytics.
<a href={Routes.stats_url(PlausibleWeb.Endpoint, :stats, @site.domain, []) <> "?__team=#{@team.identifier}"}>Click here</a> to view the stats.
<a href={Routes.stats_url(PlausibleWeb.Endpoint, :stats, @site.domain, []) <> "?__team=#{@team.identifier}"}>
Click here
</a>
to view the stats.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{@invitee_email} has accepted your invitation to "{@team.name}" team.
<a href={Routes.settings_url(PlausibleWeb.Endpoint, :team_general) <> "?__team=#{@team.identifier}"}>Click here</a> to view team settings.
<a href={Routes.settings_url(PlausibleWeb.Endpoint, :team_general) <> "?__team=#{@team.identifier}"}>
Click here
</a>
to view team settings.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{@team_invitation.email} has rejected your invitation to \"{@team.name}\" team.
<a href={Routes.settings_url(PlausibleWeb.Endpoint, :team_general) <> "?__team=#{@team.identifier}"}>Click here</a> to view team settings.
<a href={Routes.settings_url(PlausibleWeb.Endpoint, :team_general) <> "?__team=#{@team.identifier}"}>
Click here
</a>
to view team settings.
Loading
Loading