| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | namespace DCL.Quests |
| | 7 | | { |
| | 8 | | public class QuestAnalyticsService : IQuestAnalyticsService |
| | 9 | | { |
| | 10 | | private const string STARTED_QUEST = "quest_started"; |
| | 11 | | private const string COMPLETED_QUEST = "quest_completed"; |
| | 12 | | private const string CANCELLED_QUEST = "quest_cancelled"; |
| | 13 | | private const string PROGRESSED_QUEST = "quest_progressed"; |
| | 14 | | private const string JUMPED_IN_QUEST = "quest_jumped_in"; |
| | 15 | | private const string QUEST_LOG_VISIBILITY_CHANGED = "quest_log_visibility_changed"; |
| | 16 | | private const string PINNED_QUEST = "quest_pinned"; |
| | 17 | |
|
| | 18 | | private readonly IAnalytics analytics; |
| | 19 | |
|
| 0 | 20 | | public QuestAnalyticsService(IAnalytics analytics) |
| | 21 | | { |
| 0 | 22 | | this.analytics = analytics; |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | public void SendQuestStarted(string questId) => |
| 0 | 26 | | analytics.SendAnalytic(STARTED_QUEST, new Dictionary<string, string> { { "quest_id", questId } }); |
| | 27 | |
|
| | 28 | | public void SendQuestCompleted(string questId) => |
| 0 | 29 | | analytics.SendAnalytic(COMPLETED_QUEST, new Dictionary<string, string> { { "quest_id", questId } }); |
| | 30 | |
|
| | 31 | | public void SendQuestCancelled(string questId) => |
| 0 | 32 | | analytics.SendAnalytic(CANCELLED_QUEST, new Dictionary<string, string> { { "quest_id", questId } }); |
| | 33 | |
|
| | 34 | | public void SendQuestProgressed(string questId, List<string> completedTasks, List<string> pendingTasks) => |
| 0 | 35 | | analytics.SendAnalytic(PROGRESSED_QUEST, |
| | 36 | | new Dictionary<string, string> |
| | 37 | | { |
| | 38 | | { "quest_id", questId }, |
| | 39 | | { "completed_tasks", string.Join(",", completedTasks) }, |
| | 40 | | { "pending_tasks", string.Join(",", pendingTasks) } |
| | 41 | | }); |
| | 42 | |
|
| | 43 | | public void SendQuestJumpIn(string questId, string taskId, Vector2Int coordinates) => |
| 0 | 44 | | analytics.SendAnalytic(JUMPED_IN_QUEST, new Dictionary<string, string> |
| | 45 | | { |
| | 46 | | { "quest_id", questId }, |
| | 47 | | { "task_id", taskId }, |
| | 48 | | { "coordinates", $"{coordinates.x},{coordinates.y}" } |
| | 49 | | }); |
| | 50 | |
|
| | 51 | | public void SendQuestLogVisibilityChanged(bool isVisible) => |
| 0 | 52 | | analytics.SendAnalytic(QUEST_LOG_VISIBILITY_CHANGED, new Dictionary<string, string> |
| | 53 | | { |
| | 54 | | { "is_visible", isVisible.ToString() } |
| | 55 | | }); |
| | 56 | |
|
| | 57 | | public void SendPinnedQuest(string questId, bool isPinned) => |
| 0 | 58 | | analytics.SendAnalytic(PINNED_QUEST, new Dictionary<string, string> |
| | 59 | | { |
| | 60 | | { "quest_id", questId }, |
| | 61 | | { "is_pinned", isPinned.ToString() } |
| | 62 | | }); |
| | 63 | | } |
| | 64 | | } |