web-manager 3.2.50 → 3.2.52

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # CHANGELOG
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
+
7
+ ## Changelog Categories
8
+
9
+ - `BREAKING` for breaking changes.
10
+ - `Added` for new features.
11
+ - `Changed` for changes in existing functionality.
12
+ - `Deprecated` for soon-to-be removed features.
13
+ - `Removed` for now removed features.
14
+ - `Fixed` for any bug fixes.
15
+ - `Security` in case of vulnerabilities.
16
+
17
+ ---
18
+ ## [1.0.0] - 2024-06-19
19
+ ### Added
20
+ - Initial release of the project 🚀
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://cdn.itwcreativeworks.com/assets/itw-creative-works/images/logo/itw-creative-works-brandmark-black-x.svg">
2
+ <a href="https://itwcreativeworks.com">
3
3
  <img src="https://cdn.itwcreativeworks.com/assets/itw-creative-works/images/logo/itw-creative-works-brandmark-black-x.svg" width="100px">
4
4
  </a>
5
5
  </p>
@@ -28,26 +28,26 @@
28
28
  This module is best used when bundled with <a href="https://www.npmjs.com/package/webpack">webpack</a>.
29
29
  </p>
30
30
 
31
- ## Install
31
+ ## 📦 Install Web Manager
32
32
  Install with npm:
33
33
  ```shell
34
34
  npm install web-manager
35
35
  ```
36
36
 
37
- ## Features
37
+ ## 🦄 Features
38
38
  * Polyfill detection and implementation for Promises, Array methods, window.fetch, and more!
39
39
  * Dom API that acts as a super lightweight and optimized version of jQuery
40
40
  * Improved Localstorage API
41
41
  * Utility API with the most useful Lodash methods `get` and `set`
42
42
 
43
- ## Libraries
43
+ ## 📚 Libraries
44
44
  * Firebase (Firebase app, Firestore, Auth, & Messaging)
45
45
  * Lazysizes to lazyload images
46
46
  * Sentry to report errors
47
47
  * [Chatsy.ai](https://chatsy.ai) AI chatbot integration
48
48
  * Cookieconsent to comply with GDPR
49
49
 
50
- ## Example Setup
50
+ ## 📘 Example Setup
51
51
  After installing via npm, simply paste this script before the closing `</body>` tag to initialize Web Manager.
52
52
  ```html
53
53
  <script type="text/javascript">
@@ -61,7 +61,7 @@ After installing via npm, simply paste this script before the closing `</body>`
61
61
  </script>
62
62
  ```
63
63
 
64
- ## Example Usage
64
+ ## 📘 Example Usage
65
65
  Lets go over some example usage of the library.
66
66
 
67
67
  ### Kitchen Sink Config example
@@ -75,7 +75,7 @@ By default, all of the libraries are enabled. But you can simply set `enabled` t
75
75
  },
76
76
  serviceWorker: {
77
77
  path: 'firebase-messaging-sw.js' // Path to your service worker
78
- },
78
+ },
79
79
  libraries: {
80
80
  firebase_app: { // Config is required if enabled
81
81
  enabled: true,
@@ -88,7 +88,7 @@ By default, all of the libraries are enabled. But you can simply set `enabled` t
88
88
  messagingSenderId: '123456',
89
89
  appId: '1:xxx'
90
90
  }
91
- },
91
+ },
92
92
  tawk: { // Config is required if enabled
93
93
  enabled: true,
94
94
  config: {
@@ -128,7 +128,7 @@ By default, all of the libraries are enabled. But you can simply set `enabled` t
128
128
  },
129
129
  lazysizes: { // No config required
130
130
  enabled: true
131
- }
131
+ }
132
132
  }
133
133
  }
134
134
  var Manager = new (require('web-manager'));
@@ -212,7 +212,7 @@ The Web Manager .utilities() API wraps some useful functions such as getting and
212
212
  ```html
213
213
  <script type="text/javascript">
214
214
  console.log('--- Exploring the .utilities() API ---');
215
-
215
+
216
216
  // .get() and .set()
217
217
  Manager.ready(function() {
218
218
  var object = {
@@ -241,7 +241,7 @@ The Web Manager .utilities() API wraps some useful functions such as getting and
241
241
  Manager.utilities().clipboardCopy('I am copied to the clipboard!')
242
242
 
243
243
  // .escapeHTML()
244
- Manager.utilities().escapeHTML('<strong>This will will NOT render as bold!</strong>')
244
+ Manager.utilities().escapeHTML('<strong>This will will NOT render as bold!</strong>')
245
245
  </script>
246
246
  ```
247
247
 
@@ -390,11 +390,11 @@ To preserve file size and enforce optimization, the `.account()` library must be
390
390
 
391
391
 
392
392
 
393
- ## Final Words
393
+ ## 🗨️ Final Words
394
394
  If you are still having difficulty, we would love for you to post
395
395
  a question to [the Web Manager issues page](https://github.com/itw-creative-works/web-manager/issues). It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
396
396
 
397
- ## Projects Using this Library
397
+ ## 📚 Projects Using this Library
398
398
  [Somiibo](https://somiibo.com/): A Social Media Bot with an open-source module library. <br>
399
399
  [JekyllUp](https://jekyllup.com/): A website devoted to sharing the best Jekyll themes. <br>
400
400
  [Slapform](https://slapform.com/): A backend processor for your HTML forms on static sites. <br>
package/index.js CHANGED
@@ -486,6 +486,8 @@ function Manager() {
486
486
  config: {
487
487
  dsn: '',
488
488
  release: '',
489
+ replaysSessionSampleRate: 0.1,
490
+ replaysOnErrorSampleRate: 1.0,
489
491
  },
490
492
  },
491
493
  chatsy: {
@@ -1476,50 +1478,65 @@ function Manager() {
1476
1478
  if (options.libraries.sentry.enabled === true) {
1477
1479
  import('@sentry/browser')
1478
1480
  .then(function(mod) {
1481
+ // Set global
1479
1482
  window.Sentry = mod;
1483
+
1484
+ // Set config
1480
1485
  var config = options.libraries.sentry.config;
1481
1486
  config.release = config.release + '@' + self.properties.global.version;
1482
1487
  config.environment = self.properties.meta.environment;
1488
+ config.integrations = config.integrations || [];
1483
1489
 
1484
1490
  // if (self.isDevelopment()) {
1485
1491
  // config.dsn = 'https://901db748bbb9469f860dc36fb07a4374@o1120154.ingest.sentry.io/6155285';
1486
1492
  // }
1487
1493
 
1494
+ // Add integration: browser tracing
1495
+ config.integrations.push(Sentry.browserTracingIntegration());
1496
+
1497
+ // Add integration: replay
1488
1498
  if (config.replaysSessionSampleRate > 0 || config.replaysOnErrorSampleRate > 0) {
1489
- config.integrations = [
1490
- new Sentry.Replay({
1491
- // Additional SDK configuration goes in here, for example:
1492
- // maskAllText: true,
1493
- // blockAllMedia: true,
1494
- }),
1495
- ]
1499
+ config.integrations.push(Sentry.replayIntegration({
1500
+ maskAllText: false,
1501
+ blockAllMedia: false,
1502
+ }));
1496
1503
  }
1497
1504
 
1505
+ // Setup before send
1498
1506
  config.beforeSend = function (event, hint) {
1499
1507
  var startTime = self.properties.page.startTime;
1500
1508
  var hoursSinceStart = (new Date() - startTime) / (1000 * 3600);
1501
1509
 
1510
+ // Setup tags
1502
1511
  event.tags = event.tags || {};
1503
1512
  event.tags['process.type'] = event.tags['process.type'] || 'browser';
1504
-
1505
1513
  // event.tags['usage.total.opens'] = parseInt(usage.total.opens);
1506
1514
  // event.tags['usage.total.hours'] = usage.total.hours;
1507
1515
  event.tags['usage.session.hours'] = hoursSinceStart.toFixed(2);
1508
1516
  // event.tags['store'] = self.properties().isStore();
1517
+
1518
+ // Setup user
1509
1519
  event.user = event.user || {};
1510
1520
  event.user.email = storage.get('user.auth.email', '')
1511
1521
  event.user.uid = storage.get('user.auth.uid', '');
1512
1522
  // event.user.ip = storage.get('user.ip', '');
1513
1523
 
1524
+ // Log to console
1514
1525
  console.error('[SENTRY] Caught error', event, hint);
1515
1526
 
1516
- if (self.isDevelopment()) {
1517
- return null;
1518
- }
1527
+ // Skip processing the event
1528
+ // if (self.isDevelopment()) {
1529
+ // return null;
1530
+ // }
1519
1531
 
1532
+ // Process the event
1520
1533
  return event;
1521
1534
  }
1535
+
1536
+ // Initialize
1522
1537
  Sentry.init(config);
1538
+
1539
+ // Resolve
1523
1540
  resolve();
1524
1541
  })
1525
1542
  .catch(reject);
@@ -1565,7 +1582,7 @@ function Manager() {
1565
1582
  if (featuresDefault && featuresCustom) {
1566
1583
  cb();
1567
1584
  } else {
1568
- loadScript({src: 'https://polyfill.io/v3/polyfill.min.js?flags=always%2Cgated&features=default%2Ces5%2Ces6%2Ces7%2CPromise.prototype.finally%2C%7Ehtml5-elements%2ClocalStorage%2Cfetch%2CURLSearchParams'})
1585
+ loadScript({src: 'https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?flags=always%2Cgated&features=default%2Ces5%2Ces6%2Ces7%2CPromise.prototype.finally%2C%7Ehtml5-elements%2ClocalStorage%2Cfetch%2CURLSearchParams'})
1569
1586
  .then(function() {
1570
1587
  cb();
1571
1588
  })
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.50",
3
+ "version": "3.2.52",
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": {
7
7
  "test": "./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
8
8
  "test_": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
9
- "prepare_": "node -e 'require(`prepare-package`)()'"
9
+ "prepare_": "node -e 'require(`prepare-package`)()'",
10
+ "prepare": "node -e \"require('prepare-package')()\"",
11
+ "prepare:watch": "nodemon -w ./src -e '*' --exec 'npm run prepare'"
10
12
  },
11
13
  "engines": {
12
- "node": ">=6.0.0"
14
+ "node": ">=12"
13
15
  },
14
16
  "repository": {
15
17
  "type": "git",
@@ -32,15 +34,21 @@
32
34
  "lazysizes": "^5.3.2"
33
35
  }
34
36
  },
37
+ "preparePackage": {
38
+ "input": "./src",
39
+ "output": "./dist",
40
+ "replace": {}
41
+ },
35
42
  "dependencies": {
36
- "@sentry/browser": "^7.117.0",
43
+ "@sentry/browser": "^8.13.0",
37
44
  "cookieconsent": "^3.1.1",
38
45
  "firebase": "^9.23.0",
39
- "itwcw-package-analytics": "^1.0.1",
46
+ "itwcw-package-analytics": "^1.0.4",
40
47
  "lazysizes": "^5.3.2"
41
48
  },
42
49
  "devDependencies": {
43
50
  "lodash": "^4.17.21",
44
- "mocha": "^8.4.0"
51
+ "mocha": "^8.4.0",
52
+ "prepare-package": "^1.1.13"
45
53
  }
46
54
  }
package/.codeclimate.yml DELETED
@@ -1,33 +0,0 @@
1
- version: "2" # required to adjust maintainability checks
2
- checks:
3
- # argument-count:
4
- # config:
5
- # threshold: 4
6
- # complex-logic:
7
- # config:
8
- # threshold: 4
9
- # file-lines:
10
- # config:
11
- # threshold: 250
12
- # method-complexity:
13
- # config:
14
- # threshold: 5
15
- # method-count:
16
- # config:
17
- # threshold: 20
18
- method-lines:
19
- config:
20
- threshold: 200
21
- # nested-control-flow:
22
- # config:
23
- # threshold: 4
24
- # return-statements:
25
- # config:
26
- # threshold: 4
27
- # similar-code:
28
- # config:
29
- # threshold: # language-specific defaults. an override will affect all languages.
30
- # identical-code:
31
- # config:
32
- # threshold: # language-specific defaults. an override will affect all languages.
33
-
package/test/test.js DELETED
@@ -1,158 +0,0 @@
1
- const package = require('../package.json');
2
- const assert = require('assert');
3
-
4
- beforeEach(() => {
5
- });
6
-
7
- before(() => {
8
- });
9
-
10
- after(() => {
11
- });
12
-
13
- /*
14
- * ============
15
- * Test Cases
16
- * ============
17
- */
18
- describe(`${package.name}`, () => {
19
- const _ = require('../lib/utilities.js');
20
- const lodash = require('lodash');
21
-
22
- // Utilities
23
- describe('.utilities()', () => {
24
- const sample = {
25
- main: {
26
- true: true,
27
- false: false,
28
- zero: 0,
29
- one: 1,
30
- string: 'string',
31
- stringEmpty: '',
32
- object: {},
33
- array: [],
34
- null: null,
35
- undefined: undefined,
36
- nan: NaN,
37
- infinity: Infinity,
38
- negativeInfinity: -Infinity,
39
- function: function () {},
40
- }
41
- }
42
-
43
- // Normal Cases
44
- describe('.get()', () => {
45
- it('should return true', () => {
46
- // console.log('---lodash', lodash.get(sample, 'main.true'));
47
- // console.log('---_.get', _.get(sample, 'main.true'));
48
- // console.log('---_.get2', _.get2(sample, 'main.true'));
49
-
50
- assert.strictEqual(_.get(sample, 'main.true'), true);
51
- });
52
-
53
- it('should return false', () => {
54
- assert.strictEqual(_.get(sample, 'main.false'), false);
55
- });
56
-
57
- it('should return 0', () => {
58
- assert.strictEqual(_.get(sample, 'main.zero'), 0);
59
- });
60
-
61
- it('should return 1', () => {
62
- assert.strictEqual(_.get(sample, 'main.one'), 1);
63
- });
64
-
65
- it('should return a string', () => {
66
- assert.strictEqual(_.get(sample, 'main.string'), 'string');
67
- });
68
-
69
- it('should return an empty string', () => {
70
- assert.strictEqual(_.get(sample, 'main.stringEmpty'), '');
71
- });
72
-
73
- it('should return an object', () => {
74
- assert.deepStrictEqual(_.get(sample, 'main.object'), {});
75
- });
76
-
77
- it('should return an array', () => {
78
- assert.deepStrictEqual(_.get(sample, 'main.array'), []);
79
- });
80
-
81
- it('should return null', () => {
82
- assert.strictEqual(_.get(sample, 'main.null'), null);
83
- });
84
-
85
- it('should return undefined', () => {
86
- assert.strictEqual(_.get(sample, 'main.undefined'), undefined);
87
- });
88
-
89
- it('should return NaN', () => {
90
- assert.strictEqual(Number.isNaN(_.get(sample, 'main.nan')), true);
91
- });
92
-
93
- it('should return Infinity', () => {
94
- assert.strictEqual(_.get(sample, 'main.infinity'), Infinity);
95
- });
96
-
97
- it('should return -Infinity', () => {
98
- assert.strictEqual(_.get(sample, 'main.negativeInfinity'), -Infinity);
99
- });
100
-
101
- it('should return a function', () => {
102
- assert.strictEqual(typeof _.get(sample, 'main.function'), 'function');
103
- });
104
-
105
- // Non-existent
106
- it('should return undefined', () => {
107
- assert.strictEqual(_.get(sample, 'main.nonexistent'), undefined);
108
- });
109
-
110
- // No path
111
- it('should return undefined', () => {
112
- assert.strictEqual(_.get(sample), undefined);
113
- });
114
-
115
- // Empty path
116
- it('should return undefined', () => {
117
- assert.strictEqual(_.get(sample, ''), undefined);
118
- });
119
-
120
- // Default value
121
- it('should return default value', () => {
122
- assert.strictEqual(_.get(sample, 'main.nonexistent', 'default'), 'default');
123
- });
124
-
125
- it('should return actual value', () => {
126
- assert.strictEqual(_.get(sample, 'main.false', 'default'), false);
127
- });
128
-
129
- it('should return actual value', () => {
130
- assert.strictEqual(_.get(sample, 'main.null', 'default'), null);
131
- });
132
-
133
- it('should return default value', () => {
134
- assert.strictEqual(_.get(sample, 'main.undefined', 'default'), 'default');
135
- });
136
-
137
- // Non-object for object
138
- it('should return undefined', () => {
139
- assert.strictEqual(_.get(undefined, 'main.true'), undefined);
140
- });
141
-
142
- it('should return undefined', () => {
143
- assert.strictEqual(_.get(null, 'main.true'), undefined);
144
- });
145
-
146
- it('should return undefined', () => {
147
- assert.strictEqual(_.get(false, 'main.true'), undefined);
148
- });
149
-
150
- it('should return undefined', () => {
151
- assert.strictEqual(_.get('', 'main.true'), undefined);
152
- });
153
-
154
- });
155
-
156
- });
157
-
158
- })