示例#1
0
        public void MissionStarted(int id, string name, string type, Dictionary <string, object> additionalParams)
        {
            IDictionary <string, object> extras = new Dictionary <string, object>();

            extras ["missionID"]   = id;
            extras ["missionName"] = name;
            extras ["missionType"] = type;

            AndroidJavaObject sjo = GetUnityJavaObject();

            if (null != sjo)
            {
                sjo.Call("addExtras", new object[] { PsdkUtils.CreateJavaJSONObjectFromDictionary(extras) });
            }
            else
            {
                Debug.LogWarning("Not calling android psdk analytics MissionStarted ! cause object is null");
            }

            if (additionalParams != null)
            {
                foreach (var item in additionalParams)
                {
                    extras.Add(item.Key, item.Value);
                }
            }

            LogEvent(AnalyticsTargets.ANALYTICS_TARGET_DELTA_DNA, "missionStarted", extras, false, true);
        }
示例#2
0
        public void LevelUp(string skinName, string levelUpName, int level, Dictionary <string, object> additionalParams)
        {
            IDictionary <string, object> extras = new Dictionary <string, object>();

            extras ["userLevel"] = level;

            IDictionary <string, object> eventParams = new Dictionary <string, object>();

            eventParams ["levelUpName"] = levelUpName;
            eventParams ["skinName"]    = skinName;

            if (additionalParams != null)
            {
                foreach (var item in additionalParams)
                {
                    eventParams.Add(item.Key, item.Value);
                }
            }

            AndroidJavaObject sjo = GetUnityJavaObject();

            if (null != sjo)
            {
                sjo.Call("addExtras", new object[] { PsdkUtils.CreateJavaJSONObjectFromDictionary(extras) });
            }
            else
            {
                Debug.LogWarning("Not calling android psdk analytics LevelUp ! cause object is null");
            }

            LogEvent(AnalyticsTargets.ANALYTICS_TARGET_DELTA_DNA, "levelUp", eventParams, false, true);
        }
示例#3
0
 private void LogPsdkVersions()
 {
     try {
         PsdkUtils.NativeLog(PsdkSerializedData.Instance != null ? PsdkSerializedData.Instance.ToString() : "LogPsdkVersions:: null");
     }
     catch (System.Exception e) {
         Debug.LogException(e);
     }
 }
        public ConsentType GetConsent()
        {
            string      resultStr = psdkGetConsent();
            ConsentType result    = ConsentType.UNKNOWN;

            if (resultStr != null)
            {
                result = PsdkUtils.StringToConsentType(resultStr);
            }
            return(result);
        }
示例#5
0
        public void LogEvent(string eventName, IDictionary <string, object> eventParams)
        {
            AndroidJavaObject sjo = GetUnityJavaObject();

            if (null != sjo)
            {
                sjo.Call("logEvent", eventName, PsdkUtils.CreateJavaJSONObjectFromDictionary(eventParams));
            }
            else
            {
                Debug.Log("Event was not sent: " + eventName + " -> " + Json.Serialize(eventParams));
            }
        }
示例#6
0
        public void EndLogEvent(string eventName, IDictionary <string, string> eventParams)
        {
            AndroidJavaObject sjo = GetUnityJavaObject();

            if (null != sjo)
            {
                sjo.Call("endLogEvent", eventName, PsdkUtils.CreateJavaHashMapFromDictionary(eventParams));
            }
            else
            {
                Debug.LogWarning("Not calling android psdk analytics LogEvent !, cause object is null");
                Debug.Log("End timed Event was not sent: " + eventName + " -> " + PsdkUtils.BuildJsonStringFromDict(eventParams));
            }
        }
