Example #1
0
        public static void CampaignsDownloaded(List <SwrveQaUserCampaignInfo> campaignInfoList)
        {
            if (!CanLog())
            {
                return;
            }

            try {
                List <Dictionary <string, object> > logDetailsCampaignsList = new List <Dictionary <string, object> >();
                for (int i = 0; i < campaignInfoList.Count; ++i)
                {
                    SwrveQaUserCampaignInfo     qaUserCampaignInfo  = campaignInfoList[i];
                    Dictionary <string, object> logDetailsCampaigns = new Dictionary <string, object>();
                    logDetailsCampaigns.Add("id", qaUserCampaignInfo.id);
                    logDetailsCampaigns.Add("variant_id", qaUserCampaignInfo.variantId);
                    logDetailsCampaigns.Add("type", qaUserCampaignInfo.type);
                    logDetailsCampaignsList.Add(logDetailsCampaigns);
                }

                Dictionary <string, object> logDetails = new Dictionary <string, object>();
                logDetails.Add("campaigns", logDetailsCampaignsList);

                SwrveQaUser qaUser = SwrveQaUser.Instance;
                qaUser.QueueQaLogEvent("campaigns-downloaded", logDetails);
            } catch (Exception ex) {
                SwrveLog.LogError("SwrveQaUser: CampaignsDownloaded exception:" + ex.ToString());
            }
        }
Example #2
0
        private static bool CanLog()
        {
            bool        canLog = true;
            SwrveQaUser qaUser = SwrveQaUser.Instance;

            if (qaUser == null || !qaUser.loggingEnabled)
            {
                canLog = false;
            }
            return(canLog);
        }
Example #3
0
        public static void CampaignTriggeredConversationNoDisplay(string eventName, IDictionary <string, string> eventPayload)
        {
            if (!CanLog())
            {
                return;
            }
            SwrveQaUser qaUser = SwrveQaUser.Instance;
            string      reason = "No Conversation triggered because In App Message displayed";

            qaUser.CampaignTriggered(eventName, eventPayload, false, reason);
        }
Example #4
0
        public static void CampaignTriggeredMessage(string eventName, IDictionary <string, string> eventPayload, bool displayed, List <SwrveQaUserCampaignInfo> campaignInfoList)
        {
            if (!CanLog())
            {
                return;
            }

            try {
                SwrveQaUser qaUser = SwrveQaUser.Instance;
                string      noCampaignTriggeredReason = displayed ? "" : "The loaded campaigns returned no message";
                qaUser.CampaignTriggered(eventName, eventPayload, displayed, noCampaignTriggeredReason, campaignInfoList);
            } catch (Exception ex) {
                SwrveLog.LogError("SwrveQaUser: CampaignTriggeredMessage exception:" + ex.ToString());
            }
        }
Example #5
0
        public static void Init(MonoBehaviour container, string eventServer, string apiKey, int appId, string userId, string appVersion, string deviceUUID, ISwrveStorage storage)
        {
            if (Instance.qaUserQueue != null)
            {
                Instance.qaUserQueue.FlushEvents();
            }

            SwrveQaUser.Instance.qaUserQueue = new SwrveQaUserQueue(container, eventServer, apiKey, appId, userId, appVersion, deviceUUID);
            SwrveQaUser.Instance.userId      = userId;
            SwrveQaUser.Instance.storage     = storage;

            Dictionary <string, object> qaUserDictionary = null;

            qaUserDictionary = (Dictionary <string, object>)Json.Deserialize(instance.LoadQaUserFromCache());
            SwrveQaUser.Update(qaUserDictionary);
        }
