Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 9 additions & 3 deletions lib/protos.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

var Emitter = require('component-emitter');
var after = require('@ndhoule/after');
var each = require('@ndhoule/each');
var events = require('analytics-events');
var every = require('@ndhoule/every');
Expand Down Expand Up @@ -334,8 +333,15 @@ exports._wrapInitialize = function() {
*/

exports._wrapPage = function() {
// Noop the first page call if integration assumes pageview
if (this._assumesPageview) return this.page = after(2, this.page);
var page = this.page;
var initialPageSkipped = false;
this.page = function() {
if (this._assumesPageview && !initialPageSkipped) {
initialPageSkipped = true;
return;
}
return page.apply(this, arguments);
Copy link
Contributor

@fathyb fathyb Nov 19, 2019

Choose a reason for hiding this comment

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

Is there a need to store initialPageSkipped on the instance? It could be simplified to:

  var page = this.page;
  var initialPageSkipped = false;
  this.page = function() {
    if (this._assumesPageview && !initialPageSkipped) {
      return initialPageSkipped = true;
    }

    return page.apply(this, arguments);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. fixed!

};
};

/**
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
},
"homepage": "https://github.com/segmentio/analytics.js-integration#readme",
"dependencies": {
"@ndhoule/after": "^1.0.0",
"@ndhoule/clone": "^1.0.0",
"@ndhoule/defaults": "^2.0.1",
"@ndhoule/each": "^2.0.1",
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
# yarn lockfile v1


"@ndhoule/after@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@ndhoule/after/-/after-1.0.0.tgz#e6d86d121448247ac742ff3a61c63fae83ee1191"
dependencies:
"@ndhoule/arity" "^2.0.0"

"@ndhoule/arity@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@ndhoule/arity/-/arity-2.0.0.tgz#26bfa0b9755ced9aea819d4e6e7a93db27a5b658"

"@ndhoule/clone@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@ndhoule/clone/-/clone-1.0.0.tgz#0f68394a95008cf360370e101924564a70927afc"
Expand Down