only save nonnull utm properties #71
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before when fetching UTM data, we would generate a dictionary of utm keys and their values, and then sent it as an identify call once per session at the beginning of the session.
The problem is in the case where there are no UTM values present, we still generate this dictionary, but all of the keys have null/empty values. When we try to send the empty values on the identify, the event properties validator generates a bunch of warnings:
[Amplitude] WARNING: Property key "initial_utm_source" with invalid value type undefined, ignoring [Amplitude] WARNING: Property key "initial_utm_medium" with invalid value type undefined, ignoring [Amplitude] WARNING: Property key "initial_utm_campaign" with invalid value type undefined, ignoring [Amplitude] WARNING: Property key "initial_utm_term" with invalid value type undefined, ignoring [Amplitude] WARNING: Property key "initial_utm_content" with invalid value type undefined, ignoring [Amplitude] WARNING: Property key "utm_source" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_medium" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_term" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_content" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_name" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_source" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_medium" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_term" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_content" with invalid value type null, ignoring [Amplitude] WARNING: Property key "utm_name" with invalid value type null, ignoring
The solution is to only add utm keys/values to the utm data dictionary if the value is not null/empty. The logic already skips empty dictionaries.
Not super urgent as nothing is broken, but this will generate a bunch of garbage warnings in console. Will push this as v2.12.1