sendgrid-ruby icon indicating copy to clipboard operation
sendgrid-ruby copied to clipboard

Attempting to provide custom_args json object for A/B testing

Open campgurus opened this issue 10 months ago • 0 comments

But SendGrid seems not to be seeing the custom args. Category is conveyed as expected. Here is the send_email action:

def send_email(daily_content)

# Get A/B test subject line and metadata
ab_test = SubjectLineAbTestingService.new(@user).generate_subject_line_test
daily_content.subject = ab_test[:subject]

mail(
  to: @user.email,
  subject: ActionView::Base.full_sanitizer.sanitize(daily_content.subject).to_s
) do |format|
  format.html

  # Add SendGrid headers
  headers['X-SMTPAPI'] = {
    "category": ["daily_stats"],
    "custom_args": {
      "variation_id": ab_test[:variation],
      "total_variations": ab_test[:total_variations],
      "user_id": @user.id.to_s
    }
  }.to_json
end

end

campgurus avatar Mar 20 '25 16:03 campgurus