private void ValidateRequest(IUTSessionConfig config) { if (null == config) { throw new ArgumentNullException(nameof(SessionConfigUrlBuilder), " ValidateRequest() : do not pass null"); } }
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 void CheckResponseForValidInteraction(UTResponse response) { //FIXME: @igk a special error code required!!! if (response.Errors != null && response.Errors.Count > 0 && response.Errors[0].Contains("not a valid tracking interaction ID")) { this.sessionConfig = new UTSessionConfig(this.sessionConfig.InstanceUrl); } }
public virtual string BuildUrlString(IUTSessionConfig config) { this.ValidateRequest(config); string autocompletedInstanceUrl = SessionConfigValidator.AutocompleteInstanceUrlWithHttps(config.InstanceUrl); return(autocompletedInstanceUrl.ToLowerInvariant()); }
public ITrackInteractionRequest FillTrackInteractionGaps(ITrackInteractionRequest userRequest) { var utInteraction = userRequest.Interaction.DeepCopyUTInteraction(); IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); return(new TrackInteractionParameters(mergedSessionConfig, utInteraction)); }
public virtual ICompleteInteractionRequest DeepCopyCompleteInteractionRequest() { IUTSessionConfig connection = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } return(new CompleteInteractionParameters(connection)); }
public ITrackEventRequest FillTrackEventGaps(ITrackEventRequest userRequest) { IUTEvent utEvent = userRequest.Event.DeepCopyUTEvent(); //order matters! IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); utEvent = this.ApplyActiveInteraction(utEvent, mergedSessionConfig); utEvent = this.ApplyDeviceIdentifier(utEvent); return(new TrackEventParameters(mergedSessionConfig, utEvent)); }
public IUTSessionConfig FillSessionConfigGaps(IUTSessionConfig userConfig) { if (null == userConfig) { return(this.defaultSessionConfig); } var result = new SessionConfigPOD(); result.InstanceUrl = userConfig.InstanceUrl ?? this.defaultSessionConfig.InstanceUrl; return(result); }
public ITrackPageViewRequest FillTrackPageViewGaps(ITrackPageViewRequest userRequest) { var utPageView = userRequest.PageView.DeepCopyUTPageView(); //order matters! IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); var utEvent = this.ApplyActiveInteraction(utPageView, mergedSessionConfig); utEvent = this.ApplyDeviceIdentifier(utEvent); utPageView = new UTPageView(utEvent, utPageView.ItemLanguage, utPageView.ItemVersion, utPageView.Url, utPageView.SitecoreRenderingDevice); return(new TrackPageViewParameters(mergedSessionConfig, utPageView)); }
public ITrackOutcomeRequest FillTrackOutcomeGaps(ITrackOutcomeRequest userRequest) { var utOutcome = userRequest.Outcome.DeepCopyUTOutcome(); //order matters! IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); var utEvent = this.ApplyActiveInteraction(utOutcome, mergedSessionConfig); utEvent = this.ApplyDeviceIdentifier(utEvent); utOutcome = new UTOutcome(utEvent, utOutcome.CurrencyCode, utOutcome.MonetaryValue); return(new TrackOutcomeParameters(mergedSessionConfig, utOutcome)); }
public ITrackCampaignRequest FillTrackCampaignGaps(ITrackCampaignRequest userRequest) { var utCampaign = userRequest.Campaign.DeepCopyUTCampaign(); //order matters! IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); var utEvent = this.ApplyActiveInteraction(utCampaign, mergedSessionConfig); utEvent = this.ApplyDeviceIdentifier(utEvent); utCampaign = new UTCampaign(utEvent, utCampaign.CampaignDefinitionId); return(new TrackCampaignParameters(mergedSessionConfig, utCampaign)); }
public ITrackGoalRequest FillTrackGoalGaps(ITrackGoalRequest userRequest) { var utGoal = userRequest.Goal.DeepCopyUTGoal(); //order matters! IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); var utEvent = this.ApplyActiveInteraction(utGoal, mergedSessionConfig); utEvent = this.ApplyDeviceIdentifier(utEvent); utGoal = new UTGoal(utEvent); return(new TrackGoalParameters(mergedSessionConfig, utGoal)); }
public ITrackDownloadRequest FillTrackDownloadGaps(ITrackDownloadRequest userRequest) { var utDownload = userRequest.Download.DeepCopyUTDownload(); //order matters! IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); var utEvent = this.ApplyActiveInteraction(utDownload, mergedSessionConfig); utEvent = this.ApplyDeviceIdentifier(utEvent); utDownload = new UTDownload(utEvent); return(new TrackDownloadParameters(mergedSessionConfig, utDownload)); }
public ITrackSearchRequest FillTrackSearchGaps(ITrackSearchRequest userRequest) { var utSearch = userRequest.SearchEvent.DeepCopyUTSearch(); //order matters! IUTSessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionConfig); var utEvent = this.ApplyActiveInteraction(utSearch, mergedSessionConfig); utEvent = this.ApplyDeviceIdentifier(utEvent); utSearch = new UTSearch(utEvent, utSearch.Keywords); return(new TrackSearchParameters(mergedSessionConfig, utSearch)); }
public virtual ITrackPageViewRequest DeepCopyTrackPageViewRequest() { IUTSessionConfig connection = null; IUTPageView utPageView = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.PageView) { utPageView = this.PageView; } return(new TrackPageViewParameters(connection, utPageView)); }
public virtual ITrackOutcomeRequest DeepCopyTrackOutcomeRequest() { IUTSessionConfig connection = null; IUTOutcome utOutcome = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.Outcome) { utOutcome = this.Outcome; } return(new TrackOutcomeParameters(connection, utOutcome)); }
public virtual ITrackCampaignRequest DeepCopyTrackCampaignRequest() { IUTSessionConfig connection = null; IUTCampaign utCampaign = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.Campaign) { utCampaign = this.Campaign; } return(new TrackCampaignParameters(connection, utCampaign)); }
public virtual ITrackGoalRequest DeepCopyTrackGoalRequest() { IUTSessionConfig connection = null; IUTGoal utGoal = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.Goal) { utGoal = this.Goal; } return(new TrackGoalParameters(connection, utGoal)); }
public virtual ITrackSearchRequest DeepCopySearchRequest() { IUTSessionConfig connection = null; IUTSearch utSearch = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.SearchEvent) { utSearch = this.SearchEvent; } return(new TrackSearchParameters(connection, utSearch)); }
public virtual ITrackEventRequest DeepCopyTrackEventRequest() { IUTSessionConfig connection = null; IUTEvent uTEvent = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.Event) { uTEvent = this.Event; } return(new TrackEventParameters(connection, uTEvent)); }
public virtual ITrackInteractionRequest DeepCopyTrackInteractionRequest() { IUTSessionConfig connection = null; IUTInteraction uTInteraction = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.Interaction) { uTInteraction = this.Interaction; } return(new TrackInteractionParameters(connection, uTInteraction)); }
public virtual ITrackDownloadRequest DeepCopyTrackDownloadRequest() { IUTSessionConfig connection = null; IUTDownload utDownload = null; if (null != this.SessionConfig) { connection = this.SessionConfig.SessionConfigShallowCopy(); } if (null != this.Download) { utDownload = this.Download; } return(new TrackDownloadParameters(connection, utDownload)); }
public async Task <UTResponse> CompleteCurrentInteractionAsync(CancellationToken cancelToken = default(CancellationToken)) { if (this.InteractionNotExists()) { return(new UTResponse(400, "No active interaction found", null)); } ICompleteInteractionRequest request = new CompleteInteractionParameters(this.sessionConfig); var urlBuilder = new CompleteInteractionUrlBuilder <ICompleteInteractionRequest>(this.utGrammar); var taskFlow = new CompleteInteractionTask(urlBuilder, this.httpClient); var response = await RestApiCallFlow.LoadRequestFromNetworkFlow(request, taskFlow, cancelToken); if (response.Successful) { this.sessionConfig = new UTSessionConfig(this.sessionConfig.InstanceUrl); } return(response); }
public async Task <UTResponse> TrackInteractionAsync(ITrackInteractionRequest request, CancellationToken cancelToken) { BaseValidator.CheckNullAndThrow(request, this.GetType().Name + ".request"); ITrackInteractionRequest requestCopy = request.DeepCopyTrackInteractionRequest(); ITrackInteractionRequest autocompletedRequest = this.requestMerger.FillTrackInteractionGaps(requestCopy); var urlBuilder = new TrackInteractionUrlBuilder <ITrackInteractionRequest>(this.utGrammar); var taskFlow = new TrackInteractionTask(urlBuilder, this.httpClient); var response = await RestApiCallFlow.LoadRequestFromNetworkFlow(autocompletedRequest, taskFlow, cancelToken); if (response.Successful) { //@igk order matters this.sessionConfig = new UTSessionConfig(this.sessionConfig.InstanceUrl, response.Description); this.requestMerger = new UserRequestMerger(this.sessionConfig, this.defaultDeviceIdentifier); } return(response); }
private IUTEvent ApplyActiveInteraction(IUTEvent utEvent, IUTSessionConfig sessionConfig) { if (utEvent.TrackingInteractionId != null || sessionConfig.ActiveInteractionId == null) { return(utEvent); } IUTEvent mergedEvent = new UTEvent( utEvent.Timestamp, utEvent.CustomValues, utEvent.DefinitionId, utEvent.ItemId, utEvent.EngagementValue, utEvent.ParentEventId, utEvent.Text, utEvent.Duration, sessionConfig.ActiveInteractionId, utEvent.type ); return(mergedEvent); }
public UserRequestMerger(IUTSessionConfig sessionConfig, string deviceIdentifier) { this.SessionConfigMerger = new SessionConfigMerger(sessionConfig); this.defaultDeviceIdentifier = deviceIdentifier; }
public SessionConfigMerger(IUTSessionConfig defaultSessionConfig) { this.defaultSessionConfig = defaultSessionConfig; this.Validate(); }
public TrackInteractionParameters(IUTSessionConfig sessionConfig, IUTInteraction uTInteraction) { this.SessionConfig = sessionConfig; this.Interaction = uTInteraction; }
public TrackDownloadParameters(IUTSessionConfig sessionConfig, IUTDownload utDownload) { this.SessionConfig = sessionConfig; this.Download = utDownload; }
public TrackOutcomeParameters(IUTSessionConfig sessionConfig, IUTOutcome utOutcome) { this.SessionConfig = sessionConfig; this.Outcome = utOutcome; }