FlurryAnalyticsHelper.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ///----------------------------------------------
  2. /// Flurry Analytics Plugin
  3. /// Copyright © 2016 Aleksei Kuzin
  4. ///----------------------------------------------
  5. using UnityEngine;
  6. namespace KHD {
  7. public class FlurryAnalyticsHelper : MonoBehaviour {
  8. /// <summary>
  9. /// iOS API Key.
  10. /// </summary>
  11. [SerializeField] private string _iOSApiKey;
  12. /// <summary>
  13. /// Android API Key.
  14. /// </summary>
  15. [SerializeField] private string _androidApiKey;
  16. /// <summary>
  17. /// Enable debug log.
  18. /// </summary>
  19. [SerializeField] private bool _enableDebugLog = false;
  20. /// <summary>
  21. /// Send crash reports to Flurry.
  22. /// </summary>
  23. [SerializeField] private bool _sendCrashReports = true;
  24. #if (UNITY_5_2 || UNITY_5_3_OR_NEWER)
  25. /// <summary>
  26. /// Enabled data replication to Unity Analytics.
  27. /// </summary>
  28. [SerializeField] private bool _replicateDataToUnityAnalytics = false;
  29. #endif
  30. #pragma warning disable 0414 // The private field is assigned but its value is never used
  31. #if !UNITY_IOS
  32. [HideInInspector]
  33. #endif
  34. /// <summary>
  35. /// iOS: Enables implicit recording of Apple Store transactions.
  36. /// </summary>
  37. [Space(10)][SerializeField] private bool _iOSIAPReportingEnabled = false;
  38. #pragma warning restore 0414
  39. /// <summary>
  40. /// Awake is called when the script instance is being loaded.
  41. /// </summary>
  42. private void Awake() {
  43. FlurryAnalytics.Instance.SetDebugLogEnabled(_enableDebugLog);
  44. #if (UNITY_5_2 || UNITY_5_3_OR_NEWER)
  45. FlurryAnalytics.Instance.replicateDataToUnityAnalytics = _replicateDataToUnityAnalytics;
  46. #endif
  47. FlurryAnalytics.Instance.StartSession(_iOSApiKey, _androidApiKey, _sendCrashReports);
  48. #if UNITY_IOS
  49. FlurryAnalyticsIOS.SetIAPReportingEnabled(_iOSIAPReportingEnabled);
  50. #endif
  51. }
  52. }
  53. }