Skip to content

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

docs: Format web SDK

Edward Cui4bbe9fa4b879
diff --git a/docs/src/content/sdks/web.mdx b/docs/src/content/sdks/web.mdx
index 01d26d240..a04eb06ae 100644
--- a/docs/src/content/sdks/web.mdx
+++ b/docs/src/content/sdks/web.mdx
@@ -6,7 +6,7 @@ import { Callout } from "nextra/components"
```bash filename="npm"
npm install @rybbit/js
-````
+```
```bash filename="yarn"
yarn add @rybbit/js
@@ -37,18 +37,18 @@ rybbit.init({
### Configuration Options
-| Option (`init`) | Type | Default | Description |
-| :------------------- | :--------------- | :------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `analyticsHost` | `string` | — | **Required.** URL of your Rybbit analytics instance (e.g., `https://rybbit.yourdomain.com/api`). |
-| `siteId` | `string \| number` | — | **Required.** The Site ID for your website obtained from your Rybbit instance. |
-| `debounce` | `number` | `500` | Debounce time in milliseconds for tracking SPA pageviews after route changes. Set to `0` to disable debouncing (track immediately). |
-| `autoTrackPageviews` | `boolean` | `true` | If `true`, automatically tracks pageviews on initial load and (if `autoTrackSpaRoutes` is `true`) on SPA navigation. |
-| `autoTrackSpaRoutes` | `boolean` | `true` | If `true` (and `autoTrackPageviews` is `true`), automatically tracks pageviews when browser history changes (`pushState`, `popstate`). |
-| `trackQuerystring` | `boolean` | `true` | If `true`, includes the URL's query string (e.g., `?utm_source=google`) in the tracked `querystring` data. |
-| `trackOutboundLinks` | `boolean` | `true` | If `true`, automatically tracks clicks on anchor (`<a>`) tags that link to external domains. |
-| `skipPatterns` | `string[]` | `[]` | Array of path patterns. Pageviews whose path matches any pattern will **not** be tracked. See [Path Matching](#path-matching). |
-| `maskPatterns` | `string[]` | `[]` | Array of path patterns. For matching pageview paths, the original path will be **replaced** by the pattern itself in tracked data. See [Path Matching](#path-matching). |
-| `debug` | `boolean` | `false` | If `true`, enables detailed logging to the browser console. |
+| Option (`init`) | Type | Default | Description |
+| :------------------- | :----------------- | :------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `analyticsHost` | `string` | - | **Required.** URL of your Rybbit analytics instance (e.g., `https://rybbit.yourdomain.com/api`). |
+| `siteId` | `string \| number` | - | **Required.** The Site ID for your website obtained from your Rybbit instance. |
+| `debounce` | `number` | `500` | Debounce time in milliseconds for tracking SPA pageviews after route changes. Set to `0` to disable debouncing (track immediately). |
+| `autoTrackPageviews` | `boolean` | `true` | If `true`, automatically tracks pageviews on initial load and (if `autoTrackSpaRoutes` is `true`) on SPA navigation. |
+| `autoTrackSpaRoutes` | `boolean` | `true` | If `true` (and `autoTrackPageviews` is `true`), automatically tracks pageviews when browser history changes (`pushState`, `popstate`). |
+| `trackQuerystring` | `boolean` | `true` | If `true`, includes the URL's query string (e.g., `?utm_source=google`) in the tracked `querystring` data. |
+| `trackOutboundLinks` | `boolean` | `true` | If `true`, automatically tracks clicks on anchor (`<a>`) tags that link to external domains. |
+| `skipPatterns` | `string[]` | `[]` | Array of path patterns. Pageviews whose path matches any pattern will **not** be tracked. See [Path Matching](#path-matching). |
+| `maskPatterns` | `string[]` | `[]` | Array of path patterns. For matching pageview paths, the original path will be **replaced** by the pattern itself in tracked data. See [Path Matching](#path-matching). |
+| `debug` | `boolean` | `false` | If `true`, enables detailed logging to the browser console. |
## Tracking Pageviews
@@ -102,12 +102,12 @@ Use custom events to track specific user interactions or milestones beyond simpl
### Syntax
```typescript
-rybbit.event(name: string, properties?: Record<string, any>);
+rybbit.event(name: string, properties?: TrackProperties);
```
### Parameters
-- **`name`** (`string`, Required): The name of the event you want to track (e.g., `"signup"`, `"add_to_cart"`, `"video_play"`). Use clear, consistent naming.
+- **`name`** (`string`, Required): The name of the event you want to track.
- **`properties`** (`object`, Optional): An object containing additional key-value pairs related to the event. Values should ideally be strings, numbers, or booleans. Keep the structure flat.
### Example