Ruby
DataDome Ruby module detects and protects against bot activity.
The DataDome Ruby SDK was developed as a gem and can be found part of the RubyGem ecosystem.
Compatibility
This integration is compatible with
- Ruby on Rails applications with versions 3.2.2 and higher
Installation
- Install this gem by running
gem install datadome_module
.
Name of the gem is
datadome_module
Please note that there may be other gems with names containing
datadome
that are not maintained by us.
- Update the
config/application.rb
to includerequire 'datadome_module'
. - Update the environment ruby files (meaning
config/environments/development.rb
,config/environments/production.rb
, and any other environments where you want to enable the DataDome integration) to include the DataDome Module as middleware.
# This adds the DataDomeModule middleware that will be executed for each incoming request
config.middleware.use DataDomeModule
# This configures the DataDomeModule middleware to be executed before the exception handling middleware
config.middleware.insert_before ActionDispatch::ShowExceptions, DataDomeModule
- Open a terminal and set up the required configuration as environment variables.
## Mandatory
## Modify the value of the DATADOME_SERVER_SIDE_KEY to hold the value of your DataDome Server-side key available in your DataDome dashboard.
export DATADOME_SERVER_SIDE_KEY='mock'
Congrats! You can now see your traffic in your DataDome dashboard.
Configuration
Configuration of the DataDome module is done using environment variables.
Refer to the next Settings section for the full list of possible configuration settings.
Settings
Settings | Environment Variable Name | Description | Default value |
---|---|---|---|
Server-side key | DATADOME_SERVER_SIDE_KEY | Value of your Server Side Key available in the dashboard. | |
API endpoint URL | DATADOME_ENDPOINT | URL of the closest endpoint. | api.datadome.co |
DataDome Timeout | DATADOME_TIMEOUT | The maximum amount of time that the client (Faraday) will wait to receive a response from the DataDome API after sending a request. | 300ms |
Regex URL inclusion pattern matcher | DATADOME_URL_PATTERN_INCLUSION | By default, all dynamic calls invoke the DataDome API. | |
Regex URL exclusion pattern matcher | DATADOME_URL_PATTERN_EXCLUSION | By default no calls will be made to DataDome for static assets. | "\\.(avi|flv|mka|mkv|mov|mp4|mpeg|mpg|mp3|flac|ogg|ogm|opus|wav|webm|webp|bmp|gif|ico|jpeg|jpg|png|svg|svgz|swf|eot|otf|ttf|woff|woff2|css|less|js|map|json)$" |
FAQ
Can DataDome coexist with other integrations?
DataDome package has been written in the form of a Rack middleware.
Middleware components are executed in a specific order, from the outermost layer to the innermost layer. This order allows for a sequence of processing steps, and each middleware can modify the request or response before passing it to the next layer.
Consequently, the DataDome module can coexist with any other integrations present in the system.
Updated 2 days ago