
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Analytic provides visitor / session / view tracking without the need for any third-party service.
$ bundle add analytic
$ bin/rails analytic:install:migrations
$ bin/rails db:migrate
# config/routes.rb
Rails.application.routes.draw do
mount Analytic::Engine, at: '/analytic'
end
Default inline tracking is configured with:
class ApplicationController
include Analytic::Trackable
before_action :analytic_track!, if: -> { request.format.html? }
end
Alternative job tracking is configured with:
class ApplicationController
include Analytic::Trackable
before_action :analytic_enqueue_track_job!, if: -> { request.format.html? }
end
note: a queue such as sidekiq, rescue, etc must be running to see tracking
By default Analytic is not authenticated. To authenticate using Rack::Auth
generate a random username and password:
$ bin/rails secret # generate a secret
$ bin/rails credentials:edit
analytic:
username: abc...
password: def...
# config/initializers/analytic.rb
def same?(src, dst)
# https://api.rubyonrails.org/classes/ActiveSupport/SecurityUtils.html
ActiveSupport::SecurityUtils.secure_compare(src, dst)
end
Analytic.configure do |config|
unless Rails.env.local?
config.use Rack::Auth::Basic do |username, password|
credentials = Rails.application.credentials.analytic
same?(username, credentials.username) && same?(password, credentials.password)
end
end
end
By default Analytic tracks utm_source
, utm_medium
, utm_campaign
, utm_content
, utm_term
, ref
and source
parameters for each request. This list can be customized using:
# config/initializer/analytic.rb
Analytic.configure do |config|
config.params << :gclid # e.g. Google
config.params << :msclkid # e.g. Bing
end
By default Analytic uses Time.zone
. The time zone can be changed using:
# config/application.rb
class Application < Rails::Application
config.time_zone = 'Canada/Pacific'
end
The time zone may also be specified for Analytic using any ActiveSupport::TimeZone
:
# config/initializer/analytic.rb
Analytic.configure do |config|
config.time_zone = Time.find_zone('Canada/Pacific')
end
By default Analytic uses your apps main database. The database can be changed using:
# config/initializer/analytic.rb
Analytic.configure do |config|
config.connects_to = { database: { writing: :primary, reading: :replica } }
end
By default IP addresses are masked as follows:
To override both an ip_v4_mask
and ip_v6_mask
are assignable:
Analytic.configure do |config|
config.ip_v4_mask = 24 # nil skips masking
config.ip_v6_mask = 48 # nil skips masking
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that analytic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.