web-manager 3.2.56 → 3.2.57
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +233 -226
- package/package.json +1 -1
package/index.js
CHANGED
@@ -549,8 +549,8 @@ Manager.prototype.init = function(configuration, callback) {
|
|
549
549
|
config: {
|
550
550
|
dsn: '',
|
551
551
|
release: '',
|
552
|
-
replaysSessionSampleRate: 0.
|
553
|
-
replaysOnErrorSampleRate:
|
552
|
+
replaysSessionSampleRate: 0.01,
|
553
|
+
replaysOnErrorSampleRate: 0.01,
|
554
554
|
},
|
555
555
|
},
|
556
556
|
chatsy: {
|
@@ -655,10 +655,12 @@ Manager.prototype.init = function(configuration, callback) {
|
|
655
655
|
}
|
656
656
|
})
|
657
657
|
|
658
|
+
// Redirect if we have a redirect query
|
658
659
|
if (redirect && self.isValidRedirectUrl(redirect)) {
|
659
660
|
return window.location.href = redirect;
|
660
661
|
}
|
661
662
|
|
663
|
+
// Detect if we are on a page that requires authentication
|
662
664
|
if (pagePathname.match(/\/(authentication-required|authentication-success|authentication-token|forgot|oauth2|signin|signout|signup)/)) {
|
663
665
|
import('./helpers/auth-pages.js')
|
664
666
|
.then(function(mod) {
|
@@ -1305,40 +1307,43 @@ EXTERNAL LIBS
|
|
1305
1307
|
*/
|
1306
1308
|
var load_firebase = function(self, options) {
|
1307
1309
|
return new Promise(function(resolve, reject) {
|
1308
|
-
//
|
1309
|
-
// return resolve();
|
1310
|
-
// }
|
1310
|
+
// Set shortcuts
|
1311
1311
|
var setting = options.libraries.firebase_app
|
1312
|
-
if (setting.enabled === true) {
|
1313
|
-
function _post() {
|
1314
|
-
// self.log('Loaded Firebase.');
|
1315
|
-
// console.log('_post.');
|
1316
|
-
window.app = firebase.initializeApp(setting.config);
|
1317
1312
|
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1313
|
+
// Skip if not enabled
|
1314
|
+
if (!setting.enabled) {
|
1315
|
+
return resolve();
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
// Setup Firebase
|
1319
|
+
function _post() {
|
1320
|
+
// Initialize Firebase
|
1321
|
+
window.app = firebase.initializeApp(setting.config);
|
1322
|
+
|
1323
|
+
// Load Firebase libraries
|
1324
|
+
Promise.all([
|
1325
|
+
load_firebase_auth(self, options),
|
1326
|
+
load_firebase_firestore(self, options),
|
1327
|
+
load_firebase_messaging(self, options),
|
1328
|
+
load_firebase_appCheck(self, options),
|
1329
|
+
])
|
1330
|
+
.then(resolve)
|
1331
|
+
.catch(reject);
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
// Load Firebase
|
1335
|
+
if (setting.load) {
|
1336
|
+
setting.load(self)
|
1337
|
+
.then(_post)
|
1338
|
+
.catch(reject);
|
1340
1339
|
} else {
|
1341
|
-
|
1340
|
+
// import('firebase/app')
|
1341
|
+
import('firebase/compat/app')
|
1342
|
+
.then(function(mod) {
|
1343
|
+
window.firebase = mod.default;
|
1344
|
+
_post()
|
1345
|
+
})
|
1346
|
+
.catch(reject);
|
1342
1347
|
}
|
1343
1348
|
});
|
1344
1349
|
}
|
@@ -1346,266 +1351,268 @@ var load_firebase = function(self, options) {
|
|
1346
1351
|
|
1347
1352
|
var load_firebase_auth = function(self, options) {
|
1348
1353
|
return new Promise(function(resolve, reject) {
|
1349
|
-
//
|
1350
|
-
// return resolve();
|
1351
|
-
// }
|
1354
|
+
// Set shortcuts
|
1352
1355
|
var setting = options.libraries.firebase_auth;
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
.catch(reject);
|
1358
|
-
} else {
|
1359
|
-
// import('firebase/auth')
|
1360
|
-
import('firebase/compat/auth')
|
1361
|
-
.then(resolve)
|
1362
|
-
.catch(reject);
|
1363
|
-
}
|
1364
|
-
} else {
|
1365
|
-
resolve();
|
1356
|
+
|
1357
|
+
// Skip if not enabled
|
1358
|
+
if (!setting.enabled) {
|
1359
|
+
return resolve();
|
1366
1360
|
}
|
1367
1361
|
|
1362
|
+
// Load Firebase Auth
|
1363
|
+
if (setting.load) {
|
1364
|
+
setting.load(self)
|
1365
|
+
.then(resolve)
|
1366
|
+
.catch(reject);
|
1367
|
+
} else {
|
1368
|
+
// import('firebase/auth')
|
1369
|
+
import('firebase/compat/auth')
|
1370
|
+
.then(resolve)
|
1371
|
+
.catch(reject);
|
1372
|
+
}
|
1368
1373
|
});
|
1369
1374
|
}
|
1370
1375
|
|
1371
1376
|
|
1372
1377
|
var load_firebase_firestore = function(self, options) {
|
1373
1378
|
return new Promise(function(resolve, reject) {
|
1374
|
-
//
|
1375
|
-
// return resolve();
|
1376
|
-
// }
|
1379
|
+
// Set shortcuts
|
1377
1380
|
var setting = options.libraries.firebase_firestore;
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1381
|
+
|
1382
|
+
// Skip if not enabled
|
1383
|
+
if (!setting.enabled) {
|
1384
|
+
return resolve();
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
// Load Firebase Firestore
|
1388
|
+
if (setting.load) {
|
1389
|
+
setting.load(self)
|
1390
|
+
.then(resolve)
|
1391
|
+
.catch(reject);
|
1389
1392
|
} else {
|
1390
|
-
|
1393
|
+
// import('firebase/firestore')
|
1394
|
+
import('firebase/compat/firestore')
|
1395
|
+
.then(resolve)
|
1396
|
+
.catch(reject);
|
1391
1397
|
}
|
1392
1398
|
});
|
1393
1399
|
}
|
1394
1400
|
|
1395
1401
|
var load_firebase_messaging = function(self, options) {
|
1396
1402
|
return new Promise(function(resolve, reject) {
|
1397
|
-
//
|
1398
|
-
// return resolve();
|
1399
|
-
// }
|
1403
|
+
// Set shortcuts
|
1400
1404
|
var setting = options.libraries.firebase_messaging;
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1405
|
+
|
1406
|
+
// Skip if not enabled
|
1407
|
+
if (!setting.enabled) {
|
1408
|
+
return resolve();
|
1409
|
+
}
|
1410
|
+
|
1411
|
+
// Load Firebase Messaging
|
1412
|
+
if (setting.load) {
|
1413
|
+
setting.load(self)
|
1414
|
+
.then(resolve)
|
1415
|
+
.catch(reject);
|
1412
1416
|
} else {
|
1413
|
-
|
1417
|
+
// import('firebase/messaging')
|
1418
|
+
import('firebase/compat/messaging')
|
1419
|
+
.then(resolve)
|
1420
|
+
.catch(reject);
|
1414
1421
|
}
|
1415
1422
|
});
|
1416
1423
|
}
|
1417
1424
|
|
1418
1425
|
var load_firebase_appCheck = function(self, options) {
|
1419
1426
|
return new Promise(function(resolve, reject) {
|
1427
|
+
// Set shortcuts
|
1420
1428
|
var setting = options.libraries.firebase_appCheck;
|
1421
|
-
if (setting.enabled === true) {
|
1422
|
-
if (setting.load) {
|
1423
|
-
setting.load(self)
|
1424
|
-
.then(resolve)
|
1425
|
-
.catch(reject);
|
1426
|
-
} else {
|
1427
|
-
// import('firebase/app-check')
|
1428
|
-
import('firebase/compat/app-check')
|
1429
|
-
.then(function (mod) {
|
1430
|
-
var appCheck = firebase.appCheck;
|
1431
|
-
var siteKey = setting.config.siteKey;
|
1432
|
-
|
1433
|
-
if (!siteKey) {
|
1434
|
-
return resolve();
|
1435
|
-
}
|
1436
1429
|
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1430
|
+
// Skip if not enabled
|
1431
|
+
if (!setting.enabled) {
|
1432
|
+
return resolve();
|
1433
|
+
}
|
1441
1434
|
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1435
|
+
// Load Firebase AppCheck
|
1436
|
+
if (setting.load) {
|
1437
|
+
setting.load(self)
|
1438
|
+
.then(resolve)
|
1439
|
+
.catch(reject);
|
1446
1440
|
} else {
|
1447
|
-
|
1441
|
+
// import('firebase/app-check')
|
1442
|
+
import('firebase/compat/app-check')
|
1443
|
+
.then(function (mod) {
|
1444
|
+
var appCheck = firebase.appCheck;
|
1445
|
+
var siteKey = setting.config.siteKey;
|
1446
|
+
|
1447
|
+
if (!siteKey) {
|
1448
|
+
return resolve();
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
appCheck().activate(
|
1452
|
+
new appCheck.ReCaptchaEnterpriseProvider(siteKey),
|
1453
|
+
true,
|
1454
|
+
);
|
1455
|
+
|
1456
|
+
resolve();
|
1457
|
+
})
|
1458
|
+
.catch(reject);
|
1448
1459
|
}
|
1449
1460
|
});
|
1450
1461
|
}
|
1451
1462
|
|
1452
1463
|
var load_lazysizes = function(self, options) {
|
1453
1464
|
return new Promise(function(resolve, reject) {
|
1454
|
-
// if
|
1455
|
-
|
1456
|
-
|
1457
|
-
if (options.libraries.lazysizes.enabled === true) {
|
1458
|
-
import('lazysizes')
|
1459
|
-
.then(function (mod) {
|
1460
|
-
window.lazysizes = mod.default;
|
1461
|
-
|
1462
|
-
// configs come from official lazysizes demo
|
1463
|
-
var expand = Math.max(Math.min(document.documentElement.clientWidth, document.documentElement.clientHeight, 1222) - 1, 359);
|
1464
|
-
window.lazySizesConfig = {
|
1465
|
-
loadMode: 1,
|
1466
|
-
expand: expand,
|
1467
|
-
expFactor: expand < 380 ? 3 : 2,
|
1468
|
-
};
|
1469
|
-
// self.log('Loaded Lazysizes.');
|
1470
|
-
})
|
1471
|
-
.catch(reject);
|
1472
|
-
} else {
|
1473
|
-
resolve();
|
1465
|
+
// Skip if not enabled
|
1466
|
+
if (!options.libraries.lazysizes.enabled) {
|
1467
|
+
return resolve();
|
1474
1468
|
}
|
1469
|
+
|
1470
|
+
// Load Lazysizes
|
1471
|
+
import('lazysizes')
|
1472
|
+
.then(function (mod) {
|
1473
|
+
window.lazysizes = mod.default;
|
1474
|
+
|
1475
|
+
// configs come from official lazysizes demo
|
1476
|
+
var expand = Math.max(Math.min(document.documentElement.clientWidth, document.documentElement.clientHeight, 1222) - 1, 359);
|
1477
|
+
window.lazySizesConfig = {
|
1478
|
+
loadMode: 1,
|
1479
|
+
expand: expand,
|
1480
|
+
expFactor: expand < 380 ? 3 : 2,
|
1481
|
+
};
|
1482
|
+
// self.log('Loaded Lazysizes.');
|
1483
|
+
})
|
1484
|
+
.catch(reject);
|
1475
1485
|
});
|
1476
1486
|
}
|
1477
1487
|
|
1478
1488
|
var load_cookieconsent = function(self, options) {
|
1479
1489
|
return new Promise(function(resolve, reject) {
|
1480
|
-
// if
|
1481
|
-
|
1482
|
-
|
1483
|
-
if (options.libraries.cookieconsent.enabled === true) {
|
1484
|
-
import('cookieconsent')
|
1485
|
-
.then(function(mod) {
|
1486
|
-
window.cookieconsent.initialise(options.libraries.cookieconsent.config);
|
1487
|
-
// self.log('Loaded Cookieconsent.');
|
1488
|
-
resolve();
|
1489
|
-
})
|
1490
|
-
.catch(reject);
|
1491
|
-
} else {
|
1492
|
-
resolve();
|
1490
|
+
// Skip if not enabled
|
1491
|
+
if (!options.libraries.cookieconsent.enabled) {
|
1492
|
+
return resolve();
|
1493
1493
|
}
|
1494
1494
|
|
1495
|
+
// Load Cookieconsent
|
1496
|
+
import('cookieconsent')
|
1497
|
+
.then(function(mod) {
|
1498
|
+
window.cookieconsent.initialise(options.libraries.cookieconsent.config);
|
1499
|
+
// self.log('Loaded Cookieconsent.');
|
1500
|
+
resolve();
|
1501
|
+
})
|
1502
|
+
.catch(reject);
|
1495
1503
|
});
|
1496
1504
|
}
|
1497
1505
|
|
1498
1506
|
var load_chatsy = function(self, options) {
|
1499
1507
|
return new Promise(function(resolve, reject) {
|
1508
|
+
// Skip if not enabled or already requested
|
1509
|
+
if (!options.libraries.chatsy.enabled || self.properties.page._chatsyRequested) {
|
1510
|
+
return resolve();
|
1511
|
+
}
|
1500
1512
|
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
)
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
chatsy.on('status', function(event, status) {
|
1524
|
-
if (status === 'loaded') {
|
1525
|
-
chatsy.open();
|
1526
|
-
}
|
1527
|
-
})
|
1528
|
-
|
1529
|
-
resolve();
|
1513
|
+
var chatsyPath = 'libraries.chatsy.config';
|
1514
|
+
|
1515
|
+
// Immediately hide the fake button
|
1516
|
+
select('#prechat-btn').hide();
|
1517
|
+
|
1518
|
+
// Load the script
|
1519
|
+
loadScript({
|
1520
|
+
src: 'https://app.chatsy.ai/resources/script.js',
|
1521
|
+
// src: 'http://localhost:4001/resources/script.js',
|
1522
|
+
attributes: [
|
1523
|
+
{name: 'data-account-id', value: utilities.get(options, chatsyPath + '.accountId', '')},
|
1524
|
+
{name: 'data-chat-id', value: utilities.get(options, chatsyPath + '.chatId', '')},
|
1525
|
+
{name: 'data-settings', value: JSON.stringify(utilities.get(options, chatsyPath + '.settings', ''))},
|
1526
|
+
],
|
1527
|
+
crossorigin: true,
|
1528
|
+
})
|
1529
|
+
.then(function () {
|
1530
|
+
// Listen for Chatsy status
|
1531
|
+
chatsy.on('status', function(event, status) {
|
1532
|
+
if (status === 'loaded') {
|
1533
|
+
chatsy.open();
|
1534
|
+
}
|
1530
1535
|
})
|
1531
1536
|
|
1532
|
-
self.properties.page._chatsyRequested = true;
|
1533
|
-
} else {
|
1534
1537
|
resolve();
|
1535
|
-
}
|
1538
|
+
})
|
1539
|
+
|
1540
|
+
self.properties.page._chatsyRequested = true;
|
1536
1541
|
});
|
1537
1542
|
}
|
1538
1543
|
|
1539
1544
|
var load_sentry = function(self, options) {
|
1540
1545
|
return new Promise(function(resolve, reject) {
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
window.Sentry = mod;
|
1546
|
+
// Skip if not enabled
|
1547
|
+
if (!options.libraries.sentry.enabled) {
|
1548
|
+
return resolve();
|
1549
|
+
}
|
1546
1550
|
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1551
|
+
// Import Sentry
|
1552
|
+
import('@sentry/browser')
|
1553
|
+
.then(function(mod) {
|
1554
|
+
// Set global
|
1555
|
+
window.Sentry = mod;
|
1552
1556
|
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1557
|
+
// Set config
|
1558
|
+
var config = options.libraries.sentry.config;
|
1559
|
+
config.release = config.release + '@' + self.properties.global.version;
|
1560
|
+
config.environment = self.properties.meta.environment;
|
1561
|
+
config.integrations = config.integrations || [];
|
1556
1562
|
|
1557
|
-
|
1558
|
-
|
1563
|
+
// if (self.isDevelopment()) {
|
1564
|
+
// config.dsn = 'https://901db748bbb9469f860dc36fb07a4374@o1120154.ingest.sentry.io/6155285';
|
1565
|
+
// }
|
1559
1566
|
|
1560
|
-
|
1561
|
-
|
1562
|
-
config.integrations.push(Sentry.replayIntegration({
|
1563
|
-
maskAllText: false,
|
1564
|
-
blockAllMedia: false,
|
1565
|
-
}));
|
1566
|
-
}
|
1567
|
+
// Add integration: browser tracing
|
1568
|
+
config.integrations.push(Sentry.browserTracingIntegration());
|
1567
1569
|
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
event.tags['process.type'] = event.tags['process.type'] || 'browser';
|
1576
|
-
// event.tags['usage.total.opens'] = parseInt(usage.total.opens);
|
1577
|
-
// event.tags['usage.total.hours'] = usage.total.hours;
|
1578
|
-
event.tags['usage.session.hours'] = hoursSinceStart.toFixed(2);
|
1579
|
-
// event.tags['store'] = self.properties().isStore();
|
1580
|
-
|
1581
|
-
// Setup user
|
1582
|
-
event.user = event.user || {};
|
1583
|
-
event.user.email = storage.get('user.auth.email', '')
|
1584
|
-
event.user.uid = storage.get('user.auth.uid', '');
|
1585
|
-
// event.user.ip = storage.get('user.ip', '');
|
1586
|
-
|
1587
|
-
// Log to console
|
1588
|
-
console.error('[SENTRY] Caught error', event, hint);
|
1589
|
-
|
1590
|
-
// Skip processing the event
|
1591
|
-
if (self.isDevelopment()) {
|
1592
|
-
return null;
|
1593
|
-
}
|
1570
|
+
// Add integration: replay
|
1571
|
+
if (config.replaysSessionSampleRate > 0 || config.replaysOnErrorSampleRate > 0) {
|
1572
|
+
config.integrations.push(Sentry.replayIntegration({
|
1573
|
+
maskAllText: false,
|
1574
|
+
blockAllMedia: false,
|
1575
|
+
}));
|
1576
|
+
}
|
1594
1577
|
|
1595
|
-
|
1596
|
-
|
1578
|
+
// Setup before send
|
1579
|
+
config.beforeSend = function (event, hint) {
|
1580
|
+
var startTime = self.properties.page.startTime;
|
1581
|
+
var hoursSinceStart = (new Date() - startTime) / (1000 * 3600);
|
1582
|
+
|
1583
|
+
// Setup tags
|
1584
|
+
event.tags = event.tags || {};
|
1585
|
+
event.tags['process.type'] = event.tags['process.type'] || 'browser';
|
1586
|
+
// event.tags['usage.total.opens'] = parseInt(usage.total.opens);
|
1587
|
+
// event.tags['usage.total.hours'] = usage.total.hours;
|
1588
|
+
event.tags['usage.session.hours'] = hoursSinceStart.toFixed(2);
|
1589
|
+
// event.tags['store'] = self.properties().isStore();
|
1590
|
+
|
1591
|
+
// Setup user
|
1592
|
+
event.user = event.user || {};
|
1593
|
+
event.user.email = storage.get('user.auth.email', '')
|
1594
|
+
event.user.uid = storage.get('user.auth.uid', '');
|
1595
|
+
// event.user.ip = storage.get('user.ip', '');
|
1596
|
+
|
1597
|
+
// Log to console
|
1598
|
+
console.error('[SENTRY] Caught error', event, hint);
|
1599
|
+
|
1600
|
+
// Skip processing the event
|
1601
|
+
if (self.isDevelopment()) {
|
1602
|
+
return null;
|
1597
1603
|
}
|
1598
1604
|
|
1599
|
-
//
|
1600
|
-
|
1605
|
+
// Process the event
|
1606
|
+
return event;
|
1607
|
+
}
|
1608
|
+
|
1609
|
+
// Initialize
|
1610
|
+
Sentry.init(config);
|
1601
1611
|
|
1602
|
-
|
1603
|
-
resolve();
|
1604
|
-
})
|
1605
|
-
.catch(reject);
|
1606
|
-
} else {
|
1612
|
+
// Resolve
|
1607
1613
|
resolve();
|
1608
|
-
}
|
1614
|
+
})
|
1615
|
+
.catch(reject);
|
1609
1616
|
});
|
1610
1617
|
}
|
1611
1618
|
|
package/package.json
CHANGED