Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var Chartbeat = module.exports = integration('Chartbeat')
.option('uid', null)
.option('video', false)
.option('sendNameAndCategoryAsTitle', false)
.option('trackGalleryClicksAsPageviews', false)
.option('subscriberEngagementKeys', [])

.tag('<script src="//static.chartbeat.com/js/{{ script }}">');
Expand All @@ -37,6 +38,7 @@ Chartbeat.prototype.loaded = function() {

Chartbeat.prototype.initialize = function() {
this.pageCalledYet = false;
this.currentURL = window.location.href;
this._ready = true; // temporarily switch ready to true so that a single page call can fire
};

Expand All @@ -51,14 +53,15 @@ Chartbeat.prototype.initialize = function() {

Chartbeat.prototype.page = function(page) {
this.updateConfig(page);
var urlChanged = this.currentURL !== window.location.pathname;

// since chartbeat automatically calls a page when it loads, don't load chartbeat script until
// first Segment page call comes in and configures global config vars using its props
if (!this.pageCalledYet) {
this._ready = false; // switch ready to false so that no pages after the first one can fire until _initialize has loaded chartbeat script
this.pageCalledYet = true;
this._initialize();
} else {
} else if (this.options.trackGalleryClicksAsPageviews || urlChanged) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like the name of this option is very specific for user's that have image galleries. Are there potentially other types of sites that might use this feature?

var props = page.properties();
window.pSUPERFLY.virtualPage(props.path);
}
Expand Down