Stop matching by phone number when upserting members in Identity #33
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.
In general since our member phone number data quality is so poor (we have many members with duplicate phone numbers), we can't rely on matching against the phone number when pulling Spoke data into Identity.
When pulling messages and opt-outs, if an external id for a Spoke
CampaignContact
is set, use that to look up the member - the external id came from Identity so we know what member is involved.If not we must create a new member every time - because if there is zero matching members, we need to create one; if there is one matching member, that member could have a bad phone number, so we can't assume it's them, so create a new one; if there are multiple members with matching numbers, we can't pick the right one reliably, so create a new one.
For Spoke users, upsert based on their known email address, because that is more reliable.
In all cases, update external ids in Spoke when one is not known, so if multiple contacts are processed for a newly upserted member, the same member is used for all further contacts in the same campaign.