Skip to content

Commit

Permalink
fix undefined vars
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan-rudder committed Feb 17, 2020
1 parent 3154a25 commit d476016
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions integrations/Chartbeat/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Chartbeat {
window._sf_async_config.uid = config.uid;
window._sf_async_config.domain = config.domain;
this.isVideo = config.video ? true : false;
this.sendNameAndCategoryAsTitle = config.sendNameAndCategoryAsTitle;
this.sendNameAndCategoryAsTitle = config.sendNameAndCategoryAsTitle || true;
this.subscriberEngagementKeys = config.subscriberEngagementKeys || [];
this.replayEvents = [];
this.failed = false;
this.isFirstPageCallMade = false;
Expand Down Expand Up @@ -42,13 +43,16 @@ class Chartbeat {
this.initAfterPage();
} else {
if (this.failed) {
logger.debug("===ignoring cause failed integration===");
this.replayEvents = [];
return;
}
if (!isLoaded() && !this.failed) {
if (!this.isLoaded() && !this.failed) {
logger.debug("===pushing to replay queue for chartbeat===");
this.replayEvents.push(["page", rudderElement]);
return;
}
logger.debug("===processing page event in chartbeat===");
let properties = rudderElement.message.properties;
window.pSUPERFLY.virtualPage(properties.path);
}
Expand Down Expand Up @@ -82,10 +86,10 @@ class Chartbeat {

var _cbq = (window._cbq = window._cbq || []);

for (var key in props) {
if (!props.hasOwnProperty(key)) continue;
if (this.options.subscriberEngagementKeys.indexOf(key) > -1) {
_cbq.push([key, props[key]]);
for (var key in properties) {
if (!properties.hasOwnProperty(key)) continue;
if (this.subscriberEngagementKeys.indexOf(key) > -1) {
_cbq.push([key, properties[key]]);
}
}
}
Expand All @@ -105,6 +109,7 @@ class Chartbeat {
});

this.isReady(this).then(instance => {
logger.debug("===replaying on chartbeat===");
instance.replayEvents.forEach(event => {
instance[event[0]](event[1]);
});
Expand All @@ -121,10 +126,12 @@ class Chartbeat {
return new Promise(resolve => {
if (this.isLoaded()) {
this.failed = false;
logger.debug("===chartbeat loaded successfully===");
return resolve(instance);
}
if (time >= MAX_WAIT_FOR_INTEGRATION_LOAD) {
this.failed = true;
logger.debug("===chartbeat failed===");
return resolve(instance);
}
this.pause(INTEGRATION_LOAD_CHECK_INTERVAL).then(() => {
Expand Down

0 comments on commit d476016

Please sign in to comment.