Browse Source

fix(analytics): add try/catch for setUserProperties.

dev1
Hristo Terezov 6 years ago
parent
commit
50c09bcdcd
1 changed files with 19 additions and 7 deletions
  1. 19
    7
      modules/statistics/AnalyticsAdapter.js

+ 19
- 7
modules/statistics/AnalyticsAdapter.js View File

121
         }
121
         }
122
 
122
 
123
         this.analyticsHandlers = new Set(handlers);
123
         this.analyticsHandlers = new Set(handlers);
124
-        this.analyticsHandlers.forEach(
125
-            handler => {
126
-                handler.setUserProperties(this.permanentProperties);
127
-            });
124
+
125
+        this._setUserProperties();
128
 
126
 
129
         // Note that we disable the cache even if the set of handlers is empty.
127
         // Note that we disable the cache even if the set of handlers is empty.
130
         const cache = this.cache;
128
         const cache = this.cache;
135
         }
133
         }
136
     }
134
     }
137
 
135
 
136
+    /**
137
+     * Set the user properties to the analytics handlers.
138
+     *
139
+     * @returns {void}
140
+     */
141
+    _setUserProperties() {
142
+        this.analyticsHandlers.forEach(handler => {
143
+            try {
144
+                handler.setUserProperties(this.permanentProperties);
145
+            } catch (error) {
146
+                logger.warn('Error in setUserProperties method of one of the '
147
+                    + `analytics handlers: ${error}`);
148
+            }
149
+        });
150
+    }
151
+
138
     /**
152
     /**
139
      * Adds a set of permanent properties to this this AnalyticsAdapter.
153
      * Adds a set of permanent properties to this this AnalyticsAdapter.
140
      * Permanent properties will be added as "attributes" to events sent to
154
      * Permanent properties will be added as "attributes" to events sent to
151
             ...properties
165
             ...properties
152
         };
166
         };
153
 
167
 
154
-        this.analyticsHandlers.forEach(handler => {
155
-            handler.setUserProperties(this.permanentProperties);
156
-        });
168
+        this._setUserProperties();
157
     }
169
     }
158
 
170
 
159
     /**
171
     /**

Loading…
Cancel
Save