Skip to content

Commit

Permalink
feat: add tab name and portlet info to analytics events (#2694)
Browse files Browse the repository at this point in the history
* feat: add tab name and portlet info to analytics events

* chore: upgrade and configure eslint to support es2023

---------

Co-authored-by: Chris Beach <cbeach@unicon.net>
  • Loading branch information
bjagg and cbeach47 authored Nov 4, 2023
1 parent 2ababaa commit b29c1ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "uportal",
"private": true,
"devDependencies": {
"eslint": "^8.0.0",
"eslint": "^8.43.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^8.0.0",
"postcss-less": "^6.0.0",
Expand All @@ -28,6 +28,10 @@
"google",
"prettier"
],
"env": {
"es2023": true,
"browser": true
},
"rules": {
"indent": [
"error",
Expand Down
7 changes: 7 additions & 0 deletions uPortal-webapp/src/main/webapp/scripts/portal-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@
return;
}

const tab = document.querySelector('li.fl-tabs-active span');
const portletWrapper = event.target.closest('section.up-portlet-wrapper');
const portletTitleA = portletWrapper ? portletWrapper.querySelector('h2.portlet-title a') : null;

var eventDetails = {
type: 'link',
url: anchorForEvent.href,
tab_name: tab ? tab.textContent : null,
portlet_id: portletWrapper ? portletWrapper.id : null,
portlet_name: portletTitleA ? portletTitleA.title : null,
}

fetch('/uPortal/api/analytics', {
Expand Down

0 comments on commit b29c1ca

Please sign in to comment.