scoutmetrics 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/scoutmetrics/configuration.rb +24 -0
- data/lib/scoutmetrics/engagement.rb +35 -0
- data/lib/scoutmetrics/request.rb +21 -0
- data/lib/scoutmetrics/user.rb +58 -0
- data/lib/scoutmetrics.rb +26 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a42ad2a0f6b525d3949ea17bd03293dcb77c6210
|
4
|
+
data.tar.gz: a1d774b69f5805ca072fac499aae783a2ecb8b9d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa5cc6dc3350ffcfa32d240e91bc301f218882c1eee33c954264f5151084e13a3aaa68e6f6080db4fabf5c9aeaa266014e3d33489f0f7a414ca5619e47b76a23
|
7
|
+
data.tar.gz: ba3314bd668fb12b4b19a1391c8eb0a307cf282af2f1555cd7fb5879b8c42c6c4b423ea780b4ed964d52ae8393610f500364120089e4ca756996a5bdeb60f560
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ScoutMetrics
|
2
|
+
|
3
|
+
module Configuration
|
4
|
+
|
5
|
+
VALID_OPTIONS_KEYS = [
|
6
|
+
:access_token
|
7
|
+
].freeze
|
8
|
+
|
9
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
10
|
+
|
11
|
+
# Create a hash of options and their values
|
12
|
+
def options
|
13
|
+
VALID_OPTIONS_KEYS.inject({}) do |option, key|
|
14
|
+
option.merge!(key => send(key))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def configure
|
19
|
+
yield self
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ScoutMetrics
|
2
|
+
|
3
|
+
class Engagement
|
4
|
+
|
5
|
+
# Adds an "Engagement" to Scout Metrics
|
6
|
+
# For example "Liked us on Facebook"
|
7
|
+
#
|
8
|
+
# @param engagement_params [Hash] Name of the engagement
|
9
|
+
# @engagement_params name [String] Describes the engagement
|
10
|
+
# @return [Json] Returns a msg for the transaction and the status of the request
|
11
|
+
# @return msg explanation of outcome
|
12
|
+
def self.create_category(name)
|
13
|
+
ScoutMetrics::Request.new(:post, '/engagements', { engagement: { name: name } })
|
14
|
+
end
|
15
|
+
|
16
|
+
# Add/Update an "EngagementInstance" on Scout Metrics
|
17
|
+
# This tells Scout Metrics that a user performed an "Engagement" on a given date
|
18
|
+
# For example: Someone "Liked us on Facebook" on Dec 12th
|
19
|
+
# (We do not track who performed the action)
|
20
|
+
#
|
21
|
+
# @param name [String] Describes the engagement
|
22
|
+
# @param date_recorded [Date] Day the engagement happened, defaults to now
|
23
|
+
#
|
24
|
+
# @return [Json] Returns a msg for the transaction and the status of the request
|
25
|
+
# @return msg explanation of outcome
|
26
|
+
def self.create(name, date_recorded=nil)
|
27
|
+
date_recorded ||= Time.new
|
28
|
+
params = { engagement: { name: name },
|
29
|
+
engagement_instance: { date_recorded: date_recorded } }
|
30
|
+
ScoutMetrics::Request.new(:post, '/engagements/add_instance', params)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'http'
|
2
|
+
|
3
|
+
module ScoutMetrics
|
4
|
+
|
5
|
+
class Request
|
6
|
+
|
7
|
+
DOMAIN = 'https://scoutmetrics.herokuapp.com/api/v1'
|
8
|
+
|
9
|
+
def initialize(method, route, params)
|
10
|
+
params[:token] = ScoutMetrics.access_token
|
11
|
+
route = "#{DOMAIN}#{route}"
|
12
|
+
puts "METHOD: #{method}"
|
13
|
+
puts "ROUTE: #{route}"
|
14
|
+
puts 'PARAMS'
|
15
|
+
puts params
|
16
|
+
response = HTTP.send(method, route, json: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module ScoutMetrics
|
2
|
+
|
3
|
+
class User
|
4
|
+
|
5
|
+
# Adds an "AppUser" to Scout Metrics
|
6
|
+
#
|
7
|
+
# @param id [Integer] Uniquely identifies user
|
8
|
+
# @param signup_date [DateTime] Date the user signed up, defaults to now
|
9
|
+
#
|
10
|
+
# @return [Json] Returns a msg for the transaction and the status of the request
|
11
|
+
# @return msg explanation of outcome
|
12
|
+
def self.create(id, signup_date=nil)
|
13
|
+
signup_date ||= Time.new
|
14
|
+
post_update(id, { signup_date: signup_date })
|
15
|
+
end
|
16
|
+
|
17
|
+
# Update an "AppUser" on Scout Metrics
|
18
|
+
#
|
19
|
+
# @param id [Integer] Uniquely identifies user
|
20
|
+
# @param return_date [DateTime] Latest time returning to your site, defaults to now
|
21
|
+
#
|
22
|
+
# @return [Json] Returns a msg for the transaction and the status of the request
|
23
|
+
# @return msg explanation of outcome
|
24
|
+
def self.update(id, return_date=nil)
|
25
|
+
return_date ||= Time.new
|
26
|
+
post_update(id, { return_date: return_date })
|
27
|
+
end
|
28
|
+
|
29
|
+
# Activate an "AppUser" on Scout Metrics
|
30
|
+
# (Should we also reset their signup_date & return_date?)
|
31
|
+
#
|
32
|
+
# @param id [Integer] Uniquely identifies user
|
33
|
+
#
|
34
|
+
# @return [Json] Returns a msg for the transaction and the status of the request
|
35
|
+
# @return msg explanation of outcome
|
36
|
+
def self.activate(id)
|
37
|
+
post_update(id, { active: true })
|
38
|
+
end
|
39
|
+
|
40
|
+
# Deactivate an "AppUser" on Scout Metrics
|
41
|
+
#
|
42
|
+
# @param id [Integer] Uniquely identifies user
|
43
|
+
#
|
44
|
+
# @return [Json] Returns a msg for the transaction and the status of the request
|
45
|
+
# @return msg explanation of outcome
|
46
|
+
def self.deactivate(id)
|
47
|
+
post_update(id, { active: false })
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def self.post_update(id, params)
|
53
|
+
ScoutMetrics::Request.new(:put, "/app_users/#{id}", { app_user: params })
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/lib/scoutmetrics.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'scoutmetrics/configuration'
|
2
|
+
require 'scoutmetrics/engagement'
|
3
|
+
require 'scoutmetrics/request'
|
4
|
+
require 'scoutmetrics/user'
|
5
|
+
|
6
|
+
module ScoutMetrics
|
7
|
+
extend Configuration
|
8
|
+
|
9
|
+
end
|
10
|
+
# Configure in your initializer as such
|
11
|
+
#
|
12
|
+
# ScoutMetrics.configure do |config|
|
13
|
+
# config.access_token = SCOUT_PROJECT_TOKEN
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# Add a new User
|
17
|
+
# ScoutMetrics::User.create({ app_id: user.id, signup_date: DateTime.current })
|
18
|
+
#
|
19
|
+
# Update an existing User
|
20
|
+
# ScoutMetrics::User.update({ app_id: user.id, return_date: DateTime.current })
|
21
|
+
#
|
22
|
+
# Add an engagement
|
23
|
+
# ScoutMetrics::Engagement.create({ name: 'Liked us on Facebook' })
|
24
|
+
#
|
25
|
+
# Report an engagement
|
26
|
+
# ScoutMetrics::Engagement.report({ name: 'Liked us on Facebook' }, DateTime.current)
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scoutmetrics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dosty Everts
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: http_parser.rb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.6.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.6.0
|
41
|
+
description: Ruby wrapper for the Scout Metrics API
|
42
|
+
email: dosty@mustwin.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/scoutmetrics.rb
|
48
|
+
- lib/scoutmetrics/configuration.rb
|
49
|
+
- lib/scoutmetrics/engagement.rb
|
50
|
+
- lib/scoutmetrics/request.rb
|
51
|
+
- lib/scoutmetrics/user.rb
|
52
|
+
homepage: https://github.com/MustWin/scoutmetrics-ruby-gem
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.2.2
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Ruby wrapper for the Scout Metrics API
|
76
|
+
test_files: []
|