View Source Plausible.Sites (Plausible v0.0.1)

Summary

Types

@type invite_error() ::
  Ecto.Changeset.t()
  | :already_a_member
  | :transfer_to_self
  | {:over_limit, non_neg_integer()}
  | :forbidden

Functions

Link to this function

bulk_transfer_ownership(sites, inviter, invitee_email, opts \\ [])

View Source
@spec bulk_transfer_ownership(
  [Plausible.Site.t()],
  Plausible.Auth.User.t(),
  String.t(),
  Keyword.t()
) :: {:ok, [Plausible.Auth.Invitation.t()]} | {:error, invite_error()}
Link to this function

bulk_transfer_ownership_direct(sites, new_owner)

View Source
@spec bulk_transfer_ownership_direct([Plausible.Site.t()], Plausible.Auth.User.t()) ::
  {:ok, [Plausible.Site.Membership.t()]} | {:error, invite_error()}
Link to this function

create_shared_link(site, name, password \\ nil)

View Source
Link to this function

get_for_user(user_id, domain, roles \\ [:owner, :admin, :viewer])

View Source
Link to this function

get_for_user!(user_id, domain, roles \\ [:owner, :admin, :viewer])

View Source
Link to this function

has_admin_access?(user_id, site)

View Source
Link to this function

invite(site, inviter, invitee_email, role)

View Source

Invites a new team member to the given site. Returns a %Plausible.Auth.Invitation{} struct and sends the invitee an email to accept this invitation.

The inviter must have enough permissions to invite the new team member, otherwise this function returns {:error, :forbidden}.

If the new team member role is :owner, this function handles the invitation as an ownership transfer and requires the inviter to be the owner of the site.

Link to this function

is_member?(user_id, site)

View Source
Link to this function

owned_sites_domains(user)

View Source
@spec stats_start_date(Plausible.Site.t()) :: Date.t() | nil

Returns the date of the first event of the given site, or nil if the site does not have stats yet.

If this is the first time the function is called for the site, it queries Clickhouse and saves the date in the sites table.