@@ -39,19 +39,23 @@ using namespace ::AppInstaller::CLI::Execution;
39
39
40
40
namespace winrt ::Microsoft::Management::Deployment::implementation
41
41
{
42
- PackageManager::PackageManager ()
42
+ namespace
43
43
{
44
- auto previousThreadGlobals = m_threadGlobals.SetForCurrentThread ();
45
- // Immediately reset as we only want the thread globals for logging within this object.
46
- previousThreadGlobals.reset ();
47
- // TODO: Disable summary until we log more and have meaningful summary to be sent in the future.
48
- m_threadGlobals.GetTelemetryLogger ().SetUseSummary (false );
49
- m_threadGlobals.GetTelemetryLogger ().SetCaller (GetCallerName ());
50
- m_threadGlobals.GetTelemetryLogger ().LogStartup (true );
44
+ void LogStartupIfApplicable ()
45
+ {
46
+ static std::once_flag logStartupOnceFlag;
47
+ std::call_once (logStartupOnceFlag,
48
+ [&]()
49
+ {
50
+ ::AppInstaller::Logging::Telemetry ().SetCaller(GetCallerName());
51
+ ::AppInstaller::Logging::Telemetry ().LogStartup(true );
52
+ });
53
+ }
51
54
}
52
55
53
56
winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Management::Deployment::PackageCatalogReference> PackageManager::GetPackageCatalogs ()
54
57
{
58
+ LogStartupIfApplicable ();
55
59
Windows::Foundation::Collections::IVector<Microsoft::Management::Deployment::PackageCatalogReference> catalogs{ winrt::single_threaded_vector<Microsoft::Management::Deployment::PackageCatalogReference>() };
56
60
std::vector<::AppInstaller::Repository::SourceDetails> sources = ::AppInstaller::Repository::Source::GetCurrentSources ();
57
61
for (uint32_t i = 0 ; i < sources.size (); i++)
@@ -68,6 +72,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation
68
72
69
73
winrt::Microsoft::Management::Deployment::PackageCatalogReference PackageManager::GetPredefinedPackageCatalog (winrt::Microsoft::Management::Deployment::PredefinedPackageCatalog const & predefinedPackageCatalog)
70
74
{
75
+ LogStartupIfApplicable ();
71
76
::AppInstaller::Repository::Source source;
72
77
switch (predefinedPackageCatalog)
73
78
{
@@ -92,6 +97,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation
92
97
93
98
winrt::Microsoft::Management::Deployment::PackageCatalogReference PackageManager::GetLocalPackageCatalog (winrt::Microsoft::Management::Deployment::LocalPackageCatalog const & localPackageCatalog)
94
99
{
100
+ LogStartupIfApplicable ();
95
101
::AppInstaller::Repository::Source source;
96
102
switch (localPackageCatalog)
97
103
{
@@ -113,6 +119,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation
113
119
114
120
winrt::Microsoft::Management::Deployment::PackageCatalogReference PackageManager::GetPackageCatalogByName (hstring const & catalogName)
115
121
{
122
+ LogStartupIfApplicable ();
116
123
std::string name = winrt::to_string (catalogName);
117
124
if (name.empty ())
118
125
{
@@ -163,6 +170,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation
163
170
164
171
winrt::Microsoft::Management::Deployment::PackageCatalogReference PackageManager::CreateCompositePackageCatalog (winrt::Microsoft::Management::Deployment::CreateCompositePackageCatalogOptions const & options)
165
172
{
173
+ LogStartupIfApplicable ();
166
174
if (!options)
167
175
{
168
176
// Can't make a composite source if the options aren't specified.
0 commit comments