mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
Merge pull request #35516 from overleaf/rh-cio-commons-ai
[web] Send Commons AI attribute to customer.io GitOrigin-RevId: de010cc34f4e1a854a730ec39212845e1c05d4b1
This commit is contained in:
@@ -545,7 +545,7 @@ function getGroupRole(
|
||||
* Customer.io properties derived from a user's institutional affiliations.
|
||||
*
|
||||
* @param {UserEmailData[]} userEmails - email data from UserGetter.getUserFullEmails
|
||||
* @returns {{ enterprise_commons: boolean, domain_capture: boolean }}
|
||||
* @returns {{ enterprise_commons: boolean, commons_ai: boolean, domain_capture: boolean }}
|
||||
*/
|
||||
function getAffiliationProperties(userEmails) {
|
||||
const enterpriseCommons = userEmails.some(
|
||||
@@ -554,11 +554,17 @@ function getAffiliationProperties(userEmails) {
|
||||
emailData.affiliation?.institution?.commonsAccount &&
|
||||
emailData.affiliation?.institution?.enterpriseCommons
|
||||
)
|
||||
const commonsAi = userEmails.some(
|
||||
emailData =>
|
||||
emailData.emailHasInstitutionLicence &&
|
||||
emailData.affiliation?.institution?.writefullCommonsAccount === true
|
||||
)
|
||||
const domainCapture = userEmails.some(
|
||||
emailData => emailData.affiliation?.group?.domainCaptureEnabled
|
||||
)
|
||||
return {
|
||||
enterprise_commons: enterpriseCommons,
|
||||
commons_ai: commonsAi,
|
||||
domain_capture: domainCapture,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,47 @@ describe('CustomerIoPlanHelpers', function () {
|
||||
expect(properties.enterprise_commons).to.equal(false)
|
||||
})
|
||||
|
||||
it('sets commons_ai=true when the user has active commons access at a writefullCommonsAccount institution', function () {
|
||||
const properties = CustomerIoPlanHelpers.getAffiliationProperties([
|
||||
{
|
||||
emailHasInstitutionLicence: true,
|
||||
affiliation: {
|
||||
institution: { writefullCommonsAccount: true },
|
||||
},
|
||||
},
|
||||
])
|
||||
expect(properties.commons_ai).to.equal(true)
|
||||
})
|
||||
|
||||
it('sets commons_ai=false when affiliated with a writefullCommonsAccount institution but without active commons access', function () {
|
||||
const properties = CustomerIoPlanHelpers.getAffiliationProperties([
|
||||
{
|
||||
emailHasInstitutionLicence: false,
|
||||
affiliation: {
|
||||
institution: { writefullCommonsAccount: true },
|
||||
},
|
||||
},
|
||||
])
|
||||
expect(properties.commons_ai).to.equal(false)
|
||||
})
|
||||
|
||||
it('sets commons_ai=false when active access is not at a writefullCommonsAccount institution', function () {
|
||||
const properties = CustomerIoPlanHelpers.getAffiliationProperties([
|
||||
{
|
||||
emailHasInstitutionLicence: true,
|
||||
affiliation: {
|
||||
institution: { commonsAccount: true },
|
||||
},
|
||||
},
|
||||
])
|
||||
expect(properties.commons_ai).to.equal(false)
|
||||
})
|
||||
|
||||
it('sets commons_ai=false when there are no emails', function () {
|
||||
const properties = CustomerIoPlanHelpers.getAffiliationProperties([])
|
||||
expect(properties.commons_ai).to.equal(false)
|
||||
})
|
||||
|
||||
it('sets domain_capture=true when an affiliation has domain capture enabled', function () {
|
||||
const properties = CustomerIoPlanHelpers.getAffiliationProperties([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user