analytics-psw 0.0.7 → 0.0.8
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 +4 -4
- data/lib/analytics-psw.rb +12 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b96d9df2712e7cd5ba797003a3f7ba9d3b342a38
|
4
|
+
data.tar.gz: 5d8da422b4a741bdea2d5a2b87243e8f43b042f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5572db12ed7c0a66ef4300248ed952b76ee7d41e39e9d3c95b9d8d46122616488a96e7e8b8f6e1ec39bf2f9e10f46895f818c524c79ea17b3df05ce8d9b020ea
|
7
|
+
data.tar.gz: 938caa77cd889cf754069545d1be68da4e17a11afcc7755d01021fcc791fc7e9684fbd95625b9956a2e99a98bb28da7ceab9ae84d9e6f8fa77dc638169d02163
|
data/lib/analytics-psw.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
|
4
4
|
class AnalyticsPSW
|
5
5
|
|
6
|
-
VERSION = "0.0.
|
6
|
+
VERSION = "0.0.8"
|
7
7
|
API_VERSION = "v#{VERSION}"
|
8
8
|
API_URL = "/api/#{API_VERSION}/services"
|
9
9
|
JSON_CONTENT_TYPE = 'application/json'
|
@@ -11,14 +11,9 @@ class AnalyticsPSW
|
|
11
11
|
attr_accessor :service_location
|
12
12
|
|
13
13
|
def initialize(opts = {})
|
14
|
-
|
15
|
-
service_name = opts['service']
|
16
|
-
raise "Please ensure you have provided the appropriate server url and service name" unless @server_url && service_name
|
17
|
-
@server_url = @server_url.chomp("/")
|
18
|
-
@proxy = opts['proxy']
|
19
|
-
@proxy = "" if @server_url.start_with?("http://127.0.0.1") or @server_url.start_with?("http://localhost")
|
14
|
+
set_vars_from_opts(opts)
|
20
15
|
@conn = faraday_connection
|
21
|
-
@service_location = find_or_create_service(service_name)
|
16
|
+
@service_location = find_or_create_service(@service_name)
|
22
17
|
end
|
23
18
|
|
24
19
|
def record_event(event_type, metadata = {})
|
@@ -47,6 +42,15 @@ class AnalyticsPSW
|
|
47
42
|
|
48
43
|
private
|
49
44
|
|
45
|
+
def set_vars_from_opts(opts)
|
46
|
+
@server_url = opts['server_url']
|
47
|
+
@service_name = opts['service'].strip if opts['service']
|
48
|
+
raise "Please ensure you have provided the appropriate server url and service name" unless @server_url && @service_name && @service_name != ""
|
49
|
+
@server_url = @server_url.chomp("/")
|
50
|
+
@proxy = opts['proxy']
|
51
|
+
@proxy = "" if @server_url.start_with?("http://127.0.0.1") or @server_url.start_with?("http://localhost")
|
52
|
+
end
|
53
|
+
|
50
54
|
def post_json(url, object_type, metadata)
|
51
55
|
json_object = create_json_object(object_type, metadata)
|
52
56
|
@conn.post do |req|
|