@product7/feedback-sdk 1.2.3 → 1.2.4
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/package.json
CHANGED
package/src/core/FeedbackSDK.js
CHANGED
|
@@ -283,6 +283,25 @@ export class FeedbackSDK {
|
|
|
283
283
|
this.eventBus.emit('sdk:destroyed');
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
_detectEnvironment() {
|
|
287
|
+
if (typeof window === 'undefined') {
|
|
288
|
+
return 'production';
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const hostname = window.location.hostname.toLowerCase();
|
|
292
|
+
|
|
293
|
+
if (
|
|
294
|
+
hostname.includes('staging') ||
|
|
295
|
+
hostname.includes('localhost') ||
|
|
296
|
+
hostname.includes('127.0.0.1') ||
|
|
297
|
+
hostname.includes('.local')
|
|
298
|
+
) {
|
|
299
|
+
return 'staging';
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return 'production';
|
|
303
|
+
}
|
|
304
|
+
|
|
286
305
|
_validateAndMergeConfig(newConfig, existingConfig = {}) {
|
|
287
306
|
const defaultConfig = {
|
|
288
307
|
apiUrl: null,
|
|
@@ -294,7 +313,7 @@ export class FeedbackSDK {
|
|
|
294
313
|
autoShow: true,
|
|
295
314
|
debug: false,
|
|
296
315
|
mock: false,
|
|
297
|
-
env:
|
|
316
|
+
env: this._detectEnvironment(),
|
|
298
317
|
};
|
|
299
318
|
|
|
300
319
|
const mergedConfig = deepMerge(
|
|
@@ -302,6 +321,10 @@ export class FeedbackSDK {
|
|
|
302
321
|
newConfig
|
|
303
322
|
);
|
|
304
323
|
|
|
324
|
+
if (!newConfig.env && !existingConfig.env) {
|
|
325
|
+
mergedConfig.env = this._detectEnvironment();
|
|
326
|
+
}
|
|
327
|
+
|
|
305
328
|
if (!mergedConfig.workspace) {
|
|
306
329
|
throw new ConfigError('Missing required configuration: workspace');
|
|
307
330
|
}
|
|
@@ -375,4 +398,4 @@ export class FeedbackSDK {
|
|
|
375
398
|
: undefined,
|
|
376
399
|
};
|
|
377
400
|
}
|
|
378
|
-
}
|
|
401
|
+
}
|