featurely-site-manager 1.1.11 → 1.1.15

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
@@ -23,6 +23,25 @@ siteManager.init();
23
23
 
24
24
  ## ✨ Features
25
25
 
26
+ ### 🐛 Debug Overlay
27
+
28
+ - Floating debug panel injected into your site when debug mode is enabled
29
+ - **SDK tab** — live state: environment, maintenance status, active messages, feature flags
30
+ - **Logs tab** — real-time log stream with level-coloured rows (info / warn / error), error count badge, Clear button
31
+ - **Network tab** — config fetch history with status codes and timestamps
32
+ - **Events tab** — all analytics events queued or sent
33
+ - **Test tab** — send test analytics events, check feature flags by key, trigger test errors/bugs, flush the analytics queue, refresh config
34
+ - Intercepts `console.error` and `console.warn` — captured errors appear in the Logs tab
35
+ - Global `window.onerror` and `unhandledrejection` listeners capture uncaught errors
36
+ - Verbose lifecycle logging: init steps, config delta on each poll, analytics flush counts, flag lookups, maintenance state changes
37
+
38
+ ### 🌍 Environments
39
+
40
+ - Per-environment config (maintenance, debug, messages) matched by URL
41
+ - SDK auto-detects the current environment from `window.location.hostname`
42
+ - Configure environment URLs in your Featurely dashboard → Environments
43
+ - Enable/disable debug mode globally or per-environment
44
+
26
45
  ### 🔧 Maintenance Mode
27
46
 
28
47
  - **Default** or **custom** maintenance pages
@@ -245,6 +264,58 @@ When `enableAnalytics` is `true` (default), the SDK automatically tracks:
245
264
 
246
265
  Page tracking is SPA-compatible — it patches `history.pushState` and `history.replaceState` and listens to `popstate` so navigations in React, Next.js, Vue, and similar frameworks are captured automatically.
247
266
 
267
+ ### Debug Overlay
268
+
269
+ Enable the debug overlay from your Featurely dashboard (Maintenance → Debug Overlay) or pass `debugMode: true` directly. When active, a `[FT]` button appears in the bottom-right corner of your site.
270
+
271
+ ```typescript
272
+ const manager = new SiteManager({
273
+ apiKey: "ft_live_your_api_key",
274
+ projectId: "proj_your_project_id",
275
+ // debugMode is read from the server config — no client code needed.
276
+ // You can also force it on locally:
277
+ // debugMode: true,
278
+ });
279
+
280
+ manager.init();
281
+ ```
282
+
283
+ The overlay panel has five tabs:
284
+
285
+ | Tab | Contents |
286
+ | --- | --- |
287
+ | **SDK** | Environment, maintenance status, active messages, feature flag count |
288
+ | **Logs** | Real-time log stream (info / warn / error); error badge on tab; Clear button |
289
+ | **Network** | Config fetch log with status codes and timestamps |
290
+ | **Events** | Analytics events queued/sent |
291
+ | **Test** | Buttons to test analytics, errors, bugs, feature flags, flush, and refresh |
292
+
293
+ #### Test Tab Actions
294
+
295
+ - **Send test event** — fires a `test_event` analytics event
296
+ - **Flush queue** — immediately sends all queued analytics events
297
+ - **Check flag** — enter a flag key to see its current enabled state
298
+ - **Trigger test error** — throws a JS error captured in the Logs tab
299
+ - **Trigger test bug** — fires a `test_bug_report` analytics event
300
+ - **Refresh config** — manually polls the Featurely API
301
+
302
+ ### Environment-Aware Setup
303
+
304
+ When you have multiple environments (production, staging, localhost) configured in your Featurely dashboard, the SDK automatically detects the current environment from `window.location.hostname` — no manual configuration needed.
305
+
306
+ ```typescript
307
+ const manager = new SiteManager({
308
+ apiKey: "ft_live_your_api_key",
309
+ projectId: "proj_your_project_id",
310
+ // Environment is auto-detected from window.location.hostname
311
+ // matching the URL patterns set in your Featurely dashboard.
312
+ });
313
+
314
+ manager.init();
315
+ ```
316
+
317
+ Configure environment URLs in your Featurely dashboard → **Environments**. The SDK matches the current `hostname` against each environment's configured URL. The matching environment's settings (maintenance, debug, messages) take effect.
318
+
248
319
  ### Custom Poll Interval
