mozilla-rally / rally

A monorepo for Rally project containing Rally SDK, Rally Web Platform and Extensions.
Mozilla Public License 2.0
7 stars 6 forks source link

Automatically sync Rally accounts and status to Sendgrid #304

Open rhelmer opened 1 year ago

rhelmer commented 1 year ago

I was looking at the available GCP/Firebase and Sendgrid integrations, this is close to what we want but a little too simplistic: https://firebase.google.com/products/extensions/twilio-sendgrid-sync-contacts

This Firebase extension just syncs a particular Firestore document collection full of contact info to Sendgrid's contact DB.

I think what we need is something more like:

  1. create custom boolean fields for: 1a. enrollment status 1b. extension activation status 1c. extension inactive for (n) days
  2. full sync email addresses from existing Firebase Auth db to Sendgrid contacts db
  3. handleUserChanges and handleUserStudyChanges triggers to update existing contacts

This would allow us to create segments on the Sendgrid side and not need to do a special export of Firebase data, it would just stay in sync as users make changes. There are three databases involved, so it's possible for them to get out-of-sync:

We should run a periodic full sync (2), and log+report any inconsistencies. For (3) we should do the same. Having occasional problems where the full or partial sync fails is normal, so we should keep this in mind when emailing users.

The worst-case scenario of being out-of-sync is that we might email the user to take an action that they already have (for instance if they activated their extension, or started using it again, during the time period where we were out-of-sync.

rhelmer commented 1 year ago

As a first step, I am going to manually export from Firebase and import into Sendgrid, which will be the basis of the full sync (2) above.

rhelmer commented 1 year ago
1. create custom boolean fields for:
   1a. enrollment status
   1b. extension activation status
   1c. extension inactive for (n) days

We also want to be able to segment on studies that the user participated in - right now that's Pixel Hunt and Attention Stream.

rhelmer commented 1 year ago
   1c. extension inactive for (n) days

I think instead of sending this as boolean, we should just send the lastSignedIn date from the extension's account (which is a sub-account of the user's account). Then we don't need the function to decide how many days to care about, I think we can configure that in Sendgrid instead, since custom fields can be a date type: https://docs.sendgrid.com/ui/managing-contacts/custom-fields