示例#7
0
        public void EndLogEvent(string eventName, IDictionary <string, object> eventParams)
        {
            AndroidJavaObject sjo = GetUnityJavaObject();

            if (null != sjo)
            {
                sjo.Call("endLogEvent", eventName, PsdkUtils.CreateJavaJSONObjectFromDictionary(eventParams));
            }
            else
            {
                Debug.LogWarning("Not calling android psdk analytics LogComplexEvent !, cause object is null");
                Debug.Log("EndLogEvent public void ReportPurchase(string price, string currency, string productId) {was not sent: " + eventName + " -> " + Json.Serialize(eventParams));
            }
        }
示例#8
0
        public void LogEvent(long targets, string eventName, IDictionary <string, object> eventParams, bool timed, bool psdkEvent)
        {
            AndroidJavaObject sjo = GetUnityJavaObject();

            if (null != sjo)
            {
                sjo.Call("logEvent", targets, eventName, PsdkUtils.CreateJavaJSONObjectFromDictionary(eventParams), timed, psdkEvent);
            }
            else
            {
                Debug.LogWarning("Not calling android psdk analytics LogComplexEvent !, cause object is null");
                Debug.Log("Event was not sent: " + eventName + " -> " + Json.Serialize(eventParams));
            }
        }
示例#9
0
        public bool RequestEngagement(string decisionPoint, Dictionary <string, object> parameters)
        {
            bool retVal           = false;
            AndroidJavaObject sjo = GetUnityJavaObject();

            if (null != sjo)
            {
                retVal = sjo.Call <bool>("requestEngagement", decisionPoint, PsdkUtils.CreateJavaJSONObjectFromDictionary(parameters));
            }
            else
            {
                Debug.LogWarning("Not calling android psdk analytics RequestEngagement !, cause object is null");
            }
            return(retVal);
        }
        public ConsentType GetConsent()
        {
            _consentMgrObject = GetUnityJavaObject();
            ConsentType result     = ConsentType.UNKNOWN;
            string      consentStr = null;

            if (_consentMgrObject != null)
            {
                consentStr = _consentMgrObject.Call <string>("getConsentStr");
            }
            if (consentStr != null)
            {
                result = PsdkUtils.StringToConsentType(consentStr);
            }
            return(result);
        }
        private static bool IsPackageExist(string pkgName)
        {
            try {
                // removing .unitypackage.............
                int index = pkgName.IndexOf(".unitypackage");
                if (index > 0)
                {
                    pkgName.Remove(index);
                }
                string fileRelativePath = Path.Combine("psdk", Path.Combine("versions", pkgName + ".unitypackage.version.txt"));
                string version          = PsdkUtils.ReadStreamingAssetsFile(fileRelativePath);
                if (version == null)
                {
                    return(false);
                }

                return(true);
            }
            catch (System.Exception e) {
                Debug.LogException(e);
            }
            return(false);
        }
示例#12
0
 public void EndLogEvent(string eventName, IDictionary <string, string> eventParams)
 {
     Debug.Log("PSDK Analytic End Event: " + eventName + " -> " + PsdkUtils.BuildJsonStringFromDict(eventParams));
 }
示例#13
0
 public void LogEvent(string eventName, IDictionary <string, string> eventParams, bool timed)
 {
     Debug.Log("PSDK Analytic Event: " + eventName + " -> " + PsdkUtils.BuildJsonStringFromDict(eventParams) + ", timed:" + timed);
 }
