using Mogafa.App.LogEvents; using Mogafa.App.LogEvents.Intercepts; using Mogafa.Common; using Newtonsoft.Json; using System.Collections.Generic; using System.Threading.Tasks; namespace DidabuCloud.Unity.Core { public partial class Didabu : MogafaBase { //public LogEventReporter LogEventReporter { get; private set; } private bool appStartReported = false; public void InitLogEventReporter(CommonEventParameter commonEventParameters = null) { LogEventReporter.Initialize(commonEventParameters); AddCommonEventParameter("developementPlatform", "Unity"); AddCommonEventParameter("developementPlatformVersion", UnityEngine.Application.unityVersion); EnableRunDurationEventParameter(); EnableReportEventCountEventParameter(); EnablePurchaseEventParameter(); if (Config != null) { AddCommonEventParameter("controlDataVersion", Config.ControlDataVersion.ToString()); if (Config.AbGroups != null && Config.AbGroups.Count > 0) { AddCommonEventParameter("abGroups", JsonConvert.SerializeObject(Config.AbGroups)); } } if (!appStartReported) { LogEvent("app_start").Wait(); appStartReported = true; } } public void AddCommonEventParameter(string parameterName, string value) { LogEventReporter.AddCommonEventParameter(parameterName, value); } public void EnableEventCounter(List eventCounterConfigurations) { var eventCounterIntercept = new EventCounterIntercept(eventCounterConfigurations); LogEventReporter.AddIntercept(eventCounterIntercept); } public void EnableAbGroup(List abGroupEvents) { var eventIntercept = new AbGroupEventIntercept(abGroupEvents); LogEventReporter.AddIntercept(eventIntercept); } public void EnableRunDurationEventParameter() { var intercept = new RunDurationEventParameterIntercept(); LogEventReporter.AddParameterIntercept(intercept); } public void EnableReportEventCountEventParameter() { var intercept = new ReportCountEventParameterIntercept(UnityEngine.Application.persistentDataPath); LogEventReporter.AddParameterIntercept(intercept); } public void EnablePurchaseEventParameter() { LogEventReporter.AddParameterIntercept(new PurchaseEventParameterIntercept(new DidabuPurchaseDataProviderForEventParameter(this))); } public Task LogEvent(string name, Dictionary eventParameters = null) { if (eventParameters == null) { eventParameters = new Dictionary(); } return LogEventReporter.LogEvent(name, eventParameters); } } }