Skip to content

Instantly share code, notes, and snippets.

@domharrington
Last active March 8, 2023 17:58
Show Gist options
  • Save domharrington/d5d50bec5fd4963047604c786ff6acca to your computer and use it in GitHub Desktop.
Save domharrington/d5d50bec5fd4963047604c786ff6acca to your computer and use it in GitHub Desktop.
Metrics Rails Configuration
require "readme/metrics"
Rails.application.configure do
options = {
api_key: "YOUR KEY HERE",
reject_params: ['data', 'attributes']
}
config.middleware.use Readme::Metrics, options do |env|
{
api_key: "guest",
label: "Guest User",
email: "guest@example.com"
}
end
end
class JsonController < ApplicationController
def index
render json: { message: 'hello world', data: { id: '123', attributes: { email: 'test@example.com' } } }
end
end
Rails.application.routes.draw do
get '/', to: 'json#index'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment