snowplow-tracker 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjRhYzM4NmY5ZjI3ZWNkZDY0MGJkNDRhMWRiZGU0N2I0YjhkMDU3Yg==
4
+ NDIxM2I3N2NhOTgwZGE3NTE2Y2I1NTk0YTUxZjY1YjAxNGM2NTU3Yg==
5
5
  data.tar.gz: !binary |-
6
- MTVkNjQxNDU2OWRhZWU2MDc5YjRkMmNhNTg5NmVlNjU4YTE1MzY2OA==
6
+ N2Q4MTdlNmI2NzAyOWY1MTI4NTNjOGQ1MjA1OTMwNzFkZDVhMjE2ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzM1MTc1Y2E0ZGQ1ZjY3NzljZDcwNDdjYWUzYjM4Y2MzMTQ1MTE4ODUwYjk0
10
- NzIxZGQ1NjY1MDAzY2IzZTljN2M4ZWM0NmEwMTZmNzllZWY0NzYzOGMyNDMz
11
- ODZlNjY4NDYyZDlhY2ZmNGMyZDQ1M2YwMDYwOGIxYTEwMDU2NTI=
9
+ OWRlZDVmZmU1ODBiZTUxZWJiM2YyMGE0MDBjMTRmNDlhODIyNzU5OGYzZmJm
10
+ YWYxNWVjNWM5NTg4NjlhNzk2YzNlOGE0OWQ3ZTM0NjI4Njc2M2FmZjU1ZDJh
11
+ ZGMwM2JlMjNhZGVmMzliYmUwNDc5YzY2OWIzZWNmNGE0ZDQ5MWU=
12
12
  data.tar.gz: !binary |-
13
- MDMxMzZjYTQxNWU3NDhhYzUwZjJhNjkwNGI4MTk2ZTI1YzBmMjE1MDEzNWZj
14
- MTY5OGU5ZWE1MTExYmQ0YWRhMmFiNjA5MzgxNDhlNDg4NzEyYWNlMTQ1ZTU4
15
- NWE5MTkxNjg1NDUxZTU0ZjgyZGE1NjFmNWU1ODExNDZkZGY5ZDA=
13
+ Y2FlNGNmMWEzMzYyYTkzZGFlNGE5MGRmYmFhZmVlM2VlZDM0NzI2M2M5Yzdk
14
+ OWEwYTk1OGIxYWE4ODZkNWZhNjIwNTBlYjA4ZGE3ZDAzZGFiNzdiZGRiNzNl
15
+ YWU1NGM3Yzg3MmZjYmQwMzljNWM0NmM0YWJlZDQ3NjZkZjI0ZTE=
@@ -13,7 +13,7 @@
13
13
  # Copyright:: Copyright (c) 2013-2014 Snowplow Analytics Ltd
14
14
  # License:: Apache License Version 2.0
15
15
 
16
- require 'net/http'
16
+ require 'net/https'
17
17
  require 'set'
18
18
  require 'logger'
19
19
  require 'contracts'
@@ -129,7 +129,7 @@ module SnowplowTracker
129
129
  elsif @method == 'post'
130
130
  if temp_buffer.size > 0
131
131
  request = http_post({
132
- 'schema' => 'iglu:com.snowplowanalytics.snowplow/payload_data/1-0-0',
132
+ 'schema' => 'iglu:com.snowplowanalytics.snowplow/payload_data/1-0-1',
133
133
  'data' => temp_buffer
134
134
  })
135
135
 
@@ -156,7 +156,12 @@ module SnowplowTracker
156
156
  destination = URI(@collector_uri + '?' + URI.encode_www_form(payload))
157
157
  LOGGER.info("Sending GET request to #{@collector_uri}...")
158
158
  LOGGER.debug("Payload: #{payload}")
159
- response = Net::HTTP.get_response(destination)
159
+ http = Net::HTTP.new(destination.host, destination.port)
160
+ request = Net::HTTP::Get.new(destination.request_uri)
161
+ if destination.scheme == 'https'
162
+ http.use_ssl = true
163
+ end
164
+ response = http.request(request)
160
165
  LOGGER.add(response.code == '200' ? Logger::INFO : Logger::WARN) {
161
166
  "GET request to #{@collector_uri} finished with status code #{response.code}"
162
167
  }
@@ -173,6 +178,10 @@ module SnowplowTracker
173
178
  destination = URI(@collector_uri)
174
179
  http = Net::HTTP.new(destination.host, destination.port)
175
180
  request = Net::HTTP::Post.new(destination)
181
+ request = Net::HTTP::Post.new(destination.request_uri)
182
+ if destination.scheme == 'https'
183
+ http.use_ssl = true
184
+ end
176
185
  request.form_data = payload
177
186
  request.set_content_type('application/json; charset=utf-8')
178
187
  response = http.request(request)
@@ -92,6 +92,39 @@ module SnowplowTracker
92
92
  self
93
93
  end
94
94
 
95
+ # Set the domain user ID
96
+ #
97
+ Contract String => Subject
98
+ def set_domain_user_id(duid)
99
+ @standard_nv_pairs['duid'] = duid
100
+ self
101
+ end
102
+
103
+ # Set the IP address field
104
+ #
105
+ Contract String => Subject
106
+ def set_ip_address(ip)
107
+ @standard_nv_pairs['ip'] = ip
108
+ self
109
+ end
110
+
111
+ # Set the user agent
112
+ #
113
+ Contract String => Subject
114
+ def set_useragent(ua)
115
+ @standard_nv_pairs['ua'] = ua
116
+ self
117
+ end
118
+
119
+ # Set the network user ID field
120
+ # This overwrites the nuid field set by the collector
121
+ #
122
+ Contract String => Subject
123
+ def set_network_user_id(nuid)
124
+ @standard_nv_pairs['tnuid'] = nuid
125
+ self
126
+ end
127
+
95
128
  end
96
129
 
97
130
  end
@@ -14,6 +14,6 @@
14
14
  # License:: Apache License Version 2.0
15
15
 
16
16
  module SnowplowTracker
17
- VERSION = '0.3.0'
17
+ VERSION = '0.4.0'
18
18
  TRACKER_VERSION = "rb-#{VERSION}"
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snowplow-tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Dean
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-29 00:00:00.000000000 Z
12
+ date: 2014-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: contracts