vero 0.7.0 → 0.10.0

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