Different Contact Field Ids Used For Different Apps

Goal

How can contact-reference-manager handle different contact field ids being used in different apps within the same account? I.e. a consumer using both apps of a customer will have one contact reference (CR) per app because different contact-field-ids are used for login.

Problem

The contact external key (CEK) is used for login which is composed of customerId, contactFieldId and a hash of contactFieldValue. Two CRs are created because the contactFieldId and the contactFieldValue are different for the two logins.

When the contact reference is queried for a contact key (CK customerId:contactId) the most recent created (createdAt field) contact reference is returned. I.e. for one app the wrong contact reference is returned. That’s the issue we want to solve.

In other words: contact reference has a 1:1 relationship with contact external key. But a contact key can have multiple contact references.

Solution

Adding a new field app code to the DynamoDB table allows the contact-reference-manager to filter for the app code and hence the correct contact reference is used.

If there is no contact reference with the specified app code the most recent created contact reference is used (as it’s done now).

Implementation

Login

The push service login worker adds the contact key to contact references. It has to append the app code to the contact key. I.e. existing contact references which have been logged in already still have the old format.

Contact Reference Lookup By Contact Key

Lookup by ck:customerId:contactId and then filter by appCode