Trueandco_analytics
Trueandco_analytics Gems for authentication and authorization
About
Many systems analysts do not provide data about the specific user. This gem allows administrators to obtain reports on a particular user and common page statistics
Installation
- You shall have (redis, sidekiq, mysql) on your server.
- You have to include gems in your Gemfile:
gem 'trueandco_analytics'
- And then to start
bundle
- To start the initialiser, for detailed configured gem
rails g trueandco_analytics:install
After
rake db:migrate
or
rails db:migrate
That create 3 tables:
metric_users
, metric_user_sessions
, metric_user_visits
metric_users
Info about users
metric_user_sessions
Info about user sesssions
metric_user_visits
Pages which were visited by the user within the session
Add assetcs
//= require trueandco_analytics
Add helper track_user_behavior
to head for tracking
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<%= track_user_behavior %>
</head>
Add the mointing address
mount TrueandcoAnalytics::Engine, at: "/metric"
And you need to listen queue user_metric
bundle exec sidekiq --queue=user_metric
The application must have a route root
For use of the console mode. it is necessary to specify the current database.
config.db_connect = {
database: 'development_db_name',
username: 'ivan',
password: '3443555',
host: '127.0.0.1',
port: 3306
}
It is possible to include the logging mode, having specified the name
config.log = 'name of log'
Usage
Now we can take data in a convenient format.
It is necessary to specify the report and a format of data
So far only arr, csv is available
For this we use the service object `::TrueandcoAnalytics::Reports`
Available formats
```ruby
::TrueandcoAnalytics::Reports.available_formats
```
List of reports
```ruby
::TrueandcoAnalytics::Reports.available_reports
```
Get report obj with method report_name and data
```ruby
::TrueandcoAnalytics::Reports.get_report_obj('page_buy_in_date_range_report', 'csv')
::TrueandcoAnalytics::Reports.get_report_obj('page_buy_in_date_range_report', 'csv', datetme_start, datetime_end)
```
### Usage console mod
bundle exec trueandco_analytics -h
Settings
Time survey Analytics seconds
config.time_survey = 15
Specify the method available in the ApplicationController to the receiving user object. Containing id, email.
config.user_method = 'current_user'
Specify css the selector for the button purchase
config.buy_selector = '.buy'
Specify the database where redis will store the statistics for the session user
config.connect_redis = { #url: "redis://your_host:6379", #redis_password: '', redis_db: 1 }
Specify Sidekiq config
config.sidekiq_configure_client_url = 'redis://localhost:6379/1'
config.sidekiq_configure_server_url = 'redis://localhost:6379/1'
config.sidekiq_configure_namespace = 'metric'
Ruby version tested
2.2.4
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Rattt/trueandco_analytics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.