Skip to content

Experience manager

@investec/plugins-experience-manager is the journey-decision layer for pre-login and post-login navigation. It maps the authenticated customer context to a destination URL and also provides a helper for decoding encoded destinations.

Package

sh
npm install --save @investec/plugins-experience-manager

Public contract

The package exports:

  • experienceManager.activeEnvironment
  • determineJourneyPreLogin()
  • determineJourneyAfterLogin(authRes)
  • decodeDestination(destination)
  • helper exports such as setDecisionFlags(...) and getDestinationBasedOnCurrentContext(...)

Integration pattern

Set the environment first:

ts
import {
  determineJourneyAfterLogin,
  determineJourneyPreLogin,
  experienceManager,
} from '@investec/plugins-experience-manager';

experienceManager.activeEnvironment = 'staging';

Use the pre-login function for anonymous or expired-session entry:

ts
const loginUrl = determineJourneyPreLogin();

Use the post-login function after auth context is available:

ts
const destination = await determineJourneyAfterLogin(authResponse);

What the post-login logic does

The plugin:

  1. builds an initial destination from high-level client flags;
  2. routes multi-journey users to /usrroot-wpaas/types when required;
  3. applies secondary filters for special profile, masquerade, IX, intermediary, life, Mauritius, and other edge cases;
  4. returns the final URL as a string.

Encoded destinations

decodeDestination(...) reads the ZGVzdGluYXRpb24 query parameter and decodes it. If the destination points at a known dotcom hostname, it rewrites the target under /aem-content/.

How consumers extend it

The supported consumer pattern is to call the plugin first, then apply any application-owned navigation decision after the returned destination.

Use consumer code for rules that belong to one app only, such as:

  • whether to open a destination in the same tab or a new tab;
  • temporary gating or A/B behaviour around a returned path;
  • UI behaviour that depends on the chosen destination.

Change the plugin package when the journey rule itself is a shared Investec Online rule and should apply to every consumer using the package.

Extension example: wrap the returned destination with app-owned policy

ts
import { determineJourneyAfterLogin } from '@investec/plugins-experience-manager';

type NavigationTarget = {
  url: string;
  target?: '_self' | '_blank';
};

export async function resolveHomeJourney(
  authResponse: any,
  options: { openIxInSameTab: boolean }
): Promise<NavigationTarget> {
  const destination = await determineJourneyAfterLogin(authResponse);

  if (
    options.openIxInSameTab &&
    destination.startsWith('https://ix')
  ) {
    return { url: destination, target: '_self' };
  }

  if (destination.startsWith('/open-api/')) {
    return { url: destination, target: '_blank' };
  }

  return { url: destination };
}

Consumer notes

  • determineJourneyPreLogin() reads window.location directly and preserves only approved query parameters. It returns /login/form for the public /login route and preserves canonical nested /login/* journeys.
  • determineJourneyAfterLogin(...) returns a Promise even though most logic is synchronous from the consumer point of view.
  • Environment differences currently affect destination URLs used in secondary routing, especially IX and intermediary flows.