Skip to content

SAN-4053 - User Engagement Tracking#114

Merged
Myztiq merged 6 commits intomasterfrom
SAN-4053-intercom-engagement
Apr 28, 2016
Merged

SAN-4053 - User Engagement Tracking#114
Myztiq merged 6 commits intomasterfrom
SAN-4053-intercom-engagement

Conversation

@Myztiq
Copy link
Copy Markdown
Contributor

@Myztiq Myztiq commented Apr 26, 2016

Added logic to create a navi user for intercom to be able to know when the last request was made on a company.

@runnabot
Copy link
Copy Markdown

runnabot commented Apr 26, 2016

The latest push to PR-114 is running on SAN-4053-intercom-engagement-navi

Comment thread lib/models/proxy.js Outdated
user_id: 'navi-' + req.naviEntry.ownerUsername,
update_last_request_at: true,
companies: [{
company_id: req.naviEntry.ownerUsername,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we use owner githubId or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

company_id is intercom syntax. We already have it as ownerUsername everywhere.

@rsandor
Copy link
Copy Markdown
Contributor

rsandor commented Apr 27, 2016

@Myztiq - See comment about defensive programming. Other than that, do we want to add a test to ensure we are doing the reporting? Basically I'd feel better if we were testing that if statement above. 🍻

Comment thread lib/models/proxy.js Outdated
@@ -14,6 +14,8 @@ var pluck = require('101/pluck');
var put = require('101/put');
var url = require('url');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit why the space?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread lib/models/proxy.js Outdated

// This runs async, but we don't care about the results. FIRE + FORGET!
var ownerUsername = keypather.get(req, 'naviEntry.ownerUsername')
if (ownerUsername && self.intercomClient) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch on the && self.intercomClient. Have you considered just pulling this functionality out into its own method? For instance,

// Returns true if we should report via intercom
Proxy.prototype.shouldUseIntercom = function () {
  return process.env.INTERCOM_APP_ID && process.env.INTERCOM_API_KEY
}

// Reports user information to intercom
Proxy.prototype.reportToIntercom = function (req) {
  if (!this.shouldUseIntercom()) { return }
}

If we suspect there are other places where we would want this specific behavior I suggest pulling the whole intercom client out into its own module. That way you can just require the internal intercom module and don't have to repeat defensive checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea, I could see extracting this out if we end up needing to use it in another spot. I don't feel like we should do it now for the sake of "engineering" a better system. I can't think of a spot off the top of my head where we'll be reporting from navi anything to intercom other than this right now.

@anandkumarpatel
Copy link
Copy Markdown
Contributor

this LGTM

@Myztiq Myztiq merged commit f65d3a5 into master Apr 28, 2016
@Myztiq Myztiq deleted the SAN-4053-intercom-engagement branch April 28, 2016 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants