コード例 #1
0
ファイル: GameAnalytics.cs プロジェクト: yweber/Barotrauma
        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();
                }
            });
        }
コード例 #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();
            });
        }
コード例 #3
0
 public static void SetEnabledManualSessionHandling(bool flag)
 {
     GAThreading.PerformTaskOnGAThread("setEnabledManualSessionHandling", () =>
     {
         GAState.SetManualSessionHandling(flag);
     });
 }
コード例 #4
0
 public static void OnResume()
 {
     GALogger.D("OnResume() called");
     GAThreading.PerformTaskOnGAThread("onResume", () =>
     {
         GAState.ResumeSessionAndStartQueue();
     });
 }
コード例 #5
0
 public static void SetFacebookId(string facebookId)
 {
     GAThreading.PerformTaskOnGAThread("setFacebookId", () =>
     {
         if (GAValidator.ValidateFacebookId(facebookId))
         {
             GAState.SetFacebookId(facebookId);
         }
     });
 }
コード例 #6
0
 public static void SetGender(EGAGender gender)
 {
     GAThreading.PerformTaskOnGAThread("setGender", () =>
     {
         if (GAValidator.ValidateGender(gender))
         {
             GAState.SetGender(gender);
         }
     });
 }
コード例 #7
0
 public static void SetBirthYear(int birthYear)
 {
     GAThreading.PerformTaskOnGAThread("setBirthYear", () =>
     {
         if (GAValidator.ValidateBirthyear(birthYear))
         {
             GAState.SetBirthYear(birthYear);
         }
     });
 }
コード例 #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;
     });
 }
コード例 #9
0
        public static void SetGlobalCustomEventFields(IDictionary <string, object> customFields)
        {
            if (_endThread)
            {
                return;
            }

            GAThreading.PerformTaskOnGAThread("setGlobalCustomEventFields", () =>
            {
                GAState.SetGlobalCustomEventFields(customFields);
            });
        }
コード例 #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;
     });
 }
コード例 #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);
     });
 }
コード例 #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);
            });
        }
コード例 #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);
            });
        }
コード例 #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);
            });
        }
コード例 #15
0
ファイル: GameAnalytics.cs プロジェクト: yweber/Barotrauma
 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");
         }
     });
 }
コード例 #16
0
 public static void OnStop()
 {
     GALogger.D("OnStop() called");
     GAThreading.PerformTaskOnGAThread("onStop", () =>
     {
         try
         {
             GAState.EndSessionAndStopQueue();
         }
         catch (Exception)
         {
         }
     });
 }
コード例 #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);
            });
        }
コード例 #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);
            });
        }
コード例 #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;
     });
 }
コード例 #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);
            });
        }
コード例 #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;
         }
     });
 }
コード例 #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;
     });
 }
コード例 #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);
            });
        }
コード例 #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;
            });
        }
コード例 #25
0
ファイル: GameAnalytics.cs プロジェクト: yweber/Barotrauma
        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);
            });
        }
コード例 #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);
            });
        }
コード例 #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);
            });
        }
コード例 #28
0
ファイル: GameAnalytics.cs プロジェクト: yweber/Barotrauma
        public static void OnSuspend()
        {
            if (_endThread)
            {
                return;
            }

            GALogger.D("OnSuspend() called");
            GAThreading.PerformTaskOnGAThread("onSuspend", () =>
            {
                try
                {
                    GAState.EndSessionAndStopQueue(false);
                }
                catch (Exception)
                {
                }
            });
        }
コード例 #29
0
ファイル: GameAnalytics.cs プロジェクト: yweber/Barotrauma
        public static void OnQuit()
        {
            if (_endThread)
            {
                return;
            }

            GALogger.D("OnQuit() called");
            GAThreading.PerformTaskOnGAThread("onQuit", () =>
            {
                try
                {
                    _endThread = true;
                    GAState.EndSessionAndStopQueue(true);
                }
                catch (Exception)
                {
                }
            });
        }
コード例 #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();
                }
            });
        }