web-manager 3.2.56 → 3.2.58

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