/// <summary> /// Create TelemetrySessionContext with the name /// </summary> /// <param name="contextName"></param> /// <param name="theHostedSession">Session which owns this context</param> /// <param name="theScheduler"></param> /// <param name="theOverrideInit"></param> /// <param name="initializationAction"></param> internal TelemetryContext(string contextName, TelemetrySession theHostedSession, ITelemetryScheduler theScheduler = null, bool theOverrideInit = false, Action <TelemetryContext> initializationAction = null) { if (!IsContextNameValid(contextName)) { throw new ArgumentException("contextName is invalid, contextName must contain alphanumeric characters only"); } CodeContract.RequiresArgumentNotNull <TelemetrySession>(theHostedSession, "theHostedSession"); if (theScheduler == null) { theScheduler = new TelemetryScheduler(); theScheduler.InitializeTimed(TimeSpan.FromSeconds(15.0)); } ContextName = contextName; hostSession = theHostedSession; scheduler = theScheduler; overrideInit = theOverrideInit; hostSession.AddContext(this); initializationAction?.Invoke(this); if (!overrideInit) { hostSession.PostValidatedEvent(BuildStartEvent()); } }
private static TelemetrySessionInitializer BuildInitializer(TelemetrySessionSettings telemetrySessionSettings) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); DiagnosticTelemetry diagnosticTelemetry = new DiagnosticTelemetry(); EnvironmentTools environmentTools = new EnvironmentTools(); RegistryTools registryTools = (RegistryTools)(object)new RegistryTools(); ProcessTools processTools = new ProcessTools(); ILegacyApi legacyApi = GetLegacyApi((IRegistryTools)(object)registryTools); IPersistentPropertyBag persistentStorage = CreatePersistentPropertyBag(string.Empty); IPersistentPropertyBag persistentPropertyBag = CreatePersistentPropertyBag("c57a9efce9b74de382d905a89852db71"); IMACInformationProvider mACInformationProvider = GetMACInformationProvider(processTools, persistentStorage, legacyApi); IInternalSettings internalSettings = GetInternalSettings(diagnosticTelemetry, (IRegistryTools)(object)registryTools); IHostInformationProvider hostInformationProvider = GetHostInformationProvider(); IUserInformationProvider userInformationProvider = GetUserInformationProvider((IRegistryTools)(object)registryTools, internalSettings, environmentTools, legacyApi, telemetrySessionSettings); MachineInformationProvider machineInformationProvider = new MachineInformationProvider(legacyApi, userInformationProvider, mACInformationProvider); IIdentityInformationProvider identityInformationProvider = GetIdentityInformationProvider(); IPersistentPropertyBag persistentPropertyBag2 = CreatePersistentPropertyBag(hostInformationProvider.ProcessName); TelemetryScheduler telemetryScheduler = new TelemetryScheduler(); OptOutAction optOutAction = new OptOutAction(); optOutAction.AddOptOutFriendlyEventName("vs/telemetryapi/session/initialized"); optOutAction.AddOptOutFriendlyEventName("context/postproperty"); optOutAction.AddOptOutFriendlyPropertiesList(new List <string> { "Context.Default.VS.Core.BranchName", "Context.Default.VS.Core.BuildNumber", "Context.Default.VS.Core.ExeName", "Context.Default.VS.Core.ExeVersion", "Context.Default.VS.Core.HardwareId", "Context.Default.VS.Core.MacAddressHash", "Context.Default.VS.Core.Machine.Id", "Context.Default.VS.Core.SkuName", "Context.Default.VS.Core.OS.Version", "Context.Default.VS.Core.ProcessId", "Context.Default.VS.Core.User.Id", "Context.Default.VS.Core.User.IsMicrosoftInternal", "Context.Default.VS.Core.User.IsOptedIn", "Context.Default.VS.Core.User.Location.GeoId", "Context.Default.VS.Core.User.Type", "Context.Default.VS.Core.Version", "Reserved.EventId", "Reserved.SessionId", "Reserved.TimeSinceSessionStart", "VS.Core.Locale.Product", "VS.Core.Locale.System", "VS.Core.Locale.User", "VS.Core.Locale.UserUI", "VS.Core.SkuId", "VS.Sqm.SkuId" }); ClientSideThrottlingAction item = new ClientSideThrottlingAction(new List <string> { "context/create", "context/close", "context/postproperty", "vs/core/command", "vs/core/extension/installed", "vs/core/sessionstart", "vs/core/sessionend", "vs/telemetryapi/session/initialized", "vs/telemetryapi/clientsidethrottling", "vs/telemetryapi/manifest/load", "vs/telemetryapi/piiproperties" }, 0.0, 0L); PIIPropertyProcessor pIIPropertyProcessor = new PIIPropertyProcessor(); PiiAction item2 = new PiiAction(pIIPropertyProcessor); ComplexPropertyAction item3 = new ComplexPropertyAction(new JsonComplexObjectSerializerFactory(), pIIPropertyProcessor); return(new TelemetrySessionInitializer { CancellationTokenSource = cancellationTokenSource, SessionId = Guid.NewGuid().ToString(), AppInsightsInstrumentationKey = "f144292e-e3b2-4011-ac90-20e5c03fbce5", AsimovInstrumentationKey = "AIF-312cbd79-9dbb-4c48-a7da-3cc2a931cb70", DiagnosticTelemetry = diagnosticTelemetry, IdentityTelemetry = new IdentityTelemetry(identityInformationProvider, telemetryScheduler), EnvironmentTools = environmentTools, RegistryTools = (IRegistryTools2)(object)registryTools, ProcessTools = processTools, LegacyApi = legacyApi, InternalSettings = internalSettings, HostInformationProvider = hostInformationProvider, MachineInformationProvider = machineInformationProvider, UserInformationProvider = userInformationProvider, MACInformationProvider = mACInformationProvider, EventProcessorScheduler = telemetryScheduler, TelemetryManifestManagerBuilder = new TelemetryManifestManagerBuilder(), DefaultContextPropertyManager = new DefaultContextPropertyManager(GetPropertyProviders((IRegistryTools)(object)registryTools, environmentTools, hostInformationProvider, machineInformationProvider, mACInformationProvider, userInformationProvider, persistentPropertyBag, identityInformationProvider)), PersistentStorage = persistentStorage, PersistentSharedProperties = persistentPropertyBag, PersistentPropertyBag = persistentPropertyBag2, ChannelValidators = new List <IChannelValidator> { new RegistryChannelValidator(internalSettings), new InternalChannelValidator(userInformationProvider), new DisabledTelemetryChannelValidator(internalSettings) }, CustomActionToAdd = new List <IEventProcessorAction> { optOutAction, new EnforceAIRestrictionAction(), item2, item3, new MetricAction(), new SettingAction(), item, new SuppressEmptyPostPropertyEventAction() }, EventProcessorChannelBuilder = new EventProcessorChannelBuilder(persistentPropertyBag2, telemetryScheduler), WatsonSessionChannelBuilder = new WatsonSessionChannelBuilder(internalSettings.FaultEventWatsonSamplePercent(), internalSettings.FaultEventMaximumWatsonReportsPerSession(), internalSettings.FaultEventMinimumSecondsBetweenWatsonReports(), ChannelProperties.Default), OptinStatusReader = GetOptInStatusReader((IRegistryTools2)(object)registryTools), ProcessCreationTime = GetProcessCreationTime() }); }