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

gas event tracking function; documentation says action parameter is optional but code makes it required #109

Open mhm-va opened 2 months ago

mhm-va commented 2 months ago

Hello, I'm implementing some custom events on my site using the gas function and the DAP Code v7.0 Capabilities and Reference says that the action parameter (the 4th) is optional but the code ( else if ("event" === b.toLowerCase() && void 0 !== d && "" !== d) full context pasted below) clearly checks that it is there before triggering the event. I'm not sure which is incorrect (docs or code); but my suspicion is that the code should be checking the 3rd parameter (not 4th).

function gas(a, b, c, d, f, e, h) {
  if (
    void 0 !== a &&
    "" !== a &&
    void 0 !== b &&
    "" !== b &&
    void 0 !== c &&
    "" !== c
  )
    if ("pageview" === b.toLowerCase())
      try {
        _sendPageview(c, void 0 === d || "" === d ? document.title : d);
      } catch (n) { }
   else if ("event" === b.toLowerCase() && void 0 !== d && "" !== d)
      try {
        var g = !1;
        void 0 !== h &&
          "boolean" === typeof _cleanBooleanParam(h) &&
          (g = _cleanBooleanParam(h));
        _sendEvent("dap_event", {
          event_category: c,
          event_action: d,
          event_label: void 0 === f ? "" : f,
          event_value: void 0 === e || "" === e || isNaN(e) ? 0 : parseInt(e),
          non_interaction: g,
        });
      } catch (n) { }