Exemplo n.º 1
0
        public static void StartSession()
        {
            if (_endThread)
            {
                return;
            }

            GAThreading.PerformTaskOnGAThread("startSession", () =>
            {
#if WINDOWS_UWP || WINDOWS_WSA
                if (GAState.UseManualSessionHandling)
#endif
                {
                    if (!GAState.Initialized)
                    {
                        return;
                    }

                    if (GAState.IsEnabled() && GAState.SessionIsStarted())
                    {
                        GAState.EndSessionAndStopQueue(false);
                    }

                    GAState.ResumeSessionAndStartQueue();
                }
            });
        }
Exemplo n.º 2
0
        public static void Initialize(string gameKey, string gameSecret)
        {
#if WINDOWS_UWP || WINDOWS_WSA || WINDOWS_PHONE
            CoreApplication.Suspending += OnSuspending;
            CoreApplication.Resuming   += OnResuming;
#endif
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("initialize", () =>
            {
                if (IsSdkReady(true, false))
                {
                    GALogger.W("SDK already initialized. Can only be called once.");
                    return;
                }
                if (!GAValidator.ValidateKeys(gameKey, gameSecret))
                {
                    GALogger.W("SDK failed initialize. Game key or secret key is invalid. Can only contain characters A-z 0-9, gameKey is 32 length, gameSecret is 40 length. Failed keys - gameKey: " + gameKey + ", secretKey: " + gameSecret);
                    return;
                }

                GAState.SetKeys(gameKey, gameSecret);

                if (!GAStore.EnsureDatabase(false))
                {
                    GALogger.W("Could not ensure/validate local event database: " + GADevice.WritablePath);
                }

                GAState.InternalInitialize();
            });
        }
Exemplo n.º 3
0
 public static void SetEnabledManualSessionHandling(bool flag)
 {
     GAThreading.PerformTaskOnGAThread("setEnabledManualSessionHandling", () =>
     {
         GAState.SetManualSessionHandling(flag);
     });
 }
Exemplo n.º 4
0
 public static void OnResume()
 {
     GALogger.D("OnResume() called");
     GAThreading.PerformTaskOnGAThread("onResume", () =>
     {
         GAState.ResumeSessionAndStartQueue();
     });
 }
Exemplo n.º 5
0
 public static void SetFacebookId(string facebookId)
 {
     GAThreading.PerformTaskOnGAThread("setFacebookId", () =>
     {
         if (GAValidator.ValidateFacebookId(facebookId))
         {
             GAState.SetFacebookId(facebookId);
         }
     });
 }
Exemplo n.º 6
0
 public static void SetGender(EGAGender gender)
 {
     GAThreading.PerformTaskOnGAThread("setGender", () =>
     {
         if (GAValidator.ValidateGender(gender))
         {
             GAState.SetGender(gender);
         }
     });
 }
Exemplo n.º 7
0
 public static void SetBirthYear(int birthYear)
 {
     GAThreading.PerformTaskOnGAThread("setBirthYear", () =>
     {
         if (GAValidator.ValidateBirthyear(birthYear))
         {
             GAState.SetBirthYear(birthYear);
         }
     });
 }
Exemplo n.º 8
0
 public static void ConfigureAvailableCustomDimensions03(params string[] customDimensions)
 {
     GAThreading.PerformTaskOnGAThread("configureAvailableCustomDimensions03", () =>
     {
         if (IsSdkReady(true, false))
         {
             GALogger.W("Available custom dimensions must be set before SDK is initialized");
             return;
         }
         GAState.AvailableCustomDimensions03 = customDimensions;
     });
 }
Exemplo n.º 9
0
        public static void SetGlobalCustomEventFields(IDictionary <string, object> customFields)
        {
            if (_endThread)
            {
                return;
            }

            GAThreading.PerformTaskOnGAThread("setGlobalCustomEventFields", () =>
            {
                GAState.SetGlobalCustomEventFields(customFields);
            });
        }
Exemplo n.º 10
0
 public static void ConfigureAvailableResourceItemTypes(params string[] resourceItemTypes)
 {
     GAThreading.PerformTaskOnGAThread("configureAvailableResourceItemTypes", () =>
     {
         if (IsSdkReady(true, false))
         {
             GALogger.W("Available resource item types must be set before SDK is initialized");
             return;
         }
         GAState.AvailableResourceItemTypes = resourceItemTypes;
     });
 }
