@shiva004/surveys 0.5.0 → 0.6.1

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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 shiva004
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logs + Feedback POC
2
2
 
3
- Standalone proof of concept with two modules: a **Log Viewer** (with a guided tour) and a **Feedback** popup (4-step star-rating survey preview). All data is mock and lives in memory.
3
+ Standalone proof of concept with two modules: a **Log Viewer** (with a guided tour) and a **Feedback** popup (4-step star-rating survey that opens automatically). All data is mock and lives in memory.
4
4
 
5
5
  ## Use as a package
6
6
 
@@ -20,6 +20,14 @@ export default function Page() {
20
20
  `LogsApp` accepts `autoStart` (default `true`) to open the tutorial once on first load.
21
21
  `LogsFeedbackApp` renders both modules behind tabs.
22
22
 
23
+ `FeedbackApp` opens its popup automatically on mount (no button). The popup header and footer stay pinned, and the middle scrolls on short screens. Props:
24
+
25
+ | Prop | Default | Description |
26
+ | --- | --- | --- |
27
+ | `autoOpen` | `true` | Open the popup when the component mounts |
28
+ | `onClose` | – | Called after the popup is closed (X, Cancel, Done, Esc, backdrop) |
29
+ | `onSubmit` | – | Called with `{ rating, topics, otherTopic, comment, email, contactOk, submittedAt }` when the person submits |
30
+
23
31
  ### Walkthrough tour + analytics
24
32
 
25
33
  ```tsx
@@ -40,3 +48,81 @@ npm run build # production build + type declarations
40
48
 
41
49
  - Removed: Survey and User Journey modules (`SurveyApp`, `JourneyApp`, `SurveyJourneyApp`, NPS helpers, journey analytics, types, `UserJourneyDocs`).
42
50
  - Added: `LogsApp`, `FeedbackApp`, `LogsFeedbackApp`.
51
+
52
+ ## What changed in 0.6.0
53
+
54
+ - `FeedbackApp` no longer shows a "Preview Feedback" button; the popup auto-opens. New optional props `autoOpen` and `onClose`.
55
+ - Removed dead legacy source (`journey/`, `survey/`, `docs/`, `types.ts`) so `tsc` type-checks cleanly.
56
+ - Added `license`, `keywords`, `publishConfig` to `package.json`.
57
+
58
+ - New fields: "Something else" reveals a required text box, optional email (validated) with a "you can contact me" checkbox, comment counter (500 max). New `onSubmit` prop and `FeedbackResponse` type.
59
+ - New look: pinned header/footer so Back/Next are never cut off, 2-column topic chips, glow and focus rings.
60
+
61
+ ## Logger for your own app code
62
+
63
+ ```ts
64
+ import { createLogger } from '@shiva004/surveys';
65
+
66
+ const log = createLogger('login'); // adds a live "login.logger.log" file to the Log Viewer
67
+ log.info('Login request received', { email });
68
+ log.warn('Password attempt 2 of 3');
69
+ log.error('Authentication failed', err); // Error objects keep their stack trace
70
+ ```
71
+
72
+ Every call prints to the browser console and appears live in the Log Viewer with the real time.
73
+ `import { logger } from '@shiva004/surveys'` gives a default app-wide logger (source `app`).
74
+
75
+ ## Environment capture (network, IP, local time, storage)
76
+
77
+ The Log Viewer records the tester's environment automatically, in the same way as `RouteRecorderWatcher`:
78
+
79
+ - Date/time from the laptop's own clock, with timezone offset (`2026-11-10 14:32:05.123 (UTC+05:30)`)
80
+ - Network: online/offline, connection type, speed class, downlink, RTT
81
+ - Public IP, ISP and location, plus local (LAN) IP via WebRTC
82
+ - Wi-Fi name: browsers cannot read it, so the tester types it once in the Environment panel (remembered, logged)
83
+ - localStorage and sessionStorage: a snapshot at start, then every add / update / remove / clear (sensitive keys masked as `***`)
84
+
85
+ Lines appear live in `network.logger.log` and `storage.logger.log`, and in `console.log`. A collapsible Environment panel shows the current values.
86
+
87
+ ## Logging inside your own functions
88
+
89
+ ```ts
90
+ import { createLogger } from '@shiva004/surveys';
91
+ const log = createLogger('login');
92
+
93
+ // 1) Wrap: start / success + duration / failure are logged for you (sync or async)
94
+ export const login = log.wrap('login', async (email: string, password: string) => {
95
+ const res = await api.post('/login', { email, password });
96
+ return res.data;
97
+ });
98
+
99
+ // 2) Manual: log only the steps you care about
100
+ export async function checkout(cart) {
101
+ log.info('Checkout started', { items: cart.length });
102
+ try {
103
+ const order = await api.post('/orders', cart);
104
+ log.info('Order created', { id: order.id });
105
+ return order;
106
+ } catch (err) {
107
+ log.error('Checkout failed', err);
108
+ throw err;
109
+ }
110
+ }
111
+ ```
112
+
113
+ Arguments and results are not logged unless you pass `{ logArgs: true }` / `{ logResult: true }`. Never enable them for passwords or tokens.
114
+
115
+ ## Heatmap (mouse, clicks, scroll, time per section)
116
+
117
+ ```tsx
118
+ import { HeatmapApp, startHeatmapCapture } from '@shiva004/surveys';
119
+
120
+ startHeatmapCapture(); // call once at app start, so every page is recorded
121
+ <HeatmapApp /> // the report: heatmap, scroll time per page part, most hovered elements
122
+ ```
123
+
124
+ Recorded per page (route): where the mouse rests (20px grid, time in ms), where people click, scroll depth,
125
+ which tenth of the page is in the middle of the screen the longest, and the elements the mouse hovers longest.
126
+ Time only counts while the tab is visible and active (5s idle stops the clock). Typed input values are never recorded.
127
+ Data is kept in localStorage (`pulseLogs.heatmap.v1`) and a summary line per page goes to `heatmap.logger.log`.
128
+ The viewer shows one tile map of the page (each square coloured by mouse time or clicks, strongest spots numbered 1-3) with Mouse time / Clicks buttons and a Details panel.
@@ -1,3 +1,22 @@
1
1
  import React from 'react';
2
2
  import './feedback.css';
3
- export declare const FeedbackApp: React.FC;
3
+ export interface FeedbackResponse {
4
+ rating: number;
5
+ topics: string[];
6
+ /** Text typed when "Something else" is selected. */
7
+ otherTopic: string;
8
+ comment: string;
9
+ email: string;
10
+ /** True if the person agreed to be contacted about their feedback. */
11
+ contactOk: boolean;
12
+ submittedAt: string;
13
+ }
14
+ export interface FeedbackAppProps {
15
+ /** Open the popup as soon as the component mounts. Default: true. */
16
+ autoOpen?: boolean;
17
+ /** Called after the popup is closed. */
18
+ onClose?: () => void;
19
+ /** Called once with the answers when the person submits. */
20
+ onSubmit?: (response: FeedbackResponse) => void;
21
+ }
22
+ export declare const FeedbackApp: React.FC<FeedbackAppProps>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import '../logs/logs.css';
3
+ import './heatmap.css';
4
+ export declare const HeatmapApp: React.FC;
@@ -0,0 +1,33 @@
1
+ export declare const CELL = 20;
2
+ export declare const BANDS = 10;
3
+ export interface ElementStat {
4
+ ms: number;
5
+ text: string;
6
+ }
7
+ export interface PageData {
8
+ path: string;
9
+ visits: number;
10
+ activeMs: number;
11
+ docW: number;
12
+ docH: number;
13
+ maxScrollPct: number;
14
+ cells: Record<string, number>;
15
+ clicks: Record<string, number>;
16
+ clickCount: number;
17
+ bands: number[];
18
+ bandReach: number[];
19
+ elements: Record<string, ElementStat>;
20
+ updatedAt: number;
21
+ }
22
+ export type HeatStore = Record<string, PageData>;
23
+ export declare const getHeatmapData: () => HeatStore;
24
+ export declare const clearHeatmap: () => void;
25
+ export declare const useHeatmapData: () => HeatStore;
26
+ /** The heatmap viewer pauses recording while it is open, so looking at the report is not counted as page time. */
27
+ export declare const setHeatmapPaused: (v: boolean) => void;
28
+ declare global {
29
+ interface Window {
30
+ __pulseHeatmap?: boolean;
31
+ }
32
+ }
33
+ export declare function startHeatmapCapture(): void;
@@ -0,0 +1,17 @@
1
+ import { type PageData } from './capture';
2
+ /** One tile = 2x2 capture cells (40px of the page). Tiles are less noisy than single cells. */
3
+ export declare const TILE: number;
4
+ export interface Hotspot {
5
+ x: number;
6
+ y: number;
7
+ v: number;
8
+ }
9
+ export declare function buildTiles(page: PageData, metric: 'time' | 'clicks'): {
10
+ tiles: Map<string, number>;
11
+ max: number;
12
+ top: Hotspot[];
13
+ };
14
+ export declare const LEGEND_GRADIENT: string;
15
+ /** Tile map: the page is cut into squares, each coloured by how much time / how many clicks it got.
16
+ * The three strongest spots are numbered 1, 2, 3. */
17
+ export declare function drawTiles(canvas: HTMLCanvasElement, page: PageData, metric: 'time' | 'clicks', scale: number): void;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import './styles.css';
2
2
  export { App as LogsFeedbackApp } from './App';
3
3
  export { LogsApp } from './logs/LogsApp';
4
+ export { createLogger, logger } from './logs/data';
5
+ export type { Logger, WrapOptions } from './logs/data';
4
6
  export { FeedbackApp } from './feedback/FeedbackApp';
7
+ export type { FeedbackAppProps, FeedbackResponse } from './feedback/FeedbackApp';
5
8
  export * from './walkthrough';
9
+ export { getNetworkInfo, setNetworkName, refreshNetwork, setPublicLookup, isPublicLookupEnabled, formatLocalTime, } from './logs/environment';
10
+ export { HeatmapApp } from './heatmap/HeatmapApp';
11
+ export { startHeatmapCapture, clearHeatmap, getHeatmapData } from './heatmap/capture';