Has any one made or come across Rack middleware that handles identifying Clearance users for Segment analytics?
I like that Clearance exposes env[:clearance]
and I’m imaging middleware that does something like:
- Generates a unique
anonymous_id
for logged out users and stores it in the visitor’ssession
- Uses Segment’s
identify
method to track logged out users byanonymous_id
- Uses Segment’s
alias
method to track visitors with a realuser_id
once they’ve logged in - Continues to
identify
logged in users by theiruser_id
from then on
Then our Rails layer only has to worry about Segment track
related logic which would be nice.
Thanks!