コード例 #1
0
        public RudderAdjustIntegration(Dictionary <string, object> config, RudderClient client, RudderConfig rudderConfig)
        {
            RudderLogger.LogDebug("Instantiating RudderAdjustIntegration");
            string appToken = null;

            if (config.ContainsKey("appToken"))
            {
                appToken = config["appToken"] as string;
                RudderLogger.LogDebug("Adjust: appToken: " + appToken);
            }

            List <object> eventTokens = new List <object>();

            if (config.ContainsKey("customMappings"))
            {
                eventTokens = config["customMappings"] as List <object>;
                foreach (var eventConfig in eventTokens)
                {
                    Dictionary <string, object> eventTokenDict = eventConfig as Dictionary <string, object>;
                    string eventName  = eventTokenDict["from"] as string;
                    string eventToken = eventTokenDict["to"] as string;
                    RudderLogger.LogDebug("Adjust: " + eventName + " : " + eventToken);
                    this.eventTokenMap[eventName] = eventToken;
                }
            }

            string delayTime = null;

            if (config.ContainsKey("delay"))
            {
                delayTime = config["delay"] as string;
                RudderLogger.LogDebug("delayTime:" + delayTime);
            }

            if (appToken != null && !appToken.Equals(""))
            {
                RudderLogger.LogDebug("Initiating Adjust native SDK");
                AdjustConfig adjustConfig = new AdjustConfig(
                    appToken,
                    rudderConfig.logLevel >= RudderLogLevel.DEBUG ? AdjustEnvironment.Sandbox : AdjustEnvironment.Production,
                    true);
                adjustConfig.setLogLevel(rudderConfig.logLevel >= RudderLogLevel.DEBUG ? AdjustLogLevel.Verbose : AdjustLogLevel.Error);
                double delay = 0;
                try
                {
                    if (delayTime != null)
                    {
                        delay = double.Parse(delayTime);
                    }
                }
                catch (System.Exception ex)
                {
                    RudderLogger.LogError("Invalid delay time" + ex.Message);
                }
                if (delay < 0)
                {
                    delay = 0;
                }
                else if (delay > 10)
                {
                    delay = 10;
                }
                if (delay > 0)
                {
                    adjustConfig.setDelayStart(delay);
                }

                RudderLogger.LogDebug("Starting Adjust native SDK");
                Adjust.start(adjustConfig);
            }
            else
            {
                RudderLogger.LogError("appToken was not set in Dashboard");
            }
        }