Example #6
0
        public static void WrappedEvent(Dictionary <string, object> eventQueued)
        {
            if (!CanLog())
            {
                return;
            }

            try {
                // build dictionary of logDetails.
                Dictionary <string, object> logDetails = new Dictionary <string, object>();

                if (eventQueued.ContainsKey("type"))
                {
                    logDetails.Add("type", eventQueued["type"]);
                    eventQueued.Remove("type");
                }
                if (eventQueued.ContainsKey("seqnum"))
                {
                    logDetails.Add("seqnum", eventQueued["seqnum"]);
                    eventQueued.Remove("seqnum");
                }
                if (eventQueued.ContainsKey("time"))
                {
                    logDetails.Add("client_time", eventQueued["time"]);
                    eventQueued.Remove("time");
                }
                string payloadString = "{}"; // babble currently only accepting payload jsonobject as a string, and not a proper jsonobject
                if (eventQueued.ContainsKey("payload"))
                {
                    if (eventQueued["payload"] is Dictionary <string, string> )
                    {
                        Dictionary <string, string> payloadDictionary = (Dictionary <string, string>)eventQueued["payload"];
                        payloadString = Json.Serialize(payloadDictionary);
                    }
                    eventQueued.Remove("payload");
                }
                logDetails.Add("payload", payloadString);

                // add remaining details as parameters
                logDetails.Add("parameters", eventQueued); // parameters required even if empty

                SwrveQaUser qaUser = SwrveQaUser.Instance;
                qaUser.QueueQaLogEvent("event", logDetails);
            } catch (Exception ex) {
                SwrveLog.LogError("SwrveQaUser: WrappedEvent exception:" + ex.ToString());
            }
        }
Example #7
0
        public static void CampaignButtonClicked(int campaignId, int variantId, string buttonName, string actionType, string actionValue)
        {
            if (!CanLog())
            {
                return;
            }

            try {
                Dictionary <string, object> logDetails = new Dictionary <string, object>();
                logDetails.Add("campaign_id", campaignId);
                logDetails.Add("variant_id", variantId);
                logDetails.Add("button_name", buttonName);
                logDetails.Add("action_type", actionType);
                logDetails.Add("action_value", actionValue);

                SwrveQaUser qaUser = SwrveQaUser.Instance;
                qaUser.QueueQaLogEvent("campaign-button-clicked", logDetails);
            } catch (Exception ex) {
                SwrveLog.LogError("SwrveQaUser: CampaignButtonClicked exception:" + ex.ToString());
            }
        }
Example #8
0
        private void CampaignTriggered(string eventName, IDictionary <string, string> eventPayload, bool displayed, string reason, List <SwrveQaUserCampaignInfo> campaignInfoList = null)
        {
            Dictionary <string, object> logDetails = new Dictionary <string, object>();

            logDetails.Add("event_name", eventName);
            if (eventPayload == null)
            {
                eventPayload = new Dictionary <string, string>();
            }

            if (campaignInfoList == null)
            {
                campaignInfoList = new List <SwrveQaUserCampaignInfo>();
            }

            logDetails.Add("event_payload", eventPayload);
            logDetails.Add("displayed", displayed);
            logDetails.Add("reason", reason);

            List <Dictionary <string, object> > logDetailsCampaignsList = new List <Dictionary <string, object> >();

            for (int i = 0; i < campaignInfoList.Count; ++i)
            {
                SwrveQaUserCampaignInfo     qaUserCampaignInfo  = campaignInfoList[i];
                Dictionary <string, object> logDetailsCampaigns = new Dictionary <string, object>();
                logDetailsCampaigns.Add("id", qaUserCampaignInfo.id);
                logDetailsCampaigns.Add("variant_id", qaUserCampaignInfo.variantId);
                logDetailsCampaigns.Add("type", qaUserCampaignInfo.type);
                logDetailsCampaigns.Add("displayed", qaUserCampaignInfo.displayed);
                logDetailsCampaigns.Add("reason", qaUserCampaignInfo.reason);
                logDetailsCampaignsList.Add(logDetailsCampaigns);
            }
            logDetails.Add("campaigns", logDetailsCampaignsList);

            SwrveQaUser qaUser = SwrveQaUser.Instance;

            qaUser.QueueQaLogEvent("campaign-triggered", logDetails);
        }