Function: initializeAnalyticsSdk()

initializeAnalyticsSdk(config): Promise<BootstrapResponse>

Use this method to initialize the Analytics Embedding SDK with the provided configuration. Calling this method clears all event data before initialization. Successful initialization triggers a successEvent, while any failures due to configuration or authorization issues trigger an errorEvent.

config: AnalyticsSdkConfig

The configuration to use for SDK initialization

Promise<BootstrapResponse>

A promise that resolves to the result of the initialization.

The SDK supports initializing and embedding components from multiple Salesforce orgs. Use the orgConfigs array to configure multiple orgs:

Note: The orgUrl parameter must be a Lightning URL (e.g., https://yourorg.lightning.force.com), not the my.salesforce.com domain URL.

In multi-org scenarios, each org can complete with a different outcome. In single-org scenarios, the same redirect handling applies for the single org. If an org requires additional authentication, like a MFA challenge or password reset, this method can return a non-success state for that org with redirect metadata in orgStates:

  • state: AUTH_REDIRECT
  • redirectUrl: org-provided relative redirect path
  • redirectOrigin: org-provided origin

For each org in AUTH_REDIRECT, open ${redirectOrigin}${redirectUrl} in a popup/tab and complete the required auth step, then call retryOrAddOrgs() for the affected org(s) to resume initialization.

Retry parameter patterns:

  • Standard retry: use a fresh frontdoor URL/session credential { orgUrl, authCredential: "<frontdoor url>" }
  • MFA/password-reset resumed session (supported): use org URL as credential { orgUrl, authCredential: orgUrl }

When the MFA/password-reset completes and session is established, you can retry with authCredential: orgUrl without regenerating frontdoor URL. If the retry fails, regenerate frontdoor URL and retry.