@@ -499,7 +499,7 @@ var DEFAULT_OPTIONS = require('./options');
499499 * @public
500500 * @example var amplitude = new Amplitude();
501501 */
502- var Amplitude = function Amplitude ( ) {
502+ var AmplitudeClient = function Amplitude ( ) {
503503 this . _unsentEvents = [ ] ;
504504 this . _unsentIdentifys = [ ] ;
505505 this . _ua = new UAParser ( navigator . userAgent ) . getResult ( ) ;
@@ -518,8 +518,8 @@ var Amplitude = function Amplitude() {
518518 this . _sessionId = null ;
519519} ;
520520
521- Amplitude . prototype . Identify = Identify ;
522- Amplitude . prototype . Revenue = Revenue ;
521+ AmplitudeClient . prototype . Identify = Identify ;
522+ AmplitudeClient . prototype . Revenue = Revenue ;
523523
524524/**
525525 * Initializes the Amplitude Javascript SDK with your apiKey and any optional configurations.
@@ -532,7 +532,7 @@ Amplitude.prototype.Revenue = Revenue;
532532 * @param {function } opt_callback - (optional) Provide a callback function to run after initialization is complete.
533533 * @example amplitude.init('API_KEY', 'USER_ID', {includeReferrer: true, includeUtm: true}, function() { alert('init complete'); });
534534 */
535- Amplitude . prototype . init = function init ( apiKey , opt_userId , opt_config , opt_callback ) {
535+ AmplitudeClient . prototype . init = function init ( apiKey , opt_userId , opt_config , opt_callback ) {
536536 if ( type ( apiKey ) !== 'string' || utils . isEmptyString ( apiKey ) ) {
537537 utils . log ( 'Invalid apiKey. Please re-initialize with a valid apiKey' ) ;
538538 return ;
@@ -643,7 +643,7 @@ var _parseConfig = function _parseConfig(options, config) {
643643 * Run functions queued up by proxy loading snippet
644644 * @private
645645 */
646- Amplitude . prototype . runQueuedFunctions = function ( ) {
646+ AmplitudeClient . prototype . runQueuedFunctions = function ( ) {
647647 for ( var i = 0 ; i < this . _q . length ; i ++ ) {
648648 var fn = this [ this . _q [ i ] [ 0 ] ] ;
649649 if ( type ( fn ) === 'function' ) {
@@ -657,7 +657,7 @@ Amplitude.prototype.runQueuedFunctions = function () {
657657 * Check that the apiKey is set before calling a function. Logs a warning message if not set.
658658 * @private
659659 */
660- Amplitude . prototype . _apiKeySet = function _apiKeySet ( methodName ) {
660+ AmplitudeClient . prototype . _apiKeySet = function _apiKeySet ( methodName ) {
661661 if ( utils . isEmptyString ( this . options . apiKey ) ) {
662662 utils . log ( 'Invalid apiKey. Please set a valid apiKey with init() before calling ' + methodName ) ;
663663 return false ;
@@ -669,7 +669,7 @@ Amplitude.prototype._apiKeySet = function _apiKeySet(methodName) {
669669 * Load saved events from localStorage. JSON deserializes event array. Handles case where string is corrupted.
670670 * @private
671671 */
672- Amplitude . prototype . _loadSavedUnsentEvents = function _loadSavedUnsentEvents ( unsentKey ) {
672+ AmplitudeClient . prototype . _loadSavedUnsentEvents = function _loadSavedUnsentEvents ( unsentKey ) {
673673 var savedUnsentEventsString = this . _getFromStorage ( localStorage , unsentKey ) ;
674674 if ( utils . isEmptyString ( savedUnsentEventsString ) ) {
675675 return [ ] ; // new app, does not have any saved events
@@ -692,7 +692,7 @@ Amplitude.prototype._loadSavedUnsentEvents = function _loadSavedUnsentEvents(uns
692692 * @public
693693 * @return {boolean } Whether a new session was created during initialization.
694694 */
695- Amplitude . prototype . isNewSession = function isNewSession ( ) {
695+ AmplitudeClient . prototype . isNewSession = function isNewSession ( ) {
696696 return this . _newSession ;
697697} ;
698698
@@ -701,15 +701,15 @@ Amplitude.prototype.isNewSession = function isNewSession() {
701701 * @public
702702 * @return {number } Id of the current session.
703703 */
704- Amplitude . prototype . getSessionId = function getSessionId ( ) {
704+ AmplitudeClient . prototype . getSessionId = function getSessionId ( ) {
705705 return this . _sessionId ;
706706} ;
707707
708708/**
709709 * Increments the eventId and returns it.
710710 * @private
711711 */
712- Amplitude . prototype . nextEventId = function nextEventId ( ) {
712+ AmplitudeClient . prototype . nextEventId = function nextEventId ( ) {
713713 this . _eventId ++ ;
714714 return this . _eventId ;
715715} ;
@@ -718,7 +718,7 @@ Amplitude.prototype.nextEventId = function nextEventId() {
718718 * Increments the identifyId and returns it.
719719 * @private
720720 */
721- Amplitude . prototype . nextIdentifyId = function nextIdentifyId ( ) {
721+ AmplitudeClient . prototype . nextIdentifyId = function nextIdentifyId ( ) {
722722 this . _identifyId ++ ;
723723 return this . _identifyId ;
724724} ;
@@ -727,7 +727,7 @@ Amplitude.prototype.nextIdentifyId = function nextIdentifyId() {
727727 * Increments the sequenceNumber and returns it.
728728 * @private
729729 */
730- Amplitude . prototype . nextSequenceNumber = function nextSequenceNumber ( ) {
730+ AmplitudeClient . prototype . nextSequenceNumber = function nextSequenceNumber ( ) {
731731 this . _sequenceNumber ++ ;
732732 return this . _sequenceNumber ;
733733} ;
@@ -736,15 +736,15 @@ Amplitude.prototype.nextSequenceNumber = function nextSequenceNumber() {
736736 * Returns the total count of unsent events and identifys
737737 * @private
738738 */
739- Amplitude . prototype . _unsentCount = function _unsentCount ( ) {
739+ AmplitudeClient . prototype . _unsentCount = function _unsentCount ( ) {
740740 return this . _unsentEvents . length + this . _unsentIdentifys . length ;
741741} ;
742742
743743/**
744744 * Send events if ready. Returns true if events are sent.
745745 * @private
746746 */
747- Amplitude . prototype . _sendEventsIfReady = function _sendEventsIfReady ( callback ) {
747+ AmplitudeClient . prototype . _sendEventsIfReady = function _sendEventsIfReady ( callback ) {
748748 if ( this . _unsentCount ( ) === 0 ) {
749749 return false ;
750750 }
@@ -779,7 +779,7 @@ Amplitude.prototype._sendEventsIfReady = function _sendEventsIfReady(callback) {
779779 * Storage argument allows for localStoraoge and sessionStoraoge
780780 * @private
781781 */
782- Amplitude . prototype . _getFromStorage = function _getFromStorage ( storage , key ) {
782+ AmplitudeClient . prototype . _getFromStorage = function _getFromStorage ( storage , key ) {
783783 return storage . getItem ( key ) ;
784784} ;
785785
@@ -788,7 +788,7 @@ Amplitude.prototype._getFromStorage = function _getFromStorage(storage, key) {
788788 * Storage argument allows for localStoraoge and sessionStoraoge
789789 * @private
790790 */
791- Amplitude . prototype . _setInStorage = function _setInStorage ( storage , key , value ) {
791+ AmplitudeClient . prototype . _setInStorage = function _setInStorage ( storage , key , value ) {
792792 storage . setItem ( key , value ) ;
793793} ;
794794
@@ -902,7 +902,7 @@ var _saveCookieData = function _saveCookieData(scope) {
902902 * Parse the utm properties out of cookies and query for adding to user properties.
903903 * @private
904904 */
905- Amplitude . prototype . _initUtmData = function _initUtmData ( queryParams , cookieParams ) {
905+ AmplitudeClient . prototype . _initUtmData = function _initUtmData ( queryParams , cookieParams ) {
906906 queryParams = queryParams || location . search ;
907907 cookieParams = cookieParams || this . cookieStorage . get ( '__utmz' ) ;
908908 var utmProperties = getUtmData ( cookieParams , queryParams ) ;
@@ -946,15 +946,15 @@ var _sendUserPropertiesOncePerSession = function _sendUserPropertiesOncePerSessi
946946/**
947947 * @private
948948 */
949- Amplitude . prototype . _getReferrer = function _getReferrer ( ) {
949+ AmplitudeClient . prototype . _getReferrer = function _getReferrer ( ) {
950950 return document . referrer ;
951951} ;
952952
953953/**
954954 * Parse the domain from referrer info
955955 * @private
956956 */
957- Amplitude . prototype . _getReferringDomain = function _getReferringDomain ( referrer ) {
957+ AmplitudeClient . prototype . _getReferringDomain = function _getReferringDomain ( referrer ) {
958958 if ( utils . isEmptyString ( referrer ) ) {
959959 return null ;
960960 }
@@ -970,7 +970,7 @@ Amplitude.prototype._getReferringDomain = function _getReferringDomain(referrer)
970970 * Since user properties are propagated on the server, only send once per session, don't need to send with every event
971971 * @private
972972 */
973- Amplitude . prototype . _saveReferrer = function _saveReferrer ( referrer ) {
973+ AmplitudeClient . prototype . _saveReferrer = function _saveReferrer ( referrer ) {
974974 if ( utils . isEmptyString ( referrer ) ) {
975975 return ;
976976 }
@@ -986,7 +986,7 @@ Amplitude.prototype._saveReferrer = function _saveReferrer(referrer) {
986986 * Note: this is called automatically every time events are logged, unless you explicitly set option saveEvents to false.
987987 * @private
988988 */
989- Amplitude . prototype . saveEvents = function saveEvents ( ) {
989+ AmplitudeClient . prototype . saveEvents = function saveEvents ( ) {
990990 try {
991991 this . _setInStorage ( localStorage , this . options . unsentKey , JSON . stringify ( this . _unsentEvents ) ) ;
992992 } catch ( e ) { }
@@ -1002,7 +1002,7 @@ Amplitude.prototype.saveEvents = function saveEvents() {
10021002 * @param {string } domain to set.
10031003 * @example amplitude.setDomain('.amplitude.com');
10041004 */
1005- Amplitude . prototype . setDomain = function setDomain ( domain ) {
1005+ AmplitudeClient . prototype . setDomain = function setDomain ( domain ) {
10061006 if ( ! utils . validateInput ( domain , 'domain' , 'string' ) ) {
10071007 return ;
10081008 }
@@ -1025,7 +1025,7 @@ Amplitude.prototype.setDomain = function setDomain(domain) {
10251025 * @param {string } userId - identifier to set. Can be null.
10261026 * @example amplitude.setUserId('joe@gmail.com');
10271027 */
1028- Amplitude . prototype . setUserId = function setUserId ( userId ) {
1028+ AmplitudeClient . prototype . setUserId = function setUserId ( userId ) {
10291029 try {
10301030 this . options . userId = ( userId !== undefined && userId !== null && ( '' + userId ) ) || null ;
10311031 _saveCookieData ( this ) ;
@@ -1047,7 +1047,7 @@ Amplitude.prototype.setUserId = function setUserId(userId) {
10471047 * @param {string|list } groupName - the name of the group (ex: 15), or a list of names of the groups
10481048 * @example amplitude.setGroup('orgId', 15); // this adds the current user to orgId 15.
10491049 */
1050- Amplitude . prototype . setGroup = function ( groupType , groupName ) {
1050+ AmplitudeClient . prototype . setGroup = function ( groupType , groupName ) {
10511051 if ( ! this . _apiKeySet ( 'setGroup()' ) || ! utils . validateInput ( groupType , 'groupType' , 'string' ) ||
10521052 utils . isEmptyString ( groupType ) ) {
10531053 return ;
@@ -1065,7 +1065,7 @@ Amplitude.prototype.setGroup = function(groupType, groupName) {
10651065 * @param {boolean } enable - if true then no events will be logged or sent.
10661066 * @example : amplitude.setOptOut(true);
10671067 */
1068- Amplitude . prototype . setOptOut = function setOptOut ( enable ) {
1068+ AmplitudeClient . prototype . setOptOut = function setOptOut ( enable ) {
10691069 if ( ! utils . validateInput ( enable , 'enable' , 'boolean' ) ) {
10701070 return ;
10711071 }
@@ -1085,7 +1085,7 @@ Amplitude.prototype.setOptOut = function setOptOut(enable) {
10851085 * This uses src/uuid.js to regenerate the deviceId.
10861086 * @public
10871087 */
1088- Amplitude . prototype . regenerateDeviceId = function regenerateDeviceId ( ) {
1088+ AmplitudeClient . prototype . regenerateDeviceId = function regenerateDeviceId ( ) {
10891089 this . setDeviceId ( UUID ( ) + 'R' ) ;
10901090} ;
10911091
@@ -1097,7 +1097,7 @@ Amplitude.prototype.regenerateDeviceId = function regenerateDeviceId() {
10971097 * @param {string } deviceId - custom deviceId for current user.
10981098 * @example amplitude.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0');
10991099 */
1100- Amplitude . prototype . setDeviceId = function setDeviceId ( deviceId ) {
1100+ AmplitudeClient . prototype . setDeviceId = function setDeviceId ( deviceId ) {
11011101 if ( ! utils . validateInput ( deviceId , 'deviceId' , 'string' ) ) {
11021102 return ;
11031103 }
@@ -1120,7 +1120,7 @@ Amplitude.prototype.setDeviceId = function setDeviceId(deviceId) {
11201120 * memory and replace = true would replace the object in memory. Now the properties are no longer stored in memory, so replace is deprecated.
11211121 * @example amplitude.setUserProperties({'gender': 'female', 'sign_up_complete': true})
11221122 */
1123- Amplitude . prototype . setUserProperties = function setUserProperties ( userProperties ) {
1123+ AmplitudeClient . prototype . setUserProperties = function setUserProperties ( userProperties ) {
11241124 if ( ! this . _apiKeySet ( 'setUserProperties()' ) || ! utils . validateInput ( userProperties , 'userProperties' , 'object' ) ) {
11251125 return ;
11261126 }
@@ -1139,7 +1139,7 @@ Amplitude.prototype.setUserProperties = function setUserProperties(userPropertie
11391139 * @public
11401140 * @example amplitude.clearUserProperties();
11411141 */
1142- Amplitude . prototype . clearUserProperties = function clearUserProperties ( ) {
1142+ AmplitudeClient . prototype . clearUserProperties = function clearUserProperties ( ) {
11431143 if ( ! this . _apiKeySet ( 'clearUserProperties()' ) ) {
11441144 return ;
11451145 }
@@ -1175,7 +1175,7 @@ var _convertProxyObjectToRealObject = function _convertProxyObjectToRealObject(i
11751175 * var identify = new amplitude.Identify().set('colors', ['rose', 'gold']).add('karma', 1).setOnce('sign_up_date', '2016-03-31');
11761176 * amplitude.identify(identify);
11771177 */
1178- Amplitude . prototype . identify = function ( identify_obj , opt_callback ) {
1178+ AmplitudeClient . prototype . identify = function ( identify_obj , opt_callback ) {
11791179 if ( ! this . _apiKeySet ( 'identify()' ) ) {
11801180 if ( type ( opt_callback ) === 'function' ) {
11811181 opt_callback ( 0 , 'No request sent' ) ;
@@ -1210,7 +1210,7 @@ Amplitude.prototype.identify = function(identify_obj, opt_callback) {
12101210 * @param {string } versionName - The version to set for your application.
12111211 * @example amplitude.setVersionName('1.12.3');
12121212 */
1213- Amplitude . prototype . setVersionName = function setVersionName ( versionName ) {
1213+ AmplitudeClient . prototype . setVersionName = function setVersionName ( versionName ) {
12141214 if ( ! utils . validateInput ( versionName , 'versionName' , 'string' ) ) {
12151215 return ;
12161216 }
@@ -1221,7 +1221,7 @@ Amplitude.prototype.setVersionName = function setVersionName(versionName) {
12211221 * Private logEvent method. Keeps apiProperties from being publicly exposed.
12221222 * @private
12231223 */
1224- Amplitude . prototype . _logEvent = function _logEvent ( eventType , eventProperties , apiProperties , userProperties , groups , callback ) {
1224+ AmplitudeClient . prototype . _logEvent = function _logEvent ( eventType , eventProperties , apiProperties , userProperties , groups , callback ) {
12251225 _loadCookieData ( this ) ; // reload cookie before each log event to sync event meta-data between windows and tabs
12261226 if ( ! eventType || this . options . optOut ) {
12271227 if ( type ( callback ) === 'function' ) {
@@ -1301,7 +1301,7 @@ Amplitude.prototype._logEvent = function _logEvent(eventType, eventProperties, a
13011301 * Remove old events from the beginning of the array if too many have accumulated. Default limit is 1000 events.
13021302 * @private
13031303 */
1304- Amplitude . prototype . _limitEventsQueued = function _limitEventsQueued ( queue ) {
1304+ AmplitudeClient . prototype . _limitEventsQueued = function _limitEventsQueued ( queue ) {
13051305 if ( queue . length > this . options . savedMaxCount ) {
13061306 queue . splice ( 0 , queue . length - this . options . savedMaxCount ) ;
13071307 }
@@ -1324,7 +1324,7 @@ Amplitude.prototype._limitEventsQueued = function _limitEventsQueued(queue) {
13241324 * Note: the server response code and response body from the event upload are passed to the callback function.
13251325 * @example amplitude.logEvent('Clicked Homepage Button', {'finished_flow': false, 'clicks': 15});
13261326 */
1327- Amplitude . prototype . logEvent = function logEvent ( eventType , eventProperties , opt_callback ) {
1327+ AmplitudeClient . prototype . logEvent = function logEvent ( eventType , eventProperties , opt_callback ) {
13281328 if ( ! this . _apiKeySet ( 'logEvent()' ) || ! utils . validateInput ( eventType , 'eventType' , 'string' ) ||
13291329 utils . isEmptyString ( eventType ) ) {
13301330 if ( type ( opt_callback ) === 'function' ) {
@@ -1350,7 +1350,7 @@ Amplitude.prototype.logEvent = function logEvent(eventType, eventProperties, opt
13501350 * Note: the server response code and response body from the event upload are passed to the callback function.
13511351 * @example amplitude.logEventWithGroups('Clicked Button', null, {'orgId': 24});
13521352 */
1353- Amplitude . prototype . logEventWithGroups = function ( eventType , eventProperties , groups , opt_callback ) {
1353+ AmplitudeClient . prototype . logEventWithGroups = function ( eventType , eventProperties , groups , opt_callback ) {
13541354 if ( ! this . _apiKeySet ( 'logEventWithGroup()' ) ||
13551355 ! utils . validateInput ( eventType , 'eventType' , 'string' ) ) {
13561356 if ( type ( opt_callback ) === 'function' ) {
@@ -1379,7 +1379,7 @@ var _isNumber = function _isNumber(n) {
13791379 * @example var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99);
13801380 * amplitude.logRevenueV2(revenue);
13811381 */
1382- Amplitude . prototype . logRevenueV2 = function logRevenueV2 ( revenue_obj ) {
1382+ AmplitudeClient . prototype . logRevenueV2 = function logRevenueV2 ( revenue_obj ) {
13831383 if ( ! this . _apiKeySet ( 'logRevenueV2()' ) ) {
13841384 return ;
13851385 }
@@ -1408,7 +1408,7 @@ Amplitude.prototype.logRevenueV2 = function logRevenueV2(revenue_obj) {
14081408 * @param {string } product - (optional) product identifier
14091409 * @example amplitude.logRevenue(3.99, 1, 'product_1234');
14101410 */
1411- Amplitude . prototype . logRevenue = function logRevenue ( price , quantity , product ) {
1411+ AmplitudeClient . prototype . logRevenue = function logRevenue ( price , quantity , product ) {
14121412 // Test that the parameters are of the right type.
14131413 if ( ! this . _apiKeySet ( 'logRevenue()' ) || ! _isNumber ( price ) || ( quantity !== undefined && ! _isNumber ( quantity ) ) ) {
14141414 // utils.log('Price and quantity arguments to logRevenue must be numbers');
@@ -1427,7 +1427,7 @@ Amplitude.prototype.logRevenue = function logRevenue(price, quantity, product) {
14271427 * Remove events in storage with event ids up to and including maxEventId.
14281428 * @private
14291429 */
1430- Amplitude . prototype . removeEvents = function removeEvents ( maxEventId , maxIdentifyId ) {
1430+ AmplitudeClient . prototype . removeEvents = function removeEvents ( maxEventId , maxIdentifyId ) {
14311431 _removeEvents ( this , '_unsentEvents' , maxEventId ) ;
14321432 _removeEvents ( this , '_unsentIdentifys' , maxIdentifyId ) ;
14331433} ;
@@ -1458,7 +1458,7 @@ var _removeEvents = function _removeEvents(scope, eventQueue, maxId) {
14581458 * @param {Amplitude~eventCallback } callback - (optional) callback to run after events are sent.
14591459 * Note the server response code and response body are passed to the callback as input arguments.
14601460 */
1461- Amplitude . prototype . sendEvents = function sendEvents ( callback ) {
1461+ AmplitudeClient . prototype . sendEvents = function sendEvents ( callback ) {
14621462 if ( ! this . _apiKeySet ( 'sendEvents()' ) || this . _sending || this . options . optOut || this . _unsentCount ( ) === 0 ) {
14631463 if ( type ( callback ) === 'function' ) {
14641464 callback ( 0 , 'No request sent' ) ;
@@ -1527,7 +1527,7 @@ Amplitude.prototype.sendEvents = function sendEvents(callback) {
15271527 * Merge unsent events and identifys together in sequential order based on their sequence number, for uploading.
15281528 * @private
15291529 */
1530- Amplitude . prototype . _mergeEventsAndIdentifys = function _mergeEventsAndIdentifys ( numEvents ) {
1530+ AmplitudeClient . prototype . _mergeEventsAndIdentifys = function _mergeEventsAndIdentifys ( numEvents ) {
15311531 // coalesce events from both queues
15321532 var eventsToSend = [ ] ;
15331533 var eventIndex = 0 ;
@@ -1586,7 +1586,7 @@ Amplitude.prototype._mergeEventsAndIdentifys = function _mergeEventsAndIdentifys
15861586 * @public
15871587 * @deprecated
15881588 */
1589- Amplitude . prototype . setGlobalUserProperties = function setGlobalUserProperties ( userProperties ) {
1589+ AmplitudeClient . prototype . setGlobalUserProperties = function setGlobalUserProperties ( userProperties ) {
15901590 this . setUserProperties ( userProperties ) ;
15911591} ;
15921592
@@ -1596,9 +1596,9 @@ Amplitude.prototype.setGlobalUserProperties = function setGlobalUserProperties(u
15961596 * @returns {number } version number
15971597 * @example var amplitudeVersion = amplitude.__VERSION__;
15981598 */
1599- Amplitude . prototype . __VERSION__ = version ;
1599+ AmplitudeClient . prototype . __VERSION__ = version ;
16001600
1601- module . exports = Amplitude ;
1601+ module . exports = AmplitudeClient ;
16021602
16031603} , { "./constants" :4 , "./cookiestorage" :12 , "./utm" :13 , "./identify" :5 , "json" :14 , "./localstorage" :15 , "JavaScript-MD5" :16 , "object" :6 , "./xhr" :17 , "./revenue" :7 , "./type" :8 , "ua-parser-js" :18 , "./utils" :9 , "./uuid" :19 , "./version" :10 , "./options" :11 } ] ,
160416044 : [ function ( require , module , exports ) {
0 commit comments