|
544 | 544 | .filter(':visible:first') |
545 | 545 | .trigger('focus'); |
546 | 546 |
|
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()) { |
550 | 550 | return; |
551 | 551 | } |
552 | 552 |
|
553 | 553 | var href = $(this).attr('href'); |
554 | 554 | var category = $(this).data().track; |
| 555 | + |
555 | 556 | var trackValue = $(this).data().trackValue; |
| 557 | + if (typeof trackValue === 'undefined') { |
| 558 | + trackValue = 1; |
| 559 | + } |
| 560 | + |
556 | 561 | 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 | + }); |
570 | 566 | } |
571 | 567 | }; |
572 | 568 | $.each($('a[data-track]'), function () { |
573 | 569 | $(this).on('mouseup', function (e) { |
574 | 570 | if (e.which === 2) { // Middle-mouse click |
575 | | - emitClickEvent.call(this, e, true); |
| 571 | + emitClickEvent.call(this, e); |
576 | 572 | } |
577 | 573 | }); |
578 | 574 | $(this).on('click', function (e) { |
579 | | - emitClickEvent.call(this, e, e.altKey || e.ctrlKey || e.metaKey); |
| 575 | + emitClickEvent.call(this, e); |
580 | 576 | }); |
581 | 577 | }); |
582 | 578 |
|
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 | | - |
592 | 579 | // Don't close the dropdown on click events inside of the dropdown. |
593 | 580 | $(document).on('click', '.dropdown-menu', function (e) { |
594 | 581 | e.stopPropagation(); |
|
0 commit comments