< Summary

Class:QuestsControllerAnalytics
Assembly:QuestsControllerAnalytics
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Analytics/QuestsControllerAnalytics/QuestsControllerAnalytics.cs
Covered lines:47
Uncovered lines:4
Coverable lines:51
Total lines:96
Line coverage:92.1% (47 of 51)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SendQuestDiscovered(...)0%110100%
SendQuestCompleted(...)0%110100%
SendTaskCompleted(...)0%110100%
SendTaskProgressed(...)0%110100%
SendRewardObtained(...)0%110100%
FillQuestData(...)0%2.012085.71%
FillSectionData(...)0%2.022083.33%
FillTaskData(...)0%2.012085.71%
FillRewardData(...)0%2.022083.33%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Analytics/QuestsControllerAnalytics/QuestsControllerAnalytics.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3/// <summary>
 4/// These events should be tracked in the quest server.
 5/// In the meantime we will implement them here
 6/// </summary>
 7public static class QuestsControllerAnalytics
 8{
 9    private const string QUEST_DISCOVERED = "quest_discovered";
 10    private const string QUEST_COMPLETED = "quest_completed";
 11    private const string TASK_COMPLETED = "task_completed";
 12    private const string TASK_PROGRESSED = "task_progressed";
 13    private const string REWARD_OBTAINED = "reward_obtained";
 14
 15    public static void SendQuestDiscovered(QuestModel quest)
 16    {
 217        var data = new Dictionary<string, string>();
 218        FillQuestData(data, quest);
 219        GenericAnalytics.SendAnalytic(QUEST_DISCOVERED, data);
 220    }
 21
 22    public static void SendQuestCompleted(QuestModel quest)
 23    {
 124        var data = new Dictionary<string, string>();
 125        FillQuestData(data, quest);
 126        GenericAnalytics.SendAnalytic(QUEST_COMPLETED, data);
 127    }
 28
 29    public static void SendTaskCompleted(QuestModel quest, QuestSection section, QuestTask task)
 30    {
 131        var data = new Dictionary<string, string>();
 132        FillQuestData(data, quest);
 133        FillSectionData(data, section);
 134        FillTaskData(data, task);
 135        GenericAnalytics.SendAnalytic(TASK_COMPLETED, data);
 136    }
 37
 38    public static void SendTaskProgressed(QuestModel quest, QuestSection section, QuestTask task)
 39    {
 240        var data = new Dictionary<string, string>();
 241        FillQuestData(data, quest);
 242        FillSectionData(data, section);
 243        FillTaskData(data, task);
 244        GenericAnalytics.SendAnalytic(TASK_PROGRESSED, data);
 245    }
 46
 47    public static void SendRewardObtained(QuestModel quest, QuestReward reward)
 48    {
 149        var data = new Dictionary<string, string>();
 150        FillQuestData(data, quest);
 151        FillRewardData(data, reward);
 152        GenericAnalytics.SendAnalytic(REWARD_OBTAINED, data);
 153    }
 54
 55    private static void FillQuestData(Dictionary<string, string> data, QuestModel quest)
 56    {
 757        if (quest == null)
 058            return;
 59
 760        data.Add("quest_id", quest.id);
 761        data.Add("quest_name", quest.name);
 762        data.Add("quest_progress", quest.progress.ToString());
 763        data.Add("quest_status", quest.status);
 764    }
 65
 66    private static void FillSectionData(Dictionary<string, string> data, QuestSection section)
 67    {
 368        if (section == null)
 069            return;
 70
 371        data.Add("section_id", section.id);
 372        data.Add("section_name", section.name);
 373        data.Add("section_progress", section.progress.ToString());
 374    }
 75
 76    private static void FillTaskData(Dictionary<string, string> data, QuestTask task)
 77    {
 378        if (task == null)
 079            return;
 80
 381        data.Add("task_id", task.id);
 382        data.Add("task_name", task.name);
 383        data.Add("task_progress", task.progress.ToString());
 384        data.Add("task_status", task.status);
 385    }
 86
 87    private static void FillRewardData(Dictionary<string, string> data, QuestReward reward)
 88    {
 189        if (reward == null)
 090            return;
 91
 192        data.Add("reward_id", reward.id);
 193        data.Add("reward_name", reward.name);
 194        data.Add("reward_type", reward.type);
 195    }
 96}