user_trackers 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +129 -29
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6999e1efabe76b22187d7d5d24bb6e084d47f071
4
- data.tar.gz: e1ce1105f8d3b2ce35c29ecbe7de69d0dff0f706
3
+ metadata.gz: f922bacf9b960c0a4d35e77c06f3eb51dcfac107
4
+ data.tar.gz: 530878cf7a14eb7df626f0a217504191ac71b9e9
5
5
  SHA512:
6
- metadata.gz: e395186471d0f9aed09151479774adeb0379e2874bbe254b28b7816dc62c48a1e93fe82a819356c3fb686e75773329bf101c000e7e742b9e148535963edc050d
7
- data.tar.gz: 56ea33dc1ea15a7c89b6ef55eeea83987fd8708aa6922017acc283d4817ef04e2d93b2e14a29698369258788ccf2e466852cffe832e2adcb47953514c91e93ca
6
+ metadata.gz: 16e32450d1be03d673810b4e81e189ff8d910333958022b8565e86064b80409ddd2497c38d63b8bae8766a3ce93a7435510f13d5db21ccb1eeb2e8778d4ad83f
7
+ data.tar.gz: 3caa4d26b30b57c3026eeaf143546c606bd5a4703478aca7a1f8909399b79d3707c4a08e7df65d4554e3098ead3f30be023ef980801194b8458518202c468583
data/README.md CHANGED
@@ -1,43 +1,143 @@
1
- # UserTrackers
1
+ # User trackers
2
+
3
+ user_trackers is a ruby gem for tracking user's activity on a ruby on rails app using [Mixpanel](https://github.com/mixpanel/mixpanel-ruby), [Intercom](https://github.com/intercom/intercom-ruby), [Slack](https://github.com/slack-ruby/slack-ruby-client) and app's database.
4
+
5
+ If desired, the gem may track **guest users** and associate their activity to authenticated users when used with **cookies**. The gem can be executed using [sidekiq](https://github.com/mperham/sidekiq) or [resque](https://github.com/resque/resque).
6
+
7
+ # Installation
8
+
9
+ Add the following line to your Gemfile:
10
+
11
+ gem 'user_trackers'
12
+
13
+ Then run `bundle install`
14
+
15
+ Next, run the generator:
16
+
17
+ rails generate user_trackers:install
18
+
19
+ The generator will create:
20
+
21
+ - Configuration files in **config/initializers/user_trackers/**
22
+ - Configuration file **config/user_trackers.yml**
23
+ - `UserEvent` model and associated migration file
24
+
25
+ After running the generator you need to run the migration associated to `UserEvent`
26
+
27
+ rails db:migrate
28
+
29
+ # Editing configuration files
2
30
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/user_trackers`. To experiment with that code, run `bin/console` for an interactive prompt.
31
+ ## YML file
4
32
 
5
- TODO: Delete this and the text above, and describe your gem
33
+ API Tokens related to [Mixpanel](https://github.com/mixpanel/mixpanel-ruby), [Intercom](https://github.com/intercom/intercom-ruby) and [Slack](https://github.com/slack-ruby/slack-ruby-client) may be set considering **development**, **test** and **production** rails environments.
6
34
 
7
- ## Installation
35
+ **user_trackers.yml** provides the following options:
8
36
 
9
- Add this line to your application's Gemfile:
37
+ development:
38
+ ignore_events: ['ignored_event_name']
39
+ # queue_adapter: sidekiq
40
+ mixpanel:
41
+ token: <%= ENV["DEV_MIXPANEL_TOKEN"] %>
42
+ ignore_events: []
43
+ intercom:
44
+ token: <%= ENV['DEV_INTERCOM_TOKEN'] %>
45
+ ignore_events: []
46
+ slack:
47
+ token: <%= ENV['DEV_SLACK_TOKEN'] %>
48
+ activity_channel: <%= ENV['DEV_SLACK_ACTIVITY_CHANNEL'] %>
49
+ ignore_events: []
50
+ db:
51
+ ignore_events: []
52
+
53
+ production:
54
+ ignore_events: ['ignored_event_name']
55
+ queue_adapter: resque
56
+ mixpanel:
57
+ token: <%= ENV["MIXPANEL_TOKEN"] %>
58
+ intercom:
59
+ token: <%= ENV['INTERCOM_TOKEN'] %>
60
+ ignore_events: ['test_event']
61
+ slack:
62
+ token: <%= ENV['SLACK_TOKEN'] %>
63
+ activity_channel: <%= ENV['SLACK_ACTIVITY_CHANNEL'] %>
64
+ ignore_events: []
65
+ db:
66
+ ignore_events: []
67
+
68
+ test:
69
+ ignore_events: ['ignored_event_name']
70
+ mixpanel:
71
+ token: <%= ENV["TEST_MIXPANEL_TOKEN"] %>
72
+ ignore_events: []
73
+ intercom:
74
+ token: <%= ENV['TEST_INTERCOM_TOKEN'] %>
75
+ ignore_events: []
76
+ slack:
77
+ token: <%= ENV['TEST_SLACK_TOKEN'] %>
78
+ activity_channel: <%= ENV['TEST_SLACK_ACTIVITY_CHANNEL'] %>
79
+ ignore_events: []
80
+ db:
81
+ ignore_events: []
10
82
 
11
- ```ruby
12
- gem 'user_trackers'
13
- ```
83
+ You may ignore events per environment or per tracker. For running trackers on a background job, specify a `queue_adapter` option with a value of `resque` or `sidekiq`
14
84
 
15
- And then execute:
85
+ ## Configuration files for trackers
16
86
 
17
- $ bundle
87
+
18
88
 
19
- Or install it yourself as:
89
+ **config/initializers/user_trackers/** will contain configuration files with blocks for customizing `user` and `event` attributes according to your app's datamodel. Configuration blocks will have this form:
20
90
 
21
- $ gem install user_trackers
91
+ UserTrackers.configure_mixpanel do |config|
92
+ def config.user_attributes(user_id, event_name, event_attributes = {}, anonymous_id)
93
+ user = User.find(user_id)
94
+ {
95
+ '$first_name': user.first_name,
96
+ '$last_name': user.last_name,
97
+ '$email': user.email,
98
+ '$test': 'test_value2'
99
+ }
100
+ end
101
+
102
+ def config.event_attributes(user_id, event_name, event_attributes = {}, anonymous_id)
103
+ event_attributes
104
+ end
105
+ end
22
106
 
23
- ## Usage
107
+ # Usage
24
108
 
25
- TODO: Write usage instructions here
109
+ You may call `UserTrackers.track` in your rails app or use clients related to each of the gem's trackers.
26
110
 
27
- ## Development
111
+ ## Track method
28
112
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
113
+ The track method must be called with a **hash** as a parameter and may be called with an optional parameter that should be related to rails' `session`
30
114
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/user_trackers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
- ## License
38
-
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the UserTrackers project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/user_trackers/blob/master/CODE_OF_CONDUCT.md).
115
+ **Example:**
116
+
117
+ UserTrackers.track({
118
+ user_id:9,
119
+ event_name:'publish_post',
120
+ event_attributes:{ title:'Post title', description:'new post'}
121
+ },
122
+ session
123
+ )
124
+
125
+ You may call the track method with or without a `user_id` parameter. An `anonymous_id` will be generated in case no `user_id` is specified.
126
+
127
+ If `session` is specified then the gem will use cookies to track **guest users**.
128
+
129
+ ## Tracker clients
130
+
131
+ You may also use the gem calling methods related to [Mixpanel](https://github.com/mixpanel/mixpanel-ruby), [Intercom](https://github.com/intercom/intercom-ruby) and [Slack](https://github.com/slack-ruby/slack-ruby-client) gems.
132
+
133
+ **Mixpanel Example:**
134
+
135
+ UserTrackers::MixpanelTracker.client.track('User1', 'A Mixpanel Event')
136
+
137
+ **Intercom Example:**
138
+
139
+ UserTrackers::IntercomTracker.client.users.find(email: "bob@example.com")
140
+
141
+ **Slack Example:**
142
+
143
+ UserTrackers::SlackTracker.client.chat_postMessage(channel: '#general', text: 'Hello World', as_user: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_trackers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Barraza
@@ -161,7 +161,7 @@ homepage:
161
161
  licenses:
162
162
  - MIT
163
163
  metadata:
164
- source_code_uri: https://github.com/camilo-barraza/user_trackers
164
+ source_code_uri: https://github.com/flatironsdevelopment/user_trackers
165
165
  post_install_message:
166
166
  rdoc_options: []
167
167
  require_paths: