@shiva004/surveys 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/App.d.ts +10 -1
- package/dist/events/IngestionApp.d.ts +3 -0
- package/dist/events/data.d.ts +99 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8565 -1294
- package/dist/recorder/RouteRecorderWatcher.d.ts +17 -0
- package/dist/style.css +1 -1
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -49,6 +49,47 @@ npm run build # production build + type declarations
|
|
|
49
49
|
- Removed: Survey and User Journey modules (`SurveyApp`, `JourneyApp`, `SurveyJourneyApp`, NPS helpers, journey analytics, types, `UserJourneyDocs`).
|
|
50
50
|
- Added: `LogsApp`, `FeedbackApp`, `LogsFeedbackApp`.
|
|
51
51
|
|
|
52
|
+
## What changed in 0.7.0
|
|
53
|
+
|
|
54
|
+
- New **Live Events** page (`IngestionApp`): real-time event ingestion from your own app (throughput, success rate, ack latency, by-source bars, live table with filters and payload details).
|
|
55
|
+
- New pipeline in `events/`: `trackEvent`, queue + batching, retries with backoff, client rate limit, optional HTTP `endpoint` or custom `transport`.
|
|
56
|
+
- Auto-capture: page views, clicks, JS errors, `fetch` calls, tab visibility, and logger lines (`log_error`, `log_warn`).
|
|
57
|
+
- New exports: `startEventCapture`, `trackEvent`, `ingestRemote`, `identify`, `configureIngestion`, `useIngestion`, `getIngestionSnapshot`.
|
|
58
|
+
- New "Live Events" tab in `LogsFeedbackApp`.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { startEventCapture, trackEvent, identify, ingestRemote, IngestionApp } from '@shiva004/surveys';
|
|
62
|
+
import '@shiva004/surveys/style.css';
|
|
63
|
+
|
|
64
|
+
// once, at your app root (local in-app sink by default)
|
|
65
|
+
startEventCapture({
|
|
66
|
+
// endpoint: 'https://api.yourapp.com/events', // POST { events: [...] }
|
|
67
|
+
// headers: { Authorization: 'Bearer ...' },
|
|
68
|
+
// capture: { logs: { levels: ['ERROR', 'WARN', 'INFO'] } },
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
trackEvent('checkout_started', { cart_value: 49.9 }); // custom event
|
|
72
|
+
identify(user.id); // attach a user id
|
|
73
|
+
socket.onmessage = (m) => ingestRemote(JSON.parse(m.data)); // server-pushed events
|
|
74
|
+
|
|
75
|
+
<IngestionApp /> // the live viewer
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Notes: click text (first 60 characters) is recorded, add `data-ei-ignore` to skip an element. Log messages and URLs can contain private data, so check them before sending to a real backend. Events live in memory and reset on reload.
|
|
79
|
+
|
|
80
|
+
## What changed in 0.6.1
|
|
81
|
+
|
|
82
|
+
- Fixed the Log Viewer tutorial (no more state updates inside state updaters) and the highlight box near screen edges.
|
|
83
|
+
- `EnvPanel` rebuilt; environment capture now survives hot reload, ignores out-of-order network refreshes, and detects browsers that hide the LAN IP.
|
|
84
|
+
- New exports: `refreshNetwork`, `setPublicLookup`, `isPublicLookupEnabled`.
|
|
85
|
+
- `HeatmapApp`, `startHeatmapCapture`, `createLogger` and `logger` are now in the published build (0.6.0 shipped without them).
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { HeatmapApp, startHeatmapCapture } from '@shiva004/surveys';
|
|
89
|
+
startHeatmapCapture(); // once, records mouse / clicks / scroll on every page
|
|
90
|
+
<HeatmapApp /> // the viewer
|
|
91
|
+
```
|
|
92
|
+
|
|
52
93
|
## What changed in 0.6.0
|
|
53
94
|
|
|
54
95
|
- `FeedbackApp` no longer shows a "Preview Feedback" button; the popup auto-opens. New optional props `autoOpen` and `onClose`.
|
package/dist/App.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const MODULES: {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}[];
|
|
6
|
+
export interface AppProps {
|
|
7
|
+
/** Optional controlled mode: pass the active tab (e.g. from the URL) and a change handler. */
|
|
8
|
+
module?: string;
|
|
9
|
+
onModuleChange?: (id: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const App: React.FC<AppProps>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type Level } from '../logs/data';
|
|
2
|
+
export type IngestStatus = 'accepted' | 'queued' | 'failed' | 'dropped';
|
|
3
|
+
export declare const STATUSES: IngestStatus[];
|
|
4
|
+
export type Source = string;
|
|
5
|
+
/** What is actually sent over the wire (one item of the batch). */
|
|
6
|
+
export interface WireEvent {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
source: Source;
|
|
11
|
+
user_id: string;
|
|
12
|
+
session_id: string;
|
|
13
|
+
properties: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface IngestEvent {
|
|
16
|
+
id: string;
|
|
17
|
+
ts: number;
|
|
18
|
+
name: string;
|
|
19
|
+
source: Source;
|
|
20
|
+
status: IngestStatus;
|
|
21
|
+
latencyMs: number | null;
|
|
22
|
+
sizeBytes: number;
|
|
23
|
+
userId: string;
|
|
24
|
+
page: string;
|
|
25
|
+
attempts: number;
|
|
26
|
+
reason?: string;
|
|
27
|
+
payload: WireEvent;
|
|
28
|
+
}
|
|
29
|
+
export interface Point {
|
|
30
|
+
t: number;
|
|
31
|
+
rate: number;
|
|
32
|
+
failed: number;
|
|
33
|
+
}
|
|
34
|
+
export interface Snapshot {
|
|
35
|
+
events: IngestEvent[];
|
|
36
|
+
history: Point[];
|
|
37
|
+
paused: boolean;
|
|
38
|
+
capturing: boolean;
|
|
39
|
+
mode: 'local' | 'endpoint' | 'custom';
|
|
40
|
+
target: string;
|
|
41
|
+
total: number;
|
|
42
|
+
byStatus: Record<IngestStatus, number>;
|
|
43
|
+
bySource: Record<string, number>;
|
|
44
|
+
currentRate: number;
|
|
45
|
+
peakRate: number;
|
|
46
|
+
p50: number | null;
|
|
47
|
+
p95: number | null;
|
|
48
|
+
}
|
|
49
|
+
export interface IngestionConfig {
|
|
50
|
+
/** POST target. Body: { events: WireEvent[] }. Omit to use the in-app local sink. */
|
|
51
|
+
endpoint?: string;
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
/** Full control over delivery. Throw (or reject) to mark the batch as failed. */
|
|
54
|
+
transport?: (batch: WireEvent[]) => Promise<void> | void;
|
|
55
|
+
batchSize?: number;
|
|
56
|
+
flushMs?: number;
|
|
57
|
+
maxPerSecond?: number;
|
|
58
|
+
maxRetries?: number;
|
|
59
|
+
source?: Source;
|
|
60
|
+
}
|
|
61
|
+
export interface CaptureOptions {
|
|
62
|
+
pageViews?: boolean;
|
|
63
|
+
clicks?: boolean;
|
|
64
|
+
errors?: boolean;
|
|
65
|
+
network?: boolean;
|
|
66
|
+
visibility?: boolean;
|
|
67
|
+
/** Forward logger lines (console.* and logger.*) as events. Default: ERROR + WARN only. */
|
|
68
|
+
logs?: boolean | {
|
|
69
|
+
levels?: Level[];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export interface RemoteEvent {
|
|
73
|
+
id?: string;
|
|
74
|
+
name: string;
|
|
75
|
+
ts?: number | string;
|
|
76
|
+
source?: Source;
|
|
77
|
+
userId?: string;
|
|
78
|
+
properties?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
export declare const configureIngestion: (c: IngestionConfig) => void;
|
|
81
|
+
export declare const identify: (id: string) => void;
|
|
82
|
+
/** Send one event into the pipeline. Returns the event id. */
|
|
83
|
+
export declare const trackEvent: (name: string, properties?: Record<string, unknown>, opts?: {
|
|
84
|
+
source?: Source;
|
|
85
|
+
}) => string;
|
|
86
|
+
/** Push an event that was produced elsewhere (e.g. from your WebSocket / SSE handler). */
|
|
87
|
+
export declare const ingestRemote: (r: RemoteEvent) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Start capturing real events from this app. Call once at the app root; returns a stop function.
|
|
90
|
+
* Captures: page_view, click, js_error / unhandled_rejection, api_request (fetch), app_hidden / app_visible,
|
|
91
|
+
* and logger lines as log_error / log_warn (/ log_info / log_debug if enabled via capture.logs.levels).
|
|
92
|
+
*/
|
|
93
|
+
export declare const startEventCapture: (config?: IngestionConfig & {
|
|
94
|
+
capture?: CaptureOptions;
|
|
95
|
+
}) => (() => void);
|
|
96
|
+
export declare const useIngestion: () => Snapshot;
|
|
97
|
+
export declare const getIngestionSnapshot: () => Snapshot;
|
|
98
|
+
export declare const setPaused: (p: boolean) => void;
|
|
99
|
+
export declare const resetIngestion: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,10 @@ export type { FeedbackAppProps, FeedbackResponse } from './feedback/FeedbackApp'
|
|
|
8
8
|
export * from './walkthrough';
|
|
9
9
|
export { getNetworkInfo, setNetworkName, refreshNetwork, setPublicLookup, isPublicLookupEnabled, formatLocalTime, } from './logs/environment';
|
|
10
10
|
export { HeatmapApp } from './heatmap/HeatmapApp';
|
|
11
|
+
export { IngestionApp } from './events/IngestionApp';
|
|
12
|
+
export { startEventCapture, trackEvent, ingestRemote, identify, configureIngestion, useIngestion, getIngestionSnapshot, } from './events/data';
|
|
13
|
+
export type { IngestionConfig, CaptureOptions, RemoteEvent, WireEvent, IngestEvent, IngestStatus } from './events/data';
|
|
11
14
|
export { startHeatmapCapture, clearHeatmap, getHeatmapData } from './heatmap/capture';
|
|
15
|
+
export { RouteRecorderWatcher } from './recorder/RouteRecorderWatcher';
|
|
16
|
+
export type { RouteRecorderWatcherProps } from './recorder/RouteRecorderWatcher';
|
|
17
|
+
export type { AppProps } from './App';
|