Skip to content

Adobe analytics ​

@investec/plugins-adobe-analytics wraps the shared @investec/cadi-core analytics builders and pushes the resulting payloads into window.adobeDataLayer.

Package ​

Warning: By default, this package must be installed only by the platform team into the Investec Online shell application. Do not add it as a direct dependency of a consumer/feature application unless the Web Platform team has explicitly approved that specific use as a rare exception. Consumers should use this plugin's behaviour through the Invsy SDK, or contribute a bounded, governed change to this plugin's own source (see Plugin change governance).

sh
npm install --save @investec/plugins-adobe-analytics

The platform owns installation of released plugin versions. A consuming team normally contributes shared logic in this repository and then asks the platform team to adopt the published version.

This 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:

  1. builds a standardised payload through the cadi-core event builder;
  2. 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 user and digitalChannel context 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,
      },
    });
  }
}

Extend the shared plugin ​

Use these files when the platform needs reusable analytics behaviour:

ChangeLocation
Add a standard event methodadobe-analytics/src/lib/adobe-analytics.ts
Add or extend a typed event payloadadobe-analytics/src/lib/types/adobe-analytics.interface.ts
Publish a supported exportadobe-analytics/src/index.ts
Verify event construction and data-layer dispatchadobe-analytics/src/lib/adobe-analytics.spec.ts

Adding an event that uses the existing CADI builder and data-layer contract is a normal existing-plugin contribution. Obtain platform and analytics-owner approval before changing identity fields, the data-layer destination, consent behaviour, failure semantics, or the @investec/cadi-core contract.

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.