Skip to content

Commit 1d9fb86

Browse files
committed
Don't swallow integration errors
As part of adding client side metrics, we want to propagate errors to analytics.js-core so that it can capture them. https://paper.dropbox.com/doc/Analytics.js-Metrics-SDD-1hAD90lqGS4aZxHAHYPu7#:h2=analytics.js-integration analytics.js-core has already been updated to capture errors when invoking integrations (segmentio/analytics.js-core#66).
1 parent 9a5be9f commit 1d9fb86

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

lib/protos.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,9 @@ exports.invoke = function(method) {
174174
if (!this[method]) return;
175175
var args = Array.prototype.slice.call(arguments, 1);
176176
if (!this._ready) return this.queue(method, args);
177-
var ret;
178177

179-
try {
180-
this.debug('%s with %o', method, args);
181-
ret = this[method].apply(this, args);
182-
} catch (e) {
183-
this.debug('error %o calling %s with %o', e, method, args);
184-
}
185-
186-
return ret;
178+
this.debug('%s with %o', method, args);
179+
return this[method].apply(this, args);
187180
};
188181

189182
/**

test/index.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,12 @@ describe('integration', function() {
292292
assert(integration.track.calledWith('event'));
293293
});
294294

295-
it('should catch errors when it calls', function() {
295+
it('should throw errors if the integration errors', function() {
296296
integration.emit('ready');
297297
integration.initialize();
298-
integration.invoke('page', 'name');
298+
assert['throws'](function() {
299+
integration.invoke('page', 'name');
300+
}, Error, 'Should not swallow exceptions');
299301
});
300302

301303
it('should return the returned value', function(done) {

0 commit comments

Comments
 (0)