Skip to content

Commit

Permalink
add one telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
DinahK-2SO committed Dec 12, 2024
1 parent a243907 commit 7a282f2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dev/Interop/StoragePicker/FileOpenPicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "FileOpenPicker.h"
#include "Microsoft.Windows.Storage.Pickers.FileOpenPicker.g.cpp"
#include "StoragePickersTelemetry.h"
#include <windows.h>
#include <shobjidl.h>
#include <wil/cppwinrt.h>
Expand All @@ -13,6 +14,10 @@ namespace winrt::Microsoft::Windows::Storage::Pickers::implementation
{
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::StorageFile> FileOpenPicker::PickSingleFileAsync()
{
bool isAppPackaged = m_telemetryHelper.IsPackagedApp();
PCWSTR appName = m_telemetryHelper.GetAppName().c_str();
auto logCaptureOperation{ StoragePickersTelemetry::StoragePickersOperation::Start(isAppPackaged, appName) };

winrt::apartment_context ui_thread;

co_await winrt::resume_background();
Expand Down
5 changes: 5 additions & 0 deletions dev/Interop/StoragePicker/FileOpenPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include "Microsoft.Windows.Storage.Pickers.FileOpenPicker.g.h"
#include "TelemetryHelper.h"

namespace winrt::Microsoft::Windows::Storage::Pickers::implementation
{
struct FileOpenPicker : FileOpenPickerT<FileOpenPicker>
{
FileOpenPicker() = default;
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::StorageFile> PickSingleFileAsync();

private:
TelemetryHelper m_telemetryHelper;
};
}

namespace winrt::Microsoft::Windows::Storage::Pickers::factory_implementation
{
struct FileOpenPicker : FileOpenPickerT<FileOpenPicker, implementation::FileOpenPicker>
Expand Down
29 changes: 29 additions & 0 deletions dev/Interop/StoragePicker/StoragePickersTelemetry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#pragma once
#include "..\WindowsAppRuntime_Insights\WindowsAppRuntimeInsights.h"
#include <TelemetryHelper.h>

DECLARE_TRACELOGGING_CLASS(StoragePickersTelemetryProvider,
"Microsoft.WindowsAppSDK.StoragePickersTelemetry",
// {3be0d45f-3a9d-46be-a1cf-b08465473cc4}
(0x3be0d45f, 0x3a9d, 0x46be, 0xa1, 0xcf, 0xb0, 0x84, 0x65, 0x47, 0x3c, 0xc4));

class StoragePickersTelemetry : public wil::TraceLoggingProvider
{
IMPLEMENT_TELEMETRY_CLASS(StoragePickersTelemetry, StoragePickersTelemetryProvider);

public:
BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(StoragePickersOperation, PDT_ProductAndServicePerformance);
DEFINE_ACTIVITY_START(bool isAppPackaged, PCWSTR appName) noexcept try
{
TraceLoggingClassWriteStart(
StoragePickersOperation,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingBool(isAppPackaged, "IsAppPackaged"),
TraceLoggingWideString(appName, "AppName"));
}
CATCH_LOG()
END_ACTIVITY_CLASS();
};

0 comments on commit 7a282f2

Please sign in to comment.