Skip to content

[ClickAnalytics] Make input type capture configurable via trackInputTypes - #2787

Merged
Hector Hernandez (hectorhdzg) merged 3 commits into
mainfrom
hectorh/click-analytics-input-types
Nov 3, 2026
Merged

Hector Hernandez (hectorhdzg) merged 3 commits into
mainfrom
hectorh/click-analytics-input-types

Conversation

@hectorhdzg

Copy link
Copy Markdown
Member

Summary

Fixes #2771.

ClickAnalytics auto capture used a hardcoded <input> type allowlist (button, checkbox, radio, reset, submit) that was independent of trackElementTypes and not documented. Including INPUT in trackElementTypes silently ignored clicks on text, email, number, search and untyped inputs.

Changes

  • New trackInputTypes config: comma separated list of <input> type values to auto capture. The default BUTTON,CHECKBOX,RADIO,RESET,SUBMIT keeps existing behavior. Case and whitespace insensitive, and supports dynamic config changes.
  • Privacy guard: the value of input types other than button, checkbox, radio, reset and submit is never used as the default content name; it falls back to name, alt or id. Opting in to text-like inputs cannot leak user entered data through the content name. This also applies to manual capturePageAction calls on such inputs, which previously could use the typed value.
  • Bug fix (dynamic config): on any config change the plugin unloads the previous AutoCaptureHandler (removing its listeners) and creates a new one, but only called click() when autoCapture transitioned from off to on. Any runtime config change therefore silently stopped auto capture, including trackElementTypes changes. Listeners are now re-attached whenever autoCapture is enabled.
  • Docs: README now documents trackElementTypes, trackInputTypes and the input capture behavior.

Validation

  • rush build --to @microsoft/applicationinsights-clickanalytics-js
  • npm test in extensions/applicationinsights-clickanalytics-js: 27 tests, 0 failed. New test covers default filtering, untyped inputs, dynamic opt-in, typed values not being captured, and an empty list disabling input capture.
  • npm run lint-fix

- Replace the hardcoded <input> type allowlist with the trackInputTypes
  config (default BUTTON,CHECKBOX,RADIO,RESET,SUBMIT), supporting
  dynamic config changes
- Never use the value of other input types as the default content
  name to avoid collecting user entered data
- Re-attach auto capture listeners after every config change; the
  previous handler was unloaded so dynamic changes stopped auto capture
- Document trackElementTypes, trackInputTypes and input capture behavior

Fixes #2771

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 21, 2026 22:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Lowercase XHTML input tags bypass the privacy guard and can expose user-entered values in telemetry.

1 open issue
What changed in this PR

This PR makes ClickAnalytics input-type capture configurable while preserving the default allowlist. It also adds protection against capturing typed values and fixes listener reattachment after configuration changes.

Changes:

  • Adds trackInputTypes with runtime configuration support.
  • Adds an input-value privacy guard and restores auto-capture listeners after configuration updates.
  • Documents input filtering and adds tests for defaults, dynamic opt-in, and value exclusion.
File Description
extensions/​applicationinsights-clickanalytics-js/​Tests/​Unit/​src/​ClickEventTest.ts Tests input filtering, runtime updates, and value exclusion.
extensions/​applicationinsights-clickanalytics-js/​src/​Interfaces/​Datamodel.ts Declares and documents trackInputTypes.
extensions/​applicationinsights-clickanalytics-js/​src/​handlers/​DomContentHandler.ts Restricts input values used as default content names.
extensions/​applicationinsights-clickanalytics-js/​src/​handlers/​AutoCaptureHandler.ts Parses and applies configurable input-type filtering.
extensions/​applicationinsights-clickanalytics-js/​src/​ClickAnalyticsPlugin.ts Adds defaults and reattaches listeners after configuration changes.
extensions/​applicationinsights-clickanalytics-js/​README.md Documents filtering options and input privacy behavior.

Review effort: Balanced

@hectorhdzg
Hector Hernandez (hectorhdzg) merged commit 5a800a9 into main Nov 3, 2026
9 checks passed
@hectorhdzg
Hector Hernandez (hectorhdzg) deleted the hectorh/click-analytics-input-types branch November 3, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClickAnalyticsPlugin: native <input> click capture silently gated by hardcoded clickCaptureInputTypes, independent of trackElementTypes

3 participants