Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor tracking script and update documentation for SPA support

Bill Yang4f16768b1e8a
diff --git a/docs/src/content/_meta.js b/docs/src/content/_meta.js
index 5d68bfb57..84104770c 100644
--- a/docs/src/content/_meta.js
+++ b/docs/src/content/_meta.js
@@ -3,7 +3,5 @@ export default {
"self-hosting": "",
tracker: "",
features: "",
- themes: "",
advanced: "",
- usage: "",
};
diff --git a/docs/src/content/themes/_meta.js b/docs/src/content/themes/_meta.js
deleted file mode 100644
index 45e390b4d..000000000
--- a/docs/src/content/themes/_meta.js
+++ /dev/null
@@ -1,4 +0,0 @@
-export default {
- docs: 'Docs Theme',
- blog: 'Blog Theme'
-}
diff --git a/docs/src/content/themes/blog/_meta.js b/docs/src/content/themes/blog/_meta.js
deleted file mode 100644
index 9921d4fb4..000000000
--- a/docs/src/content/themes/blog/_meta.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export default {
- index: ''
-}
diff --git a/docs/src/content/themes/blog/index.mdx b/docs/src/content/themes/blog/index.mdx
deleted file mode 100644
index cc68e9132..000000000
--- a/docs/src/content/themes/blog/index.mdx
+++ /dev/null
@@ -1,96 +0,0 @@
----
-sidebarTitle: Installation
----
-
-# Get Started
-
-import { Steps } from 'nextra/components'
-
-## Configurations
-
-Similar to the docs theme, you can install the blog theme with the following
-commands:
-
-<Steps>
-
-### Install Next.js, Nextra and React
-
-```sh npm2yarn
-npm i next nextra react react-dom
-```
-
-### Install the blog theme
-
-```sh npm2yarn
-npm i nextra-theme-blog
-```
-
-### Create the following Next.js config and theme config under the root directory:
-
-```js filename="next.config.mjs"
-import nextra from 'nextra'
-
-const withNextra = nextra({
- theme: 'nextra-theme-blog',
- themeConfig: './theme.config.js'
-})
-export default withNextra()
-```
-
-```jsx filename="theme.config.js"
-export default {
- footer: <p>MIT 2021 Β© Nextra.</p>,
- head: ({ title, meta }) => (
- <>
- {meta.description && (
- <meta name="description" content={meta.description} />
- )}
- {meta.tag && <meta name="keywords" content={meta.tag} />}
- {meta.author && <meta name="author" content={meta.author} />}
- </>
- ),
- readMore: 'Read More β†’',
- titleSuffix: null,
- postFooter: null,
- cusdis: {
- appId: 'your_app_id',
- host: 'your_host(optional)',
- lang: 'your_lang'
- },
- darkMode: false,
- navs: [
- {
- url: 'https://github.com/shuding/nextra',
- name: 'Nextra'
- }
- ]
-}
-```
-
-### Create `pages/_app.js` and include the theme stylesheet:
-
-```jsx filename="_app.js"
-import 'nextra-theme-blog/style.css'
-
-export default function Nextra({ Component, pageProps }) {
- const getLayout = Component.getLayout || (page => page)
- return <Component {...pageProps} />
-}
-```
-
-### You are good to go!
-
-</Steps>
-
----
-
-> [!TIP]
->
-> You can also use
-> [`<style jsx>`](https://nextjs.org/docs/basic-features/built-in-css-support#css-in-js)
-> to style elements inside `theme.config.js`.
-
-> [!NOTE]
->
-> An example of the blog theme can be found
-> [here](https://github.com/vercel-solutions/nextjs-portfolio-starter).
diff --git a/docs/src/content/themes/docs/_meta.js b/docs/src/content/themes/docs/_meta.js
deleted file mode 100644
index f0ca57273..000000000
--- a/docs/src/content/themes/docs/_meta.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default {
- index: '',
- configuration: '',
- callout: '',
- bleed: ''
-}
diff --git a/docs/src/content/themes/docs/bleed.mdx b/docs/src/content/themes/docs/bleed.mdx
deleted file mode 100644
index de8b0eec5..000000000
--- a/docs/src/content/themes/docs/bleed.mdx
+++ /dev/null
@@ -1,82 +0,0 @@
----
-sidebarTitle: Bleed
----
-
-# Bleed Component
-
-A built-in component provided by `nextra-theme-docs`.
-
-## Example
-
-When wrapping your content with `<Bleed>`, it will be slightly wider than the
-container and will overflow on both sides.
-
-import { Bleed } from 'nextra/components'
-
-<Bleed>
- <div style={{ border: '1px solid #888', padding: '4rem 2.5rem', textAlign: 'center' }}>
- _There is nothing to writing. All you do is sit down at a typewriter and **bleed**._
-
- β€” Ernest Hemingway
-
- </div>
-</Bleed>
-
-It provides a better reading experience when you want to present some graphical
-information, which normally looks nicer in a larger size.
-
-For example, you can put text, image, video or any component inside:
-
-<Bleed>
- <iframe
- width="100%"
- height="430"
- src="https://youtube.com/embed/3hccXiXI0u8"
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
- allowFullScreen
- />
-</Bleed>
-
-You can even make it full-bleed using `<Bleed full>`:
-
-<Bleed full>![Nextra](../../../app/opengraph-image.png)</Bleed>
-
-## Usage
-
-### MDX component
-
-```mdx filename="bleed.mdx"
-<Bleed>Hey, I can use **Markdown** syntax here.</Bleed>
-
-<Bleed full>![Nextra](https://nextra.site/og.jpeg)</Bleed>
-
-<Bleed full>
- <iframe
- src="https://codesandbox.io/embed/swr-states-4une7"
- width="100%"
- height="500px"
- title="SWR-States"
- />
-</Bleed>
-```
-
-### React Component
-
-```jsx filename="bleed.jsx"
-import { Bleed } from 'nextra/components'
-
-<Bleed>Hey, I can use **Markdown** syntax here.</Bleed>
-
-<Bleed full>
- ![Nextra](https://nextra.site/og.jpeg)
-</Bleed>
-
-<Bleed full>
- <iframe
- src="https://codesandbox.io/embed/swr-states-4une7"
- width="100%"
- height="500px"
- title="SWR-States"
- />
-</Bleed>
-```
diff --git a/docs/src/content/themes/docs/callout.mdx b/docs/src/content/themes/docs/callout.mdx
deleted file mode 100644
index cefcde204..000000000
--- a/docs/src/content/themes/docs/callout.mdx
+++ /dev/null
@@ -1,66 +0,0 @@
----
-sidebarTitle: Callout
----
-
-# Callout Component
-
-A built-in component provided by `nextra/components`.
-
-## Example
-
-import { Callout } from 'nextra/components'
-
-<Callout>
- A **callout** is a short piece of text intended to attract attention.
-</Callout>
-
-## Usage
-
-### Default
-
-<Callout emoji="πŸ‘Ύ">
- **Space Invaders** is a 1978 shoot 'em up arcade game developed by Tomohiro
- Nishikado.
-</Callout>
-
-```mdx
-<Callout emoji="πŸ‘Ύ">
- **Space Invaders** is a 1978 shoot 'em up arcade game developed by Tomohiro
- Nishikado.
-</Callout>
-```
-
-### Warning
-
-<Callout type="warning">This API will be deprecated soon.</Callout>
-
-```mdx
-<Callout type="warning">This API will be deprecated soon.</Callout>
-```
-
-### Error
-
-<Callout type="error">
- This is a dangerous feature that can cause everything to explode.
-</Callout>
-
-```mdx
-<Callout type="error">
- This is a dangerous feature that can cause everything to explode.
-</Callout>
-```
-
-### React Component
-
-```jsx filename="callout.jsx"
-import { Callout } from 'nextra/components'
-
-const Component = () => {
- return (
- <Callout emoji="πŸ‘Ύ">
- **Space Invaders** is a 1978 shoot 'em up arcade game developed by
- Tomohiro Nishikado.
- </Callout>
- )
-}
-```
diff --git a/docs/src/content/themes/docs/configuration.mdx b/docs/src/content/themes/docs/configuration.mdx
deleted file mode 100644
index f08ccc8fd..000000000
--- a/docs/src/content/themes/docs/configuration.mdx
+++ /dev/null
@@ -1,510 +0,0 @@
-# Configuration
-
-To configure the theme, edit or create the `theme.config.js` file in the root
-directory. The file looks something like this:
-
-```js filename="theme.config.js"
-export default {
- projectLink: 'https://gitlab.com/librewolf-community/browser',
- titleSuffix: ' – Nextra',
- footerText: `MIT ${new Date().getFullYear()} Β© Nextra.`
-}
-```
-
-## `projectLink`
-
-The URL that the button in the top right will point to.
-
-**Type:** `string`
-
-**Default:** `https://github.com/shuding/nextra`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- projectLink: 'https://gitlab.com/librewolf-community/browser'
-}
-```
-
-## `projectLinkIcon`
-
-Changes the icon that is shown in the top right.
-
-**Type:** `ReactNode | React.FC<{ locale: string }>{:ts}`
-
-**Default:** GitHub icon
-
-**Example:**
-
-```jsx filename="theme.config.jsx"
-import Gitlab from '@geist-ui/react-icons/gitlab'
-
-export default {
- projectLinkIcon: ({ locale }) => <Gitlab />
-}
-```
-
-## `docsRepositoryBase`
-
-The base URL of the GitHub repository the docs are located in. This will be used
-for the `Edit this Page on GitHub` button.
-
-**Type:** `string`
-
-**Default:** `https://github.com/shuding/nextra`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- docsRepositoryBase: 'https://github.com/shuding/nextra'
-}
-```
-
-## `titleSuffix`
-
-Suffix that will be added to page titles in the URL bar.
-
-**Type:** `string`
-
-**Default:** `– Nextra`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- titleSuffix: '– Nextra'
-}
-```
-
-## `nextLinks` and `prevLinks`
-
-Specifies if arrows are being shown at the bottom of a page showing the next and
-previous page, like the ones at the bottom of this page.
-
-**Type:** `boolean`
-
-**Default:** `true`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- nextLinks: true,
- prevLinks: true
-}
-```
-
-## `search`
-
-Specifies if a search box should be shown in the top right.
-
-**Type:** `boolean`
-
-**Default:** `true`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- search: true
-}
-```
-
-## `searchPlaceholder`
-
-Specifies if a search box should be shown in the top right.
-
-**Type:** `string | ((props: { locale: string }) => string){:ts}`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- searchPlaceholder({ locale }) {
- if (locale === 'zh-CN') return 'ζœη΄’ζ–‡ζ‘£...'
- return 'Search documentation...'
- }
-}
-```
-
-## `customSearch`
-
-A custom component to display instead of the search bar in the top right, for
-example Algolia.
-
-**Type:** `ReactNode`
-
-**Example:**
-
-```jsx filename="theme.config.jsx"
-import Search from 'your-search'
-
-export default {
- customSearch: <Search />
-}
-```
-
-## `darkMode`
-
-Specifies if the user can select a dark mode.
-
-**Type:** `boolean`
-
-**Default:** `true`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- darkMode: true
-}
-```
-
-## `defaultMenuCollapseLevel`
-
-Specifies the folder level at which the menu on the left is collapsed by
-default.
-
-**Type:** `number`
-
-**Default:** `2`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- defaultMenuCollapseLevel: 2
-}
-```
-
-## `footer`
-
-Specifies if the footer should be shown.
-
-**Type:** `boolean`
-
-**Default:** `true`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- footer: true
-}
-```
-
-## `footerText`
-
-The text that is shown on the left of the footer.
-
-**Type:** `ReactNode | React.FC<PropsWithChildren<{ locale: string }>>{:ts}`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- footerText: ({ locale }) => `MIT ${new Date().getFullYear()} Β© Nextra.`
-}
-```
-
-## `footerEditLink`
-
-The components that should be shown on the link that leads to the editable page
-on the repository.
-
-**Type:** `ReactNode | React.FC<PropsWithChildren<{ locale: string }>>{:ts}`
-
-**Default:** `Edit this page`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- footerEditLink: ({ locale }) => 'Edit this page on GitHub'
-}
-```
-
-## `feedbackLink`
-
-The components that should be shown on the link that leads to the issues or
-discussions of the repository.
-
-**Type:** `ReactNode | React.FC<PropsWithChildren<{ locale: string }>>{:ts}`
-
-**Default:** ``
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- feedbackLink: ({ locale }) => 'Question? Give us feedback β†’'
-}
-```
-
-## `feedbackLabels`
-
-Label used for create issue or discussion.
-
-**Type:** `string`
-
-**Default:** ``
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- feedbackLabels: 'feedbacks'
-}
-```
-
-## `logo`
-
-The logo in the top left.
-
-**Type:** `ReactNode | React.FC<PropsWithChildren<{ locale: string }>>{:ts}`
-
-**Example:**
-
-```jsx filename="theme.config.jsx"
-export default {
- logo: ({ locale }) => (
- <>
- <span className="mr-2 hidden font-extrabold md:inline">Nextra</span>
- <span className="hidden font-normal text-gray-600 md:inline">
- The Next Docs Builder
- </span>
- </>
- )
-}
-```
-
-## `logoLink`
-
-Enable automaticaly linking the logo to root, or provide a custom url.
-
-**Type:** `string` | `boolean`
-
-**Default:** `true` (links to `/` by default)
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- logoLink: '/about'
-}
-```
-
-Or to disable the logo link:
-
-```js filename="theme.config.js"
-export default {
- logoLink: false
-}
-```
-
-## `head`
-
-The head that should be inserted into the html document.
-
-**Type:**
-`ReactNode | React.FC<PropsWithChildren<{ locale: string; config: DocsThemeConfig; title: string; meta: Record<string, any> }>>{:ts}`
-
-**Example:**
-
-```jsx filename="theme.config.jsx"
-export default {
- head: (
- <>
- <meta name="msapplication-TileColor" content="#fff" />
- <meta httpEquiv="Content-Language" content="en" />
- <meta name="description" content="Nextra: the next docs builder" />
- <meta name="twitter:card" content="summary_large_image" />
- <meta name="twitter:site" content="@shuding_" />
- <meta property="og:title" content="Nextra: the next docs builder" />
- <meta property="og:description" content="Nextra: the next docs builder" />
- <meta name="apple-mobile-web-app-title" content="Nextra" />
- </>
- )
-}
-```
-
-## `direction`
-
-The direction of the text on the page
-
-**Type:** `'ltr' | 'rtl'`
-
-**Default:** `'ltr'`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- direction: 'ltr'
-}
-```
-
-## `floatTOC`
-
-Specifies if the table of contents of a page (the headings) should be displayed
-floating on the right instead of being integrated in the menu on the left.
-
-**Type:** `boolean`
-
-**Default:** `false`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- floatTOC: false
-}
-```
-
-## `projectChatLink`
-
-The URL that the chat button in the top right will point to.
-
-**Type:** `string`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- projectChatLink: 'https://discord.gg/hEM84NMkRv'
-}
-```
-
-## `projectChatLinkIcon`
-
-The icon component that is used as the chat button
-
-**Type:** `ReactNode`
-
-**Example:**
-
-```jsx filename="theme.config.jsx"
-export default {
- projectChatLinkIcon: <Discord />
-}
-```
-
-## `banner`
-
-The banner content that will display at top of the page.
-
-**Type:** `ReactNode | React.FC<PropsWithChildren<{ locale: string }>>{:ts}`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- banner: ({ locale }) => 'Nextra 2'
-}
-```
-
-## `bannerKey`
-
-The key that is used to control the display of banner in localStorage.
-
-**Type:** `string`
-
-**Default:** `'nextra-banner'`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- bannerKey: 'Nextra-banner'
-}
-```
-
-## `gitTimestamp`
-
-The component that is used to display timestamp of the last commit of current
-page.
-
-**Type:**
-`string | React.FC<PropsWithChildren<{ locale: string; timestamp: Date }>>{:ts}`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- gitTimestamp: 'Last updated on'
-}
-```
-
-## `tocExtraContent`
-
-The extra content that is displayed under the table of contents.
-
-**Type:** `ReactNode | React.FC<PropsWithChildren<unknown>>{:ts}`
-
-**Example:**
-
-```jsx filename="theme.config.jsx"
-export default {
- tocExtraContent() {
- return <img src="https://placecats.com/300/200" alt="" />
- }
-}
-```
-
-## `i18n`
-
-The internationalization (i18n) config. See more [here](/features/i18n).
-
-## `faviconGlyph`
-
-A glyph that should be used as a favicon.
-
-**Type:** `char`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- faviconGlyph: '🐱'
-}
-```
-
-## `search`
-
-Enable Nextra built-in search
-
-**Type:** `boolean | { codeblocks: boolean }`
-
-**Example:**
-
-```js filename="next.config.mjs"
-import nextra from 'nextra'
-
-const withNextra = nextra({
- theme: 'nextra-theme-blog',
- themeConfig: './theme.config.js',
- search: {
- codeblocks: false
- }
-})
-export default withNextra()
-```
-
-## `searchResultEmpty`
-
-Empty component for search result.
-
-**Type:** `boolean | { codeblocks: boolean }`
-
-**Example:**
-
-```js filename="theme.config.js"
-export default {
- searchResultEmpty({ locale }) {
- if (locale === 'zh-CN') return 'ζœͺζŸ₯ζ‰Ύεˆ°η»“ζžœ'
- return 'No results found'
- }
-}
-```
diff --git a/docs/src/content/themes/docs/index.mdx b/docs/src/content/themes/docs/index.mdx
deleted file mode 100644
index 7a94afe4f..000000000
--- a/docs/src/content/themes/docs/index.mdx
+++ /dev/null
@@ -1,82 +0,0 @@
----
-sidebarTitle: Installation
----
-
-# Docs Theme
-
-import { Steps } from 'nextra/components'
-
-> [!NOTE]
->
-> This website is built with the docs theme.
-
-you can install the blog theme with the following commands:
-
-## Getting start
-
-<Steps>
-
-### Install Next.js, Nextra and React
-
-```sh npm2yarn
-npm i react react-dom next nextra
-```
-
-### Install the docs theme
-
-```sh npm2yarn
-npm i nextra-theme-docs
-```
-
-### Create the following Next.js config and theme config under the root directory:
-
-```jsx filename="next.config.mjs"
-import nextra from 'nextra'
-
-const withNextra = nextra({
- theme: 'nextra-theme-blog',
- themeConfig: './theme.config.js'
-})
-export default withNextra()
-```
-
-```jsx filename="theme.config.js"
-export default {
- projectLink: 'https://github.com/shuding/nextra', // GitHub link in the navbar
- docsRepositoryBase: 'https://github.com/shuding/nextra/blob/master', // base URL for the docs repository
- titleSuffix: ' – Nextra',
- nextLinks: true,
- prevLinks: true,
- search: true,
- customSearch: null, // customizable, you can use algolia for example
- darkMode: true,
- footer: true,
- footerText: `MIT ${new Date().getFullYear()} Β© Shu Ding.`,
- footerEditLink: `Edit this page on GitHub`,
- logo: (
- <>
- <svg>...</svg>
- <span>Next.js Static Site Generator</span>
- </>
- ),
- head: (
- <>
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta name="description" content="Nextra: the next docs builder" />
- <meta name="og:title" content="Nextra: the next docs builder" />
- </>
- )
-}
-```
-
-### You are good to go!
-
-</Steps>
-
----
-
-> [!TIP]
->
-> You can also use
-> [`<style jsx>`](https://nextjs.org/docs/basic-features/built-in-css-support#css-in-js)
-> to style elements inside `theme.config.js`.
diff --git a/docs/src/content/themes/docs/tabs.mdx b/docs/src/content/themes/docs/tabs.mdx
deleted file mode 100644
index e51192bc8..000000000
--- a/docs/src/content/themes/docs/tabs.mdx
+++ /dev/null
@@ -1,81 +0,0 @@
----
-sidebarTitle: Tabs
----
-
-# Tabs Component
-
-A built-in component provided by `nextra-theme-docs`.
-
-## Example
-
-import { Tabs } from 'nextra/components'
-
-<Tabs items={['JavaScript', 'C++', {label:'C', disabled: true}, 'Python']} defaultIndex={1}>
- <Tabs.Tab>
- ```js filename="hi.js"
- import { useState, useEffect } from 'react';
- ```
- </Tabs.Tab>
- <Tabs.Tab>
- ```cpp filename="hi.cpp"
- #include <iostream>
- ```
- </Tabs.Tab>
- <Tabs.Tab>
- ```c filename="hi.c"
- #include <stdio.h>
- ```
- </Tabs.Tab>
- <Tabs.Tab>
- ```python filename="hello.py"
- print('Hello, world!')
- ```
- </Tabs.Tab>
-</Tabs>
-
-## Usage
-
-### MDX component
-
-````mdx filename="tabs.mdx"
-<Tabs items={['JavaScript', 'C++', {label:'C', disabled: true}, 'Python']} defaultIndex={1}>
- <Tabs.Tab>
- ```js filename="hi.js"
- import { useState, useEffect } from 'react';
- ```
- </Tabs.Tab>
- <Tabs.Tab>
- ```cpp filename="hi.cpp"
- #include <iostream>
- ```
- </Tabs.Tab>
- <Tabs.Tab>
- ```c filename="hi.c"
- #include <stdio.h>
- ```
- </Tabs.Tab>
- <Tabs.Tab>
- ```python filename="hello.py"
- print('Hello, world!')
- ```
- </Tabs.Tab>
-</Tabs>
-````
-
-### React Component
-
-```jsx filename="tabs.jsx"
-import { Tabs } from 'nextra/components'
-
-const items = ['1', '2', '3', '4']
-const defaultIndex = 1
-const Component = () => (
- <Tabs items={items} defaultIndex={defaultIndex}>
- <Tabs.Tab>1</Tab>
- <Tabs.Tab>2</Tab>
- <Tabs.Tab>3</Tab>
- <Tabs.Tab>4</Tab>
- </Tabs>
-)
-export default Component
-```
diff --git a/docs/src/content/tracker.mdx b/docs/src/content/tracker.mdx
index 950ef45ee..c959b8384 100644
--- a/docs/src/content/tracker.mdx
+++ b/docs/src/content/tracker.mdx
@@ -15,19 +15,12 @@ If you are self-hosting Rybbit `api.ribbit.io` will be instead the base URL of y
You can customize the script's behavior using `data-*` attributes on the `<script>` tag:
-### `data-debounce`
-
-The delay (in milliseconds) before tracking a pageview after URL changes via the History API (`pushState`, `replaceState`). Set to `0` to disable debouncing.
-
-- **Default:** `"500"`
-- **Example:** `data-debounce="1000"`
+### `data-track-spa`
-### `data-auto-track`
-
-Set to `"false"` to disable automatic pageview tracking on initial load and History API changes. You will need to manually call `window.rybbit.pageview()` or `window.rybbit.track()`.
+Set to `"false"` to disable automatic pageview tracking for single page applications (React, Vue, etc). You will need to manually call `window.rybbit.pageview()` or `window.rybbit.track()` for all but the initial pageview.
- **Default:** `"true"`
-- **Example:** `data-auto-track="false"`
+- **Example:** `data-track-spa="false"`
### `data-skip-patterns`
@@ -43,6 +36,14 @@ A JSON string array of URL path patterns to mask. Pageviews matching these patte
- **Default:** `[]`
- **Example:** `data-mask-patterns='["/users/*/settings", "/order/*"]'`
+### `data-debounce`
+
+The delay (in milliseconds) before tracking a pageview after URL changes via the History API (`pushState`, `replaceState`). Set to `0` to disable debouncing.
+
+- **Default:** `"500"`
+- **Example:** `data-debounce="1000"`
+
+
**Example with multiple options:**
```html
diff --git a/docs/src/content/usage.mdx b/docs/src/content/usage.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/server/public/script.js b/server/public/script.js
index 7a1776556..1177e8779 100644
--- a/server/public/script.js
+++ b/server/public/script.js
@@ -22,7 +22,7 @@
? Math.max(0, parseInt(scriptTag.getAttribute("data-debounce")))
: 500;
- const autoTrackURLs = scriptTag.getAttribute("data-auto-track") !== "false";
+ const autoTrackSpa = scriptTag.getAttribute("data-track-spa") !== "false";
let skipPatterns = [];
try {
@@ -133,7 +133,7 @@
? debounce(trackPageview, debounceDuration)
: trackPageview;
- if (autoTrackURLs) {
+ if (autoTrackSpa) {
const originalPushState = history.pushState;
const originalReplaceState = history.replaceState;