telemetry 1.1.8 → 1.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTljZTRmOTQ3Y2Y5OGJhZjJiNWIwM2VlMjBiYzM4MjA3YWNhOWRkNA==
4
+ YTgwNmI1ZmEzMzVlOWNjNDRiMjQxYTM0NDc2Mjg0ZmRkMWI5YWQxNg==
5
5
  data.tar.gz: !binary |-
6
- YTE1ZWEwNjM3N2UxNzdhYmU1Y2FiMTdiODYyOTZmNDUzZGU1ZjM2MA==
6
+ ZGQzMDE5ZGZmOTM0MzIwMzIxNmQ1ZGFlN2Q0YzQ5MzdjMTY4ZTAzYQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NWFiNzEyOGI4NTQxMTM3ODUzYWZkYmM2NjBlZjdjZWMyYWM3ODUxODRmNTBk
10
- NzQ4Mjc2YzhmOWM2NDhkMzUwY2Y4YmVmMzA4NjE4MTcxM2Y0ZjA1MjcyNGI4
11
- NDI0N2YxYTYzODQ5NGE3YWU4OTBlYjgyZjFkOWNlZmM5NzM5ZWQ=
9
+ YjZkYjQ4YTkzOGY5OWNkZDc4MTk4NDdmMjhhNTliMDNkMjMwMzRlZWZmMGFk
10
+ MDkyYjVlYmIxNDczYmZhNDY5ZjMyMDFiNzQxN2MzMGZiNWMwMzcwZWY1OGQx
11
+ ZjUyYjY5NjY5ODMxY2M3MmNiOGNkNGFlMjU4YTU0Y2Q1N2QwM2Y=
12
12
  data.tar.gz: !binary |-
13
- ZGU5NzRlODM0MWZiYjQyY2MyNTMwMTY1MWE4MjFjYmE2YWJiODcxZGU0ODcw
14
- NDU2NTEzZDFjMTk0ZTA3ZGYwYjIwNTRjM2NlMGJjMzZjYzJiZGRkMGIzMGJk
15
- MTJlNDQzMzlmYmMxYzBiNjQ1MDgwYTVkZTAyNGU5Mzk1ZDk5Zjg=
13
+ NmIyYzNiY2Q5YjAxNGEyYzk4MTUzNGVjYzgxODIwZTU2NWU2M2MwMjI0ZTk4
14
+ NTU3YjAyMmNmMGQ1MGEzYmJmZDQzZmFiMDg2N2U3YjRlM2EwYWMzN2I4ODBm
15
+ NmQ0ZGNlYTRjYzEwZGI0Y2ZhZjlhZjRlOWYzY2Q4NjEyZDNmZDY=
data/README.md CHANGED
@@ -26,6 +26,25 @@ Set a hash of values for the flow to update. Each hash must contain the tag of
26
26
 
27
27
  For documentation on flows and the properties they support please see the [flow documentation](https://admin.telemetryapp.com/documentation/flows) pages.
28
28
 
29
+ ## Affiliates
30
+
31
+ This gem supports affiliate data sending. In order to use this capability call the Telemetry::Api.affiliate_send(flows, unique-identifier) method. You must have an enterprise account and get support to enable your account for affiliates first.
32
+
33
+ require 'telemetry'
34
+
35
+ Telemetry.token = "test-api-token"
36
+
37
+ # Construct a hash with the flow tags as keys and the values as the hash to use to update the data
38
+ flows = {
39
+ value_tag: {
40
+ value: 435
41
+ }
42
+ }
43
+
44
+ # Send to the unique identifier for the affiliate as created by you on the affiliate page
45
+ Telemetry::Api.affiliate_send(flows, "unique-identifier")
46
+
47
+ For more information see the [affiliate documentation](https://admin.telemetryapp.com/documentation/affiliate).
29
48
 
30
49
  ## Daemon
31
50
 
data/lib/telemetry/api.rb CHANGED
@@ -8,13 +8,12 @@ require 'logger'
8
8
 
9
9
  module Telemetry
10
10
 
11
- @affiliate_id
12
11
  @token = nil
13
12
  @logger = nil
14
13
 
15
14
  def self.api_host
16
15
  if ENV["RACK_ENV"] == 'development' || ENV["RACK_ENV"] == 'test'
17
- "http://data.test.telemetryapp.com"
16
+ "https://data.telemetryapp.com"
18
17
  else
19
18
  "https://data.telemetryapp.com"
20
19
  end
@@ -44,14 +43,6 @@ module Telemetry
44
43
  @token = token
45
44
  end
46
45
 
47
- def self.affiliate_id
48
- @token
49
- end
50
-
51
- def self.affiliate_id=(affiliate_id)
52
- @affiliate_id = affiliate_id
53
- end
54
-
55
46
  class Api
56
47
 
57
48
  def self.get_flow(id)
@@ -66,6 +57,13 @@ module Telemetry
66
57
  Telemetry::Api.send(:delete, "/flows/#{id}/data")
67
58
  end
68
59
 
60
+ def self.affiliate_send(affiliate_identifier, data)
61
+ raise Telemetry::AuthenticationFailed, "Please set your Telemetry.token" unless Telemetry.token
62
+ raise RuntimeError, "Must supply flows to send" if flows == 0 || flows.count == 0
63
+ raise RuntimeError, "Must supply a unique affiliate identifier" unless affiliate_identifier
64
+ return Telemetry::Api.send(:post, "/flows/affiliate/#{affiliate_identifier}", {:data => data})
65
+ end
66
+
69
67
  def self.flow_update(flow)
70
68
  raise Telemetry::AuthenticationFailed, "Please set your Telemetry.token" unless Telemetry.token
71
69
  values = flow.to_hash
@@ -203,16 +203,25 @@ module TelemetryDaemon
203
203
  Telemetry.logger.debug " + Executing task #{task[0]} #{task[1]}"
204
204
  block.yield
205
205
 
206
- next if @hh == {}
206
+ if @hh == {}
207
+ Telemetry.logger.debug " - Skipping empty task values #{task[0]} #{task[1]}"
208
+ next
209
+ end
207
210
 
208
211
  # Append the variant
209
212
  values = @@h.merge({variant: variant})
210
213
 
214
+ # Telemetry.logger.debug " - Values for #{task[0]} #{task[1]}:\n#{values}\n#{@@last_values[tag]}"
215
+
216
+ # Telemetry.logger.debug "LV\n\n #{@@last_values}\n\n"
217
+
211
218
  # Skip if the values haven't changed (though send 1/day regardless)
212
219
  if @@last_values[tag] != values || @@values_expires_at[tag] < now.to_i
213
220
  @@buffer[tag] = values
214
- @@last_values[tag] = values # Save the value so we dont update unless it changes
221
+ @@last_values[tag] = values.clone # Save the value so we dont update unless it changes
215
222
  @@values_expires_at[tag] = now.to_i + 86400 # Force an update 1/day
223
+ else
224
+ Telemetry.logger.debug " - Skipping update for unchanged #{task[0]} #{task[1]}:\n#{@@last_values[tag]}"
216
225
  end
217
226
  end
218
227
 
@@ -1,3 +1,3 @@
1
1
  module Telemetry
2
- TELEMETRY_VERSION = "1.1.8"
2
+ TELEMETRY_VERSION = "1.1.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telemetry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - W. Gersham Meharg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-30 00:00:00.000000000 Z
11
+ date: 2013-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj