mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-21 21:09:49 +08:00
## What
Documents the `analytics: { enabled: false }` client-app option across
the skill site and docs, so users/agents know how to opt out of
SDK-managed analytics.
Passing `analytics: { enabled: false }` to `HexclaveClientApp`:
- stops the SDK from auto-capturing `$page-view` / `$click` events, and
- silences the `ANALYTICS_NOT_ENABLED` console warning the SDK logs
every flush when it sends events to a project that hasn't enabled the
Analytics app (disabled by default on new projects).
## Why
On a new project, analytics is off by default but the client event
tracker still auto-starts, so every end-user browser logs a recurring
`ANALYTICS_NOT_ENABLED` warning. This is a docs-only change telling
people how to turn capture off; it does **not** change SDK behavior.
## Changes
Hand-edited:
-
`packages/shared/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.ts`
— adds a one-line `<Note>` to the client-app setup step (this is the
skill.hexclave.com source).
- `docs-mintlify/guides/apps/analytics/overview.mdx` — new "Disabling
Analytics Capture in the SDK" section.
- `docs-mintlify/sdk/objects/hexclave-app.mdx` — documents the
`analytics` constructor param.
Auto-generated from the prompt (`pnpm run generate-setup-prompt-docs`):
- `docs-mintlify/guides/getting-started/setup.mdx`,
`docs-mintlify/llms-full.txt`,
`docs-mintlify/snippets/home-prompt-island.jsx`
## Notes
- Phrased as an opt-out hint, not baked into the default snippet (so
analytics stays on-by-default for new setups).
- Independent of #1561 (projectId/`import.meta.env`); branched off `dev`
with no overlap.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Documented `analytics: { enabled: false }` for `HexclaveClientApp`
across the setup guides, analytics overview, and SDK reference to let
teams opt out of SDK-managed analytics. This disables
`$page-view`/`$click` capture and silences the `ANALYTICS_NOT_ENABLED`
console warning on projects without the Analytics app.
<sup>Written for commit 3a18043cc7.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/hexclave/hexclave/pull/1562?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Added guidance for disabling SDK analytics capture via analytics: {
enabled: false }.
* Clarified that the SDK auto-captures page-view and click analytics by
default in setup guides.
* Noted that disabling analytics suppresses the ANALYTICS_NOT_ENABLED
console warning.
* Updated SDK reference docs to include the optional analytics
configuration in client app setup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
130 lines
5.1 KiB
Plaintext
130 lines
5.1 KiB
Plaintext
---
|
|
title: "Analytics"
|
|
description: "Explore events, session replays, and SQL queries in your project's analytics dataset"
|
|
icon: "/images/app-icons/analytics.svg"
|
|
---
|
|
|
|
The Analytics app gives you direct access to your project's analytics dataset in Hexclave. You can inspect raw event tables, run ClickHouse SQL queries, and watch session replays to debug real user behavior.
|
|
|
|
## Overview
|
|
|
|
Analytics is organized into three areas in the dashboard:
|
|
|
|
- **Tables**: Browse event rows with sorting, search, and incremental loading
|
|
- **Queries**: Run and save reusable ClickHouse SQL queries
|
|
- **Replays**: Watch session replays and filter by user, team, duration, activity window, and click count
|
|
|
|
## How Analytics Works
|
|
|
|
Stack records analytics events and replay chunks, then exposes them through the Analytics app for read-only querying and investigation.
|
|
|
|
User activity in your app flows into Stack event ingestion, which stores data in ClickHouse. This data powers the Tables view, the SQL query runner, and the Session replay UI.
|
|
|
|
### What Gets Tracked
|
|
|
|
Stack collects both client-side and server-side analytics events:
|
|
|
|
- **Client-side events**: browser interaction events like `$page-view` and `$click`
|
|
- **Server-side events**: currently `$token-refresh` and `$sign-up-rule-trigger`
|
|
|
|
## Enabling the Analytics App
|
|
|
|
To use analytics in your project:
|
|
|
|
1. Open your Hexclave dashboard
|
|
2. Go to **Apps**
|
|
3. Open **Analytics**
|
|
4. Click **Enable**
|
|
|
|
## Quick Start
|
|
|
|
1. Enable Analytics in your Hexclave dashboard (**Apps -> Analytics**)
|
|
2. Initialize Hexclave on your frontend with `HexclaveClientApp`/`HexclaveProvider`
|
|
3. Sign in with a real user session
|
|
4. Open the app and navigate/click around
|
|
5. Check **Analytics -> Tables** to confirm events are arriving
|
|
|
|
After setup, Stack automatically captures client-side `$page-view` and `$click` events.
|
|
|
|
If you want replay recordings, also enable `analytics.replays.enabled` in your client app config.
|
|
|
|
## Tables
|
|
|
|
The **Tables** screen is the fastest way to inspect recent analytics records.
|
|
|
|
- Currently shows the `events` table
|
|
- Built-in ordering and client-side search
|
|
- Relative/absolute timestamp display toggle
|
|
- Row detail dialog for inspecting full JSON payloads
|
|
|
|
Use this view when you need to quickly answer "what just happened?" without writing SQL.
|
|
|
|
## Queries
|
|
|
|
The **Queries** screen is a ClickHouse SQL workspace for deeper analysis.
|
|
|
|
- Run read-only SQL queries with a timeout budget
|
|
- Query the users and analytics tables
|
|
- Save reusable queries into folders
|
|
- Re-run saved queries with one click
|
|
- Edit and overwrite saved query definitions
|
|
|
|
## Session Replays
|
|
|
|
The **Replays** screen helps you move from "an event happened" to "what the user actually saw."
|
|
|
|
- Filter sessions by user, team, duration, recency, and click count
|
|
- Play back multi-tab sessions
|
|
- Control playback speed
|
|
- Optionally skip inactive ranges
|
|
- Jump across click/page-view timeline markers
|
|
|
|
Use replays when metrics alone are not enough to explain user behavior.
|
|
|
|
### Enabling Replay Recording in the SDK
|
|
|
|
Session replay recording is disabled by default. To enable it, pass `analytics.replays.enabled: true` when creating your client app.
|
|
|
|
```ts
|
|
import { HexclaveClientApp } from "@hexclave/next";
|
|
|
|
export const hexclaveClientApp = new HexclaveClientApp({
|
|
projectId: process.env.NEXT_PUBLIC_STACK_PROJECT_ID!,
|
|
publishableClientKey: process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY!,
|
|
tokenStore: "nextjs-cookie",
|
|
analytics: {
|
|
replays: {
|
|
enabled: true,
|
|
// Optional. Defaults to true.
|
|
maskAllInputs: true,
|
|
},
|
|
},
|
|
});
|
|
```
|
|
|
|
`maskAllInputs` defaults to `true`, so form fields are masked unless you explicitly disable it.
|
|
|
|
### Disabling Analytics Capture in the SDK
|
|
|
|
SDK-managed analytics capture is enabled by default. If you don't want the SDK to collect any analytics, pass `analytics: { enabled: false }` when creating your client app:
|
|
|
|
```ts
|
|
import { HexclaveClientApp } from "@hexclave/next";
|
|
|
|
export const hexclaveClientApp = new HexclaveClientApp({
|
|
projectId: process.env.NEXT_PUBLIC_STACK_PROJECT_ID!,
|
|
publishableClientKey: process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY!,
|
|
tokenStore: "nextjs-cookie",
|
|
analytics: { enabled: false },
|
|
});
|
|
```
|
|
|
|
This stops the SDK from sending `$page-view` and `$click` events. It also resolves the `ANALYTICS_NOT_ENABLED` warning the SDK logs to the browser console when it tries to send events to a project that hasn't enabled the Analytics app — with capture disabled, the SDK never makes those requests. If you'd rather keep analytics, enable the Analytics app in your dashboard (**Apps -> Analytics**) instead.
|
|
|
|
## Best Practices
|
|
|
|
1. **Use Tables for quick incident triage**: the Tables UI is the fastest way to inspect recent `events` rows without writing SQL.
|
|
2. **Use Queries for repeatable analysis**: save important SQL in folders, and scope queries with filters/`LIMIT` so they stay within result and timeout limits.
|
|
3. **Use Replays for behavioral debugging**: start from an event pattern, then inspect matching session replays to understand what users actually did.
|
|
4. **Keep replay privacy defaults on**: leave `maskAllInputs` enabled unless you have a specific reason and a data-handling policy for unmasked inputs.
|