Browse Source

feat(analytics): shield handler execution

Avoid throwing an exception if an analytics handler throws one. Emit a warning
though, so the problem can be eventually caught and fixed in the handler.
dev1
Saúl Ibarra Corretgé 7 years ago
parent
commit
012bb7d196
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      modules/statistics/AnalyticsAdapter.js

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

304
             // not at the time we receive it.
304
             // not at the time we receive it.
305
             this._appendPermanentProperties(event);
305
             this._appendPermanentProperties(event);
306
 
306
 
307
-            this.analyticsHandlers.forEach(handler => handler.sendEvent(event));
307
+            for (const handler of this.analyticsHandlers) {
308
+                try {
309
+                    handler.sendEvent(event);
310
+                } catch (e) {
311
+                    logger.warn(`Error sending analytics event: ${e}`);
312
+                }
313
+            }
308
         }
314
         }
309
     }
315
     }
310
 
316
 

Loading…
Cancel
Save