Appearance
Adobe analytics
@investec/plugins-adobe-analytics wraps the shared @investec/cadi-core analytics builders and pushes the resulting payloads into window.adobeDataLayer.
Package
sh
npm install --save @investec/plugins-adobe-analyticsThis package has a peer dependency on @investec/cadi-core.
Public contract
The package exports a single class:
ts
import { AdobeAnalytics } from '@investec/plugins-adobe-analytics';Its public methods are:
initAnalytics(payload)setUserInfo(user)getUserInfo()adobeStandardizePageLoad(payload)adobeStandardizeRoadblockLoad(payload)adobeStandardizeGeneralClickEvent(payload)adobeStandardizeSearchClickEvent(payload)adobeStandardizeDownloadClickEvent(payload)adobeStandardizeFormClickEvent(payload)adobeStandardizeRoadblockClickEvent(payload)adobeStandardizeOpenClickEvent(payload)
Integration pattern
Initialise once before sending events:
ts
import { AdobeAnalytics } from '@investec/plugins-adobe-analytics';
const analytics = new AdobeAnalytics();
analytics.initAnalytics({
user,
env: 'staging',
digitalChannel,
});
analytics.adobeStandardizePageLoad({
eventName: 'page_load',
featureName: 'private-client|dashboard',
});Update the cached user context when login state or profile context changes:
ts
analytics.setUserInfo(updatedUser);Event behaviour
Each event method:
- builds a standardised payload through the cadi-core event builder;
- pushes that payload into
window.adobeDataLayer.
The plugin does not create or manage the Adobe SDK itself. It assumes the page has a writable window.adobeDataLayer.
How consumers extend it
Consumers normally extend this package by:
- supplying richer
useranddigitalChannelcontext at initialisation time; - updating the cached user context with
setUserInfo(...); - standardising business-specific event names before calling the plugin;
- wrapping the plugin in an app-owned analytics service.
Change the package itself only when the shared event-building contract needs to change for multiple consumers.
Extension example: wrap the plugin in an app-specific analytics service
ts
import { AdobeAnalytics } from '@investec/plugins-adobe-analytics';
type ProductContext = {
featureName: string;
clientSegment?: string;
};
export class ProductAnalytics {
private readonly analytics = new AdobeAnalytics();
init(user: any, env: 'test' | 'staging' | 'production') {
this.analytics.initAnalytics({
user,
env,
digitalChannel: {
application: 'wpaas-io-my-feature',
businessUnit: 'Any',
jurisdiction: 'global',
userPlatform: 'web',
},
});
}
updateUserContext(user: any) {
this.analytics.setUserInfo(user);
}
trackPrimaryAction(context: ProductContext, targetURL: string) {
this.analytics.adobeStandardizeGeneralClickEvent({
eventName: `feature|primary_action|${context.featureName}`,
featureName: context.featureName,
clickInfo: {
targetURL,
},
});
}
}Consumer notes
initAnalytics(...)must run before event methods can produce full payloads.pushToDataLayer(...)catches errors silently, so a missing or incompatible data layer does not throw back to the caller.getUserInfo()returns the builder's current cached user object, which allows the consumer to layer platform context onto the original identity payload.