Skip to content

fix(ios/core): filter out nil values from serialize method #142

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

Merged

Conversation

mukaschultze
Copy link
Contributor

@mukaschultze mukaschultze commented Oct 21, 2022

Firebase analytics' logEvent method fails on iOS when there's an array with null/undefined elements and when objects have null/undefined prop values.

With this PR the null elements are filtered out of arrays and dictionaries.

This PR also fixes a slight oversight with data.map(serialize), since this syntax causes the second argument to be the element index instead of wrapPrimitives, causing the first element not to be wrapped and all the others to be.

firebase().analytics().logEvent('eventname', [ null, undefined ]);
// Error: *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0] Error: *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]

firebase().analytics().logEvent('eventname', { someProp: null, otherProp: undefined });
// Error: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0] Error: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

firebase-database might have the same issue since it declares its own version of the serialize method, but I haven't tested it.

@cla-bot cla-bot bot added the cla: yes label Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants