assaf / vanity

Experiment Driven Development for Ruby
http://vanity.labnotes.org
MIT License
1.55k stars 270 forks source link

ActiveRecord model metrics can provide their own identity source #285

Closed peterkovacs closed 8 years ago

peterkovacs commented 8 years ago

This allows objects created on the backend (outside the ActionController) context to still have an associated identity.

Additionally, fixes a bug with the after_create callback so that the current Vanity.context.vanity_identity is passed along to properly record the conversion for the participant.

peterkovacs commented 8 years ago

If this PR is accepted, I have another in the conversions-for-particpants-only branch which fixes what I consider to be a bug. That is, currently conversions are recorded for all model metrics when they're created, even if created by a non-participant in an experiment.

The only problem with it is the fact that if you start any experiments before the user can be identified by their user_id (for example) then you will still have a problem because the user_id isn't an experiment participant, but rather the users anonymous cookie identifier. Which is why I changed the after_create callback to try to use the Vanity.context.vanity_identifier. Any objects created in the context will be associated with the correct identity and still count as conversions.

phillbaker commented 8 years ago

Looks like the build is still failing on the case with protected attributes.