Skip to content

Commit 1056024

Browse files
committed
v4.3.0
1 parent 6a35d09 commit 1056024

File tree

8 files changed

+72
-23
lines changed

8 files changed

+72
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 4.3.0 (July 16, 2018)
2+
3+
* Add more context to the 'No request sent' responses
4+
15
### 4.2.1 (April 19, 2018)
26

37
* Add `resetSessionId` method that sets the sessionId to the current time.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Please see our [installation guide](https://amplitude.zendesk.com/hc/en-us/artic
1111
[![npm version](https://badge.fury.io/js/amplitude-js.svg)](https://badge.fury.io/js/amplitude-js)
1212
[![Bower version](https://badge.fury.io/bo/amplitude-js.svg)](https://badge.fury.io/bo/amplitude-js)
1313

14-
[4.2.1 - Released on April 18, 2018](https://github.com/amplitude/Amplitude-JavaScript/releases/latest)
14+
[4.3.0 - Released on July 16, 2018](https://github.com/amplitude/Amplitude-JavaScript/releases/latest)
1515

1616

1717
# JavaScript SDK Reference #

amplitude-snippet.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script")
22
;r.type="text/javascript";r.async=true
3-
;r.src="https://cdn.amplitude.com/libs/amplitude-4.2.1-min.gz.js"
3+
;r.src="https://cdn.amplitude.com/libs/amplitude-4.3.0-min.gz.js"
44
;r.onload=function(){if(e.amplitude.runQueuedFunctions){
55
e.amplitude.runQueuedFunctions()}else{
66
console.log("[Amplitude] Error: could not load SDK")}}

amplitude.js

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5627,7 +5627,7 @@ var uuid$1 = function uuid(a) {
56275627
);
56285628
};
56295629

5630-
var version = '4.2.1';
5630+
var version = '4.3.0';
56315631

56325632
var getLanguage = function getLanguage() {
56335633
return navigator && (navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage) || undefined;
@@ -5725,7 +5725,7 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o
57255725
this.options.domain = this.cookieStorage.options().domain;
57265726

57275727
if (this._instanceName === constants.DEFAULT_INSTANCE) {
5728-
_upgradeCookeData(this);
5728+
_upgradeCookieData(this);
57295729
}
57305730
_loadCookieData(this);
57315731

@@ -6025,7 +6025,7 @@ AmplitudeClient.prototype._setInStorage = function _setInStorage(storage, key, v
60256025
* Need to unify all sources into one place with a one-time upgrade/migration.
60266026
* @private
60276027
*/
6028-
var _upgradeCookeData = function _upgradeCookeData(scope) {
6028+
var _upgradeCookieData = function _upgradeCookieData(scope) {
60296029
// skip if already migrated to 4.10+
60306030
var cookieData = scope.cookieStorage.get(scope.options.cookieName + scope._storageSuffix);
60316031
if (type(cookieData) === 'object') {
@@ -6459,7 +6459,7 @@ var _convertProxyObjectToRealObject = function _convertProxyObjectToRealObject(i
64596459
AmplitudeClient.prototype.identify = function (identify_obj, opt_callback) {
64606460
if (!this._apiKeySet('identify()')) {
64616461
if (type(opt_callback) === 'function') {
6462-
opt_callback(0, 'No request sent');
6462+
opt_callback(0, 'No request sent', { reason: 'API key is not set' });
64636463
}
64646464
return;
64656465
}
@@ -6473,13 +6473,16 @@ AmplitudeClient.prototype.identify = function (identify_obj, opt_callback) {
64736473
// only send if there are operations
64746474
if (Object.keys(identify_obj.userPropertiesOperations).length > 0) {
64756475
return this._logEvent(constants.IDENTIFY_EVENT, null, null, identify_obj.userPropertiesOperations, null, null, opt_callback);
6476+
} else {
6477+
if (type(opt_callback) === 'function') {
6478+
opt_callback(0, 'No request sent', { reason: 'No user property operations' });
6479+
}
64766480
}
64776481
} else {
64786482
utils.log.error('Invalid identify input type. Expected Identify object but saw ' + type(identify_obj));
6479-
}
6480-
6481-
if (type(opt_callback) === 'function') {
6482-
opt_callback(0, 'No request sent');
6483+
if (type(opt_callback) === 'function') {
6484+
opt_callback(0, 'No request sent', { reason: 'Invalid identify input type' });
6485+
}
64836486
}
64846487
};
64856488

@@ -6502,9 +6505,15 @@ AmplitudeClient.prototype.setVersionName = function setVersionName(versionName)
65026505
*/
65036506
AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventProperties, apiProperties, userProperties, groups, timestamp, callback) {
65046507
_loadCookieData(this); // reload cookie before each log event to sync event meta-data between windows and tabs
6505-
if (!eventType || this.options.optOut) {
6508+
if (!eventType) {
6509+
if (type(callback) === 'function') {
6510+
callback(0, 'No request sent', { reason: 'Missing eventType' });
6511+
}
6512+
return;
6513+
}
6514+
if (this.options.optOut) {
65066515
if (type(callback) === 'function') {
6507-
callback(0, 'No request sent');
6516+
callback(0, 'No request sent', { reason: 'optOut is set to true' });
65086517
}
65096518
return;
65106519
}
@@ -6568,7 +6577,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
65686577
}
65696578

65706579
if (!this._sendEventsIfReady(callback) && type(callback) === 'function') {
6571-
callback(0, 'No request sent');
6580+
callback(0, 'No request sent', { reason: 'No events to send or upload queued' });
65726581
}
65736582

65746583
return eventId;
@@ -6619,9 +6628,21 @@ AmplitudeClient.prototype.logEvent = function logEvent(eventType, eventPropertie
66196628
* @example amplitudeClient.logEvent('Clicked Homepage Button', {'finished_flow': false, 'clicks': 15});
66206629
*/
66216630
AmplitudeClient.prototype.logEventWithTimestamp = function logEvent(eventType, eventProperties, timestamp, opt_callback) {
6622-
if (!this._apiKeySet('logEvent()') || !utils.validateInput(eventType, 'eventType', 'string') || utils.isEmptyString(eventType)) {
6631+
if (!this._apiKeySet('logEvent()')) {
6632+
if (type(opt_callback) === 'function') {
6633+
opt_callback(0, 'No request sent', { reason: 'API key not set' });
6634+
}
6635+
return -1;
6636+
}
6637+
if (!utils.validateInput(eventType, 'eventType', 'string')) {
6638+
if (type(opt_callback) === 'function') {
6639+
opt_callback(0, 'No request sent', { reason: 'Invalid type for eventType' });
6640+
}
6641+
return -1;
6642+
}
6643+
if (utils.isEmptyString(eventType)) {
66236644
if (type(opt_callback) === 'function') {
6624-
opt_callback(0, 'No request sent');
6645+
opt_callback(0, 'No request sent', { reason: 'Missing eventType' });
66256646
}
66266647
return -1;
66276648
}
@@ -6644,9 +6665,15 @@ AmplitudeClient.prototype.logEventWithTimestamp = function logEvent(eventType, e
66446665
* @example amplitudeClient.logEventWithGroups('Clicked Button', null, {'orgId': 24});
66456666
*/
66466667
AmplitudeClient.prototype.logEventWithGroups = function (eventType, eventProperties, groups, opt_callback) {
6647-
if (!this._apiKeySet('logEventWithGroup()') || !utils.validateInput(eventType, 'eventType', 'string')) {
6668+
if (!this._apiKeySet('logEventWithGroups()')) {
66486669
if (type(opt_callback) === 'function') {
6649-
opt_callback(0, 'No request sent');
6670+
opt_callback(0, 'No request sent', { reason: 'API key not set' });
6671+
}
6672+
return -1;
6673+
}
6674+
if (!utils.validateInput(eventType, 'eventType', 'string')) {
6675+
if (type(opt_callback) === 'function') {
6676+
opt_callback(0, 'No request sent', { reason: 'Invalid type for eventType' });
66506677
}
66516678
return -1;
66526679
}
@@ -6751,9 +6778,27 @@ var _removeEvents = function _removeEvents(scope, eventQueue, maxId) {
67516778
* Note the server response code and response body are passed to the callback as input arguments.
67526779
*/
67536780
AmplitudeClient.prototype.sendEvents = function sendEvents(callback) {
6754-
if (!this._apiKeySet('sendEvents()') || this._sending || this.options.optOut || this._unsentCount() === 0) {
6781+
if (!this._apiKeySet('sendEvents()')) {
6782+
if (type(callback) === 'function') {
6783+
callback(0, 'No request sent', { reason: 'API key not set' });
6784+
}
6785+
return;
6786+
}
6787+
if (this.options.optOut) {
6788+
if (type(callback) === 'function') {
6789+
callback(0, 'No request sent', { reason: 'optOut is set to true' });
6790+
}
6791+
return;
6792+
}
6793+
if (this._unsentCount() === 0) {
6794+
if (type(callback) === 'function') {
6795+
callback(0, 'No request sent', { reason: 'No events to send' });
6796+
}
6797+
return;
6798+
}
6799+
if (this._sending) {
67556800
if (type(callback) === 'function') {
6756-
callback(0, 'No request sent');
6801+
callback(0, 'No request sent', { reason: 'Request already in progress' });
67576802
}
67586803
return;
67596804
}

amplitude.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "amplitude-js",
33
"author": "Amplitude <[email protected]>",
4-
"version": "4.2.1",
4+
"version": "4.3.0",
55
"license": "MIT",
66
"description": "Javascript library for Amplitude Analytics",
77
"keywords": [

src/amplitude-snippet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var as = document.createElement('script');
44
as.type = 'text/javascript';
55
as.async = true;
6-
as.src = 'https://cdn.amplitude.com/libs/amplitude-4.2.1-min.gz.js';
6+
as.src = 'https://cdn.amplitude.com/libs/amplitude-4.3.0-min.gz.js';
77
as.onload = function() {if(window.amplitude.runQueuedFunctions) {window.amplitude.runQueuedFunctions();} else {console.log('[Amplitude] Error: could not load SDK');}};
88
var s = document.getElementsByTagName('script')[0];
99
s.parentNode.insertBefore(as, s);

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default '4.2.1';
1+
export default '4.3.0';

0 commit comments

Comments
 (0)