-
Notifications
You must be signed in to change notification settings - Fork 133
Defensive cleanup #64
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
Conversation
@@ -86,6 +87,9 @@ build: $(TESTS) $(OUT) $(SNIPPET_OUT) $(SEGMENT_SNIPPET_OUT) README.md | |||
@$(DUO) --development test/tests.js > build/tests.js | |||
@$(DUO) --development test/snippet-tests.js > build/snippet-tests.js | |||
|
|||
docs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered adding this to the default make command, but the html files are timestamped, so they would be modified with every make. Whenever someone updates the API, they need to remember to update the docs
Amplitude.prototype.runQueuedFunctions = function () { | ||
for (var i = 0; i < this._q.length; i++) { | ||
var fn = this[this._q[i][0]]; | ||
if (fn && type(fn) === 'function') { | ||
if (type(fn) === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can skip the null check since type(null) will return 'null' which fails the === 'function' test
Refactoring a bunch of stuff, adding lots of sanity checks and more type-checking around user-input, handle more failure cases gracefully.
|
// utils.log(e); | ||
} | ||
var events = JSON.parse(savedUnsentEventsString); | ||
if (type(events) === 'array') { // handle case where JSON dumping of unsent events is corrupted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supposed to deserialize into an array object, but if client's have broken JSON libraries, it deserializes into a string, which breaks the SDK
@paladin8 you can skip everything in the documentation folder |
// verifies config value is defined, is the correct type, and some additional value verification | ||
var parseValidateLoad = function parseValidateLoad(key, expectedType) { | ||
var input_value = config[key]; | ||
if(input_value === undefined || !utils.validateInput(input_value, key + ' option', expectedType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after if.
really solid changes, only worry is that it is pretty big so we just want to make sure we manually test enough and that upgrades work, etc. lgtm from a code perspective though! |
No description provided.