Skip to content

Conversation

@danieljackins
Copy link
Contributor

@danieljackins danieljackins commented Nov 18, 2019

For https://segment.atlassian.net/browse/LIB-1430

This PR removes the dependency on "after" which violated customer CSP with a new Function() call.

return this._initialPageSkipped = true;
}

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!

lib/protos.js Outdated
if (this._assumesPageview) {
if (this._initialPageSkipped) return page.apply(this, arguments);

return this._initialPageSkipped = true;
Copy link

Choose a reason for hiding this comment

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

similar to my question #123

what do we expect this method to return ? It's a bit confusing reading that line, because it appears that we're returning a boolean, but that doesn't appear to be the intention. If the method return null, it might be clearer if we just used two lines, one to set the var, the other to explicitly return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

Copy link
Contributor

@fathyb fathyb left a comment

Choose a reason for hiding this comment

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

🔥

@danieljackins danieljackins merged commit 6e6df4f into master Nov 20, 2019
@danieljackins danieljackins deleted the djackins/eval branch November 20, 2019 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants