Skip to content

Commit 08b8a37

Browse files
committed
feat: add to docs
1 parent c1ac078 commit 08b8a37

File tree

1 file changed

+113
-10
lines changed

1 file changed

+113
-10
lines changed

apps/docs/content/docs/sdk.mdx

Lines changed: 113 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,120 @@ const clientId = import.meta.env.VITE_DATABUDDY_CLIENT_ID;
285285
| `sdk` | SDK name (default: `web`) |
286286
| `sdkVersion` | SDK version (auto-detected from package.json) |
287287

288-
### Observability Options
288+
### Privacy & Path Masking
289289

290-
| Option | Default | Description |
291-
|--------|---------|-------------|
292-
| `enableObservability` | `false` | Enable observability features |
293-
| `observabilityService` || Service name for observability events |
294-
| `observabilityEnvironment` || Environment for observability events |
295-
| `observabilityVersion` || Service version for observability events |
296-
| `enableLogging` | `false` | Enable structured logging |
297-
| `enableTracing` | `false` | Enable distributed tracing |
298-
| `enableErrorTracking` | `false` | Enable error tracking |
290+
Control which pages are tracked and how sensitive URL paths are handled:
291+
292+
| Option | Type | Description |
293+
|--------|------|-------------|
294+
| `skipPatterns` | `string[]` | Skip tracking on matching paths (e.g., `["/admin/**", "/private/*"]`) |
295+
| `maskPatterns` | `string[]` | Mask sensitive URL segments in analytics (e.g., `["/users/*", "/orders/**"]`) |
296+
297+
#### Pattern Syntax
298+
299+
- `*` matches a single path segment: `/users/*` matches `/users/123` but not `/users/123/settings`
300+
- `**` matches multiple path segments: `/admin/**` matches `/admin/users/edit/123`
301+
302+
#### Skip Patterns
303+
304+
Prevent tracking on sensitive pages:
305+
306+
<Tabs items={['React/Next.js', 'Vue', 'Vanilla JS']}>
307+
<Tab value="React/Next.js">
308+
309+
```tsx
310+
<Databuddy
311+
clientId="your-client-id"
312+
skipPatterns={[
313+
"/admin/**", // Skip all admin pages
314+
"/private/*", // Skip direct private pages only
315+
"/checkout/payment" // Skip specific payment page
316+
]}
317+
/>
318+
```
319+
320+
</Tab>
321+
<Tab value="Vue">
322+
323+
```vue
324+
<template>
325+
<Databuddy
326+
:client-id="clientId"
327+
:skip-patterns="['/admin/**', '/private/*', '/checkout/payment']"
328+
/>
329+
</template>
330+
```
331+
332+
</Tab>
333+
<Tab value="Vanilla JS">
334+
335+
```html
336+
<script
337+
src="https://cdn.databuddy.cc/databuddy.js"
338+
data-client-id="your-client-id"
339+
data-skip-patterns='["/admin/**", "/private/*", "/checkout/payment"]'
340+
></script>
341+
```
342+
343+
</Tab>
344+
</Tabs>
345+
346+
#### Mask Patterns
347+
348+
Hide sensitive URL segments while preserving analytics structure:
349+
350+
<Tabs items={['React/Next.js', 'Vue', 'Vanilla JS']}>
351+
<Tab value="React/Next.js">
352+
353+
```tsx
354+
<Databuddy
355+
clientId="your-client-id"
356+
maskPatterns={[
357+
"/users/*", // /users/123/profile → /users/*/profile
358+
"/orders/**", // /orders/abc/items/xyz → /orders/*
359+
"/documents/*" // /documents/secret.pdf → /documents/*
360+
]}
361+
/>
362+
```
363+
364+
</Tab>
365+
<Tab value="Vue">
366+
367+
```vue
368+
<template>
369+
<Databuddy
370+
:client-id="clientId"
371+
:mask-patterns="['/users/*', '/orders/**', '/documents/*']"
372+
/>
373+
</template>
374+
```
375+
376+
</Tab>
377+
<Tab value="Vanilla JS">
378+
379+
```html
380+
<script
381+
src="https://cdn.databuddy.cc/databuddy.js"
382+
data-client-id="your-client-id"
383+
data-mask-patterns='["/users/*", "/orders/**", "/documents/*"]'
384+
></script>
385+
```
386+
387+
</Tab>
388+
</Tabs>
389+
390+
#### Masking Behavior
391+
392+
| Pattern | Original Path | Masked Path | Description |
393+
|---------|---------------|-------------|-------------|
394+
| `/users/*` | `/users/123` | `/users/*` | Mask single segment |
395+
| `/users/*` | `/users/123/settings` | `/users/*/settings` | Mask one segment, keep rest |
396+
| `/users/**` | `/users/123/settings` | `/users/*` | Mask everything after prefix |
397+
| `/orders/**` | `/orders/abc/items/xyz` | `/orders/*` | Mask all remaining segments |
398+
399+
<Callout type="info">
400+
**Privacy by Design**: Use skip patterns for pages that should never be tracked, and mask patterns for pages where you need analytics but want to hide sensitive identifiers like user IDs, order numbers, or document names.
401+
</Callout>
299402

300403
## SDK Methods
301404

0 commit comments

Comments
 (0)