<inputname="q"type="text"class="search-input"placeholder="Search..."aria-label="Input your search terms"autocomplete="off"autocorrect="off"autocapitalize="off"spellcheck="false"/>
<p>This controller is responsible for rendering stats dashboards.</p><p>The stats dashboards are currently the only part of the app that uses client-side
rendering. Since the dashboards are heavily interactive, they are built with React
which is an appropriate choice for highly interactive browser UIs.</p><divclass="mermaid">sequenceDiagram
Note over Browser,StatsController: And so on, for all reports in the viewport</div><p>This reasoning for this sequence is as follows:</p><ol><li>First paint is fast because it doesn't do any data aggregation yet - good UX</li><li>The basic structure of the dashboard is rendered with spinners before reports are ready - good UX</li><li>Rendering on the frontend allows for maximum interactivity. Re-rendering and re-fetching can be as granular as needed.</li><li>Routing on the frontend allows the user to navigate the dashboard without reloading the page and losing context</li><li>Rendering on the frontend allows caching results in the browser to reduce pressure on backends and storage
3.1 No client-side caching has been implemented yet. This is still theoretical. See <ahref="https://github.com/plausible/analytics/discussions/1278">https://github.com/plausible/analytics/discussions/1278</a>
3.2 This is a big potential opportunity, because analytics data is mostly immutable. Clients can cache all historical data.</li><li>Since frontend rendering & navigation is harder to build and maintain than regular server-rendered HTML, we don't use SPA-style rendering anywhere else
.The only place currently where the benefits outweigh the costs is the dashboard.</li></ol>
<p> Authorizes and renders a shared link:</p><ol><li><p>Shared link with no password protection: needs to just make sure the shared link entry is still
in our database. This check makes sure shared link access can be revoked by the site admins. If the
shared link exists, render it directly.</p></li><li><p>Shared link with password protection: Same checks as without the password, but an extra step is taken to
protect the page with a password. When the user passes the password challenge, a cookie is set with Plausible.Auth.Token.sign_shared_link().
The cookie allows the user to access the dashboard for 24 hours without entering the password again.</p></li></ol><p> ### Backwards compatibility</p><p> The URL format for shared links was changed in <ahref="https://github.com/plausible/analytics/pull/752">this pull request</a> in order
to make the URLs easier to bookmark. The old format is supported along with the new in order to not break old links.</p><p> See: <ahref="https://plausible.io/docs/shared-links">https://plausible.io/docs/shared-links</a></p>
</section>
</section>
<sectionclass="detail"id="stats/2">
<divclass="detail-header">
<ahref="#stats/2"class="detail-link"title="Link to this function">