digital-analytics-program / gov-wide-code

Provides a set of javascript files and documentation to implement web analytics on US federal websites
http://www.digital.gov/dap
100 stars 50 forks source link

gaUri[0] undefined #83

Closed ghenle closed 9 months ago

ghenle commented 2 years ago

@line 675

else if(extDoc.length && arr[i].href.toLowerCase().indexOf("mailto:") !== -1 && arr[i].href.toLowerCase().indexOf("tel:") === -1){
  // Tracking outbound emails
  var gaUri = arr[i].href.match(/[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/i);
  _tagClicks(arr[i],'Outbound MailTo', gaUri[0], '', 0);
}

If regex href.match doesn't find a match it will return and set gaUri to NULL. gaUri[0] will trigger an error.

ghenle commented 2 years ago

For example. When the subject and body are included in the mailto but the destination email is not. Useful for sharing via email.

See RFC 6068 section 6.1 & 6.3 for an examples

https://datatracker.ietf.org/doc/html/rfc6068#section-6.1 https://datatracker.ietf.org/doc/html/rfc6068#section-6.3

smarina04 commented 10 months ago

@ghenle We are looking into this as part of the next code release.

smarina04 commented 9 months ago

This is fixed.