/// <inheritdoc /> public void RecordCustomEvent(string eventType, Dictionary <string, object> eventData) { try { //Every event has an embedded properties structure //First we will build the Properties structure //Then we will build the encapsulating event structure TrackPropertyBuilder propertyBuilder = new TrackPropertyBuilder(); propertyBuilder.SetCategory(eventType); //Now build the properties structure and add the //custom properties received Dictionary <string, object> customProperties = propertyBuilder.Build(); Dictionary <string, object> eventProps = AnalyticsUtils.FoolProofParams(eventData); foreach (var key in eventProps.Keys) { customProperties.Add(key, eventProps[key]); } //Now build the event structure RudderElementBuilder elementBuilder = new RudderElementBuilder(); elementBuilder.WithEventName(eventType); //Set user id if available if (WynnEngine.PlayerId.HasValue()) { elementBuilder.WithUserId(WynnEngine.PlayerId); } //Set the user properties elementBuilder.WithUserProperties(GetCommonEventData()); //Set the event properties elementBuilder.WithEventProperties(customProperties); // Create the event object RudderElement element = elementBuilder.Build(); // Set the integrations element.integrations = new Dictionary <string, object>(); element.integrations.Add("All", true); //Invoke track method rudder.Track(element); // GameEngine.LogError("RudderAnalyticsManager: Track: " + eventType); } catch (Exception e) { GameEngine.LogError("RudderAnalyticsManager: Track: Error: " + e.Message); } }
/// <inheritdoc /> void RecordPurchase(string id, double price, double amountPurchased, string currency = null, string store = null, string transactionId = null) { try { //Every event has an embedded properties structure //First we will build the Properties structure //Then we will build the encapsulating event structure TrackPropertyBuilder propertyBuilder = new TrackPropertyBuilder(); propertyBuilder.SetCategory("revenue"); Dictionary <string, object> recordPurchaseProperties = propertyBuilder.Build(); recordPurchaseProperties.Add("productId", id); recordPurchaseProperties.Add("price", price); recordPurchaseProperties.Add("quantity", 1); if (store != null) { recordPurchaseProperties.Add("revenueType", store); } if (transactionId != null) { recordPurchaseProperties.Add("transactionId", transactionId); } //Add the FoolProofParams Dictionary <string, object> eventData = AnalyticsUtils.FoolProofParams(GetCommonEventData()); foreach (var key in eventData.Keys) { var value = eventData[key]; if (value != null) { recordPurchaseProperties.Add(key, value); } } //Now build the event structure RudderElementBuilder elementBuilder = new RudderElementBuilder(); elementBuilder.WithEventName("revenue"); //Set user id if available if (WynnEngine.PlayerId.HasValue()) { elementBuilder.WithUserId(WynnEngine.PlayerId); } //Add the properties structure created to the event elementBuilder.WithEventProperties(recordPurchaseProperties); // Create the event object RudderElement element = elementBuilder.Build(); // Set the integrations element.integrations = new Dictionary <string, object>(); element.integrations.Add("All", true); //Invoke track method rudder.Track(element); // GameEngine.LogError("RudderAnalyticsManager: Track: revenue"); } catch (Exception e) { GameEngine.LogError("RudderAnalyticsManager: Track: Error: " + e.Message); } }