Skip to content

Commit cbcca3c

Browse files
authored
Bugfix - Check window for node environments (#17)
1 parent 3f4fcc5 commit cbcca3c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/FacebookEventForwarder.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,12 @@
316316

317317
function register(config) {
318318
if (!config) {
319-
window.console.log('You must pass a config object to register the kit ' + name);
319+
console.log('You must pass a config object to register the kit ' + name);
320320
return;
321321
}
322322

323323
if (!isobject(config)) {
324-
window.console.log('\'config\' must be an object. You passed in a ' + typeof config);
324+
console.log('\'config\' must be an object. You passed in a ' + typeof config);
325325
return;
326326
}
327327

@@ -335,15 +335,17 @@
335335
constructor: constructor
336336
};
337337
}
338-
window.console.log('Successfully registered ' + name + ' to your mParticle configuration');
338+
console.log('Successfully registered ' + name + ' to your mParticle configuration');
339339
}
340340

341-
if (window && window.mParticle && window.mParticle.addForwarder) {
342-
window.mParticle.addForwarder({
343-
name: name,
344-
constructor: constructor,
345-
getId: getId
346-
});
341+
if (typeof window !== 'undefined') {
342+
if (window && window.mParticle && window.mParticle.addForwarder) {
343+
window.mParticle.addForwarder({
344+
name: name,
345+
constructor: constructor,
346+
getId: getId
347+
});
348+
}
347349
}
348350

349351
module.exports = {

0 commit comments

Comments
 (0)