user_trackers 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +129 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f922bacf9b960c0a4d35e77c06f3eb51dcfac107
|
4
|
+
data.tar.gz: 530878cf7a14eb7df626f0a217504191ac71b9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16e32450d1be03d673810b4e81e189ff8d910333958022b8565e86064b80409ddd2497c38d63b8bae8766a3ce93a7435510f13d5db21ccb1eeb2e8778d4ad83f
|
7
|
+
data.tar.gz: 3caa4d26b30b57c3026eeaf143546c606bd5a4703478aca7a1f8909399b79d3707c4a08e7df65d4554e3098ead3f30be023ef980801194b8458518202c468583
|
data/README.md
CHANGED
@@ -1,43 +1,143 @@
|
|
1
|
-
#
|
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
|
-
|
31
|
+
## YML file
|
4
32
|
|
5
|
-
|
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
|
-
|
35
|
+
**user_trackers.yml** provides the following options:
|
8
36
|
|
9
|
-
|
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
|
-
|
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
|
-
|
85
|
+
## Configuration files for trackers
|
16
86
|
|
17
|
-
|
87
|
+
|
18
88
|
|
19
|
-
|
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
|
-
|
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
|
-
|
107
|
+
# Usage
|
24
108
|
|
25
|
-
|
109
|
+
You may call `UserTrackers.track` in your rails app or use clients related to each of the gem's trackers.
|
26
110
|
|
27
|
-
##
|
111
|
+
## Track method
|
28
112
|
|
29
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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.
|
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/
|
164
|
+
source_code_uri: https://github.com/flatironsdevelopment/user_trackers
|
165
165
|
post_install_message:
|
166
166
|
rdoc_options: []
|
167
167
|
require_paths:
|