@@ -4,7 +4,7 @@ import getUtmData from './utm';
44import Identify from './identify' ;
55import localStorage from './localstorage' ; // jshint ignore:line
66import md5 from 'blueimp-md5' ;
7- import assign from 'lodash/assign ' ;
7+ import merge from 'lodash/merge ' ;
88import Request from './xhr' ;
99import Revenue from './revenue' ;
1010import type from './type' ;
@@ -27,7 +27,7 @@ var AmplitudeClient = function AmplitudeClient(instanceName) {
2727 this . _unsentEvents = [ ] ;
2828 this . _unsentIdentifys = [ ] ;
2929 this . _ua = new UAParser ( navigator . userAgent ) . getResult ( ) ;
30- this . options = assign ( { } , DEFAULT_OPTIONS ) ;
30+ this . options = merge ( { } , DEFAULT_OPTIONS ) ;
3131 this . cookieStorage = new cookieStorage ( ) . getStorage ( ) ;
3232 this . _q = [ ] ; // queue for proxied functions before script load
3333 this . _sending = false ;
@@ -896,7 +896,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
896896 _saveCookieData ( this ) ;
897897
898898 userProperties = userProperties || { } ;
899- apiProperties = apiProperties || { } ;
899+ apiProperties = merge ( apiProperties || { } ) ;
900900 eventProperties = eventProperties || { } ;
901901 groups = groups || { } ;
902902 var event = {
@@ -906,12 +906,12 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
906906 event_id : eventId ,
907907 session_id : this . _sessionId || - 1 ,
908908 event_type : eventType ,
909- version_name : this . options . versionName || null ,
910- platform : this . options . platform ,
911- os_name : this . _ua . browser . name || null ,
912- os_version : this . _ua . browser . major || null ,
913- device_model : this . _ua . os . name || null ,
914- language : this . options . language ,
909+ version_name : _shouldTrackField ( this , 'version_name' ) ? ( this . options . versionName || null ) : null ,
910+ platform : _shouldTrackField ( this , 'platform' ) ? this . options . platform : null ,
911+ os_name : _shouldTrackField ( this , 'os_name' ) ? ( this . _ua . browser . name || null ) : null ,
912+ os_version : _shouldTrackField ( this , 'os_version' ) ? ( this . _ua . browser . major || null ) : null ,
913+ device_model : _shouldTrackField ( this , 'device_model' ) ? ( this . _ua . os . name || null ) : null ,
914+ language : _shouldTrackField ( this , 'language' ) ? this . options . language : null ,
915915 api_properties : apiProperties ,
916916 event_properties : utils . truncate ( utils . validateProperties ( eventProperties ) ) ,
917917 user_properties : utils . truncate ( utils . validateProperties ( userProperties ) ) ,
@@ -947,6 +947,10 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
947947 }
948948} ;
949949
950+ var _shouldTrackField = function _shouldTrackField ( scope , field ) {
951+ return ! ! scope . options . trackingOptions [ field ] ;
952+ } ;
953+
950954/**
951955 * Remove old events from the beginning of the array if too many have accumulated. Default limit is 1000 events.
952956 * @private
0 commit comments