浏览代码

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 年前
父节点
当前提交
012bb7d196
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7
    1
      modules/statistics/AnalyticsAdapter.js

+ 7
- 1
modules/statistics/AnalyticsAdapter.js 查看文件

@@ -304,7 +304,13 @@ class AnalyticsAdapter {
304 304
             // not at the time we receive it.
305 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
 

正在加载...
取消
保存