public static void AddDesignEvent(string eventId, double value, bool sendValue)
        {
            // Validate
            if (!GAValidator.ValidateDesignEvent(eventId, value))
            {
                GAHTTPApi.Instance.SendSdkErrorEvent(EGASdkErrorType.Rejected);
                return;
            }

            // Create empty eventData
            JSONClass eventData = new JSONClass();

            // Append event specifics
            eventData["category"] = CategoryDesign;
            eventData["event_id"] = eventId;

            if (sendValue)
            {
                eventData.Add("value", new JSONData(value));
            }

            // Log
            GALogger.I("Add DESIGN event: {eventId:" + eventId + ", value:" + value + "}");

            // Send to store
            AddEventToStore(eventData);
        }
        public static void AddDesignEvent(string eventId, double value, bool sendValue, IDictionary <string, object> fields)
        {
            // Validate
            if (!GAValidator.ValidateDesignEvent(eventId, value))
            {
                //GAHTTPApi.Instance.SendSdkErrorEvent(EGASdkErrorType.Rejected);
                return;
            }

            // Create empty eventData
            JSONObject eventData = new JSONObject();

            // Append event specifics
            eventData["category"] = CategoryDesign;
            eventData["event_id"] = eventId;

            if (sendValue)
            {
                eventData.Add("value", new JSONNumber(value));
            }

            // Add custom dimensions
            AddDimensionsToEvent(eventData);

            // Add custom fields
            AddFieldsToEvent(eventData, GAState.ValidateAndCleanCustomFields(fields));

            // Log
            GALogger.I("Add DESIGN event: {eventId:" + eventId + ", value:" + value + "}");

            // Send to store
            AddEventToStore(eventData);
        }
        public void TestValidateDesignEvent()
        {
            // Store result
            bool isValid;

            // Valid
            isValid = GAValidator.ValidateDesignEvent("name:name", 100);
            Assert.True(isValid, "Design event should allow nil value");

            isValid = GAValidator.ValidateDesignEvent("name:name:name", 100);
            Assert.True(isValid, "Design event should allow nil value");

            isValid = GAValidator.ValidateDesignEvent("name:name:name:name", 100);
            Assert.True(isValid, "Design event should allow nil value");

            isValid = GAValidator.ValidateDesignEvent("name:name:name:name:name", 100);
            Assert.True(isValid, "Design event should allow nil value");

            isValid = GAValidator.ValidateDesignEvent("name:name", 0);
            Assert.True(isValid, "Design event should allow nil value");

            // Invalid
            isValid = GAValidator.ValidateDesignEvent("", 100);
            Assert.False(isValid, "Design event should falset allow empty event string");

            isValid = GAValidator.ValidateDesignEvent(null, 100);
            Assert.False(isValid, "Design event should falset allow empty event string");

            isValid = GAValidator.ValidateDesignEvent("name:name:name:name:name:name", 100);
            Assert.False(isValid, "Design event should falset allow more than 5 values in event string");
        }
Exemple #4
0
        public static void AddDesignEvent(string eventID, IDictionary <string, object> fields)
        {
            string fieldsAsString = DictionaryToJsonString(fields);

#if UNITY_EDITOR
            if (GAValidator.ValidateDesignEvent(eventID))
            {
                addDesignEvent(eventID, fieldsAsString);
            }
#else
            addDesignEvent(eventID, fieldsAsString);
#endif
        }
Exemple #5
0
        public static void AddDesignEvent(string eventID, float eventValue, IDictionary <string, object> fields, bool mergeFields)
        {
            string fieldsAsString = DictionaryToJsonString(fields);

#if UNITY_EDITOR
            if (GAValidator.ValidateDesignEvent(eventID))
            {
                addDesignEventWithValue(eventID, eventValue, fieldsAsString, mergeFields);
            }
#else
            addDesignEventWithValue(eventID, eventValue, fieldsAsString, mergeFields);
#endif
        }
Exemple #6
0
        public static void AddDesignEvent(string eventId, double value, bool sendValue, IDictionary <string, object> fields, bool mergeFields)
        {
            if (!GAState.IsEventSubmissionEnabled)
            {
                return;
            }

            // Validate
            if (!GAValidator.ValidateDesignEvent(eventId, value))
            {
                //GAHTTPApi.Instance.SendSdkErrorEvent(EGASdkErrorType.Rejected);
                return;
            }

            // Create empty eventData
            JSONObject eventData = new JSONObject();

            // Append event specifics
            eventData["category"] = CategoryDesign;
            eventData["event_id"] = eventId;

            if (sendValue)
            {
                eventData.Add("value", new JSONNumber(value));
            }

            // Add custom dimensions
            AddDimensionsToEvent(eventData);

            IDictionary <string, object> fieldsToUse = new Dictionary <string, object>(fields != null && fields.Count > 0 ? fields : GAState.CurrentGlobalCustomEventFields);

            if (mergeFields && fields != null && fields.Count > 0)
            {
                foreach (KeyValuePair <string, object> pair in GAState.CurrentGlobalCustomEventFields)
                {
                    if (!fieldsToUse.ContainsKey(pair.Key))
                    {
                        fieldsToUse.Add(pair.Key, pair.Value);
                    }
                }
            }
            // Add custom fields
            AddFieldsToEvent(eventData, GAState.ValidateAndCleanCustomFields(fieldsToUse));

            // Log
            GALogger.I("Add DESIGN event: {eventId:" + eventId + ", value:" + value + "}");

            // Send to store
            AddEventToStore(eventData);
        }