@shiva004/surveys 0.9.0 → 0.11.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 +86 -0
- package/dist/elements.d.ts +36 -0
- package/dist/elements.js +20271 -0
- package/dist/events/data.d.ts +6 -0
- package/dist/events/snapshots.d.ts +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3078 -2999
- package/package.json +30 -14
package/README.md
CHANGED
|
@@ -36,6 +36,92 @@ import { JourneyProvider, useJourney, WalkthroughDemo } from '@shiva004/surveys'
|
|
|
36
36
|
|
|
37
37
|
Unchanged from 0.4.0. Needs `react` and `react-dom` 18+.
|
|
38
38
|
|
|
39
|
+
## Angular, Vue, plain HTML (web components)
|
|
40
|
+
|
|
41
|
+
The `@shiva004/surveys/elements` entry turns every page into a standard custom element. React is bundled inside and the CSS injects itself, so the host app needs **no React and no stylesheet import**.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install @shiva004/surveys
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// main.ts (Angular, Vue, Svelte, plain JS ...)
|
|
49
|
+
import { defineSurveysElements, startSurveys, configureFlags, demoFlags } from '@shiva004/surveys/elements';
|
|
50
|
+
|
|
51
|
+
defineSurveysElements(); // register the <surveys-*> tags, once
|
|
52
|
+
configureFlags({ project: 'my-app', initialFlags: demoFlags() });
|
|
53
|
+
startSurveys(); // capture events, logs, errors, heatmap, session from the first second
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<surveys-flags project="my-app" (open-events)="go('events')"></surveys-flags> <!-- Angular -->
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Angular: add `schemas: [CUSTOM_ELEMENTS_SCHEMA]` to the standalone component (or NgModule) that uses the tags. See `survey-angular-app/` for a complete example.
|
|
61
|
+
|
|
62
|
+
Import `configureFlags`, `trackEvent`, `createLogger` and the other functions from **`@shiva004/surveys/elements`** when you use the tags. They share state with the pages. (The React entry `@shiva004/surveys` is separate and keeps React external.)
|
|
63
|
+
|
|
64
|
+
| Tag | Page | Attributes | Events |
|
|
65
|
+
| --- | --- | --- | --- |
|
|
66
|
+
| `<surveys-app>` | whole dashboard with tabs | | |
|
|
67
|
+
| `<surveys-logs>` | Logs | `auto-start` | |
|
|
68
|
+
| `<surveys-live-logs>` | Live Logs | `environment` | |
|
|
69
|
+
| `<surveys-events>` | Live Events | | |
|
|
70
|
+
| `<surveys-errors>` | Error Tracking | `environment` | |
|
|
71
|
+
| `<surveys-releases>` | Releases | `environment` | `open-errors`, `open-events` |
|
|
72
|
+
| `<surveys-notifications>` | Notifications | `environment` | `open-errors`, `open-events` |
|
|
73
|
+
| `<surveys-sessions>` | Sessions | `environment` | `replay` |
|
|
74
|
+
| `<surveys-heatmap>` | Heatmap | | |
|
|
75
|
+
| `<surveys-journey>` | User Journey | `endpoint` | |
|
|
76
|
+
| `<surveys-feedback>` | Feedback popup | `auto-open` | `close`, `submitted` |
|
|
77
|
+
| `<surveys-flags>` | Feature Management | `project` | `open-events` |
|
|
78
|
+
| `<surveys-rate-limit>` | Rate Limit | `environment` | |
|
|
79
|
+
| `<surveys-queues>` | Queues | `environment` | |
|
|
80
|
+
| `<surveys-mock-api>` | Mock API | `environment` | |
|
|
81
|
+
|
|
82
|
+
Events are DOM `CustomEvent`s (callback data is in `event.detail`). For props that are not simple strings, set the `props` property: `el.props = { config: {...} }`.
|
|
83
|
+
|
|
84
|
+
Tip: if your TypeScript setup has `skipLibCheck: false`, install `@types/react` as a dev dependency (the type definitions mention React). Angular projects use `skipLibCheck: true` by default, so nothing is needed.
|
|
85
|
+
|
|
86
|
+
## What changed in 0.11.0
|
|
87
|
+
|
|
88
|
+
- New `startSnapshotReporting()` (React) / `startSurveys({ events: { endpoint } })` (Angular, on automatically): every 15-30 s and when the tab is hidden, an `environment_snapshot` event (browser, network, storage key counts) and a `heatmap_summary` event (per page: visits, active time, clicks, scroll depth, top elements) go to your endpoint. IP, ISP and location only with `includeIp: true`.
|
|
89
|
+
- Dummy backend: `node mock-api-server.mjs` (repo root). Same URLs as a real API would need: `POST /events`, `GET /sessions`, `GET /errors`.
|
|
90
|
+
|
|
91
|
+
- Every event sent to your API now carries a `context` object: browser, OS, screen, viewport, timezone, network type, CPU / memory and your own fields. A problem can be matched to the tester's laptop. No IP address, cookies or storage values are included. Switch off with `device: false`.
|
|
92
|
+
- `context` option: add your own fields to every event, e.g. `startEventCapture({ endpoint, context: { app: 'portal', release: '1.4.2', env: 'uat' } })`.
|
|
93
|
+
- Install fixes: `react` / `react-dom` are optional peers, so Angular and Vue apps (which use `/elements`) no longer download React. Bundled libraries (`rrweb`, `react-router-dom`, `lucide-react`) moved to `devDependencies`.
|
|
94
|
+
|
|
95
|
+
## What is sent to your API, and what is not
|
|
96
|
+
|
|
97
|
+
| Data | Goes to your API? | How |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| Events: page views, clicks, JS errors, failed promises, `fetch` calls (status, duration), `console.error` / `console.warn`, your `trackEvent()` calls | **Yes** | `POST { events: [...] }` to the `endpoint` you pass to `startEventCapture` (batched, retried 3 times, sent on tab close) |
|
|
100
|
+
| Device / browser / network facts | **Yes** | in each event's `context` |
|
|
101
|
+
| `console.log` / `info` / `debug` lines | Only if you ask | `capture: { logs: { levels: ['ERROR', 'WARN', 'INFO'] } }` |
|
|
102
|
+
| Environment summary, heatmap summary | **Yes** (`environment_snapshot`, `heatmap_summary` events) | `startSnapshotReporting()` |
|
|
103
|
+
| IP, Wi-Fi name, individual storage values, full heatmap grid | **No** (stay in the browser) | |
|
|
104
|
+
| Session replay recordings (rrweb) | **No** (large, stay in the browser) | |
|
|
105
|
+
| Flags, Queues, Sessions, Rate Limit, Errors, Releases, Notifications, Mock API pages | They **read** from your API; they do not upload | see `LIVE_DATA.md` |
|
|
106
|
+
|
|
107
|
+
Event body:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{ "events": [ {
|
|
111
|
+
"id": "evt_8ac630be", "name": "js_error", "timestamp": "2026-11-25T08:55:45.851Z",
|
|
112
|
+
"source": "runtime", "user_id": "u_dd6dae43dd", "session_id": "s_ece2cdc473",
|
|
113
|
+
"properties": { "message": "boom", "file": "...", "line": 12, "col": 9 },
|
|
114
|
+
"context": { "app": "portal", "platform": "Windows", "user_agent": "...", "screen": "1920x1080", "timezone": "Asia/Kolkata", "network_type": "4g", "online": true }
|
|
115
|
+
} ] }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Your server must accept `POST`, answer 2xx, and allow CORS for the app's origin (add `Authorization` to the allowed headers if you send a token). Try it locally with `node mock-api-server.mjs` from the repo root.
|
|
119
|
+
|
|
120
|
+
## What changed in 0.10.0
|
|
121
|
+
|
|
122
|
+
- New `@shiva004/surveys/elements` entry: all pages as web components for Angular, Vue and plain HTML, plus `defineSurveysElements()` and `startSurveys()`.
|
|
123
|
+
- React usage is unchanged.
|
|
124
|
+
|
|
39
125
|
## Run the demo
|
|
40
126
|
|
|
41
127
|
```bash
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-neutral entry point: every page is a standard Web Component (custom element).
|
|
3
|
+
* Works in Angular, Vue, Svelte, plain HTML, or anything else. React is bundled inside, so the host app does not need it.
|
|
4
|
+
*
|
|
5
|
+
* import { defineSurveysElements, startSurveys } from '@shiva004/surveys/elements';
|
|
6
|
+
* defineSurveysElements(); // once, at startup
|
|
7
|
+
* startSurveys(); // optional: capture events / logs / errors from the first second
|
|
8
|
+
*
|
|
9
|
+
* <surveys-flags project="my-app"></surveys-flags>
|
|
10
|
+
*
|
|
11
|
+
* The configure* / connect* / trackEvent / createLogger functions are exported from here too. Import them from THIS entry
|
|
12
|
+
* (not from '@shiva004/surveys') so the pages and your code share the same state.
|
|
13
|
+
*/
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import './styles.css';
|
|
16
|
+
import { startEventCapture } from './events/data';
|
|
17
|
+
import { type SnapshotOptions } from './events/snapshots';
|
|
18
|
+
export * from './index';
|
|
19
|
+
type Def = {
|
|
20
|
+
tag: string;
|
|
21
|
+
component: React.ComponentType<any>;
|
|
22
|
+
/** React callback prop -> DOM event name (read it with addEventListener / Angular's (event) binding). */
|
|
23
|
+
events?: Record<string, string>;
|
|
24
|
+
};
|
|
25
|
+
export declare const SURVEYS_ELEMENTS: Def[];
|
|
26
|
+
/** Register all <surveys-*> tags. Safe to call more than once. */
|
|
27
|
+
export declare const defineSurveysElements: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Start every background capture (heatmap, events, rate limit, mock API, releases, notifications, errors, live logs, session)
|
|
30
|
+
* so the pages already have data when opened. Order matters and is handled here. Returns one stop function.
|
|
31
|
+
*/
|
|
32
|
+
export declare const startSurveys: (opts?: {
|
|
33
|
+
events?: Parameters<typeof startEventCapture>[0];
|
|
34
|
+
/** Send environment + heatmap summaries to the events endpoint. Default: on when `events.endpoint` is set. */
|
|
35
|
+
snapshots?: boolean | SnapshotOptions;
|
|
36
|
+
}) => () => void;
|