whenauser 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,8 +3,8 @@ WhenAUser
3
3
 
4
4
  [WhenAUser.com](http://whenauser.com) is a rules engine as a service that uses events from your application to trigger calls to 3rd party SaaS APIs. This lets you eliminate business logic in your application, and use the WhenAUser web UI instead. This gem contains Rack middleware for connecting to WhenAUser. It generates two event streams, one for exceptions and the other for pageviews.
5
5
 
6
- Usage
7
- -----
6
+ Usage Example
7
+ -------------
8
8
 
9
9
  config.middleware.use 'WhenAUser::Rack',
10
10
  :token => CHANNEL_TOKEN
@@ -13,22 +13,54 @@ Usage
13
13
  config.middleware.use 'WhenAUser::Pageviews',
14
14
  :ignore_if => lambda { |env| env['action_controller.instance'].is_a? SillyController }
15
15
 
16
+ This gem will automatically send events for all exceptions and all pageviews (except those that filtered out by the options). You can also manually send additional events. For example:
17
+
18
+ WhenAUser.send_event(
19
+ :_actor => current_user.email,
20
+ :_timestamp => Time.now.to_f,
21
+ :_domain => 'account',
22
+ :_name => 'upgrade',
23
+ :plan => plan.name )
24
+
25
+ Options
26
+ -------
27
+
16
28
  WhenAUser::Rack accepts these options:
17
29
 
18
- * `token` -- the token for a WhenAUser channel
19
- * `webhook_url` -- defaults to 'http://whenauser.com/events'
30
+ * `token` -- the token for a WhenAUser channel
31
+ * `webhook_url` -- defaults to 'http://whenauser.com/events'
20
32
 
21
33
  WhenAUser::Exceptions accepts these options:
22
34
 
23
- * `ignore_exceptions` -- an array of exception class names, defaults to ['ActiveRecord::RecordNotFound', 'AbstractController::ActionNotFound', 'ActionController::RoutingError']
24
- * `ignore_crawlers` -- an array of strings to match against the user agent, includes a number of webcrawlers by default
25
- * `ignore_if` -- this proc is passed env and an exception; if it returns true, the exception is not reported to WhenAUser
26
- * `token` -- the token for a WhenAUser channel
27
- * `custom_data` -- this proc is passed env, and should return a hash to be merged into the event
35
+ * `ignore_exceptions` -- an array of exception class names, defaults to ['ActiveRecord::RecordNotFound', 'AbstractController::ActionNotFound', 'ActionController::RoutingError']
36
+ * `ignore_crawlers` -- an array of strings to match against the user agent, includes a number of webcrawlers by default
37
+ * `ignore_if` -- this proc is passed env and an exception; if it returns true, the exception is not reported to WhenAUser
38
+ * `token` -- the token for a WhenAUser channel
39
+ * `custom_data` -- this proc is passed env, and should return a hash to be merged into each event
28
40
 
29
41
  WhenAUser::Pageviews accepts these options:
30
42
 
31
- * `ignore_crawlers` -- an array of strings to match against the user agent, includes a number of webcrawlers by default
32
- * `ignore_if` -- this proc is passed env; if it returns true, the pageview is not reported to WhenAUser
33
- * `custom_data` -- this proc is passed env, and should return a hash to be merged into the event
43
+ * `ignore_crawlers` -- an array of strings to match against the user agent, includes a number of webcrawlers by default
44
+ * `ignore_if` -- this proc is passed env; if it returns true, the pageview is not reported to WhenAUser
45
+ * `custom_data` -- this proc is passed env, and should return a hash to be merged into each event
46
+
47
+ Use Cases
48
+ ---------
49
+
50
+ ### Example rule triggers
51
+
52
+ * whenever a `UserIsHavingAVeryBadDay` exception is raised
53
+ * the first time any exception occurs
54
+ * whenever a request takes more than 20 seconds to process
55
+ * whenever someone upgrades their account
56
+ * whenever someone does comment#create more than 10 times in a day
57
+ * whenever someone tagged 'active' doesn't login for a week
58
+
59
+ ### Example rule actions
34
60
 
61
+ * send yourself an email or a mobile push message
62
+ * send a user an email or a mobile push message
63
+ * create a ticket in your ticketing system
64
+ * add a data point to a Librato graph
65
+ * tag a user in WhenAUser, or in your CRM
66
+ * segment a user in your email campaign tool
@@ -1,3 +1,3 @@
1
1
  module WhenAUser
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
data/lib/whenauser.rb CHANGED
@@ -28,6 +28,7 @@ module WhenAUser
28
28
  def initialize(app, options={})
29
29
  options[:webhook_url] ||= 'http://whenauser.com/events'
30
30
  @app = app
31
+ WhenAUser.queue = []
31
32
  WhenAUser.filter_parameters = defined?(Rails) ? Rails.application.config.filter_parameters : []
32
33
  WhenAUser.token = options[:token]
33
34
  WhenAUser.endpoint = Faraday::Connection.new options[:webhook_url] do |builder|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whenauser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: