public void OnGUI() { GUILayout.Label("This is an example demonstrating how to use the Mixpanel integration plugin for Unity3D."); GUILayout.Label("All source code for this example is located in \"Assets/Mixpanel Analytics/MixpanelExample.cs\"."); if (string.IsNullOrEmpty(Mixpanel.Token)) { GUI.color = Color.red; GUILayout.Label("Step 1: Set the Token property on the 'Mixpanel Example' object to your unique Mixpanel token string."); } if (string.IsNullOrEmpty(Mixpanel.Token)) { return; } GUILayout.BeginHorizontal(); GUILayout.Label("Event Name:"); _eventName = GUILayout.TextField(_eventName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Property 1:"); _property1 = GUILayout.TextField(_property1); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Property 2:"); _property2 = GUILayout.TextField(_property2); GUILayout.EndHorizontal(); if (GUILayout.Button("Send Event")) { Dictionary <string, object> info = new Dictionary <string, object> { { "property1", _property1 }, { "property2", _property2 }, }; Mixpanel.EnableLogging = true; Mixpanel.SendEvent(_eventName, info); Mixpanel.SendUser(info); } }
private void RetrieveName(IGraphResult result) { foreach (var a in result.ResultDictionary) { Debug.Log(a.Key + "-" + a.Value); } string id = (string)result.ResultDictionary["id"]; string name = String.Format("{0} {1}", result.ResultDictionary["first_name"], result.ResultDictionary["last_name"]); // API APIController.SavePlayer(id, name.Replace(" ", "%20"), AccessToken.CurrentAccessToken.TokenString); // HeroicLabs Client.ApiKey = "31c210da7f0b4110bc301544870733d6"; Client.Ping(onError); Client.LoginOAuthFacebook(AccessToken.CurrentAccessToken.TokenString, (SessionClient session) => { MPScript.Data.SessionClient = session; MPScript.Data.SessionClient.Gamer((Gamer gamer) => { string nickname = name.Replace(' ', '_'); if (gamer.Nickname != nickname) { MPScript.Data.SessionClient.UpdateGamer(nickname, onSuccess, onError); } }, onError); }, onError); // Mixpanel Mixpanel.DistinctID = id; Mixpanel.SendUser(new Dictionary <string, object> { { "$first_name", result.ResultDictionary["first_name"] }, { "$last_name", result.ResultDictionary["last_name"] }, { "$name", name }, { "$email", result.ResultDictionary.ContainsKey("email") ? result.ResultDictionary["email"] : "-" } }); Mixpanel.SendEvent("Login"); }