public static IMatsTelemetryClient CreateMats(IApplicationConfiguration applicationConfiguration, IPlatformProxy platformProxy, IMatsConfig matsConfig) { string dpti = platformProxy.GetDevicePlatformTelemetryId(); if (!IsDeviceEnabled(matsConfig.AudienceType, dpti)) { return(null); } string deviceNetworkState = platformProxy.GetDeviceNetworkState(); int osPlatformCode = platformProxy.GetMatsOsPlatformCode(); bool enableAggregation = true; IEventFilter eventFilter = new EventFilter(enableAggregation); var errorStore = new ErrorStore(); var scenarioStore = new ScenarioStore(TimeConstants.ScenarioTimeoutMilliseconds, errorStore); var allowedScopes = new HashSet <string>(); if (matsConfig.AllowedScopes != null) { foreach (string s in matsConfig.AllowedScopes) { allowedScopes.Add(s); } } var actionStore = new ActionStore( TimeConstants.ActionTimeoutMilliseconds, TimeConstants.AggregationWindowMilliseconds, errorStore, eventFilter, allowedScopes); var contextStore = ContextStore.CreateContextStore( matsConfig.AudienceType, applicationConfiguration.ClientName, applicationConfiguration.ClientVersion, dpti, deviceNetworkState, matsConfig.SessionId, osPlatformCode); IUploader uploader = new TelemetryUploader(matsConfig.DispatchAction, platformProxy, applicationConfiguration.ClientName); // it's this way in mats c++ bool isScenarioUploadDisabled = true; return(new MatsTelemetryClient( applicationConfiguration, platformProxy, errorStore, uploader, actionStore, scenarioStore, contextStore, isScenarioUploadDisabled)); }
public void AddContextCorrectlyAddsFieldsToPropertyBagContents() { string sessionId = "00000000-0000-0000-0000-000000000000"; var contextStore = ContextStore.CreateContextStore(TelemetryAudienceType.PreProduction, "AppName", "1.0", "deviceId", "deviceNetworkState", sessionId, 1); var propertyBag = new PropertyBag(EventType.Scenario, null); var propertyList = new List <IPropertyBag> { propertyBag }; contextStore.AddContext(propertyList); var contentsWithContext = propertyBag.GetContents(); Assert.AreEqual(MatsConverter.AsString(TelemetryAudienceType.PreProduction), contentsWithContext.StringProperties[ContextPropertyNames.AppAudienceConstStrKey]); Assert.AreEqual("AppName", contentsWithContext.StringProperties[ContextPropertyNames.AppNameConstStrKey]); Assert.AreEqual("1.0", contentsWithContext.StringProperties[ContextPropertyNames.AppVerConstStrKey]); Assert.AreEqual("deviceId", contentsWithContext.StringProperties[ContextPropertyNames.DptiConstStrKey]); Assert.AreEqual(sessionId, contentsWithContext.StringProperties[ContextPropertyNames.SessionIdConstStrKey]); Assert.AreEqual(1, contentsWithContext.IntProperties[ContextPropertyNames.PlatformConstStrKey]); }
public static ITelemetryClient CreateMats( IApplicationConfiguration applicationConfiguration, IPlatformProxy platformProxy, ITelemetryConfig telemetryConfig) { string dpti = platformProxy.GetDevicePlatformTelemetryId(); if (!IsDeviceEnabled(telemetryConfig.AudienceType, dpti)) { return(null); } string deviceNetworkState = platformProxy.GetDeviceNetworkState(); int osPlatformCode = platformProxy.GetMatsOsPlatformCode(); bool enableAggregation = true; IEventFilter eventFilter = new EventFilter(enableAggregation); var errorStore = new ErrorStore(); var scenarioStore = new ScenarioStore(TimeConstants.ScenarioTimeoutMilliseconds, errorStore); var allowedScopes = new HashSet <string>(); // TODO: need to determine what MATS was doing with the AllowedScopes and DeniedScopes values in the C++ impl // and possibly expose this value in the ITelemetryConfig interface. //if (telemetryConfig.AllowedScopes != null) //{ // foreach (string s in telemetryConfig.AllowedScopes) // { // allowedScopes.Add(s); // } //} var actionStore = new ActionStore( TimeConstants.ActionTimeoutMilliseconds, TimeConstants.AggregationWindowMilliseconds, errorStore, eventFilter, allowedScopes); var contextStore = ContextStore.CreateContextStore( telemetryConfig.AudienceType, applicationConfiguration.ClientName, applicationConfiguration.ClientVersion, dpti, deviceNetworkState, telemetryConfig.SessionId, osPlatformCode); IUploader uploader = new TelemetryUploader(telemetryConfig.DispatchAction, platformProxy, applicationConfiguration.ClientName); // it's this way in mats c++ bool isScenarioUploadDisabled = true; return(new TelemetryClient( applicationConfiguration, platformProxy, errorStore, uploader, actionStore, scenarioStore, contextStore, isScenarioUploadDisabled)); }