if (define === undefined) {
    var define = function(fn) {
        fn(require, exports, module);
    };
}

define(function(require, exports, module) {
    "use strict";

    function formatUser(user) {
        if (!user) return {}; // empty traits get ignored

         var traits = {
                uid: user.id || user.uid,
                username: user.name || user.username,
                email: user.email,
                createdAt: user.date_add,
                active: !!user.active,
                firstName: getFirstName(user),
                lastName: getLastName(user),
                name: user.fullname || user.name,
                pricingPlan: user.premium ? "Premium" : "Free",
                region: user.region
            };

        return traits;
    }

    function getFirstName(user){
        if (user.firstname) return user.firstname;
        
        if (!user.fullname) return undefined;
       
        return user.fullname.split(' ').slice(0, 1).join(' ');
    }

    function getLastName(user){
        if (user.lastname) return user.lastname;
        
        if (!user.fullname) return undefined;
       
        return user.fullname.split(' ').slice(1).join(' ');
    }

    module.exports = formatUser;
});
if (define === undefined) {
    var define = function(fn) {
        fn(require, exports, module);
    };
}

define(function(require, exports, module) {
    "use strict";

    function formatUser(user) {
        if (!user) return {}; // empty traits get ignored

         var traits = {
                uid: user.id || user.uid,
                username: user.name || user.username,
                email: user.email,
                createdAt: user.date_add,
                active: !!user.active,
                firstName: getFirstName(user),
                lastName: getLastName(user),
                name: user.fullname || user.name,
                pricingPlan: user.premium ? "Premium" : "Free",
                referredBy: user.referrer,
                region: user.region
            };

        return traits;
    }

    function getFirstName(user){
        if (user.firstname) return user.firstname;
        
        if (!user.fullname) return undefined;
       
        return user.fullname.split(' ').slice(0, 1).join(' ');
    }

    function getLastName(user){
        if (user.lastname) return user.lastname;
        
        if (!user.fullname) return undefined;
       
        return user.fullname.split(' ').slice(1).join(' ');
    }

    module.exports = formatUser;
});
Add referrefBy to identify