Sha256: a934ea62bfdeaa48243a1a1e4e4f6700c9857c5efd39c9560dce55ab0fcfed94

Contents?: true

Size: 834 Bytes

Versions: 4

Compression:

Stored size: 834 Bytes

Contents

module Telegram
  module Bot
    class UpdatesController
      # Helpers for botan.io metrics.
      module Botan
        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

4 entries across 4 versions & 1 rubygems

Version Path
telegram-bot-0.8.0 lib/telegram/bot/updates_controller/botan.rb
telegram-bot-0.7.4 lib/telegram/bot/updates_controller/botan.rb
telegram-bot-0.7.3 lib/telegram/bot/updates_controller/botan.rb
telegram-bot-0.7.2 lib/telegram/bot/updates_controller/botan.rb