analytics_events_sender 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/analytics_events_sender.gemspec +32 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/analytics_events_sender.rb +33 -0
- data/lib/analytics_events_sender/amplitude.rb +25 -0
- data/lib/analytics_events_sender/appmetrica.rb +33 -0
- data/lib/analytics_events_sender/appsflyer.rb +43 -0
- data/lib/analytics_events_sender/dispatcher.rb +50 -0
- data/lib/analytics_events_sender/mixpanel.rb +40 -0
- data/lib/analytics_events_sender/version.rb +3 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33fb21b5f72d0e896560b9944b2145bee666dfc4ade280eba4f80e6107f7b351
|
4
|
+
data.tar.gz: 9a9aeb7327fca43d55c8ffad8b1c6e63fd270fd274f9c69c3d38417f47a66fa8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d32ba1c08bb5b8afd4786538753f665e3e145f6313f14f8772ec1300844bfc2c6d0ff6d730c4e59828f1504d609ce833c2afa2499b2d12b968dc8c0415ae1f8b
|
7
|
+
data.tar.gz: 1972867b502fcddd0738e745ab9ea1ac98badd37faafff7448a2b4f87b9c73f152a975d74a3d30bb0ed326647157eb439296b1952009c77a4aa28ca52674c0d0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at anohin56n@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 SumLare
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 SumLare
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# AnalyticsEventsSender
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/SumLare/analytics_events_sender.svg?branch=master)](https://travis-ci.org/SumLare/analytics_events_sender)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'analytics_events_sender'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install analytics_events_sender
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
First of all, you have to configure analytics events sender, by defining platforms api keys and ids in, for example, `config/initializers/analytics_events_sender.rb`:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
AnalyticsEventsSender.configuration do |config|
|
27
|
+
config.mixpanel = { token: ENV['YOUR_TOKEN'] }
|
28
|
+
config.appmetrica = { app_id: ENV['YOUR_APP_ID'], api_key: ENV['YOUR_KEY'] }
|
29
|
+
config.amplitude = { api_key: ENV['YOUR_KEY'] }
|
30
|
+
config.appsflyer = { app_id: ENV['YOUR_APP_ID'], api_key: ENV['YOUR_KEY'] }
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Call dispatcher from your controller and pass which platforms you want to use:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
AnalyticsEventsSender::Dispatcher.call(user, params, %w[mixpanel appmetrica amplitude])
|
38
|
+
```
|
39
|
+
|
40
|
+
After this it will make requests to platforms you've chosen and return `true` if they were successful.
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
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).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/analytics_events_sender. 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.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
55
|
+
|
56
|
+
## Code of Conduct
|
57
|
+
|
58
|
+
Everyone interacting in the AnalyticsEventsSender project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/analytics_events_sender/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'analytics_events_sender/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'analytics_events_sender'
|
9
|
+
spec.version = AnalyticsEventsSender::VERSION
|
10
|
+
spec.authors = ['SumLare']
|
11
|
+
spec.email = ['anohin56n@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Event sender for multiple analuytics platforms'
|
14
|
+
spec.description = 'Event sender for multiple analuytics platforms'
|
15
|
+
spec.homepage = 'https://github.com/SumLare/analytics_events_sender'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'httparty'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
spec.add_development_dependency 'pry-byebug'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
32
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'analytics_events_sender'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
require 'analytics_events_sender/dispatcher'
|
6
|
+
require 'analytics_events_sender/amplitude'
|
7
|
+
require 'analytics_events_sender/appmetrica'
|
8
|
+
require 'analytics_events_sender/mixpanel'
|
9
|
+
require 'analytics_events_sender/appsflyer'
|
10
|
+
require 'analytics_events_sender/version'
|
11
|
+
|
12
|
+
module AnalyticsEventsSender
|
13
|
+
class << self
|
14
|
+
attr_accessor :configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
self.configuration ||= Configuration.new
|
19
|
+
yield(configuration)
|
20
|
+
end
|
21
|
+
|
22
|
+
class Configuration
|
23
|
+
attr_accessor :amplitude, :mixpanel, :appmetrica, :appsflyer
|
24
|
+
|
25
|
+
# Initialize different platforms parameters
|
26
|
+
def initialize
|
27
|
+
@amplitude = {}
|
28
|
+
@mixpanel = {}
|
29
|
+
@appmetrica = {}
|
30
|
+
@appsflyer = {}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AnalyticsEventsSender
|
2
|
+
class Amplitude
|
3
|
+
BASE_URL = 'https://api.amplitude.com/httpapi'.freeze
|
4
|
+
|
5
|
+
def ininialize(user, params = {})
|
6
|
+
@user = user
|
7
|
+
@params = params
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
response = HTTParty.post(BASE_URL, body: event_params, format: :json)
|
12
|
+
|
13
|
+
return false unless response.success?
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def event_params
|
19
|
+
{
|
20
|
+
api_key: AnalyticsEventsSender.configuration.amplitude.dig(:api_key),
|
21
|
+
event: @params
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module AnalyticsEventsSender
|
2
|
+
class Appmetrica
|
3
|
+
BASE_URL = 'https://api.appmetrica.yandex.com/logs/v1/import/events.csv'.freeze
|
4
|
+
|
5
|
+
def ininialize(user, params = {})
|
6
|
+
@user = user
|
7
|
+
@params = params
|
8
|
+
@event_name = params.dig(:notification_type)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
response = HTTParty.post(complete_url, body: prepared_params, format: :json)
|
13
|
+
|
14
|
+
return false unless response.success?
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def complete_url
|
20
|
+
key = AnalyticsEventsSender.configuration.appmetrica.dig(:api_key)
|
21
|
+
|
22
|
+
"#{BASE_URL}?post_api_key=#{key}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def prepared_params
|
26
|
+
{
|
27
|
+
application_id: AnalyticsEventsSender.configuration.appmetrica.dig(:app_id),
|
28
|
+
profile_id: @user.id, event_name: @event_name,
|
29
|
+
event_timestamp: Time.now.to_i, event_json: @params.to_json
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module AnalyticsEventsSender
|
2
|
+
class Appsflyer
|
3
|
+
BASE_URL = 'https://api2.appsflyer.com/inappevent'.freeze
|
4
|
+
|
5
|
+
def ininialize(user, params = {})
|
6
|
+
@user = user
|
7
|
+
@params = params
|
8
|
+
@event_name = params.dig(:notification_type)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
return false unless @user.appsflyer_id
|
13
|
+
|
14
|
+
api_key = AnalyticsEventsSender.configuration.appsflyer.dig(:api_key)
|
15
|
+
response = HTTParty.post(BASE_URL, body: event_params, headers: { authentication: api_key })
|
16
|
+
|
17
|
+
return false unless response.success?
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def complete_url
|
23
|
+
app_id = AnalyticsEventsSender.configuration.appsflyer.dig(:app_id)
|
24
|
+
"#{base_ur}/#{app_id}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def prepated_params
|
28
|
+
customer_params = {
|
29
|
+
appsflyer_id: @user.appsflyer_id, customer_user_id: @user.id, af_events_api: true
|
30
|
+
}
|
31
|
+
customer_params.merge(event_params).to_json
|
32
|
+
end
|
33
|
+
|
34
|
+
def event_params
|
35
|
+
{
|
36
|
+
event_name: @event_name,
|
37
|
+
event_value: "#{@params.transform_values { |v| v.to_s }}",
|
38
|
+
event_time: @event_time
|
39
|
+
}.transform_keys { |key| key.to_s.split('_').map(&:capitalize).join }
|
40
|
+
.transform_values { |v| v.to_s }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module AnalyticsEventsSender
|
2
|
+
class Dispatcher
|
3
|
+
CANCELATION_EVENT = 'CANCEL'.freeze
|
4
|
+
BUY_EVENT = 'INITIAL_BUY'.freeze
|
5
|
+
RENEWAL_EVENT = 'RENEWAL'.freeze
|
6
|
+
INTERACTIVE_RENEWAL_EVENT = 'INTERACTIVE_RENEWAL'.freeze
|
7
|
+
CHANGE_PLAN_EVENT = 'DID_CHANGE_RENEWAL_PREF'.freeze
|
8
|
+
DEFAULT_PLATFORMS = %w[amplitude appmetrica appsflyer mixpanel].freeze
|
9
|
+
|
10
|
+
def self.call(user, params, analytics_platforms)
|
11
|
+
new(user, params, analytics_platforms).call
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(params, user, analytics_platforms = DEFAULT_PLATFORMS)
|
15
|
+
@user = user
|
16
|
+
@analytics_platforms = analytics_platforms
|
17
|
+
@cancelation_date = params.dig(:cancellation_date)
|
18
|
+
@event_name = params.dig(:notification_type)
|
19
|
+
@trial = params.dig(:latest_receipt_info, :is_trial_period)
|
20
|
+
@purchase_date = params.dig(:latest_receipt_info, :original_purchase_date).to_datetime
|
21
|
+
@product_id = params.dig(:auto_renew_product_id)
|
22
|
+
@period = user.receipt['latest_receipt_info'].count
|
23
|
+
@new_product_id = params.dig(:latest_receipt_info)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def call
|
29
|
+
@analytics_platforms.each do |platform|
|
30
|
+
Kernel.const_get("#{AnalyticsEventsSender}::#{platform.capitalize}").new(@user, event_params).call
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def event_params
|
35
|
+
case @event_name
|
36
|
+
when CANCELATION_EVENT
|
37
|
+
{ cancelation_date: @cancelation_date, canceledTrial: true, period: @period, subscription_id: @product_id }
|
38
|
+
when BUY_EVENT
|
39
|
+
{ trial: @trial, purhcase_date: @purchase_date, subscription_id: @product_id }
|
40
|
+
when RENEWAL_EVENT || INTERACTIVE_RENEWAL_EVENT
|
41
|
+
{ conversion_from_trial: true, period: @period, subscription_id: @product_id }
|
42
|
+
when CHANGE_PLAN_EVENT
|
43
|
+
{
|
44
|
+
conversion_from_trial: true, old_subscription_id: @product_id,
|
45
|
+
new_subscription_id: @new_product_id, period: @period
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module AnalyticsEventsSender
|
2
|
+
class Mixpanel
|
3
|
+
BASE_URL = 'https://api.mixpanel.com/track/'.freeze
|
4
|
+
SUCCESS_CODE = '1'.freeze
|
5
|
+
|
6
|
+
def ininialize(user, params = {})
|
7
|
+
@user = user
|
8
|
+
@params = params
|
9
|
+
@event_name = params.dig(:notification_type)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
response = HTTParty.post(prepared_url, format: :json)
|
14
|
+
|
15
|
+
success?(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def success?(response)
|
21
|
+
response.parsed_response == SUCCESS_CODE
|
22
|
+
end
|
23
|
+
|
24
|
+
def prepared_url
|
25
|
+
data = Base64.strict_encode64(prepared_json)
|
26
|
+
|
27
|
+
"#{BASE_URL}?data=#{data}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def prepared_json
|
31
|
+
{
|
32
|
+
event: @event_name,
|
33
|
+
properties: {
|
34
|
+
token: AnalyticsEventsSender.configuration.mixpanel.dig(:token),
|
35
|
+
distinct_id: @user.id
|
36
|
+
}.merge(@params)
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: analytics_events_sender
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SumLare
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Event sender for multiple analuytics platforms
|
112
|
+
email:
|
113
|
+
- anohin56n@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- analytics_events_sender.gemspec
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- lib/analytics_events_sender.rb
|
131
|
+
- lib/analytics_events_sender/amplitude.rb
|
132
|
+
- lib/analytics_events_sender/appmetrica.rb
|
133
|
+
- lib/analytics_events_sender/appsflyer.rb
|
134
|
+
- lib/analytics_events_sender/dispatcher.rb
|
135
|
+
- lib/analytics_events_sender/mixpanel.rb
|
136
|
+
- lib/analytics_events_sender/version.rb
|
137
|
+
homepage: https://github.com/SumLare/analytics_events_sender
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.7.6
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Event sender for multiple analuytics platforms
|
161
|
+
test_files: []
|