Sha256: 3045aa65a244de2a0dcdb6c160897edd267c27943ce9728dc5a22de2d90d17e5
Contents?: true
Size: 974 Bytes
Versions: 4
Compression:
Stored size: 974 Bytes
Contents
require 'net/https' require 'uri' module Synchrolog module Logger class HTTPS def initialize(api_key, **args) @api_key = api_key @host = args[:host] end def write(message) return unless message[:anonymous_id] json_headers = {'Authorization' => "Basic #{@api_key}", 'Content-Type' =>'application/json'} uri = URI.parse("#{@host}/v1/track-backend") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.post(uri.path, body(message).to_json, json_headers) end def body(message) { event_type: 'log', timestamp: message[:timestamp], anonymous_id: message[:anonymous_id], user_id: message[:user_id], source: 'backend', api_key: @api_key, log: message } end def close nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems