@shiva004/surveys 0.8.0 → 0.10.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 CHANGED
@@ -36,6 +36,58 @@ 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.10.0
87
+
88
+ - New `@shiva004/surveys/elements` entry: all pages as web components for Angular, Vue and plain HTML, plus `defineSurveysElements()` and `startSurveys()`.
89
+ - React usage is unchanged.
90
+
39
91
  ## Run the demo
40
92
 
41
93
  ```bash
package/dist/App.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  export declare const MODULES: {
3
3
  id: string;
4
+ group: string;
4
5
  label: string;
5
6
  }[];
6
7
  export interface AppProps {
@@ -0,0 +1,33 @@
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
+ export * from './index';
18
+ type Def = {
19
+ tag: string;
20
+ component: React.ComponentType<any>;
21
+ /** React callback prop -> DOM event name (read it with addEventListener / Angular's (event) binding). */
22
+ events?: Record<string, string>;
23
+ };
24
+ export declare const SURVEYS_ELEMENTS: Def[];
25
+ /** Register all <surveys-*> tags. Safe to call more than once. */
26
+ export declare const defineSurveysElements: () => void;
27
+ /**
28
+ * Start every background capture (heatmap, events, rate limit, mock API, releases, notifications, errors, live logs, session)
29
+ * so the pages already have data when opened. Order matters and is handled here. Returns one stop function.
30
+ */
31
+ export declare const startSurveys: (opts?: {
32
+ events?: Parameters<typeof startEventCapture>[0];
33
+ }) => () => void;