Skip to content

Commit 80cbd3f

Browse files
committed
[GH Usage] Added analytics
1 parent a1602af commit 80cbd3f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/NuGetGallery/Scripts/gallery/page-display-package.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,24 @@ $(function () {
111111
ga('send', 'event', 'dependencies', e.type);
112112
});
113113
}
114+
115+
if (window.nuget.isGaAvailable()) {
116+
// Emit a Google Analytics event when the user expands or collapses the GitHub Usage section.
117+
$("#github-usage").on('hide.bs.collapse show.bs.collapse', function (e) {
118+
ga('send', 'event', 'github-usage', e.type);
119+
});
120+
121+
// Emit a Google Analytics event when the user clicks on a repo link in the GitHub Usage section.
122+
$(".btn-gh-repo").on('click', function (e) {
123+
let elem = e.delegateTarget.parentElement.parentElement;
124+
let linkIndex = 0;
125+
while ((elem = elem.previousSibling) != null) {
126+
if (elem.nodeName === "DIV") {
127+
linkIndex++;
128+
}
129+
}
130+
131+
ga('send', 'event', 'github-usage', 'link-click-' + linkIndex);
132+
});
133+
}
114134
});

0 commit comments

Comments
 (0)