public static UTGrammar UTV1Grammar()
        {
#warning not implemented!!!
            UTGrammar result = new UTGrammar();

            result.AnalyticsInteractionEndpoint         = "interaction";
            result.AnalyticsCompleteInteractionEndpoint = "interaction/complete";
            result.AnalyticsEventEndpoint = "event";

            result.LatitudeFieldName  = "utlatitude";
            result.LongitudeFieldName = "utlongitude";

            result.ErrorFieldName            = "uterror";
            result.ErrorDescriptionFieldName = "uterrordescription";

            result.AppLaunchedFieldName = "utapplaunched";
            result.AppFinishedFieldName = "utappfinished";

            result.PageOpenedFieldName = "utpageopened";
            result.PageClosedFieldName = "utpageclosed";
            result.PageIdFieldName     = "utpageid";


            result.DeviceNameFieldName             = "utdevicename";
            result.OperatingSystemNameFieldName    = "utoperatingsystemname";
            result.OperatingSystemVersionFieldName = "utoperatingsystemversion";
            result.DeviceModelFieldName            = "utdevicemodel";
            result.DeviceLocalizedModelFieldName   = "utdevicelocalizedmodel";
            result.BatteryLevelFieldName           = "utbatterylevel";

            result.DeviceIdentifierKeyValue = "utdeviceidentifier";

            return(result);
        }
Example #2
0
        public UTSession
        (
            IUTSessionConfig config,
            IUTInteraction defaultInteraction,
            string deviceIdentifier,
            string uTTokenValue,
            IUTGrammar grammar = null
        )
        {
            if (null == config)
            {
                throw new ArgumentNullException(nameof(UTSession), " config can not be null");
            }

            if (grammar == null)
            {
                grammar = UTGrammar.UTV1Grammar();
            }

            this.utGrammar = grammar;

            this.defaultInteraction      = defaultInteraction;
            this.defaultDeviceIdentifier = deviceIdentifier;

            this.sessionConfig = config.SessionConfigShallowCopy();
            this.requestMerger = new UserRequestMerger(this.sessionConfig, this.defaultDeviceIdentifier);

            this.uTTokenValue = uTTokenValue;

            this.cookies = new CookieContainer();
            this.handler = new HttpClientHandler();
            this.handler.CookieContainer = cookies;
            this.httpClient = new HttpClient(this.handler);
        }
        private IUTEvent ApplyDeviceIdentifier(IUTEvent utEvent)
        {
            string deviceInfoKey   = UTGrammar.UTV1Grammar().DeviceIdentifierKeyValue;
            string deviceInfoValue = null;

            Dictionary <string, string> mergedCustomValues = utEvent.CustomValues;

            if (mergedCustomValues == null)
            {
                mergedCustomValues = new Dictionary <string, string>();
            }

            if (mergedCustomValues.ContainsKey(deviceInfoKey))
            {
                deviceInfoValue = mergedCustomValues[deviceInfoKey];
            }

            if (this.defaultDeviceIdentifier == null || deviceInfoValue != null)
            {
                return(utEvent);
            }

            mergedCustomValues.Add(deviceInfoKey, this.defaultDeviceIdentifier);

            IUTEvent mergedEvent = new UTEvent(
                utEvent.Timestamp,
                mergedCustomValues,
                utEvent.DefinitionId,
                utEvent.ItemId,
                utEvent.EngagementValue,
                utEvent.ParentEventId,
                utEvent.Text,
                utEvent.Duration,
                utEvent.TrackingInteractionId,
                utEvent.type
                );

            return(mergedEvent);
        }