Class: VagrantPlugins::Uplift::AppInsights::AppInsightsHelper
- Inherits:
-
Object
- Object
- VagrantPlugins::Uplift::AppInsights::AppInsightsHelper
- Defined in:
- lib/vagrant-uplift/appinsights.rb
Instance Method Summary collapse
-
#initialize(key) ⇒ AppInsightsHelper
constructor
A new instance of AppInsightsHelper.
- #track_event(event_name, event_properties) ⇒ Object
Constructor Details
#initialize(key) ⇒ AppInsightsHelper
Returns a new instance of AppInsightsHelper.
21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-uplift/appinsights.rb', line 21 def initialize(key) @key = key @endpoint = 'https://dc.services.visualstudio.com' @endpoint_api = '/v2/track' @client_id = 'uplift-vagrant:ruby:1.0.0' end |
Instance Method Details
#track_event(event_name, event_properties) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/vagrant-uplift/appinsights.rb', line 30 def track_event(event_name, event_properties) _log_debug("tracking event: #{event_name}") result = { :success => false } begin time = DateTime.now.to_time.utc.strftime('%Y-%m-%dT%H:%M:%S.%7N%z') data = { "name" => "Microsoft.ApplicationInsights.Event", "time" => time, "iKey" => @key, "tags" => { "ai.internal.sdkVersion": @client_id }, "data" => { "baseType" => "EventData", "baseData" => { "ver": 2, "name": event_name , "properties": event_properties } } } _log_debug("sending data: #{data}") _send_data_async(data) rescue => e result[:exception] = e; result[:success] = false ensure end return result end |