scoutmetrics 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/scoutmetrics/user.rb +28 -34
- data/scoutmetrics-0.0.2.gem +0 -0
- data/scoutmetrics.gemspec +1 -1
- data/vendor/assets/javascripts/scoutmetrics.js +33 -17
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa9658c79e58bd4414e2e36b8ebdcd95fe5e53f
|
4
|
+
data.tar.gz: 594b1283e8f9a6144851a73923aede910cf49328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af8243471e972dbe00c0acb0db74034c6ad276fb501044dc45bf5d8ac4c45761bd1d2e30f47e4ff429b9c6acf5440d21f9b550253623665cc7c6a7c655cf03fb
|
7
|
+
data.tar.gz: e375fc6ac4ff994b9b40dbfc21eac658bec8cc6aa8388500ffb293266f2bc8070751c49c0c7952d55b1e3f20e269125d264f84cc48016bf919dc114e79193204
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Installation
|
|
13
13
|
gem install scoutmetrics
|
14
14
|
|
15
15
|
Or include it in your application,
|
16
|
-
gem 'scoutmetrics', '~> 0.0.
|
16
|
+
gem 'scoutmetrics', '~> 0.0.3'
|
17
17
|
|
18
18
|
Usage
|
19
19
|
------------
|
@@ -27,17 +27,17 @@ end
|
|
27
27
|
|
28
28
|
### User API (found in `/lib/scoutmetrics/user.rb`)
|
29
29
|
To tell us a user has signed up
|
30
|
-
`ScoutMetrics::User.
|
30
|
+
`ScoutMetrics::User.find(user.id).signup`
|
31
31
|
|
32
32
|
Or if you wanted to backfill signups
|
33
33
|
```ruby
|
34
34
|
User.each do |user|
|
35
|
-
ScoutMetrics::User.create(user.id, user.created_at)
|
35
|
+
ScoutMetrics::User.create(id: user.id, signup_date: user.created_at, return_date: user.latest_login, active: user.active?)
|
36
36
|
end
|
37
37
|
```
|
38
38
|
|
39
39
|
To tell us about their latest login (so we can track retention for you)
|
40
|
-
`ScoutMetrics::User.
|
40
|
+
`ScoutMetrics::User.find(user.id).report_login`
|
41
41
|
|
42
42
|
### Engagement API (found in `/lib/scoutmetrics/engagement.rb`)
|
43
43
|
Tell us that one of your users commented on a post
|
data/lib/scoutmetrics/user.rb
CHANGED
@@ -2,53 +2,47 @@ module ScoutMetrics
|
|
2
2
|
|
3
3
|
class User
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
|
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 })
|
5
|
+
attr_accesor :id, :signup_date, :return_date, :active
|
6
|
+
|
7
|
+
# Create a User record with the id passed in for posting to Scout Metrics
|
8
|
+
def self.find(id)
|
9
|
+
new(id: id)
|
15
10
|
end
|
16
11
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
12
|
+
# Override save method to post the information to Scout Metrics
|
13
|
+
def save
|
14
|
+
post_update(id, { signup_date: signup_date, return_date: return_date, active: active }))
|
15
|
+
end
|
16
|
+
|
17
|
+
# Posts signup date for this user (if it doesn't exist yet the "AppUser" will be created)
|
18
|
+
def signup(signup_date=nil)
|
19
|
+
self.signup_date = signup_date || Time.new
|
20
|
+
save
|
21
|
+
end
|
22
|
+
|
23
|
+
# Tells Scout Metrics the latest login date for this "AppUser"
|
24
|
+
def report_login(return_date=nil)
|
25
|
+
self.return_date = return_date || Time.new
|
26
|
+
save
|
27
27
|
end
|
28
28
|
|
29
29
|
# Activate an "AppUser" on Scout Metrics
|
30
30
|
# (Should we also reset their signup_date & return_date?)
|
31
|
-
|
32
|
-
|
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 })
|
31
|
+
def activate
|
32
|
+
self.active = true
|
33
|
+
save
|
38
34
|
end
|
39
35
|
|
40
36
|
# Deactivate an "AppUser" on Scout Metrics
|
41
|
-
|
42
|
-
|
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 })
|
37
|
+
def deactivate
|
38
|
+
self.active = false
|
39
|
+
save
|
48
40
|
end
|
49
41
|
|
50
42
|
private
|
51
43
|
|
44
|
+
# @return [Json] Returns a msg for the transaction and the status of the request
|
45
|
+
# @return msg explanation of outcome
|
52
46
|
def self.post_update(id, params)
|
53
47
|
ScoutMetrics::Request.new(:put, "/app_users/#{id}", { app_user: params })
|
54
48
|
end
|
Binary file
|
data/scoutmetrics.gemspec
CHANGED
@@ -2,44 +2,60 @@
|
|
2
2
|
"use strict";
|
3
3
|
|
4
4
|
var ScoutMetrics = {
|
5
|
-
accessToken: '6qPPlrlPYk5erffdy7cgig'
|
5
|
+
accessToken: '6qPPlrlPYk5erffdy7cgig',
|
6
6
|
Request: {
|
7
7
|
init: function() {
|
8
|
-
this.
|
8
|
+
this.api_domain = 'https://scoutmetrics.herokuapp.com/api/v1';
|
9
9
|
},
|
10
|
-
send: function(method, route, data) {
|
10
|
+
send: function(method, route, data, callback) {
|
11
11
|
var self = this;
|
12
|
+
var url = self.api_domain + route
|
13
|
+
|
12
14
|
data['token'] = ScoutMetrics.accessToken;
|
13
15
|
$.ajax({
|
14
|
-
url: self.
|
16
|
+
url: self.api_domain + route,
|
15
17
|
type: method,
|
16
|
-
data: data
|
18
|
+
data: data,
|
19
|
+
complete: function(response) {
|
20
|
+
callback(response, 'NOTHING');
|
21
|
+
}
|
17
22
|
});
|
18
23
|
}
|
19
24
|
},
|
20
25
|
User: {
|
21
|
-
create: function(
|
22
|
-
|
23
|
-
|
26
|
+
create: function(id, signup_date, callback) {
|
27
|
+
signup_date || (signup_date = new Date());
|
28
|
+
this.postUpdate(id, { app_user: { signup_date: signup_date } }, callback);
|
29
|
+
},
|
30
|
+
update: function(id, return_date, callback) {
|
31
|
+
return_date || (return_date = new Date());
|
32
|
+
this.postUpdate(id, { app_user: { return_date: return_date } }, callback);
|
33
|
+
},
|
34
|
+
activate: function(id, callback) {
|
35
|
+
this.postUpdate(id, { active: true }, callback);
|
24
36
|
},
|
25
|
-
|
26
|
-
|
27
|
-
|
37
|
+
deactivate: function(id, callback) {
|
38
|
+
this.postUpdate(id, { active: false }, callback);
|
39
|
+
},
|
40
|
+
postUpdate: function(id, params, callback) {
|
41
|
+
ScoutMetrics.Request.send('POST', '/app_users/' + id, params, callback);
|
28
42
|
}
|
29
43
|
},
|
30
44
|
Engagement: {
|
31
|
-
|
32
|
-
Request.send('POST', '/engagements', { engagement:
|
45
|
+
create_category: function(name, callback) {
|
46
|
+
ScoutMetrics.Request.send('POST', '/engagements', { engagement: { name: name } }, callback);
|
33
47
|
},
|
34
|
-
|
48
|
+
create: function(name, date_recorded, callback) {
|
35
49
|
date_recorded || (date_recorded = new Date());
|
36
|
-
params = { engagement:
|
37
|
-
|
38
|
-
Request.send('POST', '/engagements/add_instance', params);
|
50
|
+
var params = { engagement: { name: name },
|
51
|
+
engagement_instance: { date_recorded: date_recorded } };
|
52
|
+
ScoutMetrics.Request.send('POST', '/engagements/add_instance', params, callback);
|
39
53
|
}
|
40
54
|
}
|
41
55
|
};
|
42
56
|
|
57
|
+
ScoutMetrics.Request.init();
|
58
|
+
|
43
59
|
window.ScoutMetrics = ScoutMetrics;
|
44
60
|
|
45
61
|
})(jQuery,window,document);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoutmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dosty Everts
|
@@ -14,28 +14,28 @@ dependencies:
|
|
14
14
|
name: http
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: http_parser.rb
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.6.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.6.0
|
41
41
|
description: Ruby wrapper for the Scout Metrics API
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/scoutmetrics/engagement.rb
|
51
51
|
- lib/scoutmetrics/request.rb
|
52
52
|
- lib/scoutmetrics/user.rb
|
53
|
+
- scoutmetrics-0.0.2.gem
|
53
54
|
- scoutmetrics.gemspec
|
54
55
|
- vendor/assets/javascripts/scoutmetrics.js
|
55
56
|
homepage: https://github.com/MustWin/scoutmetrics-ruby-gem
|
@@ -62,17 +63,17 @@ require_paths:
|
|
62
63
|
- lib
|
63
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
65
|
requirements:
|
65
|
-
- -
|
66
|
+
- - '>='
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
version: '0'
|
68
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
70
|
requirements:
|
70
|
-
- -
|
71
|
+
- - '>='
|
71
72
|
- !ruby/object:Gem::Version
|
72
73
|
version: '0'
|
73
74
|
requirements: []
|
74
75
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.2.
|
76
|
+
rubygems_version: 2.2.1
|
76
77
|
signing_key:
|
77
78
|
specification_version: 4
|
78
79
|
summary: Ruby wrapper for the Scout Metrics API
|