Pregunta

I have been using the following code to identify new users with Mixpanel:

    var mixpanelTries = 0;
    function handleMixpanelUser() {
        if ((window.mixpanel) && (window.mixpanel.alias)) {
            if ("@Auth.UserID" !== "0") {
                if ("@SessionWrapper.UserInitialized" === "False") {
                    try { mixpanel.alias("@Auth.UserID"); } catch (exception) {console.log("exception"); }
                    mixpanel.identify("@Auth.UserID");
                    mixpanel.people.set({
                        "$email": "@Auth.UserEmail",    // only special properties need the $
                        "$created": "@SessionWrapper.UserCreated",
                        "name": "@Auth.FullName"
                    }, function (resp) { });
                    var url = "http://" + "@Config.BaseUrl" + "/finalizeuser/" + "@Auth.UserID";
                    $.ajax({
                        type: 'POST',
                        url: url,
                        async: false
                    });
                }
                else {
                    mixpanel.identify("@Auth.UserID");
                }
            }
        }
        else {
            if (mixpanelTries < 5) {
                mixpanelTries++;
                setTimeout(handleMixpanelUser, 100);
            }
        }
    }

    $(function () {
        handleMixpanelUser();
    });

This code was written in December of 2012 and worked perfectly. However, since January 1st this code is not working, it doesn't crash, but the new users are not created in Mixpanel. There was no change in the code. Why was my code good in 2012 and bad in 2013?

Do I need to change a setting?

Thanks in advance for any help.

¿Fue útil?

Solución

I've figured out the problem: My code was working all the time, but I didn't realise it, as the Mixpanel UI has a big sorting bug. If I sort the records descending by created time, then the first shown record was created on December 31st.

But if I sort the records by Last Seen, it shows users created minutes ago.

This is a sorting bug. I believe the date sort of Mixpanel sorts alphabetically when we sort the dates.

'12/31/2012' > '1/7/2013'

So, people from 12/31/2013 are "newer" than people from 1/1/2013. I will send an email to Mixpanel to notify them about the problem.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top