PageSourceSearch

https://www.jhrl.com/sites/all/modules/bluetent/riot_solr/js/RiotSolrAppTracker.js?tlse4v

js jhrl.com collected 2026-10-06 13:17:46 UTC 4,439 bytes, 160 lines download raw bytes

1var RiotSolrAppTracker;
2
3(function(window) {
4  RiotSolrAppTracker = {
5    /**
6     * Track an event.
7     *
8     * @param eventData {object}
9     */
10    trackEvent: function(eventData) {
11      if (!window.ga) {
12        return;
13      }
14      window.ga('send', 'event', this.mapHit(eventData, 'client'));
15      if (window.ga.getByName && window.ga.getByName('bluetent')) {
16        window.ga('bluetent.send', 'event', this.mapHit(eventData, 'bluetent'));
17      }
18
19      if (typeof ga4 !== 'undefined') {
20        ga4.eventName('event', eventData);
21      }
22    },
23
24    /**
25     * Track a page view.
26     *
27     * @param pageViewData {object}
28     */
29    trackPageView: function(pageViewData) {
30      if (!window.ga) {
31        return;
32      }
33      window.ga('send', 'pageview', this.mapHit(pageViewData, 'client'));
34      if (typeof ga4 !== 'undefined') {
35        ga4.eventName('page_view', this.mapHit(pageViewData, 'client'));
36      }
37      if (window.ga.getByName && window.ga.getByName('bluetent')) {
38        window.ga('bluetent.send', 'pageview', this.mapHit(pageViewData, 'bluetent'));
39        if (typeof ga4 !== 'undefined') {
40          ga4.eventName('page_view', this.mapHit(pageViewData, 'bluetent'));
41        }
42      }
43    },
44
45    /**
46     * Track an exception.
47     *
48     * @param message {message}
49     * @param fatal {bool}
50     */
51    trackException: function(message, fatal) {
52      if (!window.ga) {
53        return;
54      }
55      var exceptionData = {
56        exDescription: message || 'unknown error',
57        exFatal: typeof fatal === 'undefined' ? true : fatal,
58      };
59
60      window.ga('send', 'exception', exceptionData);
61      if (window.ga.getByName && window.ga.getByName('bluetent')) {
62        window.ga('bluetent.send', 'exception', exceptionData);
63      }
64
65      if (typeof ga4 !== 'undefined') {
66        ga4.eventName('exception', exceptionData);
67      }
68    },
69
70    /**
71     * Transform a hit's data to match our customizable structure, dependent on GA configuration.
72     *
73     * @see riot_solr_register_ga_mappings
74     *
75     * @param hitData {object}
76     * @param settingKey {string} - The key on Drupal.settings.riot_solr.gaMappings to use for mappings.
77     * @return {object}
78     */
79    mapHit: function(hitData, settingKey) {
80      var mappedHit = {};
81      var mappings = Drupal.settings.riot_solr.gaMappings[settingKey];
82
83      // Event things.
84      mappings.category = 'eventCategory';
85      mappings.label = 'eventLabel';
86      mappings.action = 'eventAction';
87      mappings.value = 'eventValue';
88
89      // Page things.
90      mappings.title = 'title';
91      mappings.location = 'location';
92      mappings.page = 'page';
93
94      for (var prop in hitData) {
95        if (hitData.hasOwnProperty(prop) && mappings[prop]) {
96          mappedHit[mappings[prop]] = this.typeHitData(mappings[prop], hitData[prop]);
97        }
98      }
99
100      return mappedHit;
101    },
102
103    /**
104     * Cast hit data to a proper type for the destination.
105     *
106     * Google Analytics custom dimensions and metrics are typed.
107     * Dimensions must be strings, and metrics must be integers.
108     *
109     * @param destination {string} - The destination key in our event data object.
110     * @param data {mixed} - The data being sent.
111     * @return {int|string} - An integer for metrics, a string for dimensions, unmodified otherwise.
112     */
113    typeHitData: function(destination, data) {
114      var isMetric = function(a) {
115        return a.indexOf('metric') === 0;
116      };
117      var isDimension = function(a) {
118        return a.indexOf('dimension') === 0;
119      };
120
121      if (isDimension(destination)) {
122        return data + ''; // Cast to string.
123      }
124
125      if (isMetric(destination)) {
126        if (isNaN(parseInt(data, 10))) {
127          throw new Error('Attempted to map a non-numeric value to a metric.');
128        }
129        return parseInt(data, 10);
130      }
131
132      return data;
133    },
134  };
135
136  if (window.onerror) {
137    return;
138  }
139
140  window.onerror = function(messageOrEvent, source, lineno, colno, error) {
141    if (error instanceof Error) {
142      var message = error.message;
143      if (source) {
144        message += ' (' + source;
145      }
146      if (lineno) {
147        message += ' at line ' + lineno;
148      }
149      if (colno) {
150        message += ':' + colno;
151      }
152      if (source) {
153        message += ')';
154      }
155
156      RiotSolrAppTracker.trackException(message, true);
157      return false;
158    }
159  };
160})(window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.