Skip to content

Commit

Permalink
Merge pull request #41 from hull-ships/release/v0.4.10
Browse files Browse the repository at this point in the history
Release/v0.4.10
  • Loading branch information
michaloo authored Mar 7, 2018
2 parents 35f6a8e + 86d288d commit e873517
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.4.10
- adds dashboard tab
- changes ident building when saving users
- write email, first and last name to clearbit traits group, add setIfNull for `first_name` and `last_name`

## 0.4.9
- Fix Prospector UI not having a Source user to assign track & traits

Expand Down
10 changes: 9 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
"ui": false,
"picture": "picture.png",
"admin": "admin.html",
"tabs": [
{
"title": "Prospector",
"url": "admin.html",
"size": "large",
"editable": false
}
],
"source": "clearbit",
"readme": "readme.md",
"version": "0.4.9",
"version": "0.4.10",
"private_settings": [
{
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hull-clearbit",
"description": "Enrich Customer data with Clearbit",
"version": "0.4.9",
"version": "0.4.10",
"main": "index.js",
"license": "MIT",
"homepage": "https://github.com/hull-ships/hull-clearbit",
Expand Down
16 changes: 4 additions & 12 deletions server/clearbit.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,12 @@ export default class Clearbit {
* @return {Promise -> Object({ user, person })}
*/
saveUser(user = {}, person = {}, options = {}) {
const { id, external_id } = user;
const email = user.email || person.email;
const { source, incoming } = options;

// Custom Resolution strategy.
// Only uses one identifier. [Why did we do this ?]
let ident;
if (id) {
ident = { id };
} else if (external_id) {
ident = { external_id };
} else if (email) {
ident = { email };
}
// Never ever change the email address (Clearbit strips +xxx parts, so we end up with complete
// messed up ident claims if we do this). We need to pass all claims
// to the platform to allow proper identity resolution.
const ident = _.pick(user, ["id", "external_id", "email"]);

const direction = incoming ? "incoming" : "outgoing";

Expand Down
13 changes: 13 additions & 0 deletions server/clearbit/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,18 @@ export default function getUserTraitsFromPerson(
{}
);

// Overcome the value:key restrictions and add last_name and first_name to top level traits
// if the mappingName is Person
if (mappingName === "Person") {
_.set(traits, "last_name", {
value: _.get(person, "name.familyName"),
operation: "setIfNull"
});
_.set(traits, "first_name", {
value: _.get(person, "name.givenName"),
operation: "setIfNull"
});
}

return _.omitBy(traits, _.isNil);
}
5 changes: 4 additions & 1 deletion server/handlers/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export default function handleWebhook({ hostSecret, Hull }) {
metric("ship.clearbit.incoming_webhook", 1);
}
} catch (err) {
console.warn("Error on webhook onMetric: ", err);
Hull.logger.debug(
"Error when trying to increase ship.clearbit.incoming_webhook counter",
err
);
}
};
}
6 changes: 3 additions & 3 deletions server/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
"angellist.site": "clearbit/angellist_site",
avatar: "picture",
bio: "clearbit/bio",
email: "email",
email: "clearbit/email",
emailProvider: "clearbit/email_provider",
"employment.domain": "clearbit/employment_domain",
"employment.name": "clearbit/employment_name",
Expand Down Expand Up @@ -41,9 +41,9 @@ export default {
fuzzy: "clearbit/fuzzy",
"linkedin.handle": "clearbit/linkedin_handle",
location: "clearbit/location",
"name.familyName": "last_name",
"name.familyName": "clearbit/last_name",
"name.fullName": "clearbit/full_name",
"name.givenName": "first_name",
"name.givenName": "clearbit/first_name",
site: "clearbit/site",
timeZone: "clearbit/time_zone",
"twitter.avatar": "clearbit/twitter_avatar",
Expand Down
31 changes: 20 additions & 11 deletions tests/integration/enrich-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from "chai";
import _ from "lodash";
import mockr from "hull-connector-dev/lib/mockr";
import server from "../../server/server";

Expand Down Expand Up @@ -64,20 +65,28 @@ describe("Enrich action", () => {
const [first] = batch;
expect(logs[1].message).to.equal("outgoing.user.start");
expect(logs[2].message).to.equal("outgoing.user.success");
expect(first.body.last_name).to.deep.equal({
operation: "setIfNull",
value: "MacCaw"
expect(_.get(first, "body.clearbit/last_name", "")).to.equal("MacCaw");
expect(_.get(first, "body.clearbit/email", "")).to.equal(
"[email protected]"
);
expect(_.get(first, "body.clearbit/first_name", "")).to.deep.equal(
"Alex"
);
expect(_.get(first, "body.clearbit/source", "")).to.deep.equal({
value: "enrich",
operation: "setIfNull"
});
expect(first.body.last_name).to.deep.equal({
operation: "setIfNull",
value: "MacCaw"
expect(_.get(first, "body.clearbit_company/domain", "")).to.equal(
"clearbit.com"
);
expect(_.get(first, "body.last_name", "")).to.deep.equal({
value: "MacCaw",
operation: "setIfNull"
});
expect(first.body.first_name).to.deep.equal({
operation: "setIfNull",
value: "Alex"
expect(_.get(first, "body.first_name", "")).to.deep.equal({
value: "Alex",
operation: "setIfNull"
});
expect(first.body["clearbit/source"].value).to.equal("enrich");
expect(first.body["clearbit_company/domain"]).to.equal("clearbit.com");
expect(batch.length).to.equal(1);
done();
}
Expand Down

0 comments on commit e873517

Please sign in to comment.