View Source API Reference Plausible v0.0.1
Modules
Build-related macros
Clickhouse access with async inserts enabled
Functions for user authentication context.
Schema for email activation codes.
API for verifying emails.
This embedded schema stores information about the account locking grace period.
TOTP auth context
Defines an Ecto type so Cloak.Ecto can encrypt/decrypt a binary field.
Schema for TOTP recovery codes.
Provides a vault that will be used to encrypt/decrypt the TOTP secrets of users who enable it.
Schema for storing user session data.
Functions for interacting with user sessions.
Ecto type representing a feature. Features are cast and stored in the
database as strings and loaded as modules, for example: "props"
is loaded
as Plausible.Billing.Feature.Props
.
Ecto type representing a list of features. This is a proxy for
{:array, Plausible.Billing.Ecto.Feature}
and is required for Kaffy to
render the HTML input correctly.
Ecto type representing a limit, that can be either a number or unlimited.
Unlimited is dumped to the database as -1
and loaded as :unlimited
to
keep compatibility with the rest of the codebase.
This module provides an interface for managing features, e.g. Revenue Goals, Funnels and Custom Properties.
This module provides functions to work with plans usage and limits.
The subscription statuses are stored in Paddle. They can only be changed through Paddle webhooks, which always send the current subscription status via the payload.
Caching interface specific for Plausible. Usage
Interface for the underlying cache implementation. Currently: ConCache
Keeps track of hit/miss ratio for various caches.
A periodic cache warmer.
Helper function for working with Ecto changesets
Provides the core functions to retrieve and manage the CLDR data that supports formatting and localisation.
Parses HTTP Accept-Language
header values as defined in
rfc2616.
Backend module that provides functions to define new locales and display human-readable locale names for presentation purposes.
Formats numbers and currencies based upon CLDR's decimal formats specification.
Implements cardinal plural rules for numbers.
Functions to manage the collection of number patterns defined in Cldr.
Implements ordinal plural rules for numbers.
Implements plural rules for ranges
Transliteration for digits and separators.
Functions to implement the number system rule-based-number-format rules of CLDR.
Functions to implement the ordinal rule-based-number-format rules of CLDR.
Functions to implement the spellout rule-based-number-format rules of CLDR.
Event schema for when NumericIDs migration is complete
Schema for storing location id <-> translation mappings in ClickHouse
Session schema for when NumericIDs migration is complete
Custom type to cast Bool as UInt8
Extensions for Kaffy CRM
This module defines the setup for tests requiring access to the application's data layer.
Base module for coordinated Clickhouse data migrations run via remote shell or otherwise (TBD).
Backfill and sync all teams related entities.
Clean up referrer_source entries for demo site with
Direct / None
for value populated by dogfooding
Plausible stats.
Ecto.Repo for Clickhouse data migrations, to be started manually, outside of the main application supervision tree.
ClickHouse locations data migration for storing location names in ClickHouse.
Numeric IDs migration, SQL files available at: priv/data_migrations/NumericIDs/sql
Populates event session columns with data from sessions table.
Ecto.Repo for Posrtgres data migrations, to be started manually, outside of the main application supervision tree.
!!!WARNING!!!: This script is used in migrations. Please take special care when altering it.
!!!WARNING!!!: This script is used in migrations. Please take special care when altering it.
Function execution context (with arguments) to Sentry reports.
Custom type for event name. Accepts Strings and Integers and stores them as String. Returns cast error if any other type is provided. Accepting integers is important for 404 tracking.
Ensures that the regex is compiled on load
Contains functions to export data for events and sessions as Zip archives.
File helpers for Plausible.
A funnel is a marketing term used to capture and describe the journey that users go through, from initial step to conversion. A funnel consists of several steps (here: 2..8).
Compile-time convenience constants for funnel characteristics.
This module defines the database schema for a single Funnel step.
See: Plausible.Funnel
for more information.
This module implements contextual Funnel interface, allowing listing, creating and deleting funnel definitions.
This module provides an API for fetching IP geolocation.
Currency specific functions for revenue goals
API to Google services.
Mock of API to Google services.
API for Google Analytics 4.
HTTP client implementation for Google Analytics 4 API.
Report request struct for Google Analytics 4 API
HTTP Client built on top of Finch.
HelpScout callback API logic.
Provides a vault that will be used to encrypt/decrypt the stored HelpScout API access tokens.
Common helpers for JSON handling
A dedicated repo for import related mutations
Context for managing site statistics imports.
This GenServer inserts records into Clickhouse imported_*
tables. Multiple buffers are
automatically created for each table. Records are flushed when the table buffer reaches the
maximum size, defined by max_buffer_size/0
.
CSV importer from either S3 for which it uses ClickHouse s3 table function or from local storage for which it uses input function.
Import implementation for Google Analytics 4.
Definitions of import sources.
Behaviour that should be implemented for each import source.
Stub import implementation.
Site import schema.
Import implementation for Universal Analytics.
Write-centric Clickhouse access interface
This is instrumentation necessary for keeping track of per-domain internal metrics. Due to metric labels cardinality (domain x metric_name), these statistics are not suitable for prometheus/grafana exposure, hence an internal storage is used.
A buffer aggregating counters for internal metrics, within 10 seconds time buckets.
Clickhouse schema for storing ingest counter metrics
Subscribes to telemetry events emitted by Plausible.Ingestion.Event
.
Every time a request derived event is either dispatched to clickhouse or dropped,
a telemetry event is emitted respectively. That event is captured here,
its metadata is extracted and sent for internal stats aggregation via
Counters.Buffer
interface.
This module exposes the build_and_buffer/1
function capable of
turning %Plausible.Ingestion.Request{} into a series of events that in turn
are uniformly either buffered in batches (to Clickhouse) or dropped
(e.g. due to spam blocklist) from the processing pipeline.
Revenue specific functions for the ingestion scope
The %Plausible.Ingestion.Request{} struct stores all needed fields to create an event downstream. Pre-eliminary validation is made to detect user errors early.
Revenue specific functions for the ingestion scope
This module ensures that you cannot run Plausible Analytics Enterprise Edition without a valid license key. The software contained within the ee/ and assets/js/dashboard/ee directories are Copyright © Plausible Insights OÜ. We have made this code available solely for informational and transparency purposes. No rights are granted to use, distribute, or exploit this software in any form.
Temporary fix for Phoenix.LiveViewTest.render_component/2
failing CI with warnings.
Base module for to use in Clickhouse migrations
Custom OpenTelemetry sampler implementation that ignores particular traces to reduce noise. Ingestion HTTP requests and queries to Oban tables are ignored, for example.
Cursor-based pagination.
Context module for querying API capabilities
Plugins API context module for Custom Props. All high level Custom Props operations should be implemented here.
Plugins API context module for Funnels. All high level Funnel operations should be implemented here.
Plugins API context module for Goals. All high level Goal operations should be implemented here.
Plugins API context module for Shared Links. All high level Shared Links operations should be implemented here.
Ecto schema for Plugins API Tokens. Tokens are stored hashed and require a description.
Context module for Plugins API Tokens. Exposes high-level operation for token-based authentication flows.
Custom PromEx plugin for instrumenting code within Plausible app.
Context module for handling custom event props.
Deletes data from a site.
Thin wrapper around :ets.update_counter/4
and a
clean-up process to act as a rate limiter.
Custom request logger which
Helper functions for S3 exports/imports.
Sentry callbacks for filtering and grouping events
Schema for Country Block List
Allows retrieving Country Rules by domain and country code
Schema for Hostnames allow list
Allows retrieving Hostname Rules by domain
Schema for IP block list
Allows retrieving IP Rules by domain and IP
Schema for Pages block list
Allows retrieving Page Rules by domain
Contextual interface for shields.
Site schema
The cache allows lookups by both domain
and domain_changed_from
fields - this is to allow traffic from sites whose domains changed within a certain
grace period (see: Plausible.Site.Transfer
).
Basic interface for domain changes.
Thin wrapper around Plausible.RateLimit
for gate keeping domain-specific events
during the ingestion phase. When the site is allowed, gate keeping
check returns :allow
, otherwise a :deny
tagged tuple is returned
with one of the following policy markers
Embedded schema for analytics imports
Embedded schema for installation meta-data
API for site memberships and invitations
Service for accepting invitations, including ownership transfers.
Service for inviting new or existing users to a sites, including ownershhip transfers.
Service for rejecting invitations.
Service for removing invitations.
A site deletion service stub.
Configuration schema for site-specific traffic change notifications.
User-specific site preferences schema
Sites context functions.
Builds aggregate results for v1 of our stats API and dashboards.
Builds breakdown results for v1 of our stats API and dashboards.
This module provides functions for comparing query periods.
Module for querying user defined 'custom properties'.
Defines a struct similar Date.Range
, but with DateTime
instead of Date
.
This module exposes a get/2
function that returns a map
of stats needed for email reports. These stats include
A module for parsing filters used in stat queries.
Contains utility functions shared between LegacyDashboardFilterParser
and StatsAPIFilterParser
.
Module responsible for funnel evaluation, i.e. building and executing
ClickHouse funnel query based on Plausible.Funnel
definition.
Revenue specific functions for the stats scope
A module for building the base of an imported stats query
This module is responsible for generating SQL/Ecto expressions for dimensions, filters and metrics used in import table queries
A module for building an ecto where clause of a query out of a query for Imported tables.
Collection of functions to work with intervals.
Module for validating query parameters against JSON schema.
Module for traversing and modifying JSON schemas.
Deprecated module. See QueryParser for list of valid dimensions
Module used to parse URL search params to a valid Query, used to power the API for the dashboard. @deprecated
Calculation methods for legacy time_on_page metric. Note the metric has its own limitations and quirks.
A module listing all available metrics in Plausible.
Methods to manipulate Query for business logic reasons before building an ecto query.
This struct contains the (JSON-encodable) response for a query and is responsible for building it from database query results.
This module is responsible for executing a Plausible.Stats.Query and gathering results.
This module is responsible for generating SQL/Ecto expressions for dimensions and metrics used in query SELECT statement.
Various macros and common SQL fragments used in Stats code.
This module defines how special metrics like conversion_rate
and
percentage
are calculated.
A module for building am ecto where clause of a query out of a query.
Sampling related functions
This module contains logic for deciding which tables need to be queried given a query and metrics, with the purpose of reducing the number of queries and JOINs needed to perform.
Collection of functions to work with time in queries.
Builds timeseries results for v1 of our stats API and dashboards.
Utilities for modifying stat results
Core context of teams.
Guest invitation schema
Guest membership schema
Team invitation schema
Team membership schema
Site transfer schema
Team schema
Floki wrappers to help make assertions about HTML/DOM structures
Currently only supports post request, it's a drop-in replacement for our exvcr usage that wasn't ever needed (e.g. we had no way to re-record the cassettes anyway).
User context
Module defining the user-agent used for site verification.
Behaviour to be implemented by specific site verification checks.
report_progress_as()
doesn't necessarily reflect the actual check description,
it serves as a user-facing message grouping mechanism, to prevent frequent message flashing when checks rotate often.
Each check operates on state()
and is expected to return it, optionally modified, by all means.
perform_safe/1
is used to guarantee no exceptions are thrown by faulty implementations, not to interrupt LiveView.
Checks that are performed during site verification.
Each module defined in @checks
implements the Plausible.Verification.Check
behaviour.
Checks are normally run asynchronously, except when synchronous execution is optionally required
for tests. Slowdowns can be optionally added, the user doesn't benefit from running the checks too quickly.
Scans the Content Security Policy header to ensure that the Plausible domain is allowed.
See Plausible.Verification.Checks
for the execution sequence.
Fetches the body of the site and extracts the HTML document, if available, for
further processing.
See Plausible.Verification.Checks
for the execution sequence.
Calls the browserless.io service (local instance can be spawned with make browserless
)
and runs verification/verify_plausible_installed.js via the function API.
Naive way of detecting GTM and WordPress powered sites.
The check looks for Plausible snippets and tries to address the common integration issues, such as bad placement, data-domain typos, unknown attributes frequently added by performance optimization plugins, etc.
A naive way of trying to figure out whether the latest site contents
is wrapped with some CDN/caching layer.
In case no snippets were found, we'll try to bust the cache by appending a random query parameter
and re-run Plausible.Verification.Checks.FetchBody
and Plausible.Verification.Checks.Snippet
checks.
If the result is different this time, we'll assume cache likely.
Module responsible for translating diagnostics to user-friendly errors and recommendations.
Diagnostics interpretation result.
A go-to definition of all verification errors
The struct and interface describing the state of the site verification process.
Assigns are meant to be used to communicate between checks, while diagnostics
are later on interpreted (translated into user-friendly messages and recommendations)
via Plausible.Verification.Diagnostics
module.
Busting some caches by appending ?plausible_verification=12345 to it.
A worker meant to be run once a day that sends out e-mail notifications to site owners assuming
Job removing expired user sessions. A grace period is applied.
Cleans deleted site data from ClickHouse asynchronously.
Periodic worker that expires domain change transition period. Old domains are frozen for a given time, so users can still access them before redeploying their scripts and integrations.
Worker for running CSV export jobs. Supports S3 and local storage. To avoid blocking the queue, a timeout of 15 minutes is enforced.
Worker for running analytics import jobs.
Worker for cleaning local files left after analytics import jobs.
This worker delivers emails for successful and failed exports
Oban service sending out traffic drop/spike notifications
Plug for populating conn assigns with user data on the basis of authenticated session token.
This module proxies requests to BASE_URL/avatar/:hash to www.gravatar.com/avatar/:hash.
This module exposes functions for rendering and returning plan benefits for Growth, Business, and Enterprise plans.
A banner that appears on the first dashboard launch
Component for provisioning/registration flows displaying
progress status. See PlausibleWeb.Flows
for the list of
flow definitions.
Generic reusable components
Google-related components
An umbrella module for the Integrations settings section
Phoenix Component for rendering a user-facing feature toggle
capable of flipping booleans in Plausible.Site
via the toggle_feature
controller action.
Reusable components specific to 2FA
This module defines the test case to be used by tests that require setting up a connection.
Revenue specific functions for the API scope
Plausible tracking itself functions
A Plug that fetches favicon images from DuckDuckGo and returns them to the Plausible frontend.
Redirects first-launch users to registration page.
Test helper for setup blocks allowing to skip the plug processing
Static compile-time definitions for user progress flows.
See PlausibleWeb.Components.FlowProgress
for rendering capabilities.
This module supplies LiveViews with currently logged in user data if session data contains a valid token.
LiveView allowing scheduling, watching, downloading, and deleting S3 and local exports.
LiveView allowing uploading CSVs for imported tables to S3 or local storage
LiveView for upgrading to a plan, or changing an existing plan.
Phoenix LiveComponent for a combobox UI element with search and selection functionality.
Default suggestion engine for the ComboBox
component.
Generic components stolen from mix phx.new templates
LiveView implementation of modal component.
Pagination components for LiveViews.
This component is responsible for rendering the verification progress and diagnostics.
Component rendering mini-graph of site's visitors over the last 24 hours.
Flash component for LiveViews - works also when embedded within dead views
LiveView allowing listing, creating and deleting funnels.
Phoenix LiveComponent that renders a form used for setting up funnels.
Makes use of dynamically placed PlausibleWeb.Live.FunnelSettings.ComboBox
components
to allow building searchable funnel definitions out of list of goals available.
Phoenix LiveComponent module that renders a list of funnels with their names and the number of steps they have.
LiveView allowing listing, creating and deleting goals.
Live view for the goal creation form
Phoenix LiveComponent module that renders a list of goals
LiveView allowing listing and deleting imports.
User assistance module around Plausible installation instructions/onboarding
LiveView allowing listing, creating and revoking Plugins API tokens.
Live view for the goal creation form
LiveView allowing listing, allowing and disallowing custom event properties.
Live view for the custom props creation form
Phoenix LiveComponent module that renders a list of custom properties
LiveView for registration form.
LiveView for password reset form.
This module tries to supply LiveViews with some common Sentry context (without it, there is practically none).
LiveView for IP Addresses Shield
LiveView allowing Country Rules management
LiveView allowing hostname Rules management
LiveView for Hostnames Shield
LiveView for IP Addresses Shield
LiveView allowing IP Rules management
LiveView allowing page Rules management
LiveView for IP Addresses Shield
LiveView for sites index.
LiveView coordinating the site verification process. Onboarding new sites, renders a standalone component. Embedded modal variant is available for general site settings.
MJML rendered for the weekly or monthly report e-mail
Controller for Plugins API Capabilities - doesn't enforce authentication, serves as a comprehensive health check
Controller for the CustomProp resource under Plugins API
Controller for the Funnel resource under Plugins API
Controller for the Goal resource under Plugins API
Controller for the Shared Link resource under Plugins API
Common responses for Plugins API
OpenAPI schema for Capabilities
OpenAPI schema for Goal
OpenAPI schema for Custom Property disable request
OpenAPI schema for Custom Property creation request
OpenAPI schema for SharedLink list response
OpenAPI schema for an error included in a response
OpenAPI schema for Funnel
OpenAPI schema for Funnel creation request - get or creates goals along the way
OpenAPI schema for Funnel list response
OpenAPI schema for Goal
OpenAPI schema for Goal creation request
OpenAPI schema for Custom Event Goal creation request
OpenAPI schema for Pageview Goal creation request
OpenAPI schema for Custom Event Goal creation request
OpenAPI schema for Custom Event Goal object
OpenAPI schema for bulk Goal deletion request
OpenAPI schema for Goals list response
OpenAPI schema for Pageview Goal object
OpenAPI schema for Revenue Goal object
OpenAPI schema for common Goal Type
OpenAPI Link schema
OpenAPI schema for a generic 404 response
Pagination metadata OpenAPI schema
OpenAPI schema for a generic 402 response
OpenAPI schema for SharedLink object
OpenAPI schema for SharedLink creation request
OpenAPI schema for SharedLink list response
OpenAPI schema for a generic 401 response
OpenAPI schema for a generic 422 response
OpenAPI specification for the Plugins API
View for rendering Capabilities on the Plugins API
View for rendering Custom Props in the Plugins API
View for rendering Plugins REST API errors
View for rendering Funnels in the Plugins API
View for rendering Goals in the Plugins API
A view capable of rendering pagination metadata included in responses containing lists of objects.
View for rendering Shared Links in the Plugins API
This module defines the test case to be used by tests that require setting up a Plugins API connection.
Plug for Basic HTTP Authentication using Plugins API Tokens lookup.
Plug for authorizing access to Stats and Sites APIs.
Plug restricting access to site and shared link, when present.
A thin macro wrapper around Plug.ErrorHandler that adds Sentry context containing a readable support hash presented to the users. To be used in the user-facing APIs, so that we don't leak internal server errors.
Plug toggling registration according to selfhosted state.
Rejects bot requests by any means available.
Plug for bumping timeout on user session on every dashboard request.
Implements the strategy of retrieving client's remote IP
This controller deals with user management via the UI in Site Settings -> People. It's important to enforce permissions in this controller.
This controller is responsible for rendering stats dashboards.
Functions for managing session data related to Two-Factor Authentication.
Functions for user session management.
Mix Tasks
This task is meant to replicate the behavior of cancelling a subscription. On production, this action is initiated by a Paddle webhook. Currently, only the subscription status is changed with that action.
This task downloads the Country Lite database from DB-IP for self-hosted or development purposes. Plausible Cloud runs a paid version of DB-IP with more detailed geolocation data.
It's often necessary to generate fake events for development and testing purposes. This Mix Task provides a quick and easy way to generate a pageview or custom event, either in your development environment or a remote Plausible instance.