department-of-veterans-affairs / va.gov-cms

Editor-centered management for Veteran-centered content.
https://prod.cms.va.gov
GNU General Public License v2.0
97 stars 69 forks source link

Unescaped apostrophe in CLP CTAs prevents Analytics events from firing #9481

Open jilladams opened 2 years ago

jilladams commented 2 years ago

Describe the defect

A bug was found in the FE code that reports analytics events to Google Analytics. It was initially found to impact three Campaign Landing Pages. Affected CLPs:

Reported impact of bug:

At least one page (Veteran Trust in VA) was fixed by removing the apostrophe from the CTA link. It used to say "Download the VA's Trust Report":

image

Assessment

It appears that the culprit here is the unescaped apostrophe in the recordEvent event labels.

https://github.com/department-of-veterans-affairs/va.gov-cms/issues/8953 determined that we can escape using the escape filter.

It seems like encode isn't an actual filter for Liquid templating. We'll have to use the escape filter instead. The encode filter also is called here: https://github.com/department-of-veterans-affairs/content-build/blob/f30b05c3db4ef402d10d13d1fedebe7bcee36508/src/site/filters/liquid.js#L827 The only other place that encode is used in the repo is in this file: https://github.com/department-of-veterans-affairs/content-build/blob/f7bafff44f67aea4cffa94ee343d31bbd8784231/src/site/paragraphs/collapsible_panel.drupal.liquid#L39

To Reproduce

Steps to reproduce the behavior:

  1. navigate to any of the following pages:
  2. Uncaught SyntaxError in console

Expected behavior

No console errors Click events for CTA's with apostrophes are recorded

Testing analytics is an open question.

Screenshots

Screen Shot 2022-05-04 at 11 19 05 AM

Screen Shot 2022-05-04 at 11 19 30 AM

Additional context

  1. Originally reported to (by?) the analytics team in https://github.com/department-of-veterans-affairs/va.gov-team/issues/40890
  2. Assessed for scope of issue/fix in https://github.com/department-of-veterans-affairs/va.gov-cms/issues/8953

Labels

(You can delete this section once it's complete)

CMS Team

Please check the team(s) that will do this work.

jilladams commented 2 years ago

5 points was due to testing analytics (From SPIKE): https://github.com/department-of-veterans-affairs/va.gov-cms/issues/8953#issuecomment-1157055783

jilladams commented 1 year ago

Should this be labeled Icebox? I've forgotten why we moved it back to Unrefined.