Personalisation plugin
Overview
The personalisation plugin gets the content from the adobe target api based on the clients context (zeta ID). The plugins' responsibility is to pass through all the relevant activity names to adobe target, transform the response and send it back to the platform and expose it via the invsy SDK.
shell
npm install --save @investec/plugins-personalisationEnvironment
The plugin makes use of environments to differentiate between api calls.
ts
export const environment = {
production:{
baseUrl:'cxt-personalisation.secure.investec.com',
audienceManagement: true
},
beta: {
baseUrl:'cxt-personalisation.secure.investec.com',
audienceManagement: true
},
staging:{
baseUrl:'cxt-personalisationstg.secure.investec.com',
audienceManagement: true
},
test:{
baseUrl:'cxt-personalisationstg.secure.investec.com',
audienceManagement: true
}
}Implementation guide
The plugin exposes a single function to get the personalisation content from adobe target. It transforms the result and returns it to the platform.
ts
import { IAdobeTargetInterface } from './types/adobe-target.interface';
import { environment } from './environment';
import { IAuthResponse } from './types/auth-response.interface';
export const personalisation = {activeEnvironment : 'staging'}
export function getPersonalisationData(authRes:IAuthResponse){
return new Promise((resolve,reject) => {
const privateBankZaActivities = [
"InTransit"
]
const privateZaTargetMarketActivities = [
"InvestecTravel",
"AonInsurance",
"RewardsReferral",
"myInvestmentGeneric",
"SustainableSolutions",
"Pulsator_Drop_1",
"Featured_Drop_1",
"Featured_Drop_2",
"Featured_Drop_3",
"Featured_Drop_4",
"Featured_Drop_5",
"PrivateSelection_Drop_1",
"PrivateSelection_Drop_2",
"PrivateSelection_Drop_3",
"PrivateSelection_Drop_4",
"PrivateSelection_Drop_5",
"PrivateSelection_Drop_6",
"CVP_Bank_Drop_1",
"CVP_Bank_Drop_2",
"CVP_Bank_Drop_3",
"CVP_Bank_Drop_4",
"CVP_Bank_Drop_5",
"CVP_Finance_Drop_1",
"CVP_Finance_Drop_2",
"CVP_Finance_Drop_3",
"CVP_Finance_Drop_4",
"CVP_Finance_Drop_5",
"CVP_Invest_AND_Save_Drop_1",
"CVP_Invest_AND_Save_Drop_2",
"CVP_Invest_AND_Save_Drop_3",
"CVP_Invest_AND_Save_Drop_4",
"CVP_Invest_AND_Save_Drop_5",
"CVP_Insure_Drop_1",
"CVP_Insure_Drop_2",
"CVP_Insure_Drop_3",
"CVP_Travel_Drop_1",
"YouMayBeInterestedIn_Drop_1",
"YouMayBeInterestedIn_Drop_2",
"YouMayBeInterestedIn_Drop_3",
"YouMayBeInterestedIn_Drop_4",
"YouMayBeInterestedIn_Drop_5",
"CVP_All_Drop_1",
"CVP_All_Drop_2",
"CVP_All_Drop_3",
"CVP_All_Drop_4",
"CVP_All_Drop_5"
];
const lifeTargetMarketActivities = [
"LifeStarterDashboard",
"LifeInsurance",
"SevereIllness",
];
const activitiesList = []
if (environment[personalisation.activeEnvironment as keyof typeof environment].audienceManagement)
{
activitiesList.push(...privateZaTargetMarketActivities, ...privateBankZaActivities);
}
else{
authRes.PrivateBankZATargetMarket && activitiesList.push(...privateZaTargetMarketActivities);
authRes.PrivateBankZA && activitiesList.push(...privateBankZaActivities)
}
authRes.LifeTargetMarket && activitiesList.push(...lifeTargetMarketActivities);
if(activitiesList.length === 0){
reject('no activities')
} else {
fetch(`/az-proxy/${environment[personalisation.activeEnvironment as keyof typeof environment].baseUrl}/api/v1/target/profile`, {
method: 'POST',
headers: {'Content-Type': 'application/json', 'WPaaS': 'critical'},
body: JSON.stringify(
{
"ZetaId": authRes.Misc?.Zeta,
"Activities": activitiesList
}
),
}).then((personalisationData) => personalisationData.json()).then((res: IAdobeTargetInterface) => {
if (res) {
const tempObject: any = {}
res.data.execute.mboxes.forEach(mbox => {
if (mbox.options && mbox.options.length > 0) {
const name = mbox.name.split('_');
name.pop();
tempObject[name.join('_')] = mbox
}
})
resolve(tempObject);
}
}).catch(() => reject('call failed'));
}
})
}