@capillarytech/cap-ui-utils 1.2.2 → 1.2.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/GA/index.js CHANGED
@@ -16,11 +16,8 @@ const _initialize = (GAConfigs) => {
16
16
  if(GAConfigs.accessKey) {
17
17
  ReactGA.initialize(GAConfigs.accessKey,{debug: true,});
18
18
  }
19
- if(GAConfigs.trackError){
20
- //Track Error
21
- window.addEventListener('error', (e) =>{
22
- tracker.trackException(`UI Error ${e.message}`);
23
- });
19
+ if(GAConfigs.trackUIError){
20
+ errorTracks();
24
21
  }
25
22
  eventsAfterInitialize();
26
23
  log("Cap GA initialized");
@@ -34,13 +31,12 @@ const initialize = (GAConfigs) =>{
34
31
  return;
35
32
  }
36
33
  for ( const config in GAConfigs) {
37
- if (isEmpty(GAConfigs[config])) {
34
+ if (!GAConfigs[config]) {
38
35
  warn("Config is empty");
39
36
  return;
40
37
  }
41
38
  }
42
39
  _initialize(GAConfigs);
43
-
44
40
  return true;
45
41
  }
46
42
  const eventsAfterInitialize = () => {
@@ -52,6 +48,25 @@ const eventsAfterInitialize = () => {
52
48
  });
53
49
  }
54
50
 
51
+ const errorTracks = () => {
52
+ window.onerror = function (msg, url, lineNo, columnNo, error) {
53
+ // to avoid 2 times same error log
54
+ if (error.hasBeenCaught !== undefined){
55
+ return false
56
+ }
57
+ error.hasBeenCaught = true
58
+ const message = [
59
+ 'Message: ' + msg,
60
+ 'URL: ' + url,
61
+ 'Column: ' + columnNo,
62
+ 'Error object: ' + JSON.stringify(error)
63
+ ].join(' - ');
64
+ tracker.trackException({
65
+ description: message,
66
+ fatal: true,
67
+ });
68
+ };
69
+ }
55
70
 
56
71
  // ttiPolyfill.getFirstConsistentlyInteractive().then(tti => {
57
72
  // console.log('performance tti', tti);
@@ -8,7 +8,7 @@ const trackTiming = () => {}
8
8
 
9
9
  const trackPageView = () => {}
10
10
 
11
- const trackException = (description, fatal = true) => {
11
+ const trackException = ({description, fatal = true}) => {
12
12
  ReactGA.exception({
13
13
  description,
14
14
  fatal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capillarytech/cap-ui-utils",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Utility functions shared accross all the modules",
5
5
  "main": "index.js",
6
6
  "scripts": {