From 34ce3955c7dbe0424fa7df0d8cadbe166aa13d51 Mon Sep 17 00:00:00 2001 From: Alex Taker Date: Wed, 11 Dec 2024 14:39:55 -0500 Subject: [PATCH 1/2] va-language-toggle: Add label text to event, remove va-link analytics --- .../components/va-language-toggle/va-language-toggle.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/web-components/src/components/va-language-toggle/va-language-toggle.tsx b/packages/web-components/src/components/va-language-toggle/va-language-toggle.tsx index f3d3302e0..1cc7bf808 100644 --- a/packages/web-components/src/components/va-language-toggle/va-language-toggle.tsx +++ b/packages/web-components/src/components/va-language-toggle/va-language-toggle.tsx @@ -74,7 +74,7 @@ export class VaLanguageToggle { } // This method is fired whenever a link is clicked - handleToggle(e: Event, langCode: string): void { + handleToggle(e: Event, langCode: string, linkText: string): void { // don't navigate from current page but set new language if (this.routerLinks) { e.preventDefault(); @@ -82,14 +82,14 @@ export class VaLanguageToggle { window.history.replaceState(null, null, this.getUrl(langCode)); this.language = langCode; } - this.vaLanguageToggle.emit({ language: langCode }); const detail = { componentName: 'va-language-toggle', action: 'linkClick', details: { - 'pipe-delimited-list-header': langCode + 'pipe-delimited-list-header': langCode, + label: linkText, }, }; this.componentLibraryAnalytics.emit(detail); @@ -137,8 +137,9 @@ export class VaLanguageToggle { class={anchorClass} href={href} language={lang} - onClick={(e) => this.handleToggle(e, lang)} + onClick={(e) => this.handleToggle(e, lang, label)} text={label} + disableAnalytics={true} /> ) From 9daaaff0e1efc7dd6b33a9483fb6a4135c80789c Mon Sep 17 00:00:00 2001 From: Alex Taker Date: Thu, 12 Dec 2024 09:52:14 -0500 Subject: [PATCH 2/2] Update analytics test to expect 1 time --- .../va-language-toggle/test/va-language-toggle.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-components/src/components/va-language-toggle/test/va-language-toggle.e2e.ts b/packages/web-components/src/components/va-language-toggle/test/va-language-toggle.e2e.ts index aa2f2257e..842bcf406 100644 --- a/packages/web-components/src/components/va-language-toggle/test/va-language-toggle.e2e.ts +++ b/packages/web-components/src/components/va-language-toggle/test/va-language-toggle.e2e.ts @@ -55,7 +55,7 @@ describe('va-language-toggle', () => { const toggleSpy = await page.spyOnEvent('component-library-analytics'); const anchor = await page.find('va-language-toggle >>> a'); await anchor.click(); - expect(toggleSpy).toHaveReceivedEvent(); + expect(toggleSpy).toHaveReceivedEventTimes(1); }); it('passes an aXe check', async () => {