featurely-site-manager 1.1.1 → 1.1.3
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +51 -20
- package/dist/index.mjs +51 -20
- package/package.json +4 -5
package/dist/index.d.mts
CHANGED
|
@@ -113,6 +113,8 @@ declare class SiteManager {
|
|
|
113
113
|
getFeatureVariant(flagKey: string): string | null;
|
|
114
114
|
getAllFeatureFlags(): FeatureFlag[];
|
|
115
115
|
getEnabledFeatures(): string[];
|
|
116
|
+
isInMaintenanceMode(): boolean;
|
|
117
|
+
getActiveMessages(): StatusMessage[];
|
|
116
118
|
refresh(): Promise<void>;
|
|
117
119
|
trackEvent(eventName: string, properties?: Record<string, string | number | boolean>): void;
|
|
118
120
|
private fetchConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -113,6 +113,8 @@ declare class SiteManager {
|
|
|
113
113
|
getFeatureVariant(flagKey: string): string | null;
|
|
114
114
|
getAllFeatureFlags(): FeatureFlag[];
|
|
115
115
|
getEnabledFeatures(): string[];
|
|
116
|
+
isInMaintenanceMode(): boolean;
|
|
117
|
+
getActiveMessages(): StatusMessage[];
|
|
116
118
|
refresh(): Promise<void>;
|
|
117
119
|
trackEvent(eventName: string, properties?: Record<string, string | number | boolean>): void;
|
|
118
120
|
private fetchConfig;
|
package/dist/index.js
CHANGED
|
@@ -35,24 +35,6 @@ __export(index_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
var import_dompurify = __toESM(require("dompurify"));
|
|
38
|
-
var import_featurely_error_tracker = require("featurely-error-tracker");
|
|
39
|
-
var internalErrorTracker = (() => {
|
|
40
|
-
try {
|
|
41
|
-
const tracker = new import_featurely_error_tracker.ErrorTracker({
|
|
42
|
-
apiKey: "ft_live_R4nAn9dDWxk6X3oMzB-tcQh0NrYvA04IhSfwPMUmyaU",
|
|
43
|
-
apiUrl: "https://www.featurely.no",
|
|
44
|
-
environment: "production",
|
|
45
|
-
appVersion: "1.1.1",
|
|
46
|
-
maxBreadcrumbs: 30,
|
|
47
|
-
enabled: true
|
|
48
|
-
});
|
|
49
|
-
tracker.install();
|
|
50
|
-
return tracker;
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.warn("Failed to initialize SDK error tracking:", e);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
})();
|
|
56
38
|
var _SiteManager = class _SiteManager {
|
|
57
39
|
constructor(config) {
|
|
58
40
|
this.siteConfig = null;
|
|
@@ -226,6 +208,39 @@ var _SiteManager = class _SiteManager {
|
|
|
226
208
|
}
|
|
227
209
|
return this.siteConfig.featureFlags.filter((flag) => flag.enabled && this.evaluateFeatureFlag(flag)).map((flag) => flag.key);
|
|
228
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Check if the site is currently in maintenance mode (accounting for bypass)
|
|
213
|
+
*/
|
|
214
|
+
isInMaintenanceMode() {
|
|
215
|
+
var _a;
|
|
216
|
+
if (!((_a = this.siteConfig) == null ? void 0 : _a.maintenance.enabled)) return false;
|
|
217
|
+
return !this.shouldBypassMaintenance();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get all currently active status messages for the current page and time
|
|
221
|
+
*/
|
|
222
|
+
getActiveMessages() {
|
|
223
|
+
if (!this.siteConfig) return [];
|
|
224
|
+
const currentTime = /* @__PURE__ */ new Date();
|
|
225
|
+
const currentPath = typeof window !== "undefined" ? window.location.pathname : "";
|
|
226
|
+
return this.siteConfig.messages.filter((message) => {
|
|
227
|
+
if (this.dismissedMessages.has(message.id)) return false;
|
|
228
|
+
if (message.startsAt && new Date(message.startsAt) > currentTime) return false;
|
|
229
|
+
if (message.expiresAt && new Date(message.expiresAt) < currentTime) return false;
|
|
230
|
+
if (message.targetPages && message.targetPages.length > 0) {
|
|
231
|
+
const matches = message.targetPages.some((pattern) => {
|
|
232
|
+
try {
|
|
233
|
+
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
234
|
+
return new RegExp(escaped).test(currentPath);
|
|
235
|
+
} catch {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
if (!matches) return false;
|
|
240
|
+
}
|
|
241
|
+
return true;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
229
244
|
/**
|
|
230
245
|
* Manually refresh configuration
|
|
231
246
|
*/
|
|
@@ -265,7 +280,22 @@ var _SiteManager = class _SiteManager {
|
|
|
265
280
|
}
|
|
266
281
|
);
|
|
267
282
|
if (!response.ok) {
|
|
268
|
-
|
|
283
|
+
const errorData = await response.json().catch(() => ({}));
|
|
284
|
+
const message = errorData.error || response.statusText;
|
|
285
|
+
if (response.status === 401) {
|
|
286
|
+
console.error(
|
|
287
|
+
`[Featurely] Invalid or missing API key. ${message}
|
|
288
|
+
\u2192 Check your API key at https://www.featurely.no/dashboard/settings`
|
|
289
|
+
);
|
|
290
|
+
this.stopPolling();
|
|
291
|
+
} else if (response.status === 403) {
|
|
292
|
+
console.error(
|
|
293
|
+
`[Featurely] Permission denied. ${message}
|
|
294
|
+
\u2192 Ensure your API key has the required permissions at https://www.featurely.no/dashboard/settings`
|
|
295
|
+
);
|
|
296
|
+
this.stopPolling();
|
|
297
|
+
}
|
|
298
|
+
throw new Error(`Failed to fetch site configuration: ${message}`);
|
|
269
299
|
}
|
|
270
300
|
const newConfig = await response.json();
|
|
271
301
|
const configChanged = JSON.stringify(newConfig) !== JSON.stringify(this.siteConfig);
|
|
@@ -350,7 +380,8 @@ var _SiteManager = class _SiteManager {
|
|
|
350
380
|
userId: this.config.userId,
|
|
351
381
|
sessionId: this.sessionId,
|
|
352
382
|
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
353
|
-
platform: typeof navigator !== "undefined" ? navigator.platform : void 0
|
|
383
|
+
platform: typeof navigator !== "undefined" ? navigator.platform : void 0,
|
|
384
|
+
appVersion: this.config.appVersion
|
|
354
385
|
})
|
|
355
386
|
}
|
|
356
387
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import DOMPurify from "dompurify";
|
|
3
|
-
import { ErrorTracker } from "featurely-error-tracker";
|
|
4
|
-
var internalErrorTracker = (() => {
|
|
5
|
-
try {
|
|
6
|
-
const tracker = new ErrorTracker({
|
|
7
|
-
apiKey: "ft_live_R4nAn9dDWxk6X3oMzB-tcQh0NrYvA04IhSfwPMUmyaU",
|
|
8
|
-
apiUrl: "https://www.featurely.no",
|
|
9
|
-
environment: "production",
|
|
10
|
-
appVersion: "1.1.1",
|
|
11
|
-
maxBreadcrumbs: 30,
|
|
12
|
-
enabled: true
|
|
13
|
-
});
|
|
14
|
-
tracker.install();
|
|
15
|
-
return tracker;
|
|
16
|
-
} catch (e) {
|
|
17
|
-
console.warn("Failed to initialize SDK error tracking:", e);
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
})();
|
|
21
3
|
var _SiteManager = class _SiteManager {
|
|
22
4
|
constructor(config) {
|
|
23
5
|
this.siteConfig = null;
|
|
@@ -191,6 +173,39 @@ var _SiteManager = class _SiteManager {
|
|
|
191
173
|
}
|
|
192
174
|
return this.siteConfig.featureFlags.filter((flag) => flag.enabled && this.evaluateFeatureFlag(flag)).map((flag) => flag.key);
|
|
193
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Check if the site is currently in maintenance mode (accounting for bypass)
|
|
178
|
+
*/
|
|
179
|
+
isInMaintenanceMode() {
|
|
180
|
+
var _a;
|
|
181
|
+
if (!((_a = this.siteConfig) == null ? void 0 : _a.maintenance.enabled)) return false;
|
|
182
|
+
return !this.shouldBypassMaintenance();
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get all currently active status messages for the current page and time
|
|
186
|
+
*/
|
|
187
|
+
getActiveMessages() {
|
|
188
|
+
if (!this.siteConfig) return [];
|
|
189
|
+
const currentTime = /* @__PURE__ */ new Date();
|
|
190
|
+
const currentPath = typeof window !== "undefined" ? window.location.pathname : "";
|
|
191
|
+
return this.siteConfig.messages.filter((message) => {
|
|
192
|
+
if (this.dismissedMessages.has(message.id)) return false;
|
|
193
|
+
if (message.startsAt && new Date(message.startsAt) > currentTime) return false;
|
|
194
|
+
if (message.expiresAt && new Date(message.expiresAt) < currentTime) return false;
|
|
195
|
+
if (message.targetPages && message.targetPages.length > 0) {
|
|
196
|
+
const matches = message.targetPages.some((pattern) => {
|
|
197
|
+
try {
|
|
198
|
+
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
199
|
+
return new RegExp(escaped).test(currentPath);
|
|
200
|
+
} catch {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
if (!matches) return false;
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
194
209
|
/**
|
|
195
210
|
* Manually refresh configuration
|
|
196
211
|
*/
|
|
@@ -230,7 +245,22 @@ var _SiteManager = class _SiteManager {
|
|
|
230
245
|
}
|
|
231
246
|
);
|
|
232
247
|
if (!response.ok) {
|
|
233
|
-
|
|
248
|
+
const errorData = await response.json().catch(() => ({}));
|
|
249
|
+
const message = errorData.error || response.statusText;
|
|
250
|
+
if (response.status === 401) {
|
|
251
|
+
console.error(
|
|
252
|
+
`[Featurely] Invalid or missing API key. ${message}
|
|
253
|
+
\u2192 Check your API key at https://www.featurely.no/dashboard/settings`
|
|
254
|
+
);
|
|
255
|
+
this.stopPolling();
|
|
256
|
+
} else if (response.status === 403) {
|
|
257
|
+
console.error(
|
|
258
|
+
`[Featurely] Permission denied. ${message}
|
|
259
|
+
\u2192 Ensure your API key has the required permissions at https://www.featurely.no/dashboard/settings`
|
|
260
|
+
);
|
|
261
|
+
this.stopPolling();
|
|
262
|
+
}
|
|
263
|
+
throw new Error(`Failed to fetch site configuration: ${message}`);
|
|
234
264
|
}
|
|
235
265
|
const newConfig = await response.json();
|
|
236
266
|
const configChanged = JSON.stringify(newConfig) !== JSON.stringify(this.siteConfig);
|
|
@@ -315,7 +345,8 @@ var _SiteManager = class _SiteManager {
|
|
|
315
345
|
userId: this.config.userId,
|
|
316
346
|
sessionId: this.sessionId,
|
|
317
347
|
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
318
|
-
platform: typeof navigator !== "undefined" ? navigator.platform : void 0
|
|
348
|
+
platform: typeof navigator !== "undefined" ? navigator.platform : void 0,
|
|
349
|
+
appVersion: this.config.appVersion
|
|
319
350
|
})
|
|
320
351
|
}
|
|
321
352
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "featurely-site-manager",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|
|
44
|
-
"url": "https://github.com/
|
|
44
|
+
"url": "https://github.com/featurely/site-manager",
|
|
45
45
|
"directory": "packages/featurely-site-manager"
|
|
46
46
|
},
|
|
47
47
|
"bugs": {
|
|
48
|
-
"url": "https://github.com/
|
|
48
|
+
"url": "https://github.com/featurely/site-manager/issues"
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://featurely.no",
|
|
51
51
|
"devDependencies": {
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"typescript": "^5.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"dompurify": "^3.3.3"
|
|
58
|
-
"featurely-error-tracker": "^1.0.7"
|
|
57
|
+
"dompurify": "^3.3.3"
|
|
59
58
|
}
|
|
60
59
|
}
|