Closed tonydaly closed 11 years ago
This gem does not yet have direct support for Aliasing, since aliasing is only supported starting version 2.2 of the mixpanel js library.
But there is a way to do it - by using the track method as follows:
@mixpanel.track "$create_alias", { :distinct_id => "32423sfsdsdf", :alias => user.id}
would there be any issues with monkey patching render_mixpanel_scripts (https://github.com/zevarito/mixpanel/blob/master/lib/mixpanel/middleware.rb#L83) to embed 2.2?
You can do it (you would need to add the 'alias' method ref besides just the version number change), but the alias call would still not work this way (I tried the monkeypatch on a fork). You can use the above track method I provided for applying aliasing.
How can I get the auto generated distinct id in order to alias it ?
There's a fork at quadule/mixpanel that supports Mixpanel 2.2 and the alias methods. I've not tried it, but if it works, it probably makes sense to merge in.
Yes, if it works would make sense to merge it.
Hey that's me! I'm using my fork in production with no issues.
If you're thinking of merging it, I should note that I replaced the tracker's append_people_identify
method with append_identify
, following Mixpanel's 2.2 API changes. I'm not sure how you want to handle API changes in this project, but you may want to add the method back with a deprecation notice.
This works fine for me after adding the latest javascript snippet: mixpanel.append('alias', user.email) Using append_identify works fine for registering people changes for me too.
I think we should offer both versions of Mixpanel API. And let old one as the default one with deprecation notes until a new release that changes the default lib. What do you think?
I am still using my fork with the JS pasted into it in production (from #74 ) with no issues. Would be nice to be able to move back to the master branch of this gem. Why not move to a new point release and switch to the new API? Alias support is really necessary for me and is a core part of Mixpanel's docs. How long since the API changed?
Hey for everyone trying to figure this out. This worked alright for me:
mpjson = JSON.parse(cookies["mp_#{Rails.application.settings[ :mixpanel_api_token ]}_mixpanel"])
mixpanel.track "$create_alias", { :distinct_id => mpjson["distinct_id"], :alias => user.username}
mixpanel.set user.username, {:email => user.email, :ip => request.remote_ip, :name => user.username}
Version 4.0.0 is ready with this changes. Sorry about the delay, I've been running crazy without time lately.
Is there a way to use the mixpanel.alias() with this gem?