-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add auto-generated timestamp and sent_at (ruby-sdk) #97
Conversation
bcb72dc
to
5a23ada
Compare
lib/castle/client.rb
Outdated
def to_context(request, options = {}) | ||
default_context = Castle::DefaultContext.new(request, options[:cookies]).call | ||
Castle::ContextMerger.new(default_context).call(options[:context] || {}) | ||
def to_context(request, context_options = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why renaming to context_options
, I think if any I would call it additional_context
see other methods
lib/castle/client.rb
Outdated
end | ||
|
||
def to_options(options = {}) | ||
options[:timestamp] ||= Time.now.iso8601 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Time.now.utc.iso8601(3)
lib/castle/client.rb
Outdated
@@ -25,6 +34,7 @@ def authenticate(options = {}) | |||
options = Castle::Utils.deep_symbolize_keys(options || {}) | |||
|
|||
if tracked? | |||
options[:timestamp] = @timestamp if @timestamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we should allow it for authenticate
thoughts @wallin?
lib/castle/client.rb
Outdated
@@ -40,6 +50,7 @@ def identify(options = {}) | |||
options = Castle::Utils.deep_symbolize_keys(options || {}) | |||
|
|||
return unless tracked? | |||
options[:timestamp] = @timestamp if @timestamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change it for all methods to options[:timestamp] ||=
that way you can also pass in a timestamp to identify/track
lib/castle/commands/authenticate.rb
Outdated
|
||
Castle::Command.new('authenticate', options, :post) | ||
Castle::Command.new('authenticate', | ||
options.merge(context: context, sent_at: Time.now.iso8601), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time.now.utc.is8601(3)
also shouldn't this be the responsibility of Castle::Command
will DRY it up and add responsibility to the Object making the request
lib/castle/commands/identify.rb
Outdated
|
||
Castle::Command.new('identify', options, :post) | ||
Castle::Command.new('identify', | ||
options.merge(context: context, sent_at: Time.now.iso8601), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment on authenticate
lib/castle/commands/track.rb
Outdated
|
||
Castle::Command.new('track', options, :post) | ||
Castle::Command.new('track', | ||
options.merge(context: context, sent_at: Time.now.iso8601), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment on authenticate
@lluft thanks - corrected |
@wallin mentioned that we don't need to send it for |
related https://github.com/castle/api/issues/1753