TrackingSDKs
Ruby SDK
The iforevents gem for Rails, workers and CLIs
gem "iforevents"
gem "iforevents-mixpanel" # optional adapters
gem "iforevents-segment"require "iforevents"
analytics = Iforevents.new(project_key: ENV.fetch("IFOREVENTS_PROJECT_KEY"))
analytics.identify("user_123", email: "[email protected]", plan: "pro")
analytics.track("invoice_paid", amount: 120, currency: "USD")
analytics.page("/pricing")
analytics.reset # logout
analytics.shutdown # also runs at_exitStandard library only (Net::HTTP), thread-safe, batches on a background thread. Build the client yourself to add adapters:
api = Iforevents::APIIntegration.new(project_key: "pk_...", batch_size: 50)
analytics = Iforevents::Client.new([api, Iforevents::Integrations::Mixpanel.new(token: "...")])
analytics.initOptions: base_url, batch_size, flush_interval, timeout, max_retries / retry_delay, requeue_failed_events, storage / persist_queue (FileStorage), throw_on_error, on_quota_exceeded, on_error, flush_at_exit. Errors: Iforevents::APIError, AuthError, QuotaExceededError, RateLimitedError.
Source: iforevents-sdks/ruby.