示例#14
0
        public static string ReadPsdkConfigFromFile()
        {
            string fileRelativePath;
            bool   android = false;

            string json = null;

            if (RuntimePlatform.IPhonePlayer == Application.platform)
            {
                fileRelativePath = "psdk_ios.json";
            }
            else
            {
                fileRelativePath = "psdk_google.json";
                                #if AMAZON
                fileRelativePath = "psdk_amazon.json";
                                #else
                json = PsdkUtils.ReadAndroidAssetsFile(fileRelativePath);
                if (null != json)
                {
                    UnityEngine.Debug.Log("Read psdk_google.json directly from android assets folder !");
                }
                                #endif
                android = true;
            }

            if (json == null)
            {
                json = PsdkUtils.ReadStreamingAssetsFile(fileRelativePath);
            }

            if (json == null && android)
            {
                json = PsdkUtils.ReadStreamingAssetsFile("psdk_amazon.json");
            }

            if (json == null)
            {
                json = PsdkUtils.ReadStreamingAssetsFile("psdk.json");
            }

            if (null != json)
            {
                return(json);
            }

            if (RuntimePlatform.IPhonePlayer == Application.platform)
            {
                json = PsdkUtils.ReadStreamingAssetsFile("psdk_ios_.json");
            }
            else
            {
                                #if AMAZON
                json = PsdkUtils.ReadStreamingAssetsFile("psdk_amazon_.json");
                                #else
                json = PsdkUtils.ReadStreamingAssetsFile("psdk_google_.json");
                                #endif
                android = true;
            }

            if (null != json)
            {
                Debug.LogWarning("PSDK - You are using test json configuration file  !!");
                return(json);
            }


            Debug.LogError("PSDKMgr::ReadPsdkConfigFromFile failed reading json file Assets/StreamingAssets/psdk.json !!");
            return("{}");
        }
 public void LogEvent(long targets, string eventName, IDictionary <string, object> eventParams, bool timed, bool psdkEvent)
 {
     psdkAnalyticsLogEventInternal(targets, eventName, PsdkUtils.BuildJsonStringFromDict(eventParams), timed, psdkEvent);
 }
示例#16
0
 public void LogEvent(string eventName, IDictionary <string, object> eventParams)
 {
     psdkSingularLogEvent(eventName, PsdkUtils.BuildJsonStringFromDict(eventParams));
 }
示例#17
0
        private IDictionary <string, int> getISOValue()
        {
            IDictionary <string, int> ISO4217 = new Dictionary <string, int>();
            string iso4217_file_to_string     = PsdkUtils.ReadStreamingAssetsFile("iso_4217.xml");

            using (XmlReader reader = XmlReader.Create(new StringReader(iso4217_file_to_string))) {
                bool   expectingCode  = false;
                bool   expectingValue = false;
                string pulledCode     = null;
                string pulledValue    = null;

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (reader.Name.Equals("Ccy"))
                        {
                            expectingCode = true;
                        }
                        else if (reader.Name.Equals("CcyMnrUnts"))
                        {
                            expectingValue = true;
                        }
                        break;

                    case XmlNodeType.Text:
                        if (expectingCode)
                        {
                            pulledCode = reader.Value;
                        }
                        else if (expectingValue)
                        {
                            pulledValue = reader.Value;
                        }
                        break;

                    case XmlNodeType.EndElement:
                        if (reader.Name.Equals("Ccy"))
                        {
                            expectingCode = false;
                        }
                        else if (reader.Name.Equals("CcyMnrUnts"))
                        {
                            expectingValue = false;
                        }
                        else if (reader.Name.Equals("CcyNtry"))
                        {
                            if (!string.IsNullOrEmpty(pulledCode) &&
                                !string.IsNullOrEmpty(pulledValue))
                            {
                                int value;
                                try {
                                    value = int.Parse(pulledValue);
                                } catch (FormatException) {
                                    value = 0;
                                }

                                ISO4217[pulledCode] = value;
                            }

                            expectingCode  = false;
                            expectingValue = false;
                            pulledCode     = null;
                            pulledValue    = null;
                        }
                        break;
                    }
                }
            }

            return(ISO4217);
        }
