Skip to content

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

Merged
triniwiz merged 2 commits into
NativeScript:mainfrom
mukaschultze:fix/filter-out-null-event-params
Oct 31, 2022
Merged

fix(ios/core): filter out nil values from serialize method#142
triniwiz merged 2 commits into
NativeScript:mainfrom
mukaschultze:fix/filter-out-null-event-params

Conversation

@mukaschultze

@mukaschultze mukaschultze commented Oct 21, 2022

Copy link
Copy Markdown
Contributor

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
Comment thread packages/firebase-core/utils.ts Outdated
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