Skip to content

Commit

Permalink
Find out how often are people actually using marks, Themes (#14356)
Browse files Browse the repository at this point in the history
Let's find out!

* [x] This is all the current bullets in #14324. I'm going to leave that open till we signoff on the release.

(cherry picked from commit 52cc523)
Service-Card-Id: 86660872
Service-Version: 1.16
  • Loading branch information
zadjii-msft authored and DHowett committed Dec 1, 2022
1 parent 0fe29b7 commit 785704f
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/cascadia/TerminalControl/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <LibraryResources.h>
#include <WilErrorReporting.h>

// For g_hCTerminalCoreProvider
#include "../../cascadia/TerminalCore/tracing.hpp"

// Note: Generate GUID using TlgGuid.exe tool
TRACELOGGING_DEFINE_PROVIDER(
g_hTerminalControlProvider,
Expand All @@ -20,6 +23,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD reason, LPVOID /*reserved*/)
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDll);
TraceLoggingRegister(g_hTerminalControlProvider);
TraceLoggingRegister(g_hCTerminalCoreProvider);
Microsoft::Console::ErrorReporting::EnableFallbackFailureReporting(g_hTerminalControlProvider);
break;
case DLL_PROCESS_DETACH:
Expand Down
36 changes: 36 additions & 0 deletions src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@

#include "pch.h"
#include "Terminal.hpp"
#include "tracing.hpp"

#include "../src/inc/unicode.hpp"

using namespace Microsoft::Terminal::Core;
using namespace Microsoft::Console::Render;
using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::VirtualTerminal;

// Note: Generate GUID using TlgGuid.exe tool
#pragma warning(suppress : 26477) // One of the macros uses 0/NULL. We don't have control to make it nullptr.
TRACELOGGING_DEFINE_PROVIDER(g_hCTerminalCoreProvider,
"Microsoft.Terminal.Core",
// {103ac8cf-97d2-51aa-b3ba-5ffd5528fa5f}
(0x103ac8cf, 0x97d2, 0x51aa, 0xb3, 0xba, 0x5f, 0xfd, 0x55, 0x28, 0xfa, 0x5f),
TraceLoggingOptionMicrosoftTelemetry());

// Print puts the text in the buffer and moves the cursor
void Terminal::PrintString(const std::wstring_view string)
{
Expand Down Expand Up @@ -185,6 +195,19 @@ void Terminal::SetTaskbarProgress(const ::Microsoft::Console::VirtualTerminal::D

void Terminal::SetWorkingDirectory(std::wstring_view uri)
{
static bool logged = false;
if (!logged)
{
TraceLoggingWrite(
g_hCTerminalCoreProvider,
"ShellIntegrationWorkingDirSet",
TraceLoggingDescription("The CWD was set by the client application"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));

logged = true;
}

_workingDirectory = uri;
}

Expand Down Expand Up @@ -300,6 +323,19 @@ void Terminal::UseMainScreenBuffer()

void Terminal::AddMark(const Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark& mark)
{
static bool logged = false;
if (!logged)
{
TraceLoggingWrite(
g_hCTerminalCoreProvider,
"ShellIntegrationMarkAdded",
TraceLoggingDescription("A mark was added via VT at least once"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));

logged = true;
}

const til::point cursorPos{ _activeBuffer().GetCursor().GetPosition() };
AddMark(mark, cursorPos, cursorPos);
}
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalCore/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
#include "winrt/Windows.Foundation.h"

#include "winrt/Microsoft.Terminal.Core.h"

#include <til.h>
1 change: 1 addition & 0 deletions src/cascadia/TerminalCore/terminalcore-common.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ClInclude Include="..\ControlKeyStates.hpp" />
<ClInclude Include="..\pch.h" />
<ClInclude Include="..\Terminal.hpp" />
<ClInclude Include="..\tracing.hpp" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions src/cascadia/TerminalCore/tracing.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- tracing.hpp
Abstract:
- This module is used for recording tracing/debugging information to the telemetry ETW channel
--*/

#pragma once
#include <string>
#include <windows.h>
#include <winmeta.h>
#include <TraceLoggingProvider.h>
#include <telemetry/ProjectTelemetry.h>

TRACELOGGING_DECLARE_PROVIDER(g_hCTerminalCoreProvider);
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/CascadiaSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
bool _hasInvalidColorScheme(const Model::Command& command) const;
void _validateThemeExists();

void _researchOnLoad();

// user settings
winrt::hstring _hash;
winrt::com_ptr<implementation::GlobalAppSettings> _globals = winrt::make_self<implementation::GlobalAppSettings>();
Expand Down
109 changes: 91 additions & 18 deletions src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,24 +893,7 @@ try
settings->_hash = _calculateHash(settingsString, lastWriteTime);
}

// GH#13936: We're interested in how many users opt out of useAtlasEngine,
// indicating major issues that would require us to disable it by default again.
{
size_t enabled[2]{};
for (const auto& profile : settings->_activeProfiles)
{
enabled[profile.UseAtlasEngine()]++;
}

TraceLoggingWrite(
g_hSettingsModelProvider,
"AtlasEngine_Usage",
TraceLoggingDescription("Event emitted upon settings load, containing the number of profiles opted-in/out of useAtlasEngine"),
TraceLoggingUIntPtr(enabled[0], "UseAtlasEngineDisabled", "Number of profiles for which AtlasEngine is disabled"),
TraceLoggingUIntPtr(enabled[1], "UseAtlasEngineEnabled", "Number of profiles for which AtlasEngine is enabled"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
}
settings->_researchOnLoad();

return *settings;
}
Expand All @@ -927,6 +910,96 @@ catch (const SettingsTypedDeserializationException& e)
return *settings;
}

void CascadiaSettings::_researchOnLoad()
{
// Only do this if we're actually being sampled
if (TraceLoggingProviderEnabled(g_hSettingsModelProvider, 0, MICROSOFT_KEYWORD_MEASURES))
{
// GH#13936: We're interested in how many users opt out of useAtlasEngine,
// indicating major issues that would require us to disable it by default again.
{
size_t enabled[2]{};
for (const auto& profile : _activeProfiles)
{
enabled[profile.UseAtlasEngine()]++;
}

TraceLoggingWrite(
g_hSettingsModelProvider,
"AtlasEngine_Usage",
TraceLoggingDescription("Event emitted upon settings load, containing the number of profiles opted-in/out of useAtlasEngine"),
TraceLoggingUIntPtr(enabled[0], "UseAtlasEngineDisabled", "Number of profiles for which AtlasEngine is disabled"),
TraceLoggingUIntPtr(enabled[1], "UseAtlasEngineEnabled", "Number of profiles for which AtlasEngine is enabled"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
}

// ----------------------------- RE: Themes ----------------------------
const auto numThemes = GlobalSettings().Themes().Size();
const auto themeInUse = GlobalSettings().CurrentTheme().Name();
const auto changedTheme = GlobalSettings().HasTheme();

// system: 0
// light: 1
// dark: 2
// a custom theme: 3
const auto themeChoice = themeInUse == L"system" ? 0 :
themeInUse == L"light" ? 1 :
themeInUse == L"dark" ? 2 :
3;

TraceLoggingWrite(
g_hSettingsModelProvider,
"ThemesInUse",
TraceLoggingDescription("Data about the themes in use"),
TraceLoggingBool(themeChoice, "Identifier for the theme chosen. 0 is system, 1 is light, 2 is dark, and 3 indicates any custom theme."),
TraceLoggingBool(changedTheme, "True if the user actually changed the theme from the default theme"),
TraceLoggingInt32(numThemes, "Number of themes in the user's settings"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));

// --------------------------- RE: sendInput ---------------------------
auto collectSendInput = [&]() {
auto totalSendInput = 0;
const auto& allActions = GlobalSettings().ActionMap().AvailableActions();
for (const auto&& [name, actionAndArgs] : allActions)
{
if (actionAndArgs.Action() == ShortcutAction::SendInput)
{
totalSendInput++;
}
}
return totalSendInput;
};

TraceLoggingWrite(
g_hSettingsModelProvider,
"SendInputUsage",
TraceLoggingDescription("Event emitted upon settings load, containing the number of sendInput actions a user has"),
TraceLoggingInt32(collectSendInput(), "Number of sendInput actions in the user's settings"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));

// ------------------------ RE: autoMarkPrompts ------------------------
auto totalAutoMark = 0;
auto totalShowMarks = 0;
for (const auto&& p : AllProfiles())
{
totalAutoMark += p.AutoMarkPrompts() ? 1 : 0;
totalShowMarks += p.ShowMarks() ? 1 : 0;
}

TraceLoggingWrite(
g_hSettingsModelProvider,
"MarksProfilesUsage",
TraceLoggingDescription("Event emitted upon settings load, containing the number of profiles opted-in to scrollbar marks"),
TraceLoggingInt32(totalAutoMark, "Number of profiles for which AutoMarkPrompts is enabled"),
TraceLoggingInt32(totalShowMarks, "Number of profiles for which ShowMarks is enabled"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
}
}

// Function Description:
// - Loads a batch of settings curated for the Universal variant of the terminal app
// Arguments:
Expand Down

1 comment on commit 785704f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (2)

BGRA
finsh

Previously acknowledged words that are now absent aabbcc abbcc bgra DECARM DECCARA DECERA DECFRA DECRARA DECSACE DECSERA DECXCPR GETKEYSTATE hicon IWIC MAPVIRTUALKEY nto otepad Qaabbcc Qxxxxxxxxxxxxxxx Tdd VKKEYSCAN wic wincodec xwwyzz xxyyzz ZYXWVU ZYXWVUTd :arrow_right:
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the release-1.16 branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/3596789375/attempts/1'
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. If it doesn't work for you, you can manually add (one word per line) / remove items to expect.txt and the excludes.txt files.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.