microsoft / microsoft/ApplicationInsights-JS
[BUG] ClickAnalyticsPlugin: Result of callback.contentName is ignored when element contains id or data-id attribute
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 685
- Forks
- 261
- Avg merge
- 21h 33m
- Merged PRs (30d)
- 5
Description
Description/Screenshot
If element contains id or data-id attribute, result of contentName callback is ignored
Example:
const clickPluginConfig = {
autoCapture: true,
callback: {
contentName: (element: HTMLElement) => {
return 'this-is-test'
},
},
dataTags: {
useDefaultContentNameOrId: false,
}
};
<button data-id="test6id">Test6</button>
will send name: "test6id"
Steps to Reproduce
- Replace
connectionStringon line 25 - https://codepen.io/krystof-matejka/pen/LYoYBQw
Environment
- OS/Browser: Edge
- SDK Version [e.g. 22]: @microsoft/applicationinsights-clickanalytics-js: 3.2.0
- How you initialized the SDK: npm
Expected behavior
I expect that the result of contentName callback will be used.
Additional context
This issue can be overcome by changing the data-id or id attribute inside the contentName callback, but it is not always feasible
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ClickAnalyticsPlugin in @microsoft/applicationinsights-clickanalytics-js and reproduce the behavior using the linked CodePen. Trace how the contentName callback result is handled when the element has id or data-id attributes. Done means the callback result is sent as the content name in this case, with a regression test covering the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- analytics, observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100