Skip to content

Instantly share code, notes, and snippets.

@weilandia
Created November 18, 2017 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weilandia/1c3158648974752ac5f58feabc9ad8bc to your computer and use it in GitHub Desktop.
Save weilandia/1c3158648974752ac5f58feabc9ad8bc to your computer and use it in GitHub Desktop.
class Api::SendgridEventsController < Api::ApiController
def create
events = Integrations::SendgridEventsParser.new.track_events(params["_json"])
render json: events.to_json
end
end
class Integrations::SendgridEventsParser
def track_events(events)
events.each { |e|
track_event(e)
}
end
def track_event(e)
e.delete("email")
TrackEvent.ping("SendGrid: #{e["event"]}", e)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment