@@ -4,9 +4,10 @@ var request = require('request');
44var crypto = require ( 'crypto' ) ;
55
66/**
7- * varruct a new mapbox event client to send interaction events to the mapbox event service
7+ * Construct a new mapbox event client to send interaction events to the mapbox event service
88 * @param {Object } options options with which to create the service
99 * @param {String } options.accessToken the mapbox access token to make requests
10+ * @private
1011 */
1112function MapboxEventManager ( options ) {
1213 this . origin = options . origin || 'https://api.mapbox.com' ;
@@ -33,8 +34,10 @@ MapboxEventManager.prototype = {
3334 /**
3435 * Send a search.select event to the mapbox events service
3536 * This event marks the array index of the item selected by the user out of the array of possible options
37+ * @private
3638 * @param {Object } selected the geojson feature selected by the user
3739 * @param {Object } geocoder a mapbox-gl-geocoder instance
40+ * @param {Function } callback a callback function to invoke once the event has been sent (optional)
3841 * @returns {Promise }
3942 */
4043 select : function ( selected , geocoder , callback ) {
@@ -53,7 +56,9 @@ MapboxEventManager.prototype = {
5356 /**
5457 * Send a search-start event to the mapbox events service
5558 * This turnstile event marks when a user starts a new search
59+ * @private
5660 * @param {Object } geocoder a mapbox-gl-geocoder instance
61+ * @param {Function } callback
5762 * @returns {Promise }
5863 */
5964 start : function ( geocoder , callback ) {
@@ -66,7 +71,7 @@ MapboxEventManager.prototype = {
6671 *
6772 * The event is skipped if the instance is not enabled to send logging events
6873 *
69- *
74+ * @private
7075 * @param {Object } payload the http POST body of the event
7176 * @returns {Promise }
7277 */
@@ -82,7 +87,11 @@ MapboxEventManager.prototype = {
8287 if ( callback ) return callback ( ) ;
8388 } )
8489 } ,
85-
90+ /**
91+ * Get http request options
92+ * @private
93+ * @param {* } payload
94+ */
8695 getRequestOptions : function ( payload ) {
8796 var options = {
8897 // events must be sent with POST
@@ -102,6 +111,7 @@ MapboxEventManager.prototype = {
102111 /**
103112 * Get the event payload to send to the events service
104113 * Most payload properties are shared across all events
114+ * @private
105115 * @param {String } event the name of the event to send to the events service. Valid options are 'search.start', 'search.select', 'search.feedback'.
106116 * @param {Object } geocoder a mapbox-gl-geocoder instance
107117 * @returns {Object } an event payload
@@ -135,6 +145,7 @@ MapboxEventManager.prototype = {
135145 /**
136146 * Wraps the request function for easier testing
137147 * Make an http request and invoke a callback
148+ * @private
138149 * @param {Object } opts options describing the http request to be made
139150 * @param {Function } callback the callback to invoke when the http request is completed
140151 */
@@ -147,6 +158,7 @@ MapboxEventManager.prototype = {
147158 /**
148159 * Handle an error that occurred while making a request
149160 * @param {Object } err an error instance to log
161+ * @private
150162 */
151163 handleError : function ( err , callback ) {
152164 if ( callback ) return callback ( err ) ;
@@ -155,6 +167,7 @@ MapboxEventManager.prototype = {
155167 /**
156168 * Generate a session ID to be returned with all of the searches made by this geocoder instance
157169 * ID is random and cannot be tracked across sessions
170+ * @private
158171 */
159172 generateSessionID : function ( ) {
160173 var sha = crypto . createHash ( 'sha256' ) ;
@@ -164,13 +177,15 @@ MapboxEventManager.prototype = {
164177
165178 /**
166179 * Get a user agent string to send with the request to the events service
180+ * @private
167181 */
168182 getUserAgent : function ( ) {
169183 return 'mapbox-gl-geocoder.' + this . version + "." + navigator . userAgent ;
170184 } ,
171185
172186 /**
173187 * Get the 0-based numeric index of the item that the user selected out of the list of options
188+ * @private
174189 * @param {Object } selected the geojson feature selected by the user
175190 * @param {Object } geocoder a Mapbox-GL-Geocoder instance
176191 * @returns {Number } the index of the selected result
@@ -188,6 +203,7 @@ MapboxEventManager.prototype = {
188203 /**
189204 * Check whether events should be logged
190205 * Clients using a localGeocoder or an origin other than mapbox should not have events logged
206+ * @private
191207 */
192208 shouldEnableLogging : function ( options ) {
193209 if ( ! this . origin . includes ( 'api.mapbox.com' ) ) return false ;
0 commit comments