package org.sagebionetworks.web.client.widget.mixpanel;


import com.google.inject.Inject;

/**
 * Wrapper around the MixPanel library
 * @author jayhodgson
 *
 */
public class MixPanelSdk {
	String currentUser = null;
	@Inject
	public MixPanelSdk() {
	}

	public void initialize(final String userId, final String email) {
		if (!userId.equals(currentUser)) {
			_changeUser(userId, email);	
		}
	}

	public void trackClick(String description) {
		_track("click", description);
	}

	private static native void _changeUser(
			String userId,
			String synapseEmail) /*-{
		$wnd.mixpanel.identify(userId);
	    $wnd.mixpanel.register({
	        "email": synapseEmail
    	});
    }-*/;

	private static native void _track(String eventType, String eventDescription) /*-{
		$wnd.mixpanel.track(eventType, {"description" : eventDescription});
	}-*/;
}

@@ -598,20 +598,17 @@
 erId);%0A%09
-    
+%09
 $wnd.mix
@@ -629,16 +629,10 @@
 (%7B%0A%09
-        
+%09%09
 %22ema
@@ -649,20 +649,17 @@
 seEmail%0A
-    
+%09
 %09%7D);%0A   

fix indentation in native js