Пример #1
0
        public static Dictionary <string, string> GetAttribution()
        {
#if NETFX_CORE
            AdjustAttribution attribution = Adjust.GetAttributon();
            if (attribution == null)
            {
                return(new Dictionary <string, string>());
            }

            var adjustAttributionMap = AdjustAttribution.ToDictionary(attribution);
            if (adjustAttributionMap == null)
            {
                return(new Dictionary <string, string>());
            }

            // convert from <string, object> to <string, string>
            return(adjustAttributionMap.ToDictionary(
                       x => char.ToLowerInvariant(x.Key[0]) + x.Key.Substring(1),
                       x => x.Value != null ? x.Value.ToString() : "null"));
#else
            return(null);
#endif
        }
Пример #2
0
        public static void ApplicationLaunching(AdjustConfigDto adjustConfigDto)
        {
#if NETFX_CORE
            if (adjustConfigDto.LogDelegate != null)
            {
                LogAction = adjustConfigDto.LogDelegate;
            }

            LogLevel logLevel;
            string   logLevelString = char.ToUpper(adjustConfigDto.LogLevelString[0])
                                      + adjustConfigDto.LogLevelString.Substring(1);
            Enum.TryParse(logLevelString, out logLevel);

            //Log($"Setting log level to {logLevelString}.");

            var config = new AdjustConfig(adjustConfigDto.AppToken, adjustConfigDto.Environment,
                                          adjustConfigDto.LogDelegate, logLevel)
            {
                DefaultTracker   = adjustConfigDto.DefaultTracker,
                SdkPrefix        = adjustConfigDto.SdkPrefix,
                SendInBackground = adjustConfigDto.SendInBackground,
                DelayStart       = TimeSpan.FromSeconds(adjustConfigDto.DelayStart)
            };

            if (adjustConfigDto.SecretId.HasValue && adjustConfigDto.Info1.HasValue &&
                adjustConfigDto.Info2.HasValue && adjustConfigDto.Info3.HasValue &&
                adjustConfigDto.Info4.HasValue)
            {
                config.SetAppSecret(adjustConfigDto.SecretId.Value,
                                    adjustConfigDto.Info1.Value, adjustConfigDto.Info2.Value,
                                    adjustConfigDto.Info3.Value, adjustConfigDto.Info4.Value);
            }

            config.SetUserAgent(adjustConfigDto.UserAgent);

            if (adjustConfigDto.IsDeviceKnown.HasValue)
            {
                config.SetDeviceKnown(adjustConfigDto.IsDeviceKnown.Value);
            }

            if (adjustConfigDto.EventBufferingEnabled.HasValue)
            {
                config.EventBufferingEnabled = adjustConfigDto.EventBufferingEnabled.Value;
            }

            if (adjustConfigDto.ActionAttributionChangedData != null)
            {
                config.AttributionChanged = attribution =>
                {
                    var attributionMap = AdjustAttribution
                                         .ToDictionary(attribution)
                                         // convert from <string, object> to <string, string>
                                         .ToDictionary(
                        x => char.ToLowerInvariant(x.Key[0]) + x.Key.Substring(1),
                        x => x.Value != null ? x.Value.ToString() : "null");

                    adjustConfigDto.ActionAttributionChangedData(attributionMap);
                };
            }

            if (adjustConfigDto.ActionSessionSuccessData != null)
            {
                config.SesssionTrackingSucceeded = session =>
                                                   adjustConfigDto.ActionSessionSuccessData(Util.ToDictionary(session));
            }

            if (adjustConfigDto.ActionSessionFailureData != null)
            {
                config.SesssionTrackingFailed = session =>
                                                adjustConfigDto.ActionSessionFailureData(Util.ToDictionary(session));
            }

            if (adjustConfigDto.ActionEventSuccessData != null)
            {
                config.EventTrackingSucceeded = adjustEvent =>
                                                adjustConfigDto.ActionEventSuccessData(Util.ToDictionary(adjustEvent));
            }

            if (adjustConfigDto.ActionEventFailureData != null)
            {
                config.EventTrackingFailed = adjustEvent =>
                                             adjustConfigDto.ActionEventFailureData(Util.ToDictionary(adjustEvent));
            }

            if (adjustConfigDto.FuncDeeplinkResponseData != null)
            {
                config.DeeplinkResponse = uri =>
                                          adjustConfigDto.FuncDeeplinkResponseData(uri.AbsoluteUri);
            }

            Adjust.ApplicationLaunching(config);
#endif
        }