/// <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); } }
void Shoot() { // Reset the timer. timer = 0f; // Play the gun shot audioclip. gunAudio.Play(); // Enable the lights. gunLight.enabled = true; faceLight.enabled = true; // Stop the particles from playing if they were, then start the particles. gunParticles.Stop(); gunParticles.Play(); // Enable the line renderer and set it's first position to be the end of the gun. gunLine.enabled = true; gunLine.SetPosition(0, transform.position); // Set the shootRay so that it starts at the end of the gun and points forward from the barrel. shootRay.origin = transform.position; shootRay.direction = transform.forward; // Perform the raycast against gameobjects on the shootable layer and if it hits something... if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) { // Try and find an EnemyHealth script on the gameobject hit. EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth>(); // If the EnemyHealth component exist... if (enemyHealth != null) { // ... the enemy should take damage. enemyHealth.TakeDamage(damagePerShot, shootHit.point); } // Set the second position of the line renderer to the point the raycast hit. gunLine.SetPosition(1, shootHit.point); } // If the raycast didn't hit anything on the shootable layer... else { // ... set the second position of the line renderer to the fullest extent of the gun's range. gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } Dictionary <string, object> eventProperty = new TrackPropertyBuilder() .SetCategory("PlayerShooting_Shoot") .Build(); eventProperty.Add("dummy_e_prop_1", "dummy_e_prop_1_value"); eventProperty.Add("dummy_e_prop_2", "dummy_e_prop_2_value"); eventProperty.Add("dummy_e_prop_3", "dummy_e_prop_3_value"); eventProperty.Add("score", ScoreManager.score); Dictionary <string, object> userProperty = new Dictionary <string, object> (); userProperty.Add("dummy_prop_1", "dummp_prop_1_value"); userProperty.Add("dummy_prop_2", "dummp_prop_2_value"); RudderElement element = new RudderElementBuilder() .WithEventName("PlayerShooting_Shoot") .WithUserId("test_user_id_sayan_android") .WithEventProperties(eventProperty) .WithUserProperties(userProperty) .Build(); element.integrations = new Dictionary <string, object>(); element.integrations.Add("All", false); element.integrations.Add("AM", true); element.integrations.Add("GA", true); PlayerMovement.rudderClient.Track(element); }