| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace ExploreV2Analytics |
| | 6 | | { |
| | 7 | | public interface IExploreV2Analytics |
| | 8 | | { |
| | 9 | | void SendStartMenuVisibility(bool isVisible, ExploreUIVisibilityMethod method); |
| | 10 | | void SendStartMenuSectionVisibility(ExploreSection section, bool isVisible); |
| | 11 | | void SendEventTeleport(string eventId, string eventName, Vector2Int coords); |
| | 12 | | void SendClickOnEventInfo(string eventId, string eventName); |
| | 13 | | void SendPlaceTeleport(string placeId, string placeName, Vector2Int coords); |
| | 14 | | void SendClickOnPlaceInfo(string placeId, string placeName); |
| | 15 | |
|
| | 16 | | } |
| | 17 | |
|
| | 18 | | public class ExploreV2Analytics : IExploreV2Analytics |
| | 19 | | { |
| | 20 | | private const string START_MENU_VIBILILITY = "start_menu_visibility"; |
| | 21 | | private const string START_MENU_SECTION_VISIBILITY = "start_menu_section_visibility"; |
| | 22 | | private const string EXPLORE_EVENT_TELEPORT = "explore_event_teleport"; |
| | 23 | | private const string EXPLORE_CLICK_EVENT_INFO = "explore_click_event_info"; |
| | 24 | | private const string EXPLORE_PLACE_TELEPORT = "explore_place_teleport"; |
| | 25 | | private const string EXPLORE_CLICK_PLACE_INFO = "explore_click_place_info"; |
| | 26 | |
|
| | 27 | | private static DateTime? exploreMainMenuSetVisibleTimeStamp = null; |
| | 28 | | private static DateTime? exploreSectionSetVisibleTimeStamp = null; |
| | 29 | |
|
| | 30 | | public void SendStartMenuVisibility(bool isVisible, ExploreUIVisibilityMethod method) |
| | 31 | | { |
| 0 | 32 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 33 | | data.Add("visible", isVisible.ToString()); |
| 0 | 34 | | data.Add("method", method.ToString()); |
| | 35 | |
|
| 0 | 36 | | if (isVisible) |
| 0 | 37 | | exploreMainMenuSetVisibleTimeStamp = DateTime.Now; |
| | 38 | | else |
| | 39 | | { |
| 0 | 40 | | if (exploreMainMenuSetVisibleTimeStamp.HasValue) |
| | 41 | | { |
| 0 | 42 | | data.Add("open_duration_ms", (DateTime.Now - exploreMainMenuSetVisibleTimeStamp.Value).TotalMillisec |
| 0 | 43 | | exploreMainMenuSetVisibleTimeStamp = null; |
| | 44 | | } |
| | 45 | | } |
| | 46 | |
|
| 0 | 47 | | GenericAnalytics.SendAnalytic(START_MENU_VIBILILITY, data); |
| 0 | 48 | | } |
| | 49 | |
|
| | 50 | | public void SendStartMenuSectionVisibility(ExploreSection section, bool isVisible) |
| | 51 | | { |
| 0 | 52 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 53 | | data.Add("section", section.ToString()); |
| 0 | 54 | | data.Add("visible", isVisible.ToString()); |
| | 55 | |
|
| 0 | 56 | | if (isVisible) |
| 0 | 57 | | exploreSectionSetVisibleTimeStamp = DateTime.Now; |
| | 58 | | else |
| | 59 | | { |
| 0 | 60 | | if (exploreSectionSetVisibleTimeStamp.HasValue) |
| | 61 | | { |
| 0 | 62 | | data.Add("open_duration_ms", (DateTime.Now - exploreSectionSetVisibleTimeStamp.Value).TotalMilliseco |
| 0 | 63 | | exploreSectionSetVisibleTimeStamp = null; |
| | 64 | | } |
| | 65 | | } |
| | 66 | |
|
| 0 | 67 | | GenericAnalytics.SendAnalytic(START_MENU_SECTION_VISIBILITY, data); |
| 0 | 68 | | } |
| | 69 | |
|
| | 70 | | public void SendEventTeleport(string eventId, string eventName, Vector2Int coords) |
| | 71 | | { |
| 0 | 72 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 73 | | data.Add("event_id", eventId); |
| 0 | 74 | | data.Add("event_name", eventName); |
| 0 | 75 | | data.Add("event_coords_x", coords.x.ToString()); |
| 0 | 76 | | data.Add("event_coords_y", coords.y.ToString()); |
| 0 | 77 | | GenericAnalytics.SendAnalytic(EXPLORE_EVENT_TELEPORT, data); |
| 0 | 78 | | } |
| | 79 | |
|
| | 80 | | public void SendClickOnEventInfo(string eventId, string eventName) |
| | 81 | | { |
| 0 | 82 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 83 | | data.Add("event_id", eventId); |
| 0 | 84 | | data.Add("event_name", eventName); |
| 0 | 85 | | GenericAnalytics.SendAnalytic(EXPLORE_CLICK_EVENT_INFO, data); |
| 0 | 86 | | } |
| | 87 | |
|
| | 88 | | public void SendPlaceTeleport(string placeId, string placeName, Vector2Int coords) |
| | 89 | | { |
| 0 | 90 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 91 | | data.Add("place_id", placeId); |
| 0 | 92 | | data.Add("place_name", placeName); |
| 0 | 93 | | data.Add("place_coords_x", coords.x.ToString()); |
| 0 | 94 | | data.Add("place_coords_y", coords.y.ToString()); |
| 0 | 95 | | GenericAnalytics.SendAnalytic(EXPLORE_PLACE_TELEPORT, data); |
| 0 | 96 | | } |
| | 97 | |
|
| | 98 | | public void SendClickOnPlaceInfo(string placeId, string placeName) |
| | 99 | | { |
| 0 | 100 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 101 | | data.Add("event_id", placeId); |
| 0 | 102 | | data.Add("event_name", placeName); |
| 0 | 103 | | GenericAnalytics.SendAnalytic(EXPLORE_CLICK_PLACE_INFO, data); |
| 0 | 104 | | } |
| | 105 | | } |
| | 106 | | } |