Skip to content

Commit

Permalink
chore: test on 5 seconds after init stream if its working
Browse files Browse the repository at this point in the history
  • Loading branch information
juanSanchezAlcala committed Oct 5, 2023
1 parent 773cbc5 commit 2744355
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions components/o-comments/src/js/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Stream {
}

renderComments () {
return new Promise((resolve) => {
return new Promise((resolve,reject) => {
try {
/*global Coral*/
const cacheBuster = 'cachebust=20210806';
Expand Down Expand Up @@ -99,23 +99,20 @@ class Stream {
}
);
resolve();

//Test if comments were loaded after 5 seconds of initialisation
setTimeout(() => {
if(!this.embed ||
!document.querySelector("#o-comments-stream div").shadowRoot ||
!document.querySelector("#o-comments-stream div").shadowRoot.querySelector("#tabPane-ALL_COMMENTS")) {
this.logError(new Error(" comment stream object not created "))
}
},5000)

}
catch(error){
const oTrackingEvent = new CustomEvent('oTracking.event', {
bubbles : true,
detail : {
category: 'comment',
action: 'coral.initialisation',
coral: false,
content : {
asset_type: this.options.assetType,
uuid: this.options.articleId,
},
error : error.message
}
});
document.body.dispatchEvent(oTrackingEvent);
this.logError(error);
reject(error);
}
};
this.streamEl.parentNode.appendChild(scriptElement);
Expand All @@ -133,6 +130,7 @@ class Stream {

document.dispatchEvent(new Event('oCommentsReady'));
} catch (error) {
this.logError(error);
resolve();
}
});
Expand Down Expand Up @@ -265,6 +263,23 @@ class Stream {
this.displayNamePrompt({purgeCacheAfterCompletion: true});
};
}

logError(error){
const oTrackingEvent = new CustomEvent('oTracking.event', {
bubbles : true,
detail : {
category: 'comment',
action: 'coral.initialisation',
coral: false,
content : {
asset_type: this.options.assetType,
uuid: this.options.articleId,
},
error : error.message
}
});
document.body.dispatchEvent(oTrackingEvent);
}
}

export default Stream;

0 comments on commit 2744355

Please sign in to comment.