fix(analytics): validate against incomplete/invalid app_remove events#1738
fix(analytics): validate against incomplete/invalid app_remove events#1738
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request provides a solid fix for a crash caused by malformed user properties in analytics events. The approach is robust, adding defensive checks in unwrapValueAsString and filtering invalid properties during event construction. The addition of a new test case that covers various invalid inputs is excellent for ensuring correctness and preventing future regressions. I have one suggestion to improve the readability of the new filtering logic.
eee4ef2 to
16b1413
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a TypeError caused by malformed user properties in analytics events. The solution is well-implemented, particularly the defensive programming in unwrapValueAsString and the addition of comprehensive test cases to prevent regressions. I have one suggestion to further improve the robustness of the user property filtering logic to prevent partially-valid objects from being processed.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively resolves a TypeError caused by malformed user properties in analytics events. The solution is robust, introducing defensive checks in unwrapValueAsString and filtering invalid properties within the UserDimensions constructor. The accompanying test case is thorough, covering a wide range of invalid data scenarios, which is excellent for ensuring the fix's reliability. I have one suggestion to improve the maintainability of the new filtering logic by extracting it into a dedicated helper function.
This draft PR is a proposed solution to resolve #1712
Problem
When an analytics event payload contains malformed user properties, the SDK throws a
TypeErrorbefore the user's callback can execute:Error:
TypeError: Cannot convert undefined or null to object
at Function.keys ()
at unwrapValueAsString (analytics.js:206)
Solution