Skip to content

Commit f635f4b

Browse files
authored
Use Application Insights JS SDK instead of Google Analytics (#9228)
Also, delete an ancient clickonce line that is unused Progress on NuGet/Engineering#4555
1 parent 7c0f54d commit f635f4b

1 file changed

Lines changed: 14 additions & 27 deletions

File tree

src/NuGetGallery/Scripts/gallery/common.js

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -544,51 +544,38 @@
544544
.filter(':visible:first')
545545
.trigger('focus');
546546

547-
// Handle Google analytics tracking event on specific links.
548-
var emitClickEvent = function (e, emitDirectly) {
549-
if (!window.nuget.isGaAvailable()) {
547+
// Handle Application Insights tracking event on specific links.
548+
var emitClickEvent = function (e) {
549+
if (!window.nuget.isAiAvailable()) {
550550
return;
551551
}
552552

553553
var href = $(this).attr('href');
554554
var category = $(this).data().track;
555+
555556
var trackValue = $(this).data().trackValue;
557+
if (typeof trackValue === 'undefined') {
558+
trackValue = 1;
559+
}
560+
556561
if (href && category) {
557-
if (emitDirectly) {
558-
window.nuget.sendAnalyticsEvent(category, 'click', href, trackValue);
559-
} else {
560-
// This path is used when the click will result in a page transition. Because of this we need to
561-
// emit telemetry in a special way so that the event gets out before the page transition occurs.
562-
e.preventDefault();
563-
window.nuget.sendAnalyticsEvent(category, 'click', href, trackValue, {
564-
'transport': 'beacon',
565-
'hitCallback': window.nuget.createFunctionWithTimeout(function () {
566-
document.location = href;
567-
})
568-
});
569-
}
562+
window.nuget.sendMetric('BrowserClick', trackValue, {
563+
href: href,
564+
category: category
565+
});
570566
}
571567
};
572568
$.each($('a[data-track]'), function () {
573569
$(this).on('mouseup', function (e) {
574570
if (e.which === 2) { // Middle-mouse click
575-
emitClickEvent.call(this, e, true);
571+
emitClickEvent.call(this, e);
576572
}
577573
});
578574
$(this).on('click', function (e) {
579-
emitClickEvent.call(this, e, e.altKey || e.ctrlKey || e.metaKey);
575+
emitClickEvent.call(this, e);
580576
});
581577
});
582578

583-
// Show elements that require ClickOnce
584-
(function () {
585-
var userAgent = window.navigator.userAgent.toUpperCase();
586-
var hasNativeDotNet = userAgent.indexOf('.NET CLR 3.5') >= 0;
587-
if (hasNativeDotNet) {
588-
$('.no-clickonce').removeClass('no-clickonce');
589-
}
590-
})();
591-
592579
// Don't close the dropdown on click events inside of the dropdown.
593580
$(document).on('click', '.dropdown-menu', function (e) {
594581
e.stopPropagation();

0 commit comments

Comments
 (0)