void SendDeathEvent() { try { // Sending Kii Analytics event for game over stats KiiEvent ev = KiiAnalytics.NewEvent("PlayerDeath"); // Set key-value pairs ev ["time"] = Time.time; ev ["level"] = 1; // Upload Event Data to Kii Cloud KiiAnalytics.Upload((Exception e) => { if (e == null) { Debug.Log("Analytics event upload successful"); } else { Debug.Log("Analytics event upload error: " + e.ToString()); } }, ev); } catch (CloudException e) { Debug.Log("Analytics event upload error: " + e.ToString()); } }
public void Test_Non_Initialize_AnalyticsAPI_Async() { try { KiiEvent ev = KiiAnalytics.NewEvent("MyUser"); KiiAnalytics.Upload((Exception e) => { }, ev); Assert.Fail("InvalidOperationException isn't thrown"); } catch (InvalidOperationException e) { Assert.AreEqual(ErrorInfo.UTILS_KIICLIENT_NULL, e.Message); } try { ResultCondition condition = new ResultCondition(); KiiAnalytics.GetResult("1234", condition, (string ruleId, ResultCondition c, GroupedResult r, Exception e) => { }); Assert.Fail("InvalidOperationException isn't thrown"); } catch (InvalidOperationException e) { Assert.AreEqual(ErrorInfo.UTILS_KIICLIENT_NULL, e.Message); } }
/// <summary> /// You will generate event when the specified condition in the <see cref="KiiCorp.Cloud.ABTesting.KiiExperiment"/> has achieved. /// ex.) User has signed up, view the message, purchase item, etc. /// You need to call <see cref="KiiAnalytics.Upload(KiiEvent)"/> method of KiiAnalyticsSDK to send the event to Kii Analytics Cloud. /// </summary> /// <remarks> /// </remarks> /// <returns>KiiEvent represents event.</returns> /// <param name="conversionEvent">ConversionEvent to specify which conversionEvent has achieved.</param> public KiiEvent EventForConversion(ConversionEvent conversionEvent) { if (conversionEvent == null) { throw new ArgumentException("conversionEvent is null"); } if (mParentExperimentStatus != KiiExperimentStatus.RUNNING) { return(new KiiEvent.NullKiiEvent()); } KiiEvent e = KiiAnalytics.NewEvent(this.mParentExperimentID); e ["variationName"] = this.mName; e ["conversionEvent"] = conversionEvent.Name; e ["version"] = this.mParentExperimentVersion; return(e); }
void CalculateScore() { #if !UNITY_FLASH recordedTime = (int)GameScore.GameTime; #endif deaths = GameScore.Deaths; buzzerKills = GameScore.GetKills("KamikazeBuzzer"); spiderKills = GameScore.GetKills("EnemySpider"); mechKills = GameScore.GetKills("EnemyMech") + GameScore.GetKills("ConfusedEnemyMech"); points = (int)(buzzerKills * kBuzzerKillPrize + spiderKills * kSpiderKillPrize + mechKills * kMechKillPrize); if (deaths != 0) { points /= (int)(deaths * kDeathCostFactor); } // Sending Kii Analytics event for game over stats Debug.Log("Sending game over event..."); KiiEvent ev = KiiAnalytics.NewEvent("GameOver"); // Set key-value pairs #if !UNITY_FLASH ev["recordedTime"] = recordedTime; #endif ev["deaths"] = deaths; ev["buzzerKills"] = buzzerKills; ev["spiderKills"] = spiderKills; ev["mechKills"] = mechKills; ev["points"] = points; // Upload Event Data to Kii Cloud KiiAnalytics.Upload((Exception e) => { if (e == null) { Debug.Log("GameOverGU: Analytics game over event upload successful"); } else { Debug.Log("GameOverGUI: Unable to upload game over event to Kii Cloud: " + e.ToString()); } }, ev); }
// Send Analytics event for end of level time public static void EndOfLevel(float gameTime) { Debug.Log("Sending end of level event..."); KiiEvent ev = KiiAnalytics.NewEvent("EndOfLevel"); // Set key-value pairs ev ["user"] = user.Username; ev ["time"] = gameTime; // Upload Event Data to Kii Cloud KiiAnalytics.Upload((Exception e) => { if (e == null) { Debug.Log("GameScore: Analytics end-of-level event upload successful"); } else { Debug.Log("GameScore: Unable to upload end-of-level event to Kii Cloud: " + e.ToString()); } }, ev); }