/// <summary> /// Lists CustomMetrics to which the user has access. /// Documentation: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/customMetrics/list /// </summary> /// <param name="service">Valid authenticated Analytics Service</param> /// <param name="accountId">Account Id </param> /// <param name="webPropertyId">Web property Id</param> /// <returns>CCustomMetric resource https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/customMetrics#resource </returns> public static IList <CustomMetric> CustomDimensionList(AnalyticsService service, string accountId, string webPropertyId) { ManagementResource.CustomMetricsResource.ListRequest list = service.Management.CustomMetrics.List(accountId, webPropertyId); list.MaxResults = 1000; CustomMetrics feed = list.Execute(); List <CustomMetric> returnList = new List <CustomMetric>(); //// Loop through until we arrive at an empty page while (feed.Items != null) { //Adding items to return list. returnList.AddRange(feed.Items); // We will know we are on the last page when the next page token is // null. // If this is the case, break. if (feed.NextLink == null) { break; } // Prepare the next page of results list.StartIndex = feed.StartIndex + list.MaxResults; // Execute and process the next page request feed = list.Execute(); } return(returnList); }
IDictionary <string, string> GetRequiredPayloadData(string hitType, bool isNonInteractive, SessionControl sessionControl) { var result = new Dictionary <string, string>(); result.Add("v", "1"); result.Add("tid", PropertyId); result.Add("cid", AnonymousClientId); result.Add("an", AppName); result.Add("av", AppVersion); result.Add("t", hitType); if (ScreenName != null) { result.Add("cd", ScreenName); } if (isNonInteractive) { result.Add("ni", "1"); } if (AnonymizeIP) { result.Add("aip", "1"); } if (sessionControl != SessionControl.None) { result.Add("sc", sessionControl == SessionControl.Start ? "start" : "end"); } if (ScreenResolution.HasValue) { result.Add("sr", string.Format("{0}x{1}", ScreenResolution.Value.Width, ScreenResolution.Value.Height)); } if (ViewportSize.HasValue) { result.Add("vp", string.Format("{0}x{1}", ViewportSize.Value.Width, ViewportSize.Value.Height)); } if (UserLanguage != null) { result.Add("ul", UserLanguage.ToLowerInvariant()); } if (ScreenColorDepthBits.HasValue) { result.Add("sd", string.Format("{0}-bits", ScreenColorDepthBits.Value)); } if (DocumentEncoding != null) { result.Add("de", DocumentEncoding); } foreach (var dimension in CustomDimensions) { result.Add(string.Format("cd{0}", dimension.Key), dimension.Value); } foreach (var metric in CustomMetrics) { result.Add(string.Format("cm{0}", metric.Key), metric.Value.ToString(CultureInfo.InvariantCulture)); } CustomDimensions.Clear(); CustomMetrics.Clear(); return(result); }
/// <summary> /// Provide a copy of this instance containing only the information required to represent it in a save request /// </summary> /// <returns>A copy of this instance containing only the information required to represent it in a save /// request</returns> internal override ScorecardTemplateItem ConvertToSaveSchema() { return(new PatientScorecardItem() { Name = Name, ComputedMetrics = ComputedMetrics, CustomMetrics = CustomMetrics.Select(c => c.ConvertToScorecardSchema()).ToList() }); }
/// <summary> /// Helper to construct a ProKnowApi object /// </summary> /// <param name="baseUrl">The base URL to ProKnow, e.g. 'https://example.proknow.com'</param> /// <param name="credentialsId">The ID from the ProKnow credentials JSON file</param> /// <param name="credentialsSecret">The secret from the ProKnow credentials JSON file</param> /// <param name="lockRenewalBuffer">The number of seconds to use as a buffer when renewing a lock for a draft /// structure set</param> private void ConstructorHelper(string baseUrl, string credentialsId, string credentialsSecret, int lockRenewalBuffer) { LockRenewalBuffer = lockRenewalBuffer; Requestor = new Requestor(baseUrl, credentialsId, credentialsSecret); CustomMetrics = new CustomMetrics(this); ScorecardTemplates = new ScorecardTemplates(this); Workspaces = new Workspaces(this); Roles = new Roles(this); Users = new Users(this); Uploads = new Uploads(this); Patients = new Patients(this); Collections = new Collections(this); Audit = new Audits(this); }
public void GetCustomMetrics() { Google.Apis.Analytics.v3.ManagementResource.CustomMetricsResource.ListRequest request = analyticsService.Management.CustomMetrics.List(DefaultAccount.Id, DefaultProfile.WebPropertyId); try { var dimensions = request.Execute(); if (CustomMetrics == null) { CustomMetrics = new List <Google.Apis.Analytics.v3.Data.CustomMetric>(); } foreach (var item in dimensions.Items) { CustomMetrics.Add(item); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public Management.Data.CustomMetric CreateCustomMetric(string name, bool isActive) { Google.Apis.Analytics.v3.Data.CustomMetric dimension = new Google.Apis.Analytics.v3.Data.CustomMetric() { Active = isActive, AccountId = DefaultAccount.Id, Name = name, Scope = "HIT", WebPropertyId = DefaultProfile.WebPropertyId }; Google.Apis.Analytics.v3.ManagementResource.CustomMetricsResource.InsertRequest request = analyticsService.Management.CustomMetrics.Insert(dimension, DefaultAccount.Id, DefaultProfile.WebPropertyId); try { dimension = request.Execute(); CustomMetrics.Add(dimension); Management.Data.CustomMetric d = new Management.Data.CustomMetric() { Id = dimension.Id, Index = dimension.Index, Name = dimension.Name }; return(d); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(null); }
private IDictionary <string, string> GetRequiredPayloadData(string hitType, bool isNonInteractive, SessionControl sessionControl) { var result = new Dictionary <string, string>(); result.Add("v", "1"); result.Add("tid", PropertyId); result.Add("cid", AnonymousClientId); result.Add("an", AppName); result.Add("av", AppVersion); result.Add("t", hitType); if (AppId != null) { result.Add("aid", AppId); } if (AppInstallerId != null) { result.Add("aiid", AppInstallerId); } if (ScreenName != null) { result.Add("cd", ScreenName); } if (isNonInteractive) { result.Add("ni", "1"); } if (AnonymizeIP) { result.Add("aip", "1"); } if (sessionControl != SessionControl.None) { result.Add("sc", sessionControl == SessionControl.Start ? "start" : "end"); } if (ScreenResolution != null) { result.Add("sr", string.Format("{0}x{1}", ScreenResolution.Width, ScreenResolution.Height)); } if (ViewportSize != null) { result.Add("vp", string.Format("{0}x{1}", ViewportSize.Width, ViewportSize.Height)); } if (UserLanguage != null) { result.Add("ul", UserLanguage); } if (ScreenColorDepthBits.HasValue) { result.Add("sd", string.Format("{0}-bits", ScreenColorDepthBits.Value)); } if (CampaignName != null) { result.Add("cn", CampaignName); } if (CampaignSource != null) { result.Add("cs", CampaignSource); } if (CampaignMedium != null) { result.Add("cm", CampaignMedium); } if (CampaignKeyword != null) { result.Add("ck", CampaignKeyword); } if (CampaignContent != null) { result.Add("cc", CampaignContent); } if (CampaignId != null) { result.Add("ci", CampaignId); } // other params available but not usually used for apps if (Referrer != null) { result.Add("dr", Referrer); } if (DocumentEncoding != null) { result.Add("de", DocumentEncoding); } if (GoogleAdWordsId != null) { result.Add("gclid", GoogleAdWordsId); } if (GoogleDisplayAdsId != null) { result.Add("dclid", GoogleDisplayAdsId); } if (IpOverride != null) { result.Add("uip", IpOverride); } if (UserAgentOverride != null) { result.Add("ua", UserAgentOverride); } if (DocumentLocationUrl != null) { result.Add("dl", DocumentLocationUrl); } if (DocumentHostName != null) { result.Add("dh", DocumentHostName); } if (DocumentPath != null) { result.Add("dp", DocumentPath); } if (DocumentTitle != null) { result.Add("dt", DocumentTitle); } if (LinkId != null) { result.Add("linkid", LinkId); } if (ExperimentId != null) { result.Add("xid", ExperimentId); } if (ExperimentVariant != null) { result.Add("xvar", ExperimentVariant); } if (DataSource != null) { result.Add("ds", DataSource); } if (UserId != null) { result.Add("uid", UserId); } if (GeographicalId != null) { result.Add("geoid", GeographicalId); } foreach (var dimension in CustomDimensions) { result.Add(string.Format("cd{0}", dimension.Key), dimension.Value); } foreach (var metric in CustomMetrics) { result.Add(string.Format("cm{0}", metric.Key), metric.Value.ToString(CultureInfo.InvariantCulture)); } CustomDimensions.Clear(); CustomMetrics.Clear(); return(result); }
static void Main(string[] args) { Logger.SetLevel(LogLevel.DEBUG); Console.WriteLine("c# prog running"); var constantTags = new Dictionary<string, string> { {"game", "game"}, {"serverType", "svType"} }; AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs args) => { Console.WriteLine("shutting down pitaya cluster"); PitayaCluster.Terminate(); }; var customMetrics = new CustomMetrics(); customMetrics.AddHistogram( "my_histogram", new HistogramBuckets(HistogramBucketKind.Linear, 1, 2, 10), "Some test histogram", new []{"my_label"}); var metricsParameters = new MetricsConfiguration( true, "127.0.0.1", "8000", "myns", customMetrics); try { PitayaCluster.Initialize( "exampleapp", "csharp.toml", new Server( id: Guid.NewGuid().ToString(), kind: "csharp", metadata: "{}", hostname: "ololo", frontend: false ), NativeLogLevel.Debug, NativeLogKind.Console, (msg) => { Console.Write($"C# Log: {msg}"); }, metricsParameters, new PitayaCluster.ServiceDiscoveryListener((action, server) => { switch (action) { case PitayaCluster.ServiceDiscoveryAction.ServerAdded: Console.WriteLine("Server was added"); Console.WriteLine(" id: " + server.Id); Console.WriteLine(" kind: " + server.Kind); break; case PitayaCluster.ServiceDiscoveryAction.ServerRemoved: Console.WriteLine("Server was removed"); Console.WriteLine(" id: " + server.Id); Console.WriteLine(" kind: " + server.Kind); break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } })); } catch (PitayaException exc) { Logger.Error("Failed to create cluster: {0}", exc.Message); Environment.Exit(1); } Logger.Info("pitaya lib initialized successfully :)"); PitayaCluster.RegisterRemote(new TestRemote()); PitayaCluster.RegisterHandler(new TestHandler()); TrySendRpc(); PitayaCluster.WaitShutdownSignal(); }
public ToolViewViewModel( IKCVDBClient client, string sessionId, IDispatcher dispatcher) : base(dispatcher) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (sessionId == null) { throw new ArgumentNullException(nameof(sessionId)); } Client = client; SessionId = sessionId; // Register metrics CustomMetrics.Add(new StartedTimeMetrics(DateTimeOffset.Now)); CustomMetrics.Add(new TransferredApiCountMetrics(Client)); CustomMetrics.Add(new SuccessCountMetrics(Client)); CustomMetrics.Add(new FailureCountMetrics(Client)); CustomMetrics.Add(new TransferredDataAmountMetrics(Client)); CustomMetrics.Add(new TransferredDataAmountPerHourMetrics(Client)); // Register a listener to update history Observable.FromEventPattern <ApiDataSentEventArgs>(Client, nameof(Client.ApiDataSent)) .Select(x => x.EventArgs) .Select(x => { var now = DateTimeOffset.Now; return(x.ApiData.Select(apiData => new HistoryItem { Time = now, Body = apiData.RequestUri.PathAndQuery, Success = true, })); }) .SubscribeOnDispatcher(System.Windows.Threading.DispatcherPriority.Normal) .Subscribe(historyItems => { try { HistoryItems = new ObservableCollection <HistoryItem>( historyItems.Reverse().Concat(HistoryItems).Take(MaxHistoryCount)); } catch (Exception ex) { TelemetryClient.TrackException("Failed to update history.", ex); if (ex.IsCritical()) { throw; } } }); // Register a listener to notify chinese option chaning Subscriptions.Add(Observable.FromEventPattern <PropertyChangedEventArgs>(Settings.Default, nameof(Settings.PropertyChanged)) .Where(x => x.EventArgs.PropertyName == nameof(Settings.ShowTraditionalChinese)) .SubscribeOnDispatcher() .Subscribe(_ => { try { RaisePropertyChanged(nameof(EnableSendingTelemetry)); RaisePropertyChanged(nameof(ShowTraditionalChinese)); } catch (Exception ex) { TelemetryClient.TrackException("Failed to raise property chaning of show traditional chinese option", ex); if (ex.IsCritical()) { throw; } } })); // Register a listener to receive language switching event Subscriptions.Add(Observable.FromEventPattern <PropertyChangedEventArgs>(ResourceHolder.Instance, nameof(ResourceHolder.PropertyChanged)) .Where(x => x.EventArgs.PropertyName == nameof(ResourceHolder.Culture)) .SubscribeOnDispatcher() .Subscribe(_ => { try { CurrentLanguageTwoLetterName = ResourceHolder.Instance.Culture?.TwoLetterISOLanguageName; } catch (Exception ex) { TelemetryClient.TrackException("Failed to update current language two letter name.", ex); if (ex.IsCritical()) { throw; } } })); CurrentLanguageTwoLetterName = ResourceHolder.Instance.Culture?.TwoLetterISOLanguageName; }