Sha256: 95c030c026e8f2095d67f8dac924f19c0863945becf7df7f28543ea7bdfd51de

Contents?: true

Size: 834 Bytes

Versions: 17

Compression:

Stored size: 834 Bytes

Contents

module Telegram
  module Bot
    class Botan
      # Helpers for botan.io metrics.
      module ControllerHelpers
        class MissingFrom < Error; end

        protected

        def botan
          @botan ||= bot.try!(:botan)
        end

        # Track custom event for user taken from `from` field:
        #
        #   botan_track :my_event, {data: :val}
        #
        def botan_track(event, data = {})
          raise MissingFrom, 'Can not track without user' unless from
          botan.try! { |x| x.track(event, from['id'], data) }
        end

        # Track current action and payload for current user. Best used with `before_action`:
        #
        #   before_action :botan_track_action
        #
        def botan_track_action
          botan_track(action_name, payload)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
telegram-bot-0.14.0 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.13.1 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.13.0 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.12.4 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.12.3 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.12.1 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.12.0 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.11.3 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.11.2 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.11.1 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.11.0 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.10.2 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.10.1 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.10.0 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.9.0 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.9.0.alpha2 lib/telegram/bot/botan/controller_helpers.rb
telegram-bot-0.9.0.alpha1 lib/telegram/bot/botan/controller_helpers.rb