Appearance
Personalisation
@investec/plugins-personalisation wraps the Adobe Target personalisation endpoints used by the platform and provides helpers for generating profile-update payloads from returned content cards.
Package
sh
npm install --save @investec/plugins-personalisationPublic contract
The package exports:
personalisation.activeEnvironmentgetAdobeTargetDataByTemplate(authRes, payload)postProfileUpdatesByTemplate(template)postProfileUpdatesOnCallToAction(card, callToActionType)- mapping helpers such as
buildProfileMapByTemplate(...),buildProfileMapByCallToAction(...),combineProfileUpdates(...),sanitizeStringForProfile(...)
Integration pattern
ts
import {
getAdobeTargetDataByTemplate,
personalisation,
postProfileUpdatesOnCallToAction,
} from '@investec/plugins-personalisation';
personalisation.activeEnvironment = 'staging';
const response = await getAdobeTargetDataByTemplate(authResponse, {
Templates: ['Pulsator_Template'],
});
await postProfileUpdatesOnCallToAction(card, 'primary');Template retrieval
getAdobeTargetDataByTemplate(...) posts to:
text
/edge/personalisation/api/v1/target/personalisationIt requires a payload containing a non-empty Templates array.
Profile update helpers
The package supports two update flows:
- impression/template-level updates through
postProfileUpdatesByTemplate(...) - CTA engagement updates through
postProfileUpdatesOnCallToAction(...)
Both methods derive profile attributes from Adobe Target response data and post them to:
text
/edge/personalisation/api/v1/target/profile-updateHow consumers extend it
Consumers usually extend this package by controlling:
- which template names are requested;
- when a returned card should trigger a profile update;
- whether to inspect or test the generated profile map before posting it.
The mapping helpers make that easier without changing the shared package.
Change the package when the Adobe Target response contract, endpoint contract, or shared profile-mapping rules need to change.
Extension example: inspect the generated CTA profile update before posting
ts
import {
buildProfileMapByCallToAction,
postProfileUpdatesOnCallToAction,
type IRefinedMbox,
} from '@investec/plugins-personalisation';
export async function trackPrimaryOfferClick(card: IRefinedMbox) {
const previewProfileMap = buildProfileMapByCallToAction(card, 'primary');
console.log('Profile update payload preview:', previewProfileMap);
const posted = await postProfileUpdatesOnCallToAction(card, 'primary');
if (!posted) {
console.warn('Profile update failed');
}
}Consumer notes
- The current implementation accepts
authResingetAdobeTargetDataByTemplate(...), but uses only the configured endpoint and request payload. postProfileUpdatesByTemplate(...)andpostProfileUpdatesOnCallToAction(...)returnfalseon failure rather than throwing.- The mapping helpers are useful when the consumer needs to inspect or test the exact profile payload before posting it.