public async Task <GoogleExperiment> CreateExperimentAsync(string profileId, string name, int?nodeId = null) { var command = new CreateExperiment(AnalyticsAccount.GetByUniqueId(profileId), name, nodeId == null, nodeId); return(await ExecuteAsync(command)); }
public async Task DeleteVariationAsync(string profileId, [FromBody] DeleteVariationRequest request) { await ExecuteAsync(new DeleteVariation(AnalyticsAccount.GetByUniqueId(profileId)) { GoogleExperimentId = request.ExperimentId, VariationName = request.VariationName }); }
public override Task <ActionResult> IndexAsync(AuthorizationCodeResponseUrl authorizationCode, CancellationToken taskCancellationToken) { var stateWithoutRandomToken = authorizationCode.State.Substring(0, authorizationCode.State.Length - AuthorizationCodeWebApp.StateRandomLength); var uri = new Uri(stateWithoutRandomToken); var profileId = uri.ParseQueryString().Get("profileId"); var config = AnalyticsAccount.GetByUniqueId(profileId); _flowData = new uSplitFlowMetadata(config); return(base.IndexAsync(authorizationCode, taskCancellationToken)); }
public async Task <IHttpActionResult> SetSegmentAsync(string profileId, [FromBody] SetSegmentRequest request) { await ExecuteAsync(new SetSegment(AnalyticsAccount.GetByUniqueId(profileId)) { ExperimentId = request.ExperimentId, ProviderKey = request.ProviderKey, Value = request.Value }); return(Ok()); }
public async Task <HttpResponseMessage> AddVariationAsync(string profileId, [FromBody] AddVariationRequest request) { var variationDetails = await ExecuteAsync(new AddVariation(AnalyticsAccount.GetByUniqueId(profileId)) { Name = request.Name, GoogleExperimentId = request.ExperimentId, NodeId = request.NodeId }); return(CreateResponse(variationDetails)); }
public async Task <HttpResponseMessage> StopExperimentAsync(string id, string profileId) { var experiment = await ExecuteAsync(new StopExperiment(AnalyticsAccount.GetByUniqueId(profileId), id)); var details = await ExecuteAsync(new GetExperimentDetails() { Experiment = experiment }); return(CreateResponse(details)); }
public async Task <ActionResult> ReauthorizeAsync(string originalUrl, string profileId, CancellationToken cancellationToken) { var config = AnalyticsAccount.GetByUniqueId(profileId); var flow = uSplitAuthorizationCodeFlow.GetInstance(config); if (await flow.IsConnected(cancellationToken)) { await flow.DeleteTokenAsync(Constants.Google.SystemUserId, cancellationToken); } return(RedirectToAction(nameof(AuthorizeAsync), new { originalUrl, profileId })); }
public async Task <ActionResult> AuthorizeAsync(string originalUrl, string profileId, CancellationToken cancellationToken) { var config = AnalyticsAccount.GetByUniqueId(profileId); var result = await new AuthorizationCodeMvcApp(this, new uSplitFlowMetadata(config)).AuthorizeAsync(cancellationToken); if (result.Credential == null) { //no token, lets go to Google return(new RedirectResult(result.RedirectUri)); } //refresh the experiments cache await ExperimentsUpdater.Instance.UpdateExperimentsCacheAsync(); //got a token, we can return back return(new RedirectResult(originalUrl)); }
public async Task DeleteExperimentAsync(string id, string profileId) { var accountConfigs = AnalyticsAccount.GetAll().ToList(); AnalyticsAccount config; if ((id.IsNullOrWhiteSpace() || id == "-1") && accountConfigs.Count == 1) { config = accountConfigs.First(); } else { config = AnalyticsAccount.GetByUniqueId(profileId); } //TODO: add an option to delete variations (e.g. Umbraco content linked to it) await ExecuteAsync(new DeleteExperiment(config) { GoogleExperimentId = id }); }
public async Task <bool> Status(string profileId, CancellationToken cancellationToken) { var config = AnalyticsAccount.GetByUniqueId(profileId); return(await uSplitAuthorizationCodeFlow.GetInstance(config).IsConnected(cancellationToken)); }