From 0ecbd8b2374c2a1d752d96fc8010e647f4fc8a30 Mon Sep 17 00:00:00 2001 From: carlad Date: Thu, 3 Dec 2015 15:04:50 +0100 Subject: [PATCH] add customerio gem and event --- Gemfile | 1 + Gemfile.lock | 8 ++++++++ lib/travis/api/app/endpoint/authorization.rb | 12 +++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 9334227c..ce0fe1b8 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,7 @@ gem 'skylight', '~> 0.6.0.beta.1' gem 'stackprof' gem 'jemalloc' +gem 'customerio' group :test do gem 'rspec', '~> 2.13' diff --git a/Gemfile.lock b/Gemfile.lock index 71cb022d..24c64a46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -157,6 +157,9 @@ GEM composite_primary_keys (5.0.14) activerecord (~> 3.2.0, >= 3.2.9) connection_pool (2.1.1) + customerio (0.6.1) + httparty (>= 0.5, < 0.12) + multi_json (~> 1.0) dalli (2.7.2) data_migrations (0.0.1) activerecord @@ -187,6 +190,9 @@ GEM hashr (0.0.22) hike (1.2.3) hitimes (1.2.3) + httparty (0.11.0) + multi_json (~> 1.0) + multi_xml (>= 0.5.2) httpclient (2.7.0.1) i18n (0.7.0) ice_nine (0.11.1) @@ -215,6 +221,7 @@ GEM mocha (0.14.0) metaclass (~> 0.0.1) multi_json (1.11.2) + multi_xml (0.5.5) multipart-post (2.0.0) net-http-persistent (2.9.4) net-http-pipeline (1.0.1) @@ -335,6 +342,7 @@ PLATFORMS DEPENDENCIES active_model_serializers bunny (~> 0.8.0) + customerio dalli database_cleaner (~> 0.8.0) factory_girl (~> 2.4.0) diff --git a/lib/travis/api/app/endpoint/authorization.rb b/lib/travis/api/app/endpoint/authorization.rb index e6081389..2c8b8403 100644 --- a/lib/travis/api/app/endpoint/authorization.rb +++ b/lib/travis/api/app/endpoint/authorization.rb @@ -160,8 +160,18 @@ class Travis::Api::App def check_first_login(user) return if user.first_logged_in_at puts "this is the first log in!!" + # send event to customer.io + customerio = Customerio::Client.new(Travis.config.customerio.site_id, Travis.config.customerio.api_key, :json => true) + $customerio.identify( + :id => user.id, + :name => user.name, + :login => user.login, + :email => user.email, + :created_at => user.created_at.to_i, + :github_id => user.github_id, + :education => user.education + ) # user.update_attributes(first_logged_in_at: Time.now) - # #send event to customer.io end def serialize_user(user)