Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/Extensions.cpp (C++)

Code before:
    static constexpr std::wstring_view ExtensionSubPageId{ L"page.extensions.extensionView" };

    Extensions::Extensions()
    {
        InitializeComponent();

        _extensionPackageIdentifierTemplateSelector = Resources().Lookup(box_value(L"ExtensionPackageIdentifierTemplateSelector")).as<Editor::ExtensionPackageTemplateSelector>();

        Automation::AutomationProperties::SetName(ActiveExtensionsList(), RS_(L"Extensions_ActiveExtensionsHeader/Text"));
        Automation::AutomationProperties::SetName(ModifiedProfilesList(), RS_(L"Extensions_ModifiedProfilesHeader/Text"));
        Automation::AutomationProperties::SetName(AddedProfilesList(), RS_(L"Extensions_AddedProfilesHeader/Text"));
        Automation::AutomationProperties::SetName(AddedColorSchemesList(), RS_(L"Extensions_AddedColorSchemesHeader/Text"));
    }

    void Extensions::OnNavigatedTo(const NavigationEventArgs& e)
    {
        _ViewModel = e.Parameter().as<Editor::ExtensionsViewModel>();
        auto vmImpl = get_self<ExtensionsViewModel>(_ViewModel);
        vmImpl->ExtensionPackageIdentifierTemplateSelector(_extensionPackageIdentifierTemplateSelector);
        vmImpl->LazyLoadExtensions();
        vmImpl->MarkAsVisited();

        if (_ViewModel.IsExtensionView())
        {
            const auto& currentPkgVM = _ViewModel.CurrentExtensionPackage();
            const auto& currentPkg = currentPkgVM.Package();
            TraceLoggingWrite(
                g_hTerminalSettingsEditorProvider,
                "NavigatedToPage",
                TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
                TraceLoggingValue(ExtensionSubPageId.data(), "PageId", "The identifier of the page that was navigated to"),
                TraceLoggingValue(currentPkg.Source().c_str(), "FragmentSource", "The source of the fragment included in this extension package"),
                TraceLoggingValue(currentPkgVM.FragmentExtensions().Size(), "FragmentCount", "The number of fragments included in this extension package"),
                TraceLoggingValue(currentPkgVM.Enabled(), "Enabled", "The enabled status of the extension"),
                TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
                TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
        }
        else
        {
            TraceLoggingWrite(
                g_hTerminalSettingsEditorProvider,
                "NavigatedToPage",
                TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
                TraceLoggingValue(ExtensionPageId.data(), "PageId", "The identifier of the page that was navigated to"),
                TraceLoggingValue(_ViewModel.ExtensionPackages().Size(), "ExtensionPackageCount", "The number of extension packages displayed"),
                TraceLoggingValue(_ViewModel.ProfilesModified().Size(), "ProfilesModifiedCount", "The number of profiles modified by enabled extensions"),
                TraceLoggingValue(_ViewModel.ProfilesAdded().Size(), "ProfilesAddedCount", "The number of profiles added by enabled extensions"),
                TraceLoggingValue(_ViewModel.ColorSchemesAdded().Size(), "ColorSchemesAddedCount", "The number of color schemes added by enabled extensions"),
                TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
                TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
        }

Review comment (suggestion):
```suggestion
            const auto currentPkgVM = _ViewModel.CurrentExtensionPackage();
            const auto currentPkg = currentPkgVM.Package();
```

Code after:
    {
        InitializeComponent();

        _extensionPackageIdentifierTemplateSelector = Resources().Lookup(box_value(L"ExtensionPackageIdentifierTemplateSelector")).as<Editor::ExtensionPackageTemplateSelector>();

        Automation::AutomationProperties::SetName(ActiveExtensionsList(), RS_(L"Extensions_ActiveExtensionsHeader/Text"));
        Automation::AutomationProperties::SetName(ModifiedProfilesList(), RS_(L"Extensions_ModifiedProfilesHeader/Text"));
        Automation::AutomationProperties::SetName(AddedProfilesList(), RS_(L"Extensions_AddedProfilesHeader/Text"));
        Automation::AutomationProperties::SetName(AddedColorSchemesList(), RS_(L"Extensions_AddedColorSchemesHeader/Text"));
    }

    void Extensions::OnNavigatedTo(const NavigationEventArgs& e)
    {
        _ViewModel = e.Parameter().as<Editor::ExtensionsViewModel>();
        auto vmImpl = get_self<ExtensionsViewModel>(_ViewModel);
        vmImpl->ExtensionPackageIdentifierTemplateSelector(_extensionPackageIdentifierTemplateSelector);
        vmImpl->LazyLoadExtensions();
        vmImpl->MarkAsVisited();

        if (vmImpl->IsExtensionView())
        {
            const auto currentPkgVM = vmImpl->CurrentExtensionPackage();
            const auto currentPkg = currentPkgVM.Package();
            TraceLoggingWrite(
                g_hTerminalSettingsEditorProvider,
                "NavigatedToPage",
                TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
                TraceLoggingValue("extensions.extensionView", "PageId", "The identifier of the page that was navigated to"),
                TraceLoggingValue(currentPkg.Source().c_str(), "FragmentSource", "The source of the fragment included in this extension package"),
                TraceLoggingValue(currentPkgVM.FragmentExtensions().Size(), "FragmentCount", "The number of fragments included in this extension package"),
                TraceLoggingValue(currentPkgVM.Enabled(), "Enabled", "The enabled status of the extension"),
                TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
                TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
        }
        else
        {
            TraceLoggingWrite(
                g_hTerminalSettingsEditorProvider,
                "NavigatedToPage",
                TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
                TraceLoggingValue("extensions", "PageId", "The identifier of the page that was navigated to"),
                TraceLoggingValue(vmImpl->ExtensionPackages().Size(), "ExtensionPackageCount", "The number of extension packages displayed"),
                TraceLoggingValue(vmImpl->ProfilesModified().Size(), "ProfilesModifiedCount", "The number of profiles modified by enabled extensions"),
                TraceLoggingValue(vmImpl->ProfilesAdded().Size(), "ProfilesAddedCount", "The number of profiles added by enabled extensions"),
                TraceLoggingValue(vmImpl->ColorSchemesAdded().Size(), "ColorSchemesAddedCount", "The number of color schemes added by enabled extensions"),
                TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
                TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
        }
    }

    void Extensions::ExtensionNavigator_Click(const IInspectable& sender, const RoutedEventArgs& /*args*/)