Exemplo n.º 11
0
 public static void SetCustomDimension03(string dimension)
 {
     GAThreading.PerformTaskOnGAThread("setCustomDimension03", () =>
     {
         if (!GAValidator.ValidateDimension03(dimension))
         {
             GALogger.W("Could not set custom03 dimension value to '" + dimension + "'. Value not found in available custom03 dimension values");
             return;
         }
         GAState.SetCustomDimension03(dimension);
     });
 }
Exemplo n.º 12
0
        public static void AddDesignEvent(string eventId, double value)
        {
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addDesignEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add design event"))
                {
                    return;
                }
                GAEvents.AddDesignEvent(eventId, value, true);
            });
        }
Exemplo n.º 13
0
        public static void AddDesignEvent(string eventId, IDictionary <string, object> fields = null)
        {
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addDesignEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add design event"))
                {
                    return;
                }
                GAEvents.AddDesignEvent(eventId, 0, false, fields);
            });
        }
Exemplo n.º 14
0
        public static void AddErrorEvent(EGAErrorSeverity severity, string message)
        {
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addErrorEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add error event"))
                {
                    return;
                }
                GAEvents.AddErrorEvent(severity, message);
            });
        }
Exemplo n.º 15
0
 private static void OnResuming(object sender, object e)
 {
     GAThreading.PerformTaskOnGAThread("onResuming", () =>
     {
         if (!GAState.UseManualSessionHandling)
         {
             OnResume();
         }
         else
         {
             GALogger.I("OnResuming: Not calling GameAnalytics.OnResume() as using manual session handling");
         }
     });
 }
Exemplo n.º 16
0
 public static void OnStop()
 {
     GALogger.D("OnStop() called");
     GAThreading.PerformTaskOnGAThread("onStop", () =>
     {
         try
         {
             GAState.EndSessionAndStopQueue();
         }
         catch (Exception)
         {
         }
     });
 }
Exemplo n.º 17
0
        public static void AddBusinessEvent(string currency, int amount, string itemType, string itemId, string cartType)
        {
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addBusinessEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add business event"))
                {
                    return;
                }
                // Send to events
                GAEvents.AddBusinessEvent(currency, amount, itemType, itemId, cartType);
            });
        }
Exemplo n.º 18
0
        public static void AddResourceEvent(EGAResourceFlowType flowType, string currency, float amount, string itemType, string itemId)
        {
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addResourceEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add resource event"))
                {
                    return;
                }

                GAEvents.AddResourceEvent(flowType, currency, amount, itemType, itemId);
            });
        }
Exemplo n.º 19
0
 public static void ConfigureGameEngineVersion(string gameEngineVersion)
 {
     GAThreading.PerformTaskOnGAThread("configureGameEngineVersion", () =>
     {
         if (IsSdkReady(true, false))
         {
             return;
         }
         if (!GAValidator.ValidateEngineVersion(gameEngineVersion))
         {
             GALogger.I("Validation fail - configure sdk version: Sdk version not supported. String: " + gameEngineVersion);
             return;
         }
         GADevice.GameEngineVersion = gameEngineVersion;
     });
 }
Exemplo n.º 20
0
        public static void AddProgressionEvent(EGAProgressionStatus progressionStatus, string progression01, string progression02, string progression03, double score)
        {
            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addProgressionEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add progression event"))
                {
                    return;
                }

                // Send to events
                // TODO(nikolaj): check if this cast from int to double is OK
                GAEvents.AddProgressionEvent(progressionStatus, progression01, progression02, progression03, score, true);
            });
        }
Exemplo n.º 21
0
 public static void SetEnabledVerboseLog(bool flag)
 {
     GAThreading.PerformTaskOnGAThread("setEnabledVerboseLog", () =>
     {
         if (flag)
         {
             GALogger.VerboseLog = flag;
             GALogger.I("Verbose logging enabled");
         }
         else
         {
             GALogger.I("Verbose logging disabled");
             GALogger.VerboseLog = flag;
         }
     });
 }
Exemplo n.º 22
0
 public static void ConfigureBuild(string build)
 {
     GAThreading.PerformTaskOnGAThread("configureBuild", () =>
     {
         if (IsSdkReady(true, false))
         {
             GALogger.W("Build version must be set before SDK is initialized.");
             return;
         }
         if (!GAValidator.ValidateBuild(build))
         {
             GALogger.I("Validation fail - configure build: Cannot be null, empty or above 32 length. String: " + build);
             return;
         }
         GAState.Build = build;
     });
 }
Exemplo n.º 23
0
        public static void AddDesignEvent(string eventId, double value, IDictionary <string, object> customFields = null, bool mergeFields = false)
        {
            if (_endThread)
            {
                return;
            }

            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addDesignEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add design event"))
                {
                    return;
                }
                GAEvents.AddDesignEvent(eventId, value, true, customFields, mergeFields);
            });
        }
Exemplo n.º 24
0
        public static void ConfigureUserId(string uId)
        {
            GAThreading.PerformTaskOnGAThread("configureUserId", () =>
            {
                if (IsSdkReady(true, false))
                {
                    GALogger.W("A custom user id must be set before SDK is initialized.");
                    return;
                }
                if (!GAValidator.ValidateUserId(uId))
                {
                    GALogger.I("Validation fail - configure user_id: Cannot be null, empty or above 64 length. Will use default user_id method. Used string: " + uId);
                    return;
                }

                GAState.UserId = uId;
            });
        }
Exemplo n.º 25
0
        public static void AddErrorEvent(EGAErrorSeverity severity, string message /*, IDictionary<string, object> fields = null*/)
        {
            if (_endThread)
            {
                return;
            }

            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addErrorEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add error event"))
                {
                    return;
                }
                GAEvents.AddErrorEvent(severity, message, null);
            });
        }
Exemplo n.º 26
0
        public static void AddResourceEvent(EGAResourceFlowType flowType, string currency, float amount, string itemType, string itemId, IDictionary <string, object> customFields = null, bool mergeFields = false)
        {
            if (_endThread)
            {
                return;
            }

            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addResourceEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add resource event"))
                {
                    return;
                }

                GAEvents.AddResourceEvent(flowType, currency, amount, itemType, itemId, customFields, mergeFields);
            });
        }
Exemplo n.º 27
0
        public static void AddBusinessEvent(string currency, int amount, string itemType, string itemId, string cartType, IDictionary <string, object> customFields = null, bool mergeFields = false)
        {
            if (_endThread)
            {
                return;
            }

            GADevice.UpdateConnectionType();

            GAThreading.PerformTaskOnGAThread("addBusinessEvent", () =>
            {
                if (!IsSdkReady(true, true, "Could not add business event"))
                {
                    return;
                }
                // Send to events
                GAEvents.AddBusinessEvent(currency, amount, itemType, itemId, cartType, customFields, mergeFields);
            });
        }
Exemplo n.º 28
0
        public static void OnSuspend()
        {
            if (_endThread)
            {
                return;
            }

            GALogger.D("OnSuspend() called");
            GAThreading.PerformTaskOnGAThread("onSuspend", () =>
            {
                try
                {
                    GAState.EndSessionAndStopQueue(false);
                }
                catch (Exception)
                {
                }
            });
        }
Exemplo n.º 29
0
        public static void OnQuit()
        {
            if (_endThread)
            {
                return;
            }

            GALogger.D("OnQuit() called");
            GAThreading.PerformTaskOnGAThread("onQuit", () =>
            {
                try
                {
                    _endThread = true;
                    GAState.EndSessionAndStopQueue(true);
                }
                catch (Exception)
                {
                }
            });
        }
Exemplo n.º 30
0
        public static void StartSession()
        {
            GAThreading.PerformTaskOnGAThread("startSession", () =>
            {
                if (GAState.UseManualSessionHandling)
                {
                    if (!GAState.Initialized)
                    {
                        return;
                    }

                    if (GAState.IsEnabled() && GAState.SessionIsStarted())
                    {
                        GAState.EndSessionAndStopQueue();
                    }

                    GAState.ResumeSessionAndStartQueue();
                }
            });
        }