138 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| namespace Guru
 | |
| {
 | |
|     public class CuruAnalyticsDemo: MonoBehaviour
 | |
|     {
 | |
|         [SerializeField] private bool _isDebug = true; 
 | |
|         [SerializeField] private Button _btnInitSDK;
 | |
|         [SerializeField] private Button _btnStatus;
 | |
|         [SerializeField] private Button _btnUserProperties;
 | |
|         [SerializeField] private Button _btnEvents;
 | |
|         [SerializeField] private Button _btnEvents2;
 | |
|         [SerializeField] private Button _btnReport;
 | |
|         [SerializeField] private Button _btnTestCrash;
 | |
| 
 | |
|         // ----------- All Status IDs -----------
 | |
|         private static readonly string AdjustID = "e35b41522140fa2db9089ef3c78eb8f9";
 | |
|         private static readonly string FirebaseID = "b7ab5fc399a7bc8725c004943fa82837";
 | |
|         private static readonly string UID = "BS-YYYYF";
 | |
|         private static readonly string AdID = "dda3cc2b-5a5e-44cb-8a59-4a0b1b3780fd";
 | |
|         private static readonly string DeviceID = "e2fb3c5a4c36473648c989bd86a41153";
 | |
|         private static readonly string AppID = "";
 | |
|         private static readonly string DeviceInfo = "";
 | |
|         
 | |
|         
 | |
|         private static readonly string ScreenName = "MainMenu";
 | |
| 
 | |
| 
 | |
|         
 | |
|         private void Awake()
 | |
|         {
 | |
|             _btnInitSDK.onClick.AddListener(OnClickInit);
 | |
|             _btnStatus.onClick.AddListener(OnClickStatus);
 | |
|             _btnUserProperties.onClick.AddListener(OnClickUserProperties);
 | |
|             _btnEvents.onClick.AddListener(OnClickEvents);
 | |
|             _btnEvents2.onClick.AddListener(OnClickEvents2);
 | |
|             _btnReport.onClick.AddListener(OnClickReport);
 | |
|             _btnTestCrash.onClick.AddListener(OnClickTestCrash);
 | |
| #if !UNITY_IOS
 | |
|             _btnTestCrash.gameObject.SetActive(false);
 | |
| #endif
 | |
|             
 | |
|             
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         #region Button Callbacks
 | |
| 
 | |
| 
 | |
|         private void OnClickInit()
 | |
|         {
 | |
|             Debug.Log($"---- [DEMO] Call Analytics init");
 | |
|             GuruAnalytics.Init(AppID, DeviceInfo, _isDebug);
 | |
|         }
 | |
|         
 | |
|         private void OnClickStatus()
 | |
|         {
 | |
|             Debug.Log($"---- [DEMO] Report Stats IDs:  UID:{UID}  DeviceID:{DeviceID}  FirebaseID:{FirebaseID} AdID:{AdID}  AdjustID:{AdjustID}");
 | |
|             GuruAnalytics.SetUid(UID);
 | |
|             GuruAnalytics.SetDeviceId(DeviceID);
 | |
|             GuruAnalytics.SetFirebaseId(FirebaseID);
 | |
|             GuruAnalytics.SetAdId(AdID);
 | |
|             GuruAnalytics.SetAdjustId(AdjustID);
 | |
|         }
 | |
| 
 | |
|         private void OnClickUserProperties()
 | |
|         {
 | |
|             string item_category = "main";
 | |
|             int level = 7;
 | |
|             Debug.Log($"---- [DEMO] Call SetUserProperty: item_category:{item_category}  level:{level}");
 | |
|             GuruAnalytics.SetUserProperty("item_category", item_category);
 | |
|             GuruAnalytics.SetUserProperty("level", level.ToString());
 | |
|         }
 | |
| 
 | |
|         private void OnClickEvents()
 | |
|         {
 | |
|             Debug.Log($"---- [DEMO] Report Screen: {ScreenName}");
 | |
|             GuruAnalytics.SetScreen(ScreenName);
 | |
| 
 | |
|             string eventName = "user_get_coin";
 | |
|             Dictionary<string, dynamic> data = new Dictionary<string, dynamic>()
 | |
|             {
 | |
|                 { "level", 7 },
 | |
|                 { "user_coin", 105L },
 | |
|                 { "win_rate", 21.25f },
 | |
|                 { "b_level", 7 },
 | |
|                 { "result", "retry" }
 | |
|             };
 | |
| 
 | |
|             string s = "---- Data ----\n";
 | |
|             foreach (var k in data.Keys)
 | |
|             {
 | |
|                 s += $"-- K:{k}  V:{data[k]}\n";
 | |
|             }
 | |
|             Debug.Log(s);   
 | |
| 
 | |
|             Debug.Log($"---- [DEMO] Call LogEvent");
 | |
|             GuruAnalytics.LogEvent(eventName, data);
 | |
|         }
 | |
| 
 | |
|         private void OnClickEvents2()
 | |
|         {
 | |
|             string eventName = "user_data_loaded";
 | |
|             GuruAnalytics.LogEvent(eventName);
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void OnClickReport()
 | |
|         {
 | |
|             GuruAnalytics.ReportEventSuccessRate();
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void OnClickTestCrash()
 | |
|         {
 | |
| #if UNITY_IOS
 | |
|             Debug.Log($"--> OnClickTestCrash");
 | |
|             GuruAnalytics.TestCrash();
 | |
| #endif
 | |
|         }
 | |
| 
 | |
| 
 | |
|         #endregion
 | |
|         
 | |
|         
 | |
|         
 | |
|         
 | |
|         
 | |
|         
 | |
|         
 | |
|         
 | |
|     }
 | |
| } |