示例#18
0
        /// <summary>
        /// <summary>_analyticsService
        /// Setup the specified store, domain, language and orientation.
        /// </summary>
        /// <param name="store">Store.</param>
        /// <param name="domain">Domain.</param>
        /// <param name="language">Language.</param>
        /// <param name="orientation">Orientation.</param>
        public bool Setup(string language = null, string configJson = null)
        {
            if (_psdkSetup)
            {
                return(true);
            }
            _psdkSetup = true;

            PsdkEventSystem.Instance.Init();

            _configJson = configJson;

            LogPsdkVersions();

            if (System.String.IsNullOrEmpty(_configJson))
            {
                Debug.Log("Reading psdk json configuration from steamingAssets/psdk.json file !");
                _configJson = PsdkUtils.ReadPsdkConfigFromFile();
            }

            if (System.String.IsNullOrEmpty(_configJson))
            {
                Debug.LogError("Null or empty psdk configuration json, please put it in Assets/SteamingAssets/psdk.json !");
                return(false);
            }

            PsdkUtils.NativeLog("psdk config: " + _configJson);
            LocalConfig = new PsdkLocalConfig(_configJson);

            if (LocalConfig.GetBool(new string[] { "appsFlyer", "included" }, false) && LocalConfig.GetBool(new string[] { "singular", "included" }, false))
            {
                Debug.LogError("appsFlyer and singluar are both included. this is not allowed. build will fail.");
            }

            DebugMode = isDebugMode(_configJson);

            RunObbDownloaderIfNeeded();

            SetupAppLifecycleManager();
            // initial analytics listner

            PsdkEventSystem.Instance.Init();

            if (!SetupCrossDevicePersistency())
            {
                Debug.Log("CrossDevicePersistency not initialized !");
            }

            if (!SetupBilling())
            {
                Debug.Log("Billing not initialized !");
            }

            if (!SetupRateUs())
            {
                Debug.Log("RateUs not initialized !");
            }

            if (!SetupShare())
            {
                Debug.Log("Share not initialized !");
            }

            if (!SetupSocial())
            {
                Debug.Log("Social not initialized !");
            }


            if (!SetupAudience())
            {
                Debug.Log("PSDK Audience not initialized!");
            }

            if (!SetupInAppPurchase())
            {
                Debug.Log("PSDK InAppPurchase not initialized!");
            }

            if (!SetupExternalConfiguration())
            {
                Debug.Log("PSDK External Configuration not initialized!");
            }

            if (!SetupAnalyticsService())
            {
                Debug.Log("PSDK Analytics not inititalized  !");
            }

            if (!SetupLocationManagerService())
            {
                Debug.Log("location manager not inititalized  !");
            }

            if (!SetupRewardedAdsService())
            {
                Debug.Log("RewardedAds not initialized !");
            }

            if (!SetupGameLevelData())
            {
                Debug.Log("GLD not initialized !");
            }

            if (!SetupSplash())
            {
                Debug.Log("Splash not initialized !");
            }

            if (!SetupBanners())
            {
                Debug.Log("Banners not initialized !");
            }

            if (!SetupCrashMonitoringTool())
            {
                Debug.Log("CrashMonitoringTool not initialized !");
            }

            if (!SetupNativeCampaign())
            {
                Debug.Log("NativeCampaign not initialized !");
            }

            if (!SetupSingular())
            {
                Debug.Log("Singular not initialized !");
            }


//			string newConfigJson = preProcessConfigJsonAccordingToInstalledPkgs(_configJson);

            bool rc = false;

            if (null != _impl)
            {
                rc = _impl.Setup(_configJson, language);
                _nativePsdkStarted = true;
                _silent            = false;
                PsdkEventSystem.RegisterNativeCallbacksAfterPsdkInitialization();
            }

            if (rc)
            {
                AppLifeCycleResumeState or = _appLifeCycleMgrService.OnResume();
                Debug.Log("PSDKMgr::Start resume state: " + or.ToString());
                foreach (IPsdkService ps in _registeredServices)
                {
                    try {
                        ps.psdkStartedEvent();
                    }
                    catch (System.Exception e) {
                        Debug.LogException(e);
                    }
                }
                if (or != AppLifeCycleResumeState.ALCRS_NONE)
                {
                    PsdkEventSystem.Instance.SendMessage("OnResumeEvent", or);
                }
            }

            return(rc);
        }