bg-common 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/jobs/bg/common/analytics/ga_event_job.rb +3 -1
- data/app/jobs/bg/common/analytics/intercom_create_user_job.rb +3 -1
- data/app/jobs/bg/common/analytics/intercom_event_job.rb +3 -1
- data/app/jobs/bg/common/analytics/intercom_export_users_job.rb +3 -1
- data/app/jobs/bg/common/analytics/intercom_update_users_job.rb +3 -1
- data/app/jobs/bg/common/analytics/keen_event_job.rb +3 -1
- data/lib/bg/common.rb +15 -6
- data/lib/bg/common/analytics.rb +24 -3
- data/lib/bg/common/analytics/google_analytics/client.rb +4 -0
- data/lib/bg/common/analytics/google_analytics/events.rb +1 -1
- data/lib/bg/common/analytics/intercom/client.rb +4 -0
- data/lib/bg/common/analytics/intercom/events.rb +1 -1
- data/lib/bg/common/analytics/keen/client.rb +4 -0
- data/lib/bg/common/analytics/keen/events.rb +2 -2
- data/lib/bg/common/analytics/tracker.rb +10 -6
- data/lib/bg/common/version.rb +1 -1
- 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: 32c5b7cf0dbee6773715a5d12a06bbc031e13e39
|
4
|
+
data.tar.gz: 53bac4ac88f1d5af07b4e9da2a1507cad219a1e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3706f3cafd53430cea56bcfe15e40438a98b18bb571651198bf35f3f687a0e8b0434d70b9c43d2de639cf6d801bb40fcd5feaf42478eae75ab97f3e3d5ca472
|
7
|
+
data.tar.gz: ee7ee55d4b56925f1cfe7ffd0e5b9ec04298279b319bbad69df6f8b859a4816594057ea6063672a9afdcc02a0bb05700e784dcef82d82352016c7fd0f7a9195b
|
data/README.md
CHANGED
@@ -270,5 +270,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
270
270
|
|
271
271
|
## Contributing
|
272
272
|
|
273
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
273
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bearandgiraffe/bg-common. 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.
|
274
274
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'bg/common/analytics'
|
2
|
+
|
1
3
|
module BG
|
2
4
|
module Common
|
3
5
|
module Analytics
|
@@ -5,7 +7,7 @@ module BG
|
|
5
7
|
queue_as :analytics
|
6
8
|
|
7
9
|
def perform data
|
8
|
-
Intercom::Client.new.make_intercom_call do |client|
|
10
|
+
BG::Common::Analytics::Intercom::Client.new.make_intercom_call do |client|
|
9
11
|
client.users.create data
|
10
12
|
end
|
11
13
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'bg/common/analytics'
|
2
|
+
|
1
3
|
module BG
|
2
4
|
module Common
|
3
5
|
module Analytics
|
@@ -5,7 +7,7 @@ module BG
|
|
5
7
|
queue_as :analytics
|
6
8
|
|
7
9
|
def perform data
|
8
|
-
Intercom::Client.
|
10
|
+
BG::Common::Analytics::Intercom::Client.call data
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'bg/common/analytics'
|
2
|
+
|
1
3
|
module BG
|
2
4
|
module Common
|
3
5
|
module Analytics
|
@@ -5,7 +7,7 @@ module BG
|
|
5
7
|
queue_as :analytics
|
6
8
|
|
7
9
|
def perform data
|
8
|
-
Intercom::Client.new.make_intercom_call do |client|
|
10
|
+
BG::Common::Analytics::Intercom::Client.new.make_intercom_call do |client|
|
9
11
|
client.users.submit_bulk_job(create_items: data)
|
10
12
|
end
|
11
13
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'bg/common/analytics'
|
2
|
+
|
1
3
|
module BG
|
2
4
|
module Common
|
3
5
|
module Analytics
|
@@ -8,7 +10,7 @@ module BG
|
|
8
10
|
users = User.all
|
9
11
|
|
10
12
|
users.each do |user|
|
11
|
-
Analytics::Intercom.update_user user
|
13
|
+
BG::Common::Analytics::Intercom.update_user user
|
12
14
|
end unless users.blank?
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'bg/common/analytics'
|
2
|
+
|
1
3
|
module BG
|
2
4
|
module Common
|
3
5
|
module Analytics
|
@@ -5,7 +7,7 @@ module BG
|
|
5
7
|
queue_as :analytics
|
6
8
|
|
7
9
|
def perform event, data
|
8
|
-
Keen::Client.
|
10
|
+
BG::Common::Analytics::Keen::Client.call event, data
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/bg/common.rb
CHANGED
@@ -13,17 +13,26 @@ module BG
|
|
13
13
|
|
14
14
|
def logger
|
15
15
|
# TODO: Make this configurable
|
16
|
-
|
17
|
-
|
16
|
+
if defined?(::Logging)
|
17
|
+
@logger ||= ::Logging.logger['bg_common']
|
18
|
+
@logger.level = :debug
|
19
|
+
|
20
|
+
@logger.add_appenders \
|
21
|
+
::Logging.appenders.stdout,
|
22
|
+
::Logging.appenders.file('log/bg_common.log')
|
23
|
+
else
|
24
|
+
require 'logger'
|
25
|
+
|
26
|
+
@logger ||= ::Logger.new(STDOUT)
|
27
|
+
@logger.level = ::Logger::DEBUG
|
28
|
+
end
|
18
29
|
|
19
|
-
@logger
|
20
|
-
Logging.appenders.stdout,
|
21
|
-
Logging.appenders.file('log/bg_common.log')
|
30
|
+
return @logger
|
22
31
|
end
|
23
32
|
|
24
33
|
# Paths
|
25
34
|
def gem_path
|
26
|
-
@gem_path ||= File.expand_path '../..', File.dirname(__FILE__)
|
35
|
+
@gem_path ||= ::File.expand_path '../..', ::File.dirname(__FILE__)
|
27
36
|
end
|
28
37
|
|
29
38
|
def active_job?
|
data/lib/bg/common/analytics.rb
CHANGED
@@ -11,15 +11,36 @@ module BG
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def ga?
|
14
|
-
|
14
|
+
begin
|
15
|
+
require 'gabba'
|
16
|
+
defined?(::Gabba) && ENV['GA_TRACKER_CODE'] && ENV['GA_DOMAIN']
|
17
|
+
rescue LoadError
|
18
|
+
BG::Common.logger.info 'GA is not loaded'
|
19
|
+
|
20
|
+
return false
|
21
|
+
end
|
15
22
|
end
|
16
23
|
|
17
24
|
def intercom?
|
18
|
-
|
25
|
+
begin
|
26
|
+
require 'intercom'
|
27
|
+
defined?(::Intercom) && ENV['INTERCOM_ACCESS_TOKEN']
|
28
|
+
rescue LoadError
|
29
|
+
BG::Common.logger.info 'Intercom is not loaded'
|
30
|
+
|
31
|
+
return false
|
32
|
+
end
|
19
33
|
end
|
20
34
|
|
21
35
|
def keen?
|
22
|
-
|
36
|
+
begin
|
37
|
+
require 'keen'
|
38
|
+
defined?(::Keen) && ENV['KEEN_PROJECT_ID']
|
39
|
+
rescue LoadError
|
40
|
+
BG::Common.logger.info 'Keen is not loaded'
|
41
|
+
|
42
|
+
return false
|
43
|
+
end
|
23
44
|
end
|
24
45
|
|
25
46
|
private
|
@@ -19,9 +19,9 @@ module BG
|
|
19
19
|
#
|
20
20
|
def create_event event, data
|
21
21
|
if BG::Common.active_job?
|
22
|
-
KeenEventJob.perform_later event, data
|
22
|
+
BG::Common::Analytics::KeenEventJob.perform_later event, data
|
23
23
|
else
|
24
|
-
Client.
|
24
|
+
BG::Common::Analytics::Keen::Client.call event, data
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -5,17 +5,21 @@ module BG
|
|
5
5
|
def initialize
|
6
6
|
end
|
7
7
|
|
8
|
+
def self.call data
|
9
|
+
self.new.call data
|
10
|
+
end
|
11
|
+
|
8
12
|
def call data
|
9
|
-
if Analytics.ga? and data[:ga]
|
10
|
-
GA.create_event data[:ga]
|
13
|
+
if BG::Common::Analytics.ga? and data[:ga]
|
14
|
+
BG::Common::Analytics::GA.create_event data[:ga]
|
11
15
|
end
|
12
16
|
|
13
|
-
if Analytics.intercom? and data[:intercom]
|
14
|
-
Intercom.create_event data[:intercom]
|
17
|
+
if BG::Common::Analytics.intercom? and data[:intercom]
|
18
|
+
BG::Common::Analytics::Intercom.create_event data[:intercom]
|
15
19
|
end
|
16
20
|
|
17
|
-
if Analytics.keen? and data[:keen]
|
18
|
-
Keen.create_event data[:keen][:event], data[:keen][:data]
|
21
|
+
if BG::Common::Analytics.keen? and data[:keen]
|
22
|
+
BG::Common::Analytics::Keen.create_event data[:keen][:event], data[:keen][:data]
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
data/lib/bg/common/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bg-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Youssef Chaker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|