Active Record Segment

ActiveRecordSegment is an ActiveRecord Extension that logs all changes to your segment destinations. ActiveRecordSegment could also record who made those changes.

Installation

Add this line to your application's Gemfile:

gem 'active_record_segment'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_record_segment

Then, create configuration file for ActiveRecordSegment with following command

rails generate active_record_segment:install

Configuration

After successfully install this gem in your Rails project, please specify configurations in `config/initializer/active_record_segment.rb'

segment_write_key = "YOUR_WRITE_KEY_OF_SEGMENT"

ActiveRecordSegment.configure do |config|
  # Feature toggle
  config.enabled = true

  config.env = Rails.env.to_s

  config.logger = Rails.logger

  # Instruction: https://github.com/segmentio/analytics-ruby
  config.segment_write_key = segment_write_key
  # Ignore changes happen to the following columns of each table.
  # Default value is `created_at` and `updated_at`
  config.ignored_attributes = %w[created_at updated_at]

  # By default, all the classes, that are inherited from ActiveRecord, will be logged. Please specify which classes you
  # would like to ignore.
  # config.ignored_klasses = []
end

Usage

When you application runs, this extension will automatically log all changes of ActiveRecord to segment.com.

Development

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.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/helloworld1812/active_record_segment. 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.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Activerecordsegment project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.