π Open source, privacy-first web analytics β a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Nicer docs
Blue Mouse572d6fba8581
diff --git a/docs/components/provider-icons.tsx b/docs/components/provider-icons.tsxindex 729d6d93e..b45b82a34 100644--- a/docs/components/provider-icons.tsx+++ b/docs/components/provider-icons.tsx@@ -77,6 +77,21 @@ export const PlausibleIcon = ({ className }: { className?: string }) => (</svg>);+export const NpmIcon = ({ className }: { className?: string }) => (+ <svg+ className={className}+ role="img"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ width="16"+ height="16"+ fill="#CB3837"+ >+ <title>npm</title>+ <path d="M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z" />+ </svg>+);+export const FathomIcon = ({ className }: { className?: string }) => (<svg className={className} viewBox="0 0 67.851 50" width="16" height="16"><g transform="translate(11882.544 12524.362)">diff --git a/docs/content/docs/adblockers/managed-proxy.mdx b/docs/content/docs/adblockers/managed-proxy.mdxindex 86d5c32e4..f654b94d7 100644--- a/docs/content/docs/adblockers/managed-proxy.mdx+++ b/docs/content/docs/adblockers/managed-proxy.mdx@@ -7,7 +7,15 @@ Swetrix Cloud can run a reverse proxy for you on a subdomain you control, so theThis page walks you through setting one up. The whole process takes about 5 minutes plus DNS propagation time.-> **Looking for the most effective option?** A [self-hosted proxy](/adblockers/how-to#best-self-hosted-proxy-least-detectable) running on your own infrastructure is the gold standard for adblocker bypass β it's fully indistinguishable from any other request to your site. It requires more technical knowledge to set up. The managed reverse proxy described here is highly effective for most users and far easier to configure, but the request ultimately resolves to a Swetrix-controlled edge, which makes it slightly more detectable to aggressive blocklists.+<Callout type="info">+ **Looking for the most effective option?** A [self-hosted+ proxy](/adblockers/how-to#best-self-hosted-proxy-least-detectable) running on your own+ infrastructure is the gold standard for adblocker bypass β it's fully indistinguishable from any+ other request to your site. It requires more technical knowledge to set up. The managed reverse+ proxy described here is highly effective for most users and far easier to configure, but the+ request ultimately resolves to a Swetrix-controlled edge, which makes it slightly more detectable+ to aggressive blocklists.+</Callout>## How it works@@ -15,13 +23,13 @@ This page walks you through setting one up. The whole process takes about 5 minuVisitor's browser βββΊ t.example.com β(CNAME)ββΊ <random-id>.proxy.swetrix.orgββΌ- Swetrix edge proxy- (Let's Encrypt cert- issued automatically)+ Swetrix edge proxy+ (Let's Encrypt cert+ issued automatically)βββββββββββββββ΄ββββββββββββββΌ βΌ- swetrix.com/swetrix.js api.swetrix.com/log+ swetrix.com/swetrix.js api.swetrix.com/log```- You add a CNAME record on a subdomain you own β for example `t.example.com` β pointing at a target hostname Swetrix gives you (`<random-id>.proxy.swetrix.org`).@@ -32,7 +40,11 @@ Visitor's browser βββΊ t.example.com β(CNAME)ββΊ <random-id>.proxy.sweThe visitor's real IP address is preserved via `X-Forwarded-For`, and we strip cookies / authorisation headers before forwarding requests upstream.-## Step 1 β Pick a subdomain+## Setup++<Steps>+<Step>+<h3>Pick a subdomain</h3>Pick a subdomain on a domain you control. The subdomain should be something **generic** β try to avoid words ad blockers commonly target.@@ -45,7 +57,9 @@ Pick a subdomain on a domain you control. The subdomain should be something **geYou can register up to 5 managed proxy domains per project.-## Step 2 β Add the domain in Swetrix+</Step>+<Step>+<h3>Add the domain in Swetrix</h3>1. Open your project in the Swetrix dashboard.2. Go to **Settings β Managed proxy**.@@ -53,7 +67,9 @@ You can register up to 5 managed proxy domains per project.You'll see the domain appear in the list with a `Waiting` status and a **CNAME target** that looks like `<random-id>.proxy.swetrix.org`.-## Step 3 β Add the CNAME record+</Step>+<Step>+<h3>Add the CNAME record</h3>In your DNS provider, create a `CNAME` record:@@ -61,13 +77,18 @@ In your DNS provider, create a `CNAME` record:| -------------------------------------- | ------- | -------------------------------- | ---------------- || `t` (or whatever subdomain you picked) | `CNAME` | `<random-id>.proxy.swetrix.org.` | 3600 (or "Auto") |+<Callout type="warn">A few common gotchas:- **Cloudflare users:** make sure the record is **DNS-only** (gray cloud, not orange). Cloudflare's proxy will interfere with our cert provisioning.- **Apex domains** (e.g. `example.com`) cannot be used directly because CNAME records aren't allowed on the root. Use a subdomain.- DNS propagation can take a few minutes.-## Step 4 β Wait for the status to flip+</Callout>++</Step>+<Step>+<h3>Wait for the status to flip</h3>After the CNAME resolves, the status moves from `Waiting` β `Issuing` β `Live` automatically (we re-check every minute). You can also click the refresh icon to force a re-check.@@ -76,10 +97,19 @@ After the CNAME resolves, the status moves from `Waiting` β `Issuing` β `Liv- `Live` β your subdomain is fully operational.- `Error` β something went wrong. The reason is shown next to the domain.-## Step 5 β Update your tracker code+</Step>+<Step>+<h3>Update your tracker code</h3>Once your domain is `Live`, replace your existing tracker tag:+<Tabs defaultValue="script">+<TabsList>+ <TabsTrigger value="script"><CodeIcon /> Script tag</TabsTrigger>+ <TabsTrigger value="npm"><NpmIcon /> npm package</TabsTrigger>+</TabsList>+<TabsContent value="script">+```html<script src="https://t.example.com/script.js" defer></script><script>@@ -92,6 +122,9 @@ Once your domain is `Live`, replace your existing tracker tag:</script>```+</TabsContent>+<TabsContent value="npm">+If you're using the [npm package](/install-script#install-swetrix-via-npm), only set the `apiURL` β the script itself is bundled with your app:```ts@@ -103,8 +136,14 @@ swetrix.init("YOUR_PROJECT_ID", {swetrix.trackViews();```+</TabsContent>+</Tabs>+The `apiURL` option overrides the default API host for _all_ requests the tracker makes (events, session pings, profile identification, etc.) β there's nothing else to configure.+</Step>+</Steps>+## Limits- Up to **5 proxy domains per project**.@@ -113,14 +152,25 @@ The `apiURL` option overrides the default API host for _all_ requests the tracke## Troubleshooting-**The status is stuck on `Waiting`.**+<Accordions>+<Accordion title="The status is stuck on Waiting">+The CNAME hasn't propagated yet. You can check from your machine with `dig CNAME t.example.com` β the answer should match the target Swetrix gave you. If you've waited more than an hour, double-check that the record is a CNAME (not an A) and that any DNS proxy (e.g. Cloudflare) is disabled for this record.-**The status flipped to `Error`.**+</Accordion>+<Accordion title="The status flipped to Error">+The error message in the UI explains what's wrong. The most common causes are CNAME records pointing to the wrong target, DNS-level proxies (Cloudflare orange cloud) breaking the certificate validation, or the CNAME being removed.-**Adblockers are still blocking my events.**+</Accordion>+<Accordion title="Adblockers are still blocking my events">+Most likely the subdomain you picked contains a flagged keyword (`analytics`, `track`, `stats`, etc.). Add a different subdomain with a generic name and switch your tracker code to it.-**I removed the CNAME / I deleted the domain in Swetrix.**+</Accordion>+<Accordion title="I removed the CNAME / I deleted the domain in Swetrix">+That immediately stops accepting traffic on that hostname. Tracker calls will start failing β make sure your tracker code points at a domain that's still live.++</Accordion>+</Accordions>diff --git a/docs/content/docs/add-script.mdx b/docs/content/docs/add-script.mdxindex 31fd39311..0d666b5b5 100644--- a/docs/content/docs/add-script.mdx+++ b/docs/content/docs/add-script.mdx@@ -14,8 +14,12 @@ See [CMS & website builder integrations](/integrations#cms--website-builders).</Callout>-<Tabs items={["HTML script tag", "npm package"]}>-<Tab value="HTML script tag">+<Tabs defaultValue="html">+<TabsList>+ <TabsTrigger value="html"><CodeIcon /> HTML script tag</TabsTrigger>+ <TabsTrigger value="npm"><NpmIcon /> npm package</TabsTrigger>+</TabsList>+<TabsContent value="html">The easiest way to add the tracking script to your website is to edit the HTML code of your website.To do this, paste the following code snippet into the Body section (`<body>` tag). You have to place the script within the `<body>...</body>` tags.@@ -45,8 +49,8 @@ It's important to remember to replace `YOUR_PROJECT_ID` with your actual ProjectDone. Now you can start using Swetrix on your website.-</Tab>-<Tab value="npm package">+</TabsContent>+<TabsContent value="npm">If you are using a website based on a JavaScript framework such as React or Vue, you can install Swetrix via npm and use it on your website.@@ -82,5 +86,5 @@ Swetrix.trackViews();</Step></Steps>-</Tab>+</TabsContent></Tabs>diff --git a/docs/mdx-components.tsx b/docs/mdx-components.tsxindex 20e114519..aef610b48 100644--- a/docs/mdx-components.tsx+++ b/docs/mdx-components.tsx@@ -8,9 +8,11 @@ import {SimpleAnalyticsIcon,FathomIcon,PlausibleIcon,+ NpmIcon,} from "@/components/provider-icons";import { Accordion, Accordions } from "fumadocs-ui/components/accordion";import { File, Folder, Files } from "fumadocs-ui/components/files";+import { CodeIcon } from "@phosphor-icons/react/dist/ssr";import type { MDXComponents } from "mdx/types";export function getMDXComponents(components?: MDXComponents): MDXComponents {@@ -29,6 +31,8 @@ export function getMDXComponents(components?: MDXComponents): MDXComponents {SimpleAnalyticsIcon,FathomIcon,PlausibleIcon,+ NpmIcon,+ CodeIcon,Accordion,Accordions,File,