vero 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +15 -1
- data/Gemfile.lock +95 -73
- data/README.markdown +145 -121
- data/lib/generators/vero_generator.rb +18 -19
- data/lib/vero.rb +7 -3
- data/lib/vero/api.rb +14 -4
- data/lib/vero/api/base_api.rb +11 -10
- data/lib/vero/api/events/track_api.rb +5 -3
- data/lib/vero/api/users/delete_api.rb +21 -0
- data/lib/vero/api/users/edit_api.rb +5 -3
- data/lib/vero/api/users/edit_tags_api.rb +7 -5
- data/lib/vero/api/users/reidentify_api.rb +5 -3
- data/lib/vero/api/users/resubscribe_api.rb +3 -1
- data/lib/vero/api/users/track_api.rb +5 -3
- data/lib/vero/api/users/unsubscribe_api.rb +3 -1
- data/lib/vero/app.rb +4 -2
- data/lib/vero/config.rb +11 -8
- data/lib/vero/context.rb +9 -11
- data/lib/vero/context/api.rb +9 -7
- data/lib/vero/dsl.rb +3 -1
- data/lib/vero/railtie.rb +5 -3
- data/lib/vero/sender.rb +12 -31
- data/lib/vero/senders/base.rb +3 -1
- data/lib/vero/senders/delayed_job.rb +7 -7
- data/lib/vero/senders/invalid.rb +5 -3
- data/lib/vero/senders/resque.rb +8 -8
- data/lib/vero/senders/sidekiq.rb +3 -1
- data/lib/vero/senders/{thread.rb → sucker_punch.rb} +5 -3
- data/lib/vero/trackable.rb +4 -2
- data/lib/vero/trackable/base.rb +10 -9
- data/lib/vero/trackable/interface.rb +3 -1
- data/lib/vero/utility/ext.rb +3 -1
- data/lib/vero/utility/logger.rb +4 -6
- data/lib/vero/version.rb +3 -1
- data/lib/vero/view_helpers/javascript.rb +20 -20
- data/spec/lib/api/base_api_spec.rb +10 -8
- data/spec/lib/api/events/track_api_spec.rb +23 -21
- data/spec/lib/api/users/delete_api_spec.rb +33 -0
- data/spec/lib/api/users/edit_api_spec.rb +12 -10
- data/spec/lib/api/users/edit_tags_api_spec.rb +22 -20
- data/spec/lib/api/users/reidentify_spec.rb +16 -14
- data/spec/lib/api/users/resubscribe_api_spec.rb +16 -10
- data/spec/lib/api/users/track_api_spec.rb +21 -19
- data/spec/lib/api/users/unsubscribe_api_spec.rb +12 -10
- data/spec/lib/api_spec.rb +29 -24
- data/spec/lib/app_spec.rb +12 -10
- data/spec/lib/config_spec.rb +31 -29
- data/spec/lib/context_spec.rb +13 -11
- data/spec/lib/dsl_spec.rb +3 -1
- data/spec/lib/sender_spec.rb +12 -24
- data/spec/lib/senders/sidekiq_spec.rb +16 -9
- data/spec/lib/trackable_spec.rb +88 -114
- data/spec/lib/view_helpers_spec.rb +12 -8
- data/spec/spec_helper.rb +10 -4
- data/spec/support/base_config_shared_examples.rb +5 -3
- data/spec/support/user_support.rb +15 -7
- data/spec/support/vero_user_support.rb +4 -2
- data/vero.gemspec +14 -30
- metadata +30 -125
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613bdd22722909307a31f9216cadf88cdbab3ef8
|
4
|
+
data.tar.gz: 75cf2287ad113db6da85c725ad2e60e4241198bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2096897426a341a5eb32081d8a3590341befb1b4d02d9c46898b7945568fe7e0bf47bcacb634c3f4068e4fd4ac2ed06aae2776696a3bc33532e0483a0d7678c
|
7
|
+
data.tar.gz: 8c0edb41c39c2ef8a475ffdec1b05012b147f5ad415eb9887b8b8d338a74b2f0bae3edc4e894b2782e80f4ef84a22e19d0b4918809ca48104d55bdc180daca04
|
data/Gemfile
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'http://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem 'delayed_job', '~> 3.0.0'
|
9
|
+
gem 'delayed_job_active_record'
|
10
|
+
gem 'rails', '~> 3.0'
|
11
|
+
gem 'resque'
|
12
|
+
gem 'sidekiq', '~> 3.5.1'
|
13
|
+
gem 'sucker_punch', '~> 1.6.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
gem 'rspec', group: :test
|
17
|
+
gem 'rubocop', group: :development
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vero (0.
|
4
|
+
vero (0.10.0)
|
5
5
|
json
|
6
6
|
rest-client
|
7
|
-
sucker_punch (~> 1.6.0)
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: http://rubygems.org/
|
11
10
|
specs:
|
12
|
-
actionmailer (3.2.22)
|
13
|
-
actionpack (= 3.2.22)
|
11
|
+
actionmailer (3.2.22.5)
|
12
|
+
actionpack (= 3.2.22.5)
|
14
13
|
mail (~> 2.5.4)
|
15
|
-
actionpack (3.2.22)
|
16
|
-
activemodel (= 3.2.22)
|
17
|
-
activesupport (= 3.2.22)
|
14
|
+
actionpack (3.2.22.5)
|
15
|
+
activemodel (= 3.2.22.5)
|
16
|
+
activesupport (= 3.2.22.5)
|
18
17
|
builder (~> 3.0.0)
|
19
18
|
erubis (~> 2.7.0)
|
20
19
|
journey (~> 1.0.4)
|
@@ -22,23 +21,24 @@ GEM
|
|
22
21
|
rack-cache (~> 1.2)
|
23
22
|
rack-test (~> 0.6.1)
|
24
23
|
sprockets (~> 2.2.1)
|
25
|
-
activemodel (3.2.22)
|
26
|
-
activesupport (= 3.2.22)
|
24
|
+
activemodel (3.2.22.5)
|
25
|
+
activesupport (= 3.2.22.5)
|
27
26
|
builder (~> 3.0.0)
|
28
|
-
activerecord (3.2.22)
|
29
|
-
activemodel (= 3.2.22)
|
30
|
-
activesupport (= 3.2.22)
|
27
|
+
activerecord (3.2.22.5)
|
28
|
+
activemodel (= 3.2.22.5)
|
29
|
+
activesupport (= 3.2.22.5)
|
31
30
|
arel (~> 3.0.2)
|
32
31
|
tzinfo (~> 0.3.29)
|
33
|
-
activeresource (3.2.22)
|
34
|
-
activemodel (= 3.2.22)
|
35
|
-
activesupport (= 3.2.22)
|
36
|
-
activesupport (3.2.22)
|
32
|
+
activeresource (3.2.22.5)
|
33
|
+
activemodel (= 3.2.22.5)
|
34
|
+
activesupport (= 3.2.22.5)
|
35
|
+
activesupport (3.2.22.5)
|
37
36
|
i18n (~> 0.6, >= 0.6.4)
|
38
37
|
multi_json (~> 1.0)
|
39
38
|
arel (3.0.3)
|
39
|
+
ast (2.4.1)
|
40
40
|
builder (3.0.4)
|
41
|
-
celluloid (0.17.
|
41
|
+
celluloid (0.17.4)
|
42
42
|
celluloid-essentials
|
43
43
|
celluloid-extras
|
44
44
|
celluloid-fsm
|
@@ -53,89 +53,108 @@ GEM
|
|
53
53
|
timers (>= 4.1.1)
|
54
54
|
celluloid-pool (0.20.5)
|
55
55
|
timers (>= 4.1.1)
|
56
|
-
celluloid-supervision (0.20.
|
56
|
+
celluloid-supervision (0.20.6)
|
57
57
|
timers (>= 4.1.1)
|
58
|
-
|
58
|
+
concurrent-ruby (1.1.7)
|
59
|
+
connection_pool (2.2.3)
|
59
60
|
delayed_job (3.0.5)
|
60
61
|
activesupport (~> 3.0)
|
61
|
-
delayed_job_active_record (4.
|
62
|
-
activerecord (>= 3.0, <
|
63
|
-
delayed_job (>= 3.0, <
|
64
|
-
diff-lcs (1.
|
65
|
-
domain_name (0.5.
|
62
|
+
delayed_job_active_record (4.1.4)
|
63
|
+
activerecord (>= 3.0, < 6.1)
|
64
|
+
delayed_job (>= 3.0, < 5)
|
65
|
+
diff-lcs (1.4.4)
|
66
|
+
domain_name (0.5.20190701)
|
66
67
|
unf (>= 0.0.5, < 1.0.0)
|
67
68
|
erubis (2.7.0)
|
68
69
|
hike (1.2.3)
|
69
|
-
|
70
|
-
|
71
|
-
http-cookie (1.0.2)
|
70
|
+
http-accept (1.7.0)
|
71
|
+
http-cookie (1.0.3)
|
72
72
|
domain_name (~> 0.5)
|
73
|
-
i18n (0.
|
73
|
+
i18n (0.9.5)
|
74
|
+
concurrent-ruby (~> 1.0)
|
74
75
|
journey (1.0.4)
|
75
|
-
json (1.8.
|
76
|
-
|
77
|
-
mail (2.5.4)
|
76
|
+
json (1.8.6)
|
77
|
+
mail (2.5.5)
|
78
78
|
mime-types (~> 1.16)
|
79
79
|
treetop (~> 1.4.8)
|
80
80
|
mime-types (1.25.1)
|
81
81
|
mono_logger (1.1.0)
|
82
|
-
multi_json (1.
|
83
|
-
netrc (0.
|
82
|
+
multi_json (1.15.0)
|
83
|
+
netrc (0.11.0)
|
84
|
+
parallel (1.19.2)
|
85
|
+
parser (2.7.1.4)
|
86
|
+
ast (~> 2.4.1)
|
84
87
|
polyglot (0.3.5)
|
85
88
|
rack (1.4.7)
|
86
|
-
rack-cache (1.
|
89
|
+
rack-cache (1.12.0)
|
87
90
|
rack (>= 0.4)
|
88
|
-
rack-protection (1.5.
|
91
|
+
rack-protection (1.5.5)
|
89
92
|
rack
|
90
93
|
rack-ssl (1.3.4)
|
91
94
|
rack
|
92
95
|
rack-test (0.6.3)
|
93
96
|
rack (>= 1.0)
|
94
|
-
rails (3.2.22)
|
95
|
-
actionmailer (= 3.2.22)
|
96
|
-
actionpack (= 3.2.22)
|
97
|
-
activerecord (= 3.2.22)
|
98
|
-
activeresource (= 3.2.22)
|
99
|
-
activesupport (= 3.2.22)
|
97
|
+
rails (3.2.22.5)
|
98
|
+
actionmailer (= 3.2.22.5)
|
99
|
+
actionpack (= 3.2.22.5)
|
100
|
+
activerecord (= 3.2.22.5)
|
101
|
+
activeresource (= 3.2.22.5)
|
102
|
+
activesupport (= 3.2.22.5)
|
100
103
|
bundler (~> 1.0)
|
101
|
-
railties (= 3.2.22)
|
102
|
-
railties (3.2.22)
|
103
|
-
actionpack (= 3.2.22)
|
104
|
-
activesupport (= 3.2.22)
|
104
|
+
railties (= 3.2.22.5)
|
105
|
+
railties (3.2.22.5)
|
106
|
+
actionpack (= 3.2.22.5)
|
107
|
+
activesupport (= 3.2.22.5)
|
105
108
|
rack-ssl (~> 1.3.2)
|
106
109
|
rake (>= 0.8.7)
|
107
110
|
rdoc (~> 3.4)
|
108
111
|
thor (>= 0.14.6, < 2.0)
|
109
|
-
|
112
|
+
rainbow (3.0.0)
|
113
|
+
rake (13.0.1)
|
110
114
|
rdoc (3.12.2)
|
111
115
|
json (~> 1.4)
|
112
|
-
redis (3.
|
113
|
-
redis-namespace (1.
|
114
|
-
redis (
|
115
|
-
|
116
|
+
redis (3.3.5)
|
117
|
+
redis-namespace (1.8.0)
|
118
|
+
redis (>= 3.0.4)
|
119
|
+
regexp_parser (1.7.1)
|
120
|
+
resque (2.0.0)
|
116
121
|
mono_logger (~> 1.0)
|
117
122
|
multi_json (~> 1.0)
|
118
|
-
redis-namespace (~> 1.
|
123
|
+
redis-namespace (~> 1.6)
|
119
124
|
sinatra (>= 0.9.2)
|
120
125
|
vegas (~> 0.1.2)
|
121
|
-
rest-client (1.
|
126
|
+
rest-client (2.1.0)
|
127
|
+
http-accept (>= 1.7.0, < 2.0)
|
122
128
|
http-cookie (>= 1.0.2, < 2.0)
|
123
|
-
mime-types (>= 1.16, <
|
124
|
-
netrc (~> 0.
|
125
|
-
|
126
|
-
|
127
|
-
rspec-
|
128
|
-
rspec-
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
mime-types (>= 1.16, < 4.0)
|
130
|
+
netrc (~> 0.8)
|
131
|
+
rexml (3.2.4)
|
132
|
+
rspec (3.9.0)
|
133
|
+
rspec-core (~> 3.9.0)
|
134
|
+
rspec-expectations (~> 3.9.0)
|
135
|
+
rspec-mocks (~> 3.9.0)
|
136
|
+
rspec-core (3.9.2)
|
137
|
+
rspec-support (~> 3.9.3)
|
138
|
+
rspec-expectations (3.9.2)
|
132
139
|
diff-lcs (>= 1.2.0, < 2.0)
|
133
|
-
rspec-support (~> 3.
|
134
|
-
rspec-mocks (3.
|
140
|
+
rspec-support (~> 3.9.0)
|
141
|
+
rspec-mocks (3.9.1)
|
135
142
|
diff-lcs (>= 1.2.0, < 2.0)
|
136
|
-
rspec-support (~> 3.
|
137
|
-
rspec-support (3.3
|
138
|
-
|
143
|
+
rspec-support (~> 3.9.0)
|
144
|
+
rspec-support (3.9.3)
|
145
|
+
rubocop (0.91.0)
|
146
|
+
parallel (~> 1.10)
|
147
|
+
parser (>= 2.7.1.1)
|
148
|
+
rainbow (>= 2.2.2, < 4.0)
|
149
|
+
regexp_parser (>= 1.7)
|
150
|
+
rexml
|
151
|
+
rubocop-ast (>= 0.4.0, < 1.0)
|
152
|
+
ruby-progressbar (~> 1.7)
|
153
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
154
|
+
rubocop-ast (0.4.1)
|
155
|
+
parser (>= 2.7.1.4)
|
156
|
+
ruby-progressbar (1.10.1)
|
157
|
+
sidekiq (3.5.4)
|
139
158
|
celluloid (~> 0.17.2)
|
140
159
|
connection_pool (~> 2.2, >= 2.2.0)
|
141
160
|
json (~> 1.0)
|
@@ -152,23 +171,21 @@ GEM
|
|
152
171
|
tilt (~> 1.1, != 1.3.0)
|
153
172
|
sucker_punch (1.6.0)
|
154
173
|
celluloid (~> 0.17.2)
|
155
|
-
thor (0.
|
174
|
+
thor (1.0.1)
|
156
175
|
tilt (1.4.1)
|
157
|
-
timers (4.
|
158
|
-
hitimes
|
176
|
+
timers (4.3.2)
|
159
177
|
treetop (1.4.15)
|
160
178
|
polyglot
|
161
179
|
polyglot (>= 0.3.1)
|
162
|
-
tzinfo (0.3.
|
180
|
+
tzinfo (0.3.57)
|
163
181
|
unf (0.1.4)
|
164
182
|
unf_ext
|
165
|
-
|
166
|
-
|
183
|
+
unf_ext (0.0.7.7)
|
184
|
+
unicode-display_width (1.7.0)
|
167
185
|
vegas (0.1.11)
|
168
186
|
rack (>= 1.0.0)
|
169
187
|
|
170
188
|
PLATFORMS
|
171
|
-
java
|
172
189
|
ruby
|
173
190
|
|
174
191
|
DEPENDENCIES
|
@@ -177,5 +194,10 @@ DEPENDENCIES
|
|
177
194
|
rails (~> 3.0)
|
178
195
|
resque
|
179
196
|
rspec
|
197
|
+
rubocop
|
180
198
|
sidekiq (~> 3.5.1)
|
199
|
+
sucker_punch (~> 1.6.0)
|
181
200
|
vero!
|
201
|
+
|
202
|
+
BUNDLED WITH
|
203
|
+
1.17.3
|
data/README.markdown
CHANGED
@@ -12,38 +12,47 @@ For more information about the platform, [click here](http://getvero.com).
|
|
12
12
|
|
13
13
|
Include in your Gemfile:
|
14
14
|
|
15
|
-
|
15
|
+
```
|
16
|
+
gem 'vero'
|
17
|
+
```
|
16
18
|
|
17
19
|
Or install the gem:
|
18
20
|
|
19
|
-
|
21
|
+
```
|
22
|
+
gem install vero
|
23
|
+
```
|
20
24
|
|
21
25
|
Create an initializer in your config/initializers folder called vero.rb with the
|
22
26
|
following:
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
```ruby
|
29
|
+
# config/initializers/vero.rb
|
30
|
+
Vero::App.init do |config|
|
31
|
+
if Rails.env.production?
|
32
|
+
config.api_key = "Your Production API key goes here"
|
33
|
+
config.secret = "Your Production API secret goes here"
|
34
|
+
else
|
35
|
+
config.api_key = "Your Development API key goes here"
|
36
|
+
config.secret = "Your Development API secret goes here"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
```
|
34
40
|
|
35
41
|
You will be able to find your API key and secret by logging into Vero
|
36
42
|
([sign up](http://getvero.com) if you haven't already) and clicking the
|
37
43
|
'Your Account' link at the top of the page then select 'API Keys'.
|
38
44
|
|
39
|
-
By default, events are sent
|
40
|
-
We recommend that you select one of the supported queue-based alternatives
|
45
|
+
By default, events are sent synchronously.
|
46
|
+
We recommend that you select one of the supported background thread/queue-based alternatives and add their
|
47
|
+
respective gem to your Gemfile:
|
41
48
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
```ruby
|
50
|
+
config.async = :none # Synchronously
|
51
|
+
config.async = :sucker_punch # SuckerPunch
|
52
|
+
config.async = :delayed_job # DelayedJob
|
53
|
+
config.async = :sidekiq # Sidekiq
|
54
|
+
config.async = :resque # Resque (recommended)
|
55
|
+
```
|
47
56
|
|
48
57
|
**Note:** If you're using Mongoid with DelayedJob, you must add
|
49
58
|
`gem "delayed_job_mongoid"` to your Gemfile.
|
@@ -51,7 +60,9 @@ We recommend that you select one of the supported queue-based alternatives:
|
|
51
60
|
Finally, if you wish to disable Vero requests when running your automated tests,
|
52
61
|
add the following line to your initializer:
|
53
62
|
|
54
|
-
|
63
|
+
```ruby
|
64
|
+
config.disabled = Rails.env.test?
|
65
|
+
```
|
55
66
|
|
56
67
|
If you have any additional questions, please contact support@getvero.com.
|
57
68
|
|
@@ -60,13 +71,15 @@ If you have any additional questions, please contact support@getvero.com.
|
|
60
71
|
You will need to define who should be tracked and what information about them
|
61
72
|
you would like sent to Vero. In this example we'll track users:
|
62
73
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
74
|
+
```ruby
|
75
|
+
# app/models/user.rb
|
76
|
+
class User < ActiveRecord::Base
|
77
|
+
include Vero::Trackable
|
78
|
+
trackable :id, :email, :name
|
67
79
|
|
68
|
-
|
69
|
-
|
80
|
+
# ...
|
81
|
+
end
|
82
|
+
```
|
70
83
|
|
71
84
|
As you can see we're saying that a User is trackable and that we'd like to pass
|
72
85
|
up their user id, email address, and name.
|
@@ -74,17 +87,19 @@ up their user id, email address, and name.
|
|
74
87
|
Each symbol passed to trackable should reference either an instance method or
|
75
88
|
field. Therefore it's perfectly legal to do something like:
|
76
89
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
90
|
+
```ruby
|
91
|
+
# app/models/user.rb
|
92
|
+
class User < ActiveRecord::Base
|
93
|
+
include Vero::Trackable
|
94
|
+
trackable :id, :email, :contest_count
|
81
95
|
|
82
|
-
|
96
|
+
has_many :contests
|
83
97
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
98
|
+
def contest_count
|
99
|
+
self.contests.count
|
100
|
+
end
|
101
|
+
end
|
102
|
+
```
|
88
103
|
|
89
104
|
There is one caveat: you must pass an "id" to the API in order to perform
|
90
105
|
requests. In many cases the user "id" will simply be their email address. The
|
@@ -94,31 +109,35 @@ the "id".
|
|
94
109
|
If the user's email address is stored under a different field, you can do the
|
95
110
|
following:
|
96
111
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
112
|
+
```ruby
|
113
|
+
# app/models/user.rb
|
114
|
+
class User < ActiveRecord::Base
|
115
|
+
include Vero::Trackable
|
116
|
+
trackable :id, :email
|
101
117
|
|
102
|
-
|
103
|
-
|
118
|
+
def email; self.primary_contact; end
|
119
|
+
end
|
120
|
+
```
|
104
121
|
|
105
122
|
Finally, you can track multiple properties stored in a Hash by doing the
|
106
123
|
following:
|
107
124
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
125
|
+
```ruby
|
126
|
+
# app/models/user.rb
|
127
|
+
class User < ActiveRecord::Base
|
128
|
+
include Vero::Trackable
|
129
|
+
trackable :id, :email, {:extras => :properties}
|
112
130
|
|
113
|
-
|
131
|
+
def email; self.primary_contact; end
|
114
132
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
133
|
+
def properties
|
134
|
+
{
|
135
|
+
:first_name => "James",
|
136
|
+
:last_name => "Lamont"
|
137
|
+
}
|
138
|
+
end
|
139
|
+
end
|
140
|
+
```
|
122
141
|
|
123
142
|
**Note:** You may choose to bypass extending the `User` model by calling the
|
124
143
|
API via [simple DSL](https://github.com/getvero/vero#simple-dsl) found below.
|
@@ -129,51 +148,54 @@ Events can be sent by any model which has been previously marked as trackable.
|
|
129
148
|
|
130
149
|
To send an event:
|
131
150
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
151
|
+
```ruby
|
152
|
+
# app/controllers/contests_controller.rb
|
153
|
+
class ContestsController < ActionController::Base
|
154
|
+
before_filter :authenticate_user!
|
155
|
+
# ...
|
137
156
|
|
138
|
-
|
139
|
-
|
157
|
+
def create
|
158
|
+
@contest = current_user.contests.build(params[:contest])
|
140
159
|
|
141
|
-
|
142
|
-
|
143
|
-
|
160
|
+
if @contest.save
|
161
|
+
# Tell Vero that a new contest has been created
|
162
|
+
current_user.track!('new_contest_created')
|
144
163
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
end
|
151
|
-
end
|
164
|
+
flash[:notice] = "New contest saved successfully!"
|
165
|
+
redirect_to contests_path
|
166
|
+
else
|
167
|
+
flash[:alert] = "Unable to create your contest. Please review your details and try again."
|
168
|
+
render 'new'
|
152
169
|
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
```
|
153
173
|
|
154
174
|
You may want to send additional data about an event:
|
155
175
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
176
|
+
```ruby
|
177
|
+
# app/controllers/contests_controller.rb
|
178
|
+
class ContestsController < ActionController::Base
|
179
|
+
before_filter :authenticate_user!
|
180
|
+
# ...
|
160
181
|
|
161
182
|
|
162
|
-
|
163
|
-
|
183
|
+
def create
|
184
|
+
@contest = current_user.contests.build(params[:contest])
|
164
185
|
|
165
|
-
|
166
|
-
|
167
|
-
|
186
|
+
if @contest.save
|
187
|
+
# Tell Vero that a new contest has been created, and the id and name
|
188
|
+
current_user.track!('new_contest_created', {:id => @contest.id, :name => @content.name})
|
168
189
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
end
|
175
|
-
end
|
190
|
+
flash[:notice] = "New contest saved successfully!"
|
191
|
+
redirect_to contests_path
|
192
|
+
else
|
193
|
+
flash[:alert] = "Unable to create your contest. Please review your details and try again."
|
194
|
+
render 'new'
|
176
195
|
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
```
|
177
199
|
|
178
200
|
## Simple DSL
|
179
201
|
|
@@ -183,41 +205,43 @@ using a simple DSL (thanks @jherdman) as you would from the Javascript library.
|
|
183
205
|
First, ensure you've correctly configured the gem following the instructions as
|
184
206
|
outlined in Installation. Now you can call the API using the following methods:
|
185
207
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
208
|
+
```ruby
|
209
|
+
class UsersController < ApplicationController
|
210
|
+
include Vero::DSL
|
211
|
+
|
212
|
+
def perform_action
|
213
|
+
# Tracking an event
|
214
|
+
vero.events.track!({
|
215
|
+
:event_name => "test_event",
|
216
|
+
:data => {:date => "2013-02-12 16:17"},
|
217
|
+
:identity => {:id => 123, :email => "james@getvero.com"}
|
218
|
+
})
|
219
|
+
end
|
220
|
+
|
221
|
+
def create
|
222
|
+
# Identifying a user
|
223
|
+
vero.users.track!({:id => 123, :data => {}})
|
224
|
+
end
|
225
|
+
|
226
|
+
def update
|
227
|
+
# Editing a user
|
228
|
+
vero.users.edit_user!({:id => 123, :changes => {:age => 25}})
|
229
|
+
|
230
|
+
# Editing a user's tags
|
231
|
+
vero.users.edit_user_tags!({:id => 123, :add => ["awesome"], :remove => []})
|
232
|
+
|
233
|
+
# Changing a user's id
|
234
|
+
vero.users.reidentify!({:id => 123, :new_id => "honeybadger@getvero.com"})
|
235
|
+
|
236
|
+
# Resubscribing a user
|
237
|
+
vero.users.resubscribe!({:id => 123})
|
238
|
+
end
|
239
|
+
|
240
|
+
def destroy
|
241
|
+
vero.users.unsubscribe!({:id => 123})
|
242
|
+
end
|
243
|
+
end
|
244
|
+
```
|
221
245
|
|
222
246
|
## License Information
|
223
247
|
|