Sha256: d777ba0b3f79a3f6e913097a6ddec7eaec4bd23d7306f14d5a7890c9c6a90118
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require 'securerandom' require 'json' module Synchrolog class Middleware def initialize app @app = app end def call env request = ActionDispatch::Request.new(env) if request.original_fullpath == "/synchrolog-time" [ 200, {'Content-Type' => 'application/json'}, [{ time: Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ") }.to_json] ] else if request.cookie_jar['synchrolog_anonymous_id'].nil? request.cookie_jar['synchrolog_anonymous_id'] = SecureRandom.hex end anonymous_id = request.cookie_jar['synchrolog_anonymous_id'] user_id = request.cookie_jar['synchrolog_user_id'] SYNCHROLOG.logger.tagged("synchrolog_anonymous_id:#{anonymous_id}", "synchrolog_user_id:#{user_id}") do begin response = @app.call(env) rescue Exception => exception SYNCHROLOG.exception_logger.capture(response, exception, env, anonymous_id, user_id) raise end exception = env['rack.exception'] || env['action_dispatch.exception'] SYNCHROLOG.exception_logger.capture(response, exception, env, anonymous_id, user_id) if exception response end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
synchrolog-ruby-0.1.7 | lib/synchrolog/middleware.rb |