249
320
 
250
321
  ```typescript
@@ -283,6 +354,7 @@ manager.init();
283
354
  | `onUpdateAvailable` | `function` | ❌ | - | Callback when update is available |
284
355
  | `onUpdateRequired` | `function` | ❌ | - | Callback when update is required (forced) |
285
356
  | `onError` | `function` | ❌ | - | Error callback |
357
+ | `debugMode` | `boolean` | ❌ | `false` | Force-enable debug overlay locally |
286
358
 
287
359
  ## 🎯 API Methods
288
360
 
package/dist/index.d.mts CHANGED
@@ -90,6 +90,8 @@ interface SiteManagerConfig {
90
90
  onUpdateAvailable?: (versionInfo: VersionCheckResponse) => void;
91
91
  onUpdateRequired?: (versionInfo: VersionCheckResponse) => void;
92
92
  onError?: (error: Error) => void;
93
+ debugMode?: boolean;
94
+ environment?: string;
93
95
  }
94
96
  declare class SiteManager {
95
97
  private config;
@@ -109,6 +111,20 @@ declare class SiteManager {
109
111
  private pageEntryTime;
110
112
  private static readonly MAX_CONSECUTIVE_FAILURES;
111
113
  private lastVersionCheck;
114
+ private debugOverlayEl;
115
+ private debugRefreshId;
116
+ private debugLogs;
117
+ private networkLog;
118
+ private analyticsEventsSent;
119
+ private debugMinimized;
120
+ private debugTab;
121
+ private recentAnalyticsEvents;
122
+ private testFlagKey;
123
+ private testFeedback;
124
+ private errorCount;
125
+ private consoleIntercepted;
126
+ private originalConsoleError;
127
+ private originalConsoleWarn;
112
128
  constructor(config: SiteManagerConfig);
113
129
  init(): Promise<void>;
114
130
  destroy(): void;
@@ -127,6 +143,13 @@ declare class SiteManager {
127
143
  private startAnalyticsFlushing;
128
144
  private stopAnalyticsFlushing;
129
145
  private flushAnalytics;
146
+ private debugLog;
147
+ private debugNetwork;
148
+ private stopDebugOverlay;
149
+ private setupGlobalErrorCapture;
150
+ private setupDebugOverlay;
151
+ private renderDebugOverlay;
152
+ private handleTestAction;
130
153
  private setupPageTracking;
131
154
  private trackPageView;
132
155
  private trackPageExit;
package/dist/index.d.ts CHANGED
@@ -90,6 +90,8 @@ interface SiteManagerConfig {
90
90
  onUpdateAvailable?: (versionInfo: VersionCheckResponse) => void;
91
91
  onUpdateRequired?: (versionInfo: VersionCheckResponse) => void;
92
92
  onError?: (error: Error) => void;
93
+ debugMode?: boolean;
94
+ environment?: string;
93
95
  }
94
96
  declare class SiteManager {
95
97
  private config;
@@ -109,6 +111,20 @@ declare class SiteManager {
109
111
  private pageEntryTime;
110
112
  private static readonly MAX_CONSECUTIVE_FAILURES;
111
113
  private lastVersionCheck;
114
+ private debugOverlayEl;
115
+ private debugRefreshId;
116
+ private debugLogs;
117
+ private networkLog;
118
+ private analyticsEventsSent;
119
+ private debugMinimized;
120
+ private debugTab;
121
+ private recentAnalyticsEvents;
122
+ private testFlagKey;
123
+ private testFeedback;
124
+ private errorCount;
125
+ private consoleIntercepted;
126
+ private originalConsoleError;
127
+ private originalConsoleWarn;
112
128
  constructor(config: SiteManagerConfig);
113
129
  init(): Promise<void>;
114
130
  destroy(): void;
@@ -127,6 +143,13 @@ declare class SiteManager {
127
143
  private startAnalyticsFlushing;
128
144
  private stopAnalyticsFlushing;
129
145
  private flushAnalytics;
146
+ private debugLog;
147
+ private debugNetwork;
148
+ private stopDebugOverlay;
149
+ private setupGlobalErrorCapture;
150
+ private setupDebugOverlay;
151
+ private renderDebugOverlay;
152
+ private handleTestAction;
130
153
  private setupPageTracking;
131
154
  private trackPageView;
132
155
  private trackPageExit;