featurely-site-manager 1.1.15 → 1.1.18

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/dist/index.d.mts CHANGED
@@ -91,7 +91,6 @@ interface SiteManagerConfig {
91
91
  onUpdateRequired?: (versionInfo: VersionCheckResponse) => void;
92
92
  onError?: (error: Error) => void;
93
93
  debugMode?: boolean;
94
- environment?: string;
95
94
  }
96
95
  declare class SiteManager {
97
96
  private config;
package/dist/index.d.ts CHANGED
@@ -91,7 +91,6 @@ interface SiteManagerConfig {
91
91
  onUpdateRequired?: (versionInfo: VersionCheckResponse) => void;
92
92
  onError?: (error: Error) => void;
93
93
  debugMode?: boolean;
94
- environment?: string;
95
94
  }
96
95
  declare class SiteManager {
97
96
  private config;
package/dist/index.js CHANGED
@@ -98,8 +98,7 @@ var _SiteManager = class _SiteManager {
98
98
  // 1 hour
99
99
  onUpdateAvailable: config.onUpdateAvailable,
100
100
  onUpdateRequired: config.onUpdateRequired,
101
- debugMode: (_f = config.debugMode) != null ? _f : false,
102
- environment: config.environment
101
+ debugMode: (_f = config.debugMode) != null ? _f : false
103
102
  };
104
103
  this.loadDismissedMessages();
105
104
  }
@@ -107,7 +106,6 @@ var _SiteManager = class _SiteManager {
107
106
  * Initialize and start the site manager
108
107
  */
109
108
  async init() {
110
- var _a;
111
109
  if (typeof window === "undefined" || typeof document === "undefined") {
112
110
  console.warn(
113
111
  "Featurely Site Manager: Can only be initialized in a browser environment"
@@ -117,7 +115,7 @@ var _SiteManager = class _SiteManager {
117
115
  if (this.config.debugMode) {
118
116
  this.setupDebugOverlay();
119
117
  }
120
- this.debugLog("info", `[init] v1.1.14 | project: ${this.config.projectId} | env: ${(_a = this.config.environment) != null ? _a : "\u2014"}`);
118
+ this.debugLog("info", `[init] v1.1.16 | project: ${this.config.projectId} | hostname: ${typeof window !== "undefined" ? window.location.hostname : "\u2014"}`);
121
119
  this.debugLog("info", `[init] analytics: ${this.config.enableAnalytics ? "on" : "off"} | poll: ${this.config.pollInterval}ms | debug: ${this.config.debugMode ? "on" : "off"}`);
122
120
  if (this.config.enableAnalytics) {
123
121
  this.debugLog("info", "[init] starting analytics + page tracking");
@@ -366,10 +364,12 @@ var _SiteManager = class _SiteManager {
366
364
  if (newConfig.debugMode === true && !this.debugOverlayEl) {
367
365
  this.setupDebugOverlay();
368
366
  }
369
- if (!this.debugOverlayEl && this.config.environment) {
367
+ if (!this.debugOverlayEl) {
368
+ const hostname = typeof window !== "undefined" ? window.location.hostname : "";
370
369
  const envs = newConfig.environments;
371
- const env = envs == null ? void 0 : envs.find((e) => e.slug === this.config.environment || e.name === this.config.environment);
372
- if ((env == null ? void 0 : env.debugEnabled) === true) {
370
+ const matchedEnv = hostname ? envs == null ? void 0 : envs.find((e) => typeof e.url === "string" && e.url !== "" && e.url === hostname) : void 0;
371
+ if ((matchedEnv == null ? void 0 : matchedEnv.debugEnabled) === true) {
372
+ this.debugLog("info", `[env] matched environment "${matchedEnv.name}" (${hostname})`);
373
373
  this.setupDebugOverlay();
374
374
  }
375
375
  }
@@ -484,13 +484,13 @@ var _SiteManager = class _SiteManager {
484
484
  }
485
485
  } catch (fetchError) {
486
486
  const sentViaBeacon = typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function" && navigator.sendBeacon(url, payload);
487
+ const errMsg = fetchError instanceof Error ? fetchError.message : String(fetchError);
487
488
  if (!sentViaBeacon) {
488
- const errMsg = fetchError instanceof Error ? fetchError.message : String(fetchError);
489
489
  console.error(`[Featurely] Failed to send analytics event "${event.eventName}":`, fetchError);
490
490
  this.debugLog("error", `[analytics] send failed for "${event.eventName}": ${errMsg}`);
491
491
  this.errorCount++;
492
492
  } else {
493
- this.debugLog("warn", `[analytics] fetch failed for "${event.eventName}", delivered via sendBeacon`);
493
+ this.debugLog("warn", `[analytics] fetch failed for "${event.eventName}" (${errMsg}), delivered via sendBeacon`);
494
494
  }
495
495
  }
496
496
  }
@@ -629,9 +629,9 @@ var _SiteManager = class _SiteManager {
629
629
  const flagCount = (_c = (_b = sc == null ? void 0 : sc.featureFlags) == null ? void 0 : _b.length) != null ? _c : 0;
630
630
  const msgCount = (_e = (_d = sc == null ? void 0 : sc.messages) == null ? void 0 : _d.length) != null ? _e : 0;
631
631
  content = `
632
- ${row("SDK Version", "1.1.14")}
632
+ ${row("SDK Version", "1.1.16")}
633
633
  ${row("Project", cfg.projectId)}
634
- ${row("Environment", cfg.environment || "\u2014")}
634
+ ${row("Hostname", typeof window !== "undefined" ? window.location.hostname : "\u2014")}
635
635
  ${row("API URL", cfg.apiUrl)}
636
636
  ${row("Maintenance", maintenance)}
637
637
  ${row("Feature Flags", `${flagCount} active`)}
@@ -653,18 +653,19 @@ var _SiteManager = class _SiteManager {
653
653
  }
654
654
  }
655
655
  } else if (tab === "logs") {
656
- const logs = this.debugLogs.slice(0, 50);
656
+ const logs = this.debugLogs;
657
657
  const errorsInLog = logs.filter((l) => l.level === "error").length;
658
658
  const clearBtn = `<button data-action="clear-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Clear</button>`;
659
+ const copyBtn = `<button data-action="copy-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Copy</button>`;
659
660
  const errBadge = errorsInLog > 0 ? `<span style="font-size:9px;color:${RED}">${errorsInLog} error${errorsInLog > 1 ? "s" : ""}</span>` : "";
660
- const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}${clearBtn}</div>`;
661
+ const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}<div style="display:flex;gap:4px">${copyBtn}${clearBtn}</div></div>`;
661
662
  if (logs.length === 0) {
662
663
  content = logHeader + `<div style="color:${MUTED};padding:12px;text-align:center">No logs yet</div>`;
663
664
  } else {
664
- content = logHeader + logs.map((l) => {
665
+ content = logHeader + `<div style="user-select:text;-webkit-user-select:text">` + logs.map((l) => {
665
666
  const c = l.level === "error" ? RED : l.level === "warn" ? YELLOW : "#a5b4fc";
666
- return `<div style="padding:2px 0;display:flex;gap:6px;align-items:flex-start;border-bottom:1px solid rgba(255,255,255,0.03)"><span style="color:${MUTED};white-space:nowrap;font-size:9px">${l.ts}</span><span style="color:${c};flex:1;word-break:break-word">${l.msg}</span></div>`;
667
- }).join("");
667
+ return `<div style="padding:2px 0;display:flex;gap:6px;align-items:flex-start;border-bottom:1px solid rgba(255,255,255,0.03)"><span style="color:${MUTED};white-space:nowrap;font-size:9px">${l.ts}</span><span style="color:${c};flex:1;word-break:break-word;cursor:text">${l.msg}</span></div>`;
668
+ }).join("") + `</div>`;
668
669
  }
669
670
  } else if (tab === "network") {
670
671
  const calls = this.networkLog.slice(0, 20);
@@ -817,6 +818,15 @@ var _SiteManager = class _SiteManager {
817
818
  await this.fetchConfig();
818
819
  feedback("Config refreshed", true);
819
820
  break;
821
+ case "copy-logs": {
822
+ const text = this.debugLogs.slice().reverse().map((l) => `[${l.ts}] [${l.level.toUpperCase()}] ${l.msg}`).join("\n");
823
+ void navigator.clipboard.writeText(text).then(() => {
824
+ feedback(`Copied ${this.debugLogs.length} log line${this.debugLogs.length !== 1 ? "s" : ""}`, true);
825
+ }).catch(() => {
826
+ feedback("Copy failed \u2014 clipboard not available", false);
827
+ });
828
+ break;
829
+ }
820
830
  case "clear-logs":
821
831
  this.debugLogs = [];
822
832
  this.testFeedback = [];
package/dist/index.mjs CHANGED
@@ -63,8 +63,7 @@ var _SiteManager = class _SiteManager {
63
63
  // 1 hour
64
64
  onUpdateAvailable: config.onUpdateAvailable,
65
65
  onUpdateRequired: config.onUpdateRequired,
66
- debugMode: (_f = config.debugMode) != null ? _f : false,
67
- environment: config.environment
66
+ debugMode: (_f = config.debugMode) != null ? _f : false
68
67
  };
69
68
  this.loadDismissedMessages();
70
69
  }
@@ -72,7 +71,6 @@ var _SiteManager = class _SiteManager {
72
71
  * Initialize and start the site manager
73
72
  */
74
73
  async init() {
75
- var _a;
76
74
  if (typeof window === "undefined" || typeof document === "undefined") {
77
75
  console.warn(
78
76
  "Featurely Site Manager: Can only be initialized in a browser environment"
@@ -82,7 +80,7 @@ var _SiteManager = class _SiteManager {
82
80
  if (this.config.debugMode) {
83
81
  this.setupDebugOverlay();
84
82
  }
85
- this.debugLog("info", `[init] v1.1.14 | project: ${this.config.projectId} | env: ${(_a = this.config.environment) != null ? _a : "\u2014"}`);
83
+ this.debugLog("info", `[init] v1.1.16 | project: ${this.config.projectId} | hostname: ${typeof window !== "undefined" ? window.location.hostname : "\u2014"}`);
86
84
  this.debugLog("info", `[init] analytics: ${this.config.enableAnalytics ? "on" : "off"} | poll: ${this.config.pollInterval}ms | debug: ${this.config.debugMode ? "on" : "off"}`);
87
85
  if (this.config.enableAnalytics) {
88
86
  this.debugLog("info", "[init] starting analytics + page tracking");
@@ -331,10 +329,12 @@ var _SiteManager = class _SiteManager {
331
329
  if (newConfig.debugMode === true && !this.debugOverlayEl) {
332
330
  this.setupDebugOverlay();
333
331
  }
334
- if (!this.debugOverlayEl && this.config.environment) {
332
+ if (!this.debugOverlayEl) {
333
+ const hostname = typeof window !== "undefined" ? window.location.hostname : "";
335
334
  const envs = newConfig.environments;
336
- const env = envs == null ? void 0 : envs.find((e) => e.slug === this.config.environment || e.name === this.config.environment);
337
- if ((env == null ? void 0 : env.debugEnabled) === true) {
335
+ const matchedEnv = hostname ? envs == null ? void 0 : envs.find((e) => typeof e.url === "string" && e.url !== "" && e.url === hostname) : void 0;
336
+ if ((matchedEnv == null ? void 0 : matchedEnv.debugEnabled) === true) {
337
+ this.debugLog("info", `[env] matched environment "${matchedEnv.name}" (${hostname})`);
338
338
  this.setupDebugOverlay();
339
339
  }
340
340
  }
@@ -449,13 +449,13 @@ var _SiteManager = class _SiteManager {
449
449
  }
450
450
  } catch (fetchError) {
451
451
  const sentViaBeacon = typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function" && navigator.sendBeacon(url, payload);
452
+ const errMsg = fetchError instanceof Error ? fetchError.message : String(fetchError);
452
453
  if (!sentViaBeacon) {
453
- const errMsg = fetchError instanceof Error ? fetchError.message : String(fetchError);
454
454
  console.error(`[Featurely] Failed to send analytics event "${event.eventName}":`, fetchError);
455
455
  this.debugLog("error", `[analytics] send failed for "${event.eventName}": ${errMsg}`);
456
456
  this.errorCount++;
457
457
  } else {
458
- this.debugLog("warn", `[analytics] fetch failed for "${event.eventName}", delivered via sendBeacon`);
458
+ this.debugLog("warn", `[analytics] fetch failed for "${event.eventName}" (${errMsg}), delivered via sendBeacon`);
459
459
  }
460
460
  }
461
461
  }
@@ -594,9 +594,9 @@ var _SiteManager = class _SiteManager {
594
594
  const flagCount = (_c = (_b = sc == null ? void 0 : sc.featureFlags) == null ? void 0 : _b.length) != null ? _c : 0;
595
595
  const msgCount = (_e = (_d = sc == null ? void 0 : sc.messages) == null ? void 0 : _d.length) != null ? _e : 0;
596
596
  content = `
597
- ${row("SDK Version", "1.1.14")}
597
+ ${row("SDK Version", "1.1.16")}
598
598
  ${row("Project", cfg.projectId)}
599
- ${row("Environment", cfg.environment || "\u2014")}
599
+ ${row("Hostname", typeof window !== "undefined" ? window.location.hostname : "\u2014")}
600
600
  ${row("API URL", cfg.apiUrl)}
601
601
  ${row("Maintenance", maintenance)}
602
602
  ${row("Feature Flags", `${flagCount} active`)}
@@ -618,18 +618,19 @@ var _SiteManager = class _SiteManager {
618
618
  }
619
619
  }
620
620
  } else if (tab === "logs") {
621
- const logs = this.debugLogs.slice(0, 50);
621
+ const logs = this.debugLogs;
622
622
  const errorsInLog = logs.filter((l) => l.level === "error").length;
623
623
  const clearBtn = `<button data-action="clear-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Clear</button>`;
624
+ const copyBtn = `<button data-action="copy-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Copy</button>`;
624
625
  const errBadge = errorsInLog > 0 ? `<span style="font-size:9px;color:${RED}">${errorsInLog} error${errorsInLog > 1 ? "s" : ""}</span>` : "";
625
- const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}${clearBtn}</div>`;
626
+ const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}<div style="display:flex;gap:4px">${copyBtn}${clearBtn}</div></div>`;
626
627
  if (logs.length === 0) {
627
628
  content = logHeader + `<div style="color:${MUTED};padding:12px;text-align:center">No logs yet</div>`;
628
629
  } else {
629
- content = logHeader + logs.map((l) => {
630
+ content = logHeader + `<div style="user-select:text;-webkit-user-select:text">` + logs.map((l) => {
630
631
  const c = l.level === "error" ? RED : l.level === "warn" ? YELLOW : "#a5b4fc";
631
- return `<div style="padding:2px 0;display:flex;gap:6px;align-items:flex-start;border-bottom:1px solid rgba(255,255,255,0.03)"><span style="color:${MUTED};white-space:nowrap;font-size:9px">${l.ts}</span><span style="color:${c};flex:1;word-break:break-word">${l.msg}</span></div>`;
632
- }).join("");
632
+ return `<div style="padding:2px 0;display:flex;gap:6px;align-items:flex-start;border-bottom:1px solid rgba(255,255,255,0.03)"><span style="color:${MUTED};white-space:nowrap;font-size:9px">${l.ts}</span><span style="color:${c};flex:1;word-break:break-word;cursor:text">${l.msg}</span></div>`;
633
+ }).join("") + `</div>`;
633
634
  }
634
635
  } else if (tab === "network") {
635
636
  const calls = this.networkLog.slice(0, 20);
@@ -782,6 +783,15 @@ var _SiteManager = class _SiteManager {
782
783
  await this.fetchConfig();
783
784
  feedback("Config refreshed", true);
784
785
  break;
786
+ case "copy-logs": {
787
+ const text = this.debugLogs.slice().reverse().map((l) => `[${l.ts}] [${l.level.toUpperCase()}] ${l.msg}`).join("\n");
788
+ void navigator.clipboard.writeText(text).then(() => {
789
+ feedback(`Copied ${this.debugLogs.length} log line${this.debugLogs.length !== 1 ? "s" : ""}`, true);
790
+ }).catch(() => {
791
+ feedback("Copy failed \u2014 clipboard not available", false);
792
+ });
793
+ break;
794
+ }
785
795
  case "clear-logs":
786
796
  this.debugLogs = [];
787
797
  this.testFeedback = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "featurely-site-manager",
3
- "version": "1.1.15",
3
+ "version": "1.1.18",
4
4
  "description": "Complete site management SDK for maintenance mode, status messages, feature flags, version checking, and analytics",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",