Comments (3)
Do you have a full stack trace?
What endpoint are you hitting when you get this exception?
from closeio.
Thanks for your reply.
Our endpoint (Heroku / DNSimple / Comodo certificate):
heroku certs -a tidyme-production
Endpoint Common Name(s) Expires Trusted
---------------------------- ------------------------------ -------------------- -------
yamaguchi-8516.herokussl.com *.tidyme.com.au, tidyme.com.au 2016-06-24 23:59 UTC True
This is the stacktrace we got from Airbrake:
vendor/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:923 in connect
vendor/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:923 in block in connect
vendor/ruby-2.2.3/lib/ruby/2.2.0/timeout.rb:73 in timeout
vendor/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:923 in connect
vendor/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:863 in do_start
vendor/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:852 in start
vendor/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:1375 in request
vendor/bundle/ruby/2.2.0/gems/rack-mini-profiler-0.9.7/lib/patches/net_patches.rb:7 in block in request_with_mini_profiler
vendor/bundle/ruby/2.2.0/gems/rack-mini-profiler-0.9.7/lib/mini_profiler/profiling_methods.rb:38 in step
vendor/bundle/ruby/2.2.0/gems/rack-mini-profiler-0.9.7/lib/patches/net_patches.rb:6 in request_with_mini_profiler
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/net.rb:27 in block (2 levels) in request_with_newrelic_trace
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent.rb:431 in disable_all_tracing
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/net.rb:26 in block in request_with_newrelic_trace
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/cross_app_tracing.rb:48 in tl_trace_http_request
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/net.rb:23 in request_with_newrelic_trace
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:82 in perform_request
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:40 in block in call
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:87 in with_net_http_connection
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:32 in call
vendor/bundle/ruby/2.2.0/gems/faraday_middleware-0.10.0/lib/faraday_middleware/response_middleware.rb:30 in call
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/response.rb:8 in call
vendor/bundle/ruby/2.2.0/gems/faraday_middleware-0.10.0/lib/faraday_middleware/request/encode_json.rb:23 in call
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139 in build_response
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/connection.rb:377 in run_request
vendor/bundle/ruby/2.2.0/gems/faraday-0.9.1/lib/faraday/connection.rb:177 in put
vendor/bundle/ruby/2.2.0/gems/closeio-2.4.2/lib/closeio/client.rb:42 in put
vendor/bundle/ruby/2.2.0/gems/closeio-2.4.2/lib/closeio/resources/lead.rb:25 in update_lead
app/services/close_io.rb:33 in update_lead
app/jobs/customer/close_io_update_customer_job.rb:10 in perform
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/execution.rb:32 in block in perform_now
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:117 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:117 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:555 in block (2 levels) in compile
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:498 in block (2 levels) in around
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:343 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:343 in block (2 levels) in simple
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/active_job.rb:46 in call
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/active_job.rb:46 in perform
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/active_job.rb:20 in block (3 levels) in <top (required)>
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:441 in instance_exec
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:441 in block in make_lambda
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:342 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:342 in block in simple
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:497 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:497 in block in around
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:498 in block (2 levels) in around
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:343 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:343 in block (2 levels) in simple
vendor/bundle/ruby/2.2.0/gems/i18n-0.7.0/lib/i18n.rb:257 in with_locale
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/translation.rb:7 in block (2 levels) in <module:Translation>
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:441 in instance_exec
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:441 in block in make_lambda
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:342 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:342 in block in simple
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:497 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:497 in block in around
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:498 in block (2 levels) in around
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:343 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:343 in block (2 levels) in simple
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/logging.rb:23 in call
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/logging.rb:23 in block (4 levels) in <module:Logging>
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164 in block in instrument
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications/instrumenter.rb:20 in instrument
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164 in instrument
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/logging.rb:22 in block (3 levels) in <module:Logging>
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/logging.rb:43 in block in tag_logger
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/tagged_logging.rb:68 in block in tagged
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/tagged_logging.rb:26 in tagged
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/tagged_logging.rb:68 in tagged
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/logging.rb:43 in tag_logger
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/logging.rb:19 in block (2 levels) in <module:Logging>
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:441 in instance_exec
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:441 in block in make_lambda
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:342 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:342 in block in simple
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:497 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:497 in block in around
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:505 in call
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:92 in __run_callbacks__
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:778 in _run_perform_callbacks
vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:81 in run_callbacks
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/execution.rb:31 in perform_now
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/execution.rb:21 in execute
vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/sidekiq_adapter.rb:42 in perform
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:75 in execute_job
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:52 in block (2 levels) in process
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:127 in block in invoke
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/sidekiq.rb:33 in block in call
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:362 in perform_action_with_newrelic_trace
vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.13.0.299/lib/new_relic/agent/instrumentation/sidekiq.rb:29 in call
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:129 in block in invoke
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/server/active_record.rb:6 in call
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:129 in block in invoke
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/server/logging.rb:15 in block in call
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/logging.rb:30 in with_context
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/server/logging.rb:11 in call
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:129 in block in invoke
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:132 in call
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:132 in invoke
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:51 in block in process
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:98 in stats
vendor/bundle/ruby/2.2.0/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:50 in process
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26 in public_send
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26 in dispatch
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:122 in dispatch
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60 in block in invoke
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71 in block in task
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357 in block in task
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57 in block in initialize
vendor/bundle/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15 in block in create
And these are the classes that get called:
close_io_update_customer_job.rb
# In case close.io is too slow with creating the lead, make sure it doesn't crash when submitting an event to the lead
class Customer::CloseIoUpdateCustomerJob < ActiveJob::Base
queue_as :default
def perform(user)
close_io = CloseIo.new
close_io.find_or_create_lead(user)
sleep 3 # make sure lead gets created before trying to update it
close_io.convert_to_customer(user)
close_io.update_lead(user)
end
end
close_io.rb
class CloseIo
class_attribute :backend
self.backend = Closeio::Client.new(ENV['CLOSEIO_API_KEY'], false) # disable logger to not have logs cluttered with HTTP calls
def find_or_create_lead(user)
@lead ||= find_lead(user)
if @lead.present?
return @lead
else
@lead = backend.create_lead(params(user))
end
end
def convert_to_customer(user)
@lead ||= find_lead(user)
return unless @lead.present?
#raise "Couldn't find lead" unless @lead
# Update status Lead -> Customer unless admins have specified another status
lead_status = find_status('Lead')
if @lead.status_id == lead_status.id
backend.update_lead(@lead.id, status: find_status('Customer').id)
else
return @lead
end
end
def update_lead(user)
@lead ||= find_lead(user)
return unless @lead.present?
#raise "Couldn't find lead" unless @lead
@lead = backend.update_lead(@lead.id, lead_params(user))
if @lead.contacts.present?
contact_id = @lead.contacts.first.id
backend.update_contact(contact_id, contact_params(user))
else
backend.update_lead(@lead.id, contacts: [contact_params(user)])
end
# address_id = @lead.addresses.first.id
# backend.update_address(address_id, address_params(user))
return @lead
end
def create_event(user, data)
@lead ||= find_lead(user)
return unless @lead.present?
#raise "Couldn't find lead" unless @lead
backend.create_note(lead_id: @lead.id, note: event_text(data))
end
def track_job(event_name, job, optional_properties = {})
properties = {eventName: event_name}.merge(job_properties(job))
properties.merge!(optional_properties.strip_blank_values)
create_event(User.find(job.customer_id), properties) # job.customer will return nil if the associated record is not a customer
end
def track_form(user, event_name, errors, path)
properties = {eventName: event_name, errors: errors, path: path}
create_event(User.find(user), properties)
end
private
def lead_params(user)
params = {}
params[:name] = user.full_name if user.full_name
params[:custom] = {}
params[:custom]['Global ID'] = user.id
params[:custom]['Highest Frequency'] = user.highest_frequency.humanize if user.try(:highest_frequency)
params[:custom]['Lifespan'] = user.lifespan if user.try(:lifespan)
params[:custom]['First booking time'] = user.first_booking_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ') if user.try(:first_booking_time)
params[:custom]['First frequency'] = user.first_frequency.humanize if user.try(:first_frequency)
# Ignore everything except true or false
params[:custom]['Active'] = user.active? if user.try(:active?).in?([true, false])
params[:custom]['Multiple once off'] = user.multiple_once_off? if user.try(:multiple_once_off?).in?([true, false])
params[:custom]['Paused'] = user.paused? if user.try(:paused?).in?([true, false])
params[:custom]['Paused until'] = user.paused_until.utc.strftime('%Y-%m-%dT%H:%M:%SZ') if user.try(:paused_until)
params[:custom]['Upgraded'] = user.upgraded? if user.try(:upgraded?).in?([true, false])
params[:custom]['Downgraded'] = user.downgraded? if user.try(:downgraded?).in?([true, false])
params[:custom]['Churned'] = user.churned? if user.try(:churned?).in?([true, false])
return params
end
def contact_params(user)
params = {
emails: [{type: "home", email: user.email}]
}
if user.full_name
params[:name] = user.full_name
end
if user.mobile
params[:phones] = [{type: "mobile", phone: user.mobile}]
end
return params
end
# def utm_params(utm_source, utm_medium, utm_campaign)
# params[:custom] = {}
# params[:custom]['UTM Source'] = utm_source if utm_source
# params[:custom]['UTM Medium'] = utm_medium if utm_medium
# params[:custom]['UTM Campaign'] = utm_campaign if utm_campaign
# params
# end
def params(user)
lead_params(user).merge(contacts: [contact_params(user)])
# params[:custom]['UTM Source'] = utm_source if utm_source
# params[:custom]['UTM Medium'] = utm_medium if utm_medium
# params[:custom]['UTM Campaign'] = utm_campaign if utm_campaign
# params
end
# def address_params(user)
# if user.has_address?
# {
# label: "home",
# address_1: user.address,
# city: user.city,
# zipcode: user.postcode,
# country: 'AU'
# }
# end
# end
def event_text(data)
string = ''
data.each do |key, value|
next if value.blank?
string << "#{key.to_s.underscore.humanize}: #{value}\n"
end
string
end
def find_lead(user)
backend.list_leads(user.email).data.try(:first)
end
def find_status(name)
backend.list_lead_statuses.data.each do |status|
return status if status[:label] == name
end
return nil
end
def job_properties(job)
{
jobId: job.id,
frequency: job.frequency.try(:humanize),
coupon: job.coupon_code,
couponValue: job.coupon_value,
bedrooms: job.bedrooms,
bathrooms: job.bathrooms,
firstBookingTime: stringify_time(job.occurrences.first.try(:booking_time)),
duration: job.duration,
postalCode: job.postcode,
priceScheme: job.price_scheme.try(:humanize),
referrerId: job.referrer.try(:id),
referrerEmail: job.referrer.try(:email)
}.strip_blank_values
end
def stringify_time(rails_time)
return nil unless rails_time
rails_time.strftime("%A %d %B %Y at %I:%M%p")
end
end
from closeio.
Close.io helped me to get to the bottom of this, please have a look at the pull request here: #25
from closeio.
Related Issues (20)
- updating custom fields for a lead HOT 2
- list_opportunities endpoint adds query param to filter queries HOT 1
- Seems like responses with code 400 aren't actually throwing errors when creating an opportunity HOT 2
- "You are setting a key that conflicts with a built-in method Hashie::Mash#object_id defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method." HOT 3
- Add multiple values for the same field
- Lead is returning hash instead of object HOT 7
- Paginate option returns result with symbolized keys HOT 2
- Wrong url for sent emails report HOT 1
- get request return plain html HOT 3
- list_leads email query returning 0 results HOT 12
- List leads does not work properly HOT 1
- Update `email_account` resource to `connected_account` HOT 2
- Updating a contact's custom fields?
- Faraday warnings with gem closeio (~> 3.6) HOT 1
- Unable to List Contacts by attributes
- Advanced Filters API HOT 2
- Support Faraday 2.x HOT 3
- Faraday 2 upgrade is incompatible with Faraday 1.x HOT 7
- verifying webhook
- How to Pass Sorting Options?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from closeio.