Skip to content

Instantly share code, notes, and snippets.

@rxco
Last active May 17, 2018 22:06
Show Gist options
  • Save rxco/6c9d1961f40521f92ed538e3f6926605 to your computer and use it in GitHub Desktop.
Save rxco/6c9d1961f40521f92ed538e3f6926605 to your computer and use it in GitHub Desktop.
Ometria

User already registered in Ometria, with EXPLICITY_OPTEDOUT

=> <Spree::User id: 2382720, email: "wondrbly-stg4-sync@yopmail.com", persistence_token: nil, perishable_token: nil, last_request_at: nil, login: "wondrbly-stg4-sync@yopmail.com", ship_address_id: nil, bill_address_id: nil, authentication_token: "uUJdd1MNJJS9x1gsZeCq", created_at: "2018-05-17 21:37:58", updated_at: "2018-05-17 21:37:58", spree_api_key: nil, firstname: "Jess", lastname: "Bach", raw_confirmation_token: "35gKsUFnxuL3Wz4yUjyS", referred_user_token: "KCDE3aGtYEJzAq2m2Q41", sent_emails: [], email_unsubscriptions: [], nps: nil, settings: nil, deleted_at: nil, signup_country_id: 44, marketing_opt_in: false, email_tracking_token: "jwGZMOzpSjbsCT3V6TrZUS-5DuSAUwRY", signup_locale: "de", signup_source: "onsite:co">

When trying to send a double optin email:

From: /Users/magmalabs/rails/wonderbly/eagle/app/workers/ometria_sync_worker.rb @ line 54 OmetriaSyncWorker#perform:

    49:         Eagle::Ometria::Submitter.user(user) if user
    50:         binding.pry
    51:         Eagle::Ometria::DoubleOptIn.send_email(user) if user && Eagle::Ometria::DoubleOptIn.should_send_email?(user)
    52:       end
    53:     rescue OmetriaClient::HttpError => e
 => 54:       Rails.logger.info(
    55:         "info=OmetriaSyncWorker" +
    56:         "exception=#{e.to_s}" +
    57:         "action=#{action} " +
    58:         "id=#{id} " +
    59:         "time=#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}"
[13] pry(#<OmetriaSyncWorker>)> e
=> <OmetriaClient::HttpError: OmetriaClient.new.send_de_optin_email: wondrbly-stg4-sync@yopmail.com 500 {"status":"ERROR","code":500,"message":"Internal server error","timestamp":1526593931}>

Also debugged this with mayday url:

From: /Users/magmalabs/rails/wonderbly/eagle/app/services/spree/user_registration_service.rb @ line 19 Spree::UserRegistrationService#initialize:

     5: def initialize(opts)
     6:   @email = opts.fetch(:email)
     7:   @user = Spree::User.find_by_lowercase_email(@email)
     8:   binding.pry
     9:   @user ||= Spree::User.new(
    10:     email: @email,
    11:     password: opts.fetch(:password, SecureRandom.hex),
    12:     referral_code: opts.fetch(:referral_code, nil),
    13:     firstname: opts.fetch(:firstname, nil),
    14:     lastname: opts.fetch(:lastname, nil),
    15:     marketing_opt_in: opts.fetch(:marketing_opt_in, false),
    16:     signup_country_id: opts.fetch(:signup_country, nil).try(:id),
    17:     signup_locale: opts.fetch(:signup_locale, I18n.locale),
    18:     signup_source: opts.fetch(:signup_source, nil),
 => 19:   )
    20: end

[1] pry(#<Spree::UserRegistrationService>)> opts
=> {:referral_code=>nil,
 :signup_country=>
  #<Spree::Country:0x00007f966ccfc218
   id: 44,
   iso_name: "UNITED KINGDOM",
   iso: "GB",
   iso3: "GBR",
   name: "United Kingdom",
   numcode: 826,
   states_required: false,
   updated_at: Wed, 10 Sep 2014 19:23:23 UTC +00:00,
   created_at: nil>,
 :signup_source=>"onsite:co",
 :firstname=>"Francisco",
 :lastname=>"Perez",
 :email=>"wondrbly-stg5-sync@yopmail.com"}
[2] pry(#<Spree::UserRegistrationService>)> opts.fetch(:marketing_opt_in, false)
=> false
[3] pry(#<Spree::UserRegistrationService>)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment