Ejemplo n.º 1
0
        public static AnalyticsResult Custom(string eventName, IDictionary <string, object> eventData = null)
        {
            AnalyticsResult analyticsResult = AnalyticsResult.UnsupportedPlatform;
            string          text            = string.Empty;

            if (string.IsNullOrEmpty(eventName))
            {
                AnalyticsEvent.OnValidationFailed("Custom event name cannot be set to null or an empty string.");
            }
            if (eventData == null)
            {
                analyticsResult = Analytics.CustomEvent(eventName);
            }
            else
            {
                analyticsResult = Analytics.CustomEvent(eventName, eventData);
            }
            if (AnalyticsEvent.debugMode)
            {
                if (eventData == null)
                {
                    text += "\n  Event Data (null)";
                }
                else
                {
                    text += string.Format("\n  Event Data ({0} params):", eventData.Count);
                    foreach (KeyValuePair <string, object> keyValuePair in eventData)
                    {
                        text += string.Format("\n    Key: '{0}';  Value: '{1}'", keyValuePair.Key, keyValuePair.Value);
                    }
                }
            }
            switch (analyticsResult)
            {
            case AnalyticsResult.Ok:
                if (AnalyticsEvent.debugMode)
                {
                    Debug.LogFormat("Successfully sent '{0}' event (Result: '{1}').{2}", new object[]
                    {
                        eventName,
                        analyticsResult,
                        text
                    });
                }
                return(analyticsResult);

            default:
                if (analyticsResult != AnalyticsResult.InvalidData)
                {
                    Debug.LogWarningFormat("Unable to send '{0}' event (Result: '{1}').{2}", new object[]
                    {
                        eventName,
                        analyticsResult,
                        text
                    });
                    return(analyticsResult);
                }
                break;

            case AnalyticsResult.TooManyItems:
                break;
            }
            Debug.LogErrorFormat("Failed to send '{0}' event (Result: '{1}').{2}", new object[]
            {
                eventName,
                analyticsResult,
                text
            });
            return(analyticsResult);
        }
Ejemplo n.º 2
0
 public static AnalyticsResult GameStart(IDictionary <string, object> eventData = null)
 {
     AnalyticsEvent.m_EventData.Clear();
     AnalyticsEvent.AddCustomEventData(eventData);
     return(AnalyticsEvent.Custom("game_start", AnalyticsEvent.m_EventData));
 }
Ejemplo n.º 3
0
 public static AnalyticsResult PushNotificationEnable(IDictionary <string, object> eventData = null)
 {
     AnalyticsEvent.m_EventData.Clear();
     AnalyticsEvent.AddCustomEventData(eventData);
     return(AnalyticsEvent.Custom("push_notification_enable", AnalyticsEvent.m_EventData));
 }
Ejemplo n.º 4
0
 public static AnalyticsResult ChatMessageSent(IDictionary <string, object> eventData = null)
 {
     AnalyticsEvent.m_EventData.Clear();
     AnalyticsEvent.AddCustomEventData(eventData);
     return(AnalyticsEvent.Custom("chat_message_sent", AnalyticsEvent.m_EventData));
 }