Created
March 28, 2023 11:53
-
-
Save DominicFinn/542643b5433651e7b5e10c9033682958 to your computer and use it in GitHub Desktop.
Event handlers handling fire store documents create / updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const IterableDataService = require('../../iterable/IterableDataService'); | |
module.exports = functions.firestore.document('prospecting-student/{email}').onCreate(async (snap, context) => { | |
const student = snap.data(); | |
const result = await IterableDataService.putUserData({ | |
email: snap.id, | |
userId: student.uuid, | |
dataFields: { | |
emailOptIn: true, | |
isProspectingUser: 'true', // specifically not overwriting userType because some users will already exist | |
addressable: true, | |
campaigns: student.campaigns | |
} | |
}); | |
functions.logger.info('Iterable putUserData result', result); | |
return true; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const IterableDataService = require('../../iterable/IterableDataService'); | |
module.exports = functions.firestore.document('prospecting-student/{email}').onUpdate(async (change, context) => { | |
const student = change.after.data(); | |
const result = await IterableDataService.putUserData({ | |
email: change.after.id, | |
userId: student.uuid, | |
dataFields: { | |
emailOptIn: true, | |
isProspectingUser: 'true', // specifically not overwriting userType because some users will already exist | |
addressable: true, | |
campaigns: student.campaigns | |
} | |
}); | |
// functions.logger.info('Iterable putUserData result', result); | |
return true; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment