Пример #1
0
    private void OnAdsEvent(FAdsEventData data)
    {
        if (data == null)
        {
            return;
        }
        if (data.eventName == "ad_banner_request")
        {
            return;
        }
        bool firebaseOnly = false;
        Dictionary <string, string> dictionary = data.EventDataToDictionary();
        string eventName = data.eventName;

        switch (eventName)
        {
        case "ad_banner_impression":
            if (dictionary == null)
            {
                dictionary = new Dictionary <string, string>();
            }
            dictionary.Add("banner_shown_type", (!AdsManager.Instance.IsTabletAdUnit) ? "phone" : "tablet");
            dictionary.Add("banner_position", (this.bannerPosition != BannerPosition.Bottom) ? "top" : "bottom");
            break;

        case "ad_interstitial_request":
            firebaseOnly = true;
            break;

        case "ad_interstitial_show":
        case "ad_interstitial_click":
            if (dictionary == null)
            {
                dictionary = new Dictionary <string, string>();
            }
            dictionary.Add("placement", this.fsAdPlacement);
            break;

        case "ad_rewarded_show":
        {
            if (dictionary == null)
            {
                dictionary = new Dictionary <string, string>();
            }
            dictionary.Add("place", AdsManager.Instance.rewardInfo.place.ToString().ToLower());
            dictionary.Add("count_d", AdsManager.Instance.rewardInfo.ImpDay.ToString());
            Dictionary <string, string> dictionary2 = dictionary;
            string key        = "count_s";
            int    impSession = AdsManager.Instance.rewardInfo.ImpSession;
            dictionary2.Add(key, impSession.ToString());
            break;
        }

        case "ad_rewarded_request":
            firebaseOnly = true;
            AdsManager.Instance.rewardInfo.IterateRequest();
            if (dictionary == null)
            {
                dictionary = new Dictionary <string, string>();
            }
            dictionary.Add("count_d", AdsManager.Instance.rewardInfo.ReqDay.ToString());
            dictionary.Add("count_s", AdsManager.Instance.rewardInfo.ReqSession.ToString());
            break;

        case "ad_rewarded_cached":
            AdsManager.Instance.rewardInfo.IterateLoaded();
            if (dictionary == null)
            {
                dictionary = new Dictionary <string, string>();
            }
            dictionary.Add("count_d", AdsManager.Instance.rewardInfo.LoadedDay.ToString());
            dictionary.Add("count_s", AdsManager.Instance.rewardInfo.LoadedSession.ToString());
            break;
        }
        if (dictionary != null)
        {
            AnalyticsManager.AdsEventLog(data.eventName, dictionary, firebaseOnly);
        }
        else
        {
            AnalyticsManager.AdsEventLog(data.eventName, firebaseOnly);
        }
    }