Developer Telemetry Sandbox

Mock Analytics & Event Telemetry Stream

Test PostHog, Mixpanel, Segment, and custom event tracking beacons, validate frontend telemetry hooks, and write automated Playwright E2E assertions without polluting production dashboards.

Live Analytics & Telemetry Stream

Live Ingestion

Simulate PostHog, Mixpanel, and Segment event tracking in your isolated session sandbox.

Total Ingested
0
Event Types
0
Unique Users
0
Top Event
None
Event Name
User / Distinct ID
Event Properties (JSON)
Ingested Event Stream

No Telemetry Events Recorded Yet

Click any preset event on the left or send a POST /api/v1/analytics/track request.

Events are stored in your isolated session sandbox (resource = analytics_events) and can be queried or cleared anytime.

Zero Dashboard Pollution

Keep your real PostHog, Mixpanel, and Google Analytics clean. Run dev builds, tests, and CI pipelines against an isolated mock telemetry endpoint.

Batch & Beacon Ingestion

Supports both single /analytics/track calls and bulk /analytics/batch payloads up to 50 events per batch.

Automated E2E Assertions

Query GET /analytics/events in Playwright or Cypress to assert that specific business events and metadata were dispatched.

Integration Recipes & Usage

1. Ingest Single Event Beacon

Dispatches a single event payload containing event name, user ID, properties, and timestamp.

javascript
1
// 1. Ingest a Single Telemetry Event Beacon
2
fetch('https://playground.nileslabs.com/api/v1/analytics/track', {
3
method: 'POST',
4
headers: {
5
'Content-Type': 'application/json'
6
},
7
body: JSON.stringify({
8
event: 'button_clicked',
9
userId: 'usr_dev_101',
10
properties: {
11
page: '/pricing',
12
plan: 'pro_annual',
13
cta_position: 'hero'
14
},
15
timestamp: new Date().toISOString()
16
})
17
})
18
.then(res => res.json())
19
.then(data => {
20
console.log('Event recorded:', data.event.id);
21
});

2. Bulk Batch Ingestion (Segment / Mixpanel Parity)

Send an array of events in a single HTTP request for offline queue flushes and SDK periodic syncs.

javascript
1
// 2. Bulk Event Beacon Batching (Segment / Mixpanel Parity)
2
fetch('https://playground.nileslabs.com/api/v1/analytics/batch', {
3
method: 'POST',
4
headers: {
5
'Content-Type': 'application/json'
6
},
7
body: JSON.stringify({
8
batch: [
9
{ event: 'page_view', properties: { path: '/home' } },
10
{ event: 'scroll_depth', properties: { depth: '75%' } },
11
{ event: 'checkout_started', properties: { cartTotal: 129.00 } }
12
]
13
})
14
})
15
.then(res => res.json())
16
.then(data => {
17
console.log(Batch processed: ${data.summary.processed}/${data.summary.total} events);
18
});

3. Official TypeScript SDK

Type-safe analytics methods with automatic session identity routing.

typescript
1
// 3. Official TypeScript SDK Usage
2
import { PlaygroundClient } from 'playground-api';
3
4
const client = new PlaygroundClient({
5
identityToken: 'your_sandbox_token'
6
});
7
8
// A. Track single event
9
await client.analytics.track({
10
event: 'subscription_upgraded',
11
userId: 'usr_alice',
12
properties: { fromTier: 'free', toTier: 'enterprise' }
13
});
14
15
// B. Ingest batch of events
16
await client.analytics.batch([
17
{ event: 'feature_used', properties: { feature: 'dark_mode' } },
18
{ event: 'export_downloaded', properties: { format: 'csv' } }
19
]);
20
21
// C. Fetch stream summary and events
22
const summary = await client.analytics.summary();
23
console.log('Total tracked events:', summary.summary.totalEvents);
24
25
const stream = await client.analytics.list({ limit: 10 });
26
console.log('Latest event:', stream.data[0]);

4. React Custom useAnalytics() Hook

Lightweight client-side telemetry hook with offline retry queueing.

tsx
1
// 4. Custom React useAnalytics() Hook with Offline Queueing
2
import { useEffect, useRef } from 'react';
3
4
export function useAnalytics() {
5
const queue = useRef<any[]>([]);
6
7
const track = (event: string, properties: Record<string, any> = {}) => {
8
const payload = {
9
event,
10
properties,
11
timestamp: new Date().toISOString()
12
};
13
14
// Attempt beacon dispatch
15
fetch('https://playground.nileslabs.com/api/v1/analytics/track', {
16
method: 'POST',
17
headers: { 'Content-Type': 'application/json' },
18
body: JSON.stringify(payload)
19
}).catch(() => {
20
// Queue offline if network error
21
queue.current.push(payload);
22
});
23
};
24
25
return { track };
26
}

5. Playwright E2E Test Assertion

Verify that critical conversion funnels and user actions trigger the expected tracking telemetry.

typescript
1
// 5. Automated E2E Test Assertion (Playwright)
2
import { test, expect } from '@playwright/test';
3
4
test('Clicking Buy Now dispatches analytics beacon', async ({ page, request }) => {
5
await page.goto('http://localhost:3000/pricing');
6
await page.click('#buy-pro-btn');
7
8
// Verify beacon arrived in Playground API sandbox
9
const res = await request.get('https://playground.nileslabs.com/api/v1/analytics/events?event=button_clicked');
10
const body = await res.json();
11
12
expect(res.status()).toBe(200);
13
expect(body.data.length).toBeGreaterThanOrEqual(1);
14
expect(body.data[0].properties.plan).toBe('pro_annual');
15
});

Analytics API Reference

MethodEndpointDescription
POST/api/v1/analytics/trackIngest a single event beacon with properties and traits.
POST/api/v1/analytics/batchIngest a batch of up to 50 event beacons atomically.
GET/api/v1/analytics/eventsList recorded telemetry stream with filtering (?event=..., ?userId=...).
GET/api/v1/analytics/summaryGet aggregated metrics, unique users count, and top events breakdown.
DELETE/api/v1/analytics/eventsClear all recorded analytics events for this session sandbox.