Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not overwrite flushIntervalMillis=0 with default value (10 seconds) #589

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/amplitude-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ var _parseConfig = function _parseConfig(options, config) {
// Add exception in headers
const freeFormObjectKeys = new Set(['headers']);

const zeroAllowedKeys = new Set(['eventUploadPeriodMillis']);

// validates config value is defined, is the correct type, and some additional value sanity checks
var parseValidateAndLoad = function parseValidateAndLoad(key) {
if (!Object.prototype.hasOwnProperty.call(options, key)) {
Expand All @@ -433,7 +435,7 @@ var _parseConfig = function _parseConfig(options, config) {
options[key] = !!inputValue;
} else if (
(expectedType === 'string' && !utils.isEmptyString(inputValue)) ||
(expectedType === 'number' && inputValue > 0) ||
(expectedType === 'number' && (inputValue > 0 || (inputValue === 0 && zeroAllowedKeys.has(key)))) ||
expectedType === 'function'
) {
options[key] = inputValue;
Expand Down
9 changes: 9 additions & 0 deletions test/amplitude-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ describe('AmplitudeClient', function () {
assert.equal(amplitude.options.bogusKey, undefined);
});

it('should not overwrite eventUploadPeriodMillis=0 with default value', function () {
var config = {
eventUploadPeriodMillis: 0,
};

amplitude.init(apiKey, userId, config);
assert.equal(amplitude.options.eventUploadPeriodMillis, 0);
});

it('should set the default log level', function () {
const config = {};

Expand Down