Create a gist now

Instantly share code, notes, and snippets.

Clearbit Reveal/Drift integration
drift.on('ready',function(api, payload) {
api.showWelcomeOrAwayMessage(<%== @options.to_json %>);
});
get '/drift.js' do
reveal = Clearbit::Reveal.find(ip: request.ip)
content_type 'application/javascript'
qualified =
reveal &&
reveal.company.metrics.employees.to_i >= 30 &&
%{private public}.include?(reveal.company.type)
if qualified
unless reveal.fuzzy
name = reveal.company.name.gsub(/\W/, '')
message = %{We ♥ #{name}. Have any questions?}
end
@options = {
showAvatar: true,
slide: true,
message: message,
}
erb :'site/drift/show'
else
200
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment