Example #1
0
 public MacMachinePropertyProvider(IMachineInformationProvider machineInformationProvider, IRegistryTools regTools, IMACInformationProvider macInformationProvider)
 {
     CodeContract.RequiresArgumentNotNull <IMachineInformationProvider>(machineInformationProvider, "machineInformationProvider");
     CodeContract.RequiresArgumentNotNull <IRegistryTools>(regTools, "regTools");
     CodeContract.RequiresArgumentNotNull <IMACInformationProvider>(macInformationProvider, "macInformationProvider");
     this.machineInformationProvider = machineInformationProvider;
     this.macInformationProvider     = macInformationProvider;
     memoryInformation = new Lazy <PerformanceCounter>(() => InitializeOSMemoryInformation(), false);
     systemInformation = new Lazy <SystemInfo>(() => InitializeSystemInformation(), false);
 }
 public MachineInformationProvider(ILegacyApi legacyApi, IUserInformationProvider userInformationProvider, IMACInformationProvider macInformationProvider)
 {
     CodeContract.RequiresArgumentNotNull <ILegacyApi>(legacyApi, "legacyApi");
     CodeContract.RequiresArgumentNotNull <IUserInformationProvider>(userInformationProvider, "userInformationProvider");
     CodeContract.RequiresArgumentNotNull <IMACInformationProvider>(macInformationProvider, "macInformationProvider");
     this.legacyApi = legacyApi;
     this.userInformationProvider = userInformationProvider;
     this.macInformationProvider  = macInformationProvider;
     machineId = new Lazy <Guid>(() => CalculateMachineId(), LazyThreadSafetyMode.ExecutionAndPublication);
 }
Example #3
0
 public WindowsMachinePropertyProvider(IMachineInformationProvider machineInformationProvider, IRegistryTools regTools, IMACInformationProvider macInformationProvider)
 {
     CodeContract.RequiresArgumentNotNull <IMachineInformationProvider>(machineInformationProvider, "machineInformationProvider");
     CodeContract.RequiresArgumentNotNull <IRegistryTools>(regTools, "regTools");
     CodeContract.RequiresArgumentNotNull <IMACInformationProvider>(macInformationProvider, "macInformationProvider");
     this.machineInformationProvider = machineInformationProvider;
     registryTools = regTools;
     this.macInformationProvider = macInformationProvider;
     memoryInformation           = new Lazy <NativeMethods.MemoryStatus>(() => InitializeOSMemoryInformation(), false);
     systemInformation           = new Lazy <NativeMethods.SystemInfo>(() => InitializeSystemInformation(), false);
     processorDescription        = new Lazy <string>(() => InitializeProcessorDescription(), false);
     processorFrequency          = new Lazy <int?>(() => registryTools.GetRegistryIntValueFromLocalMachineRoot("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "~MHz", (int?)null), false);
     azureVMImageName            = new Lazy <string>(() => InitializeAzureVMImageName(), false);
 }
Example #4
0
        /// <summary>
        /// Set up telemetry session properties
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="initializerObject"></param>
        /// <param name="isCloned"></param>
        private TelemetrySession(TelemetrySessionSettings settings, bool isCloned, TelemetrySessionInitializer initializerObject)
        {
            CodeContract.RequiresArgumentNotNull <TelemetrySessionInitializer>(initializerObject, "initializerObject");
            initializerObject.Validate();
            initializerObject.AppInsightsInstrumentationKey = settings.AppInsightsInstrumentationKey;
            initializerObject.AsimovInstrumentationKey      = settings.AsimovInstrumentationKey;
            TelemetryService.EnsureEtwProviderInitialized();
            sessionInitializer      = initializerObject;
            sessionSettings         = settings;
            isSessionCloned         = isCloned;
            cancellationTokenSource = initializerObject.CancellationTokenSource;
            diagnosticTelemetry     = initializerObject.DiagnosticTelemetry;
            identityTelemetry       = initializerObject.IdentityTelemetry;
            optinStatusReader       = initializerObject.OptinStatusReader;
            channelValidators       = initializerObject.ChannelValidators;
            telemetryBufferChannel  = new TelemetryBufferChannel();
            initializerObject.WatsonSessionChannelBuilder.Build(this);
            WatsonSessionChannel sessionChannel = initializerObject.WatsonSessionChannelBuilder.WatsonSessionChannel;

            if (IsValidChannel(sessionChannel))
            {
                watsonSessionChannel = sessionChannel;
            }
            machineInformationProvider    = initializerObject.MachineInformationProvider;
            macInformationProvider        = initializerObject.MACInformationProvider;
            userInformationProvider       = initializerObject.UserInformationProvider;
            defaultContextPropertyManager = initializerObject.DefaultContextPropertyManager;
            persistentPropertyBag         = initializerObject.PersistentPropertyBag;
            initializerObject.EventProcessorChannelBuilder.Build(this);
            persistentSharedProperties = initializerObject.PersistentSharedProperties;
            EventProcessor             = initializerObject.EventProcessorChannelBuilder.EventProcessor;
            if (initializerObject.CustomActionToAdd != null)
            {
                foreach (IEventProcessorAction item in initializerObject.CustomActionToAdd)
                {
                    EventProcessor.AddCustomAction(item);
                }
            }
            eventProcessorChannel    = initializerObject.EventProcessorChannelBuilder.EventProcessorChannel;
            telemetryManifestManager = new Lazy <ITelemetryManifestManager>(() => initializerObject.TelemetryManifestManagerBuilder.Build(this));
            contextScheduler         = initializerObject.ContextScheduler;
            if (initializerObject.ChannelsToAdd != null)
            {
                AddSessionChannels(initializerObject.ChannelsToAdd);
            }
            defaultContext = CreateDefaultContext();
            macInformationProvider.MACAddressHashCalculationCompleted += MACAddressHashCalculationCompleted;
            identityTelemetry.IdentityInformationProvider.HardwareIdCalculationCompleted += HardwareIdCalculationCompleted;
        }
Example #5
0
        private static IEnumerable <IPropertyProvider> GetPropertyProviders(IRegistryTools registryTools, IEnvironmentTools environmentTools, IHostInformationProvider host, IMachineInformationProvider machine, IMACInformationProvider macAddress, IUserInformationProvider user, IPersistentPropertyBag sharedProperties, IIdentityInformationProvider identity)
        {
            yield return(new IdentityPropertyProvider());

            if (Platform.IsMac)
            {
                yield return(new MacHostPropertyProvider(host, new NsBundleInformationProvider()));

                yield return(new AssemblyPropertyProvider());

                yield return(new MacLocalePropertyProvider());

                yield return(new MacMachinePropertyProvider(machine, registryTools, macAddress));

                yield return(new MacOSPropertyProvider(environmentTools));

                yield return(new MacUserPropertyProvider(user));

                yield return(new PersistentSharedPropertyProvider(sharedProperties));
            }
            else if (Platform.IsLinux)
            {
                yield return(new LinuxHostPropertyProvider(host));

                yield return(new AssemblyPropertyProvider());

                yield return(new LinuxLocalePropertyProvider());

                yield return(new PersistentSharedPropertyProvider(sharedProperties));
            }
            else
            {
                yield return(new WindowsHostPropertyProvider(host));

                yield return(new AssemblyPropertyProvider());

                yield return(new WindowsLocalePropertyProvider(registryTools));

                yield return(new WindowsMachinePropertyProvider(machine, registryTools, macAddress));

                yield return(new WindowsOSPropertyProvider(environmentTools, registryTools));

                yield return(new WindowsUserPropertyProvider(user));

                yield return(new PersistentSharedPropertyProvider(sharedProperties));
            }
        }
Example #6
0
        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()
            });
        }