Description
So, I'd like to be able to set a dynamic wait:
value on a campaign step. Basically, in the app I'm integrating Heya into, it starts with a 7 day free trial. But by using certain features, users can extend their trials by up to 14 days. I'd like to start a new campaign when a user starts their first extra day, which has 2 steps - One that gets sent right away, and the other that gets sent at the end of their trial. Since the trial end date can change over time, how can I handle sending that second step at the correct time? Here's what I'm trying for that campaign:
class TrialConversionCampaignExtended < ApplicationCampaign
step :added_first_extra_day
step :ended,
wait: ->(member) {
ActiveSupport::Duration.build((member.group.trial_ends_at - Time.current).to_i)
}
end
Of course, the wait:
value is expecting an ActiveSupport::Duration
object (e.g. 3.days
). But in that case I'm seeing this error:
undefined method `to_i' for an instance of Proc (NoMethodError)
The relevant stack trace points to the build_arel
function in /lib/heya/active_record_extension.rb
Any thoughts on how to make this situation work?