Analytics Embedding SDK

Use the Analytics Embedding SDK to embed Tableau Next analytical components in any web page. This SDK supports typescript, javascript and HTML formats. This version of the SDK is compatible with Salesforce API v65.0 and above.

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

You can pass an optional custom view ID so the embedded dashboard opens with the same saved filter state (custom view) as in Tableau Next. This aligns with share links that include a customViewId query parameter, and helps preserve dashboard interactivity when embedding in other surfaces (for example Slack).

TypeScript / JavaScript — set customViewId on the dashboard props (or assign dashboard.customViewId after construction):

HTML — use the custom-view-id attribute on <analytics-dashboard>:

If your app parses a dashboard URL, read the customViewId query parameter and pass it through as shown above.

Configure actions on the dashboard in Tableau Next using Salesforce Help: add actions to a dashboard.

Dashboard actions (buttons configured on the dashboard) are supported in third-party embedding. That includes actions such as Salesforce Flows, page navigation, and URL navigation, consistent with the embedded dashboard experience in Tableau Next.

The SDK provides two ways to apply filters: a simplified API that automatically constructs filter objects from individual parameters, and the original API that accepts pre-built filter objects.

The simplified API eliminates manual filter object construction by accepting Field and DataSource objects directly. It automatically constructs fieldName from Field objects (retrieved via getFields()) and accepts DataSource objects (from getDataSources()).

TypeScript / JavaScript:

For metrics and visualizations, omit the dataSource property:

Use the SDK to build valid filters. The SDK provides metadata you can use to assemble a UnifiedFilterJson object. See the applyFilters method and the filters property in the component classes. Filter validation informs you what you can filter on, not the final JSON object. Follow these rules to combine datasources, fields, operators, and values into a filter that passes validation.

Supported for dashboards only.

Methods: getDataSources(), getInteractionDetails().dataSources

Returns which semantic model a row belongs to. On dashboards with multiple data sources, set dataSource on each filter to the API name that matches the map key for that field. With a single data source, dataSource is optional in the type; setting it anyway avoids ambiguity.

Methods: getFields(), getInteractionDetails().fields — use filterFields from getInteractionDetails() when you only need columns that support filtering.

Each field includes dataType, fieldType, apiName, and optional objectName.

Enum: FilterOperator — choose a value that is valid for the field’s data type, for example, range operators for numbers, relative-date operators for dates. The SDK returns dataType on each field, not a list of allowed operators. Mapping data type → operator, and any extra rules, is up to your app unless your product supplies a separate list.

Operators that don’t take operands, such as IsNull, should omit values or use an empty array as required. Others, for example relative date operators, may require specific values. Follow the operator’s contract.

Method: getFilterFieldValues(fieldApiName, fieldObjectName?, searchTerm?)

Use for discrete lists or typeahead. Pass fieldObjectName when getFields() / getInteractionDetails() include objectName on that field; otherwise omit it.

  1. Wait until the component is ready — Call filter helpers after render() resolves and the asset has loaded. For example after EventName.COMPONENT_LOADED or EventName.RECEIVED_DATASOURCES on dashboards when you rely on datasource lists.
  2. Pick scope — Dashboard: choose a dataSource API name from getDataSources() or getInteractionDetails().dataSources. It must match the map key for the field you use. Metric or visualization: there is a single implicit context; don’t set dataSource on the filter object.
  3. Pick a field — Use the field list for that data source’s key in the map for a dashboard. Iterate getFields() / getInteractionDetails() maps for metrics and visualizations, which often have one key. Build fieldName as objectName + "." + apiName when objectName is present; otherwise use the field’s apiName alone, consistent with how filters are shown in the embedding API examples.
  4. Pick an operator — Must match the field’s data type and your product’s allowed set. Metric note: Equals and DoesNotEquals are translated to In and NotIn in current behavior.
  5. Pick values — Use getFilterFieldValues when the user needs actual members. All entries in values must share the same type (all strings, all numbers, and so on). Omit values when the operator doesn’t need them.
  6. Apply — Pass an array to applyFilters. Dashboards and metrics replace the filter set. Visualizations add to existing filters. When applying filters repeatedly, plan getFilters() / clearFilters() accordingly.

Minimal dashboard example:

For metrics and visualizations, the same fieldName / operator / values rules apply; omit dataSource.

Invalid or mismatched combinations, such as wrong data source for the field, bad fieldName shape, operator incompatible with type, or mixed-type values, can cause an ERROR event and the filter isn’t applied. Validate inputs before calling applyFilters.

The AnalyticsAgent component embeds your Analytics and Visualization agent powered by Agentforce. It helps users understand data through natural language insights, visualizations, and proactive alerts.

The agent supports two operating modes:

  • Single-context mode — Provide contextConfig to bind the agent to a specific dashboard, metric, or semantic model.
  • Multi-component mode — Omit contextConfig to automatically track all embedded AnalyticsDashboard and AnalyticsMetric components on the page.

The AgentContextType enum specifies the type of analytics asset to bind the agent to:

ValueDescription
AgentContextType.DASHBOARDDashboard context
AgentContextType.METRICMetric context
AgentContextType.SDMSemantic Model context

Use the styleTokens property to theme the agent UI:

Call startNewAgentSession() to programmatically restart the conversation:

The SDK supports embedding components from multiple Salesforce orgs in a single application. Use orgConfigs instead of a single orgUrl and authCredential:

Note:

  • The orgUrl is required when creating components in a multi-org scenario, to ensure your component connects to the correct org.

You can add new orgs or retry failed orgs after initial SDK initialization using retryOrAddOrgs:

The retryOrAddOrgs function returns the same BootstrapResponse format as initializeAnalyticsSdk.

The initializeAnalyticsSdk function returns a BootstrapResponse object:

Sample response:

Status values:

  • Status.SUCCESS - All orgs initialized successfully
  • Status.PARTIAL_SUCCESS - Some orgs initialized successfully (multi-org only)
  • Status.FAILURE - Initialization failed

For a single org or multiple orgs, Salesforce may require an extra step before the session is valid—such as multi-factor authentication (MFA) or a forced password reset. In that case initializeAnalyticsSdk can return a non-success overall status while the affected org appears in response.orgStates with:

  • state: AUTH_REDIRECT (see OrgStates.AUTH_REDIRECT when importing the enum)
  • redirectUrl: org-provided path (often relative)
  • redirectOrigin: origin to combine with redirectUrl

What to do

  1. For each org entry in AUTH_REDIRECT, send the user to the challenge UI, typically by opening ${redirectOrigin}${redirectUrl} in a new window or tab (popups may be blocked; fall back to a full tab).
  2. After the user finishes MFA or password reset and the browser session is established for that org, resume the SDK by calling retryOrAddOrgs for that org.

Credentials when retrying

  • Normal retry: pass a fresh frontdoor URL (or equivalent session credential) as authCredential together with the same Lightning orgUrl.
  • After MFA / password reset: once the session exists in the browser, you can retry with the Lightning org URL as the credential: { orgUrl, authCredential: orgUrl }, without generating a new frontdoor URL first. If that retry does not succeed, obtain a new frontdoor URL and retry with it.

The retryOrAddOrgs response uses the same BootstrapResponse shape as initializeAnalyticsSdk, so you can inspect orgStates again for any remaining AUTH_REDIRECT or errors.

The SDK provides a logout function to log out from Salesforce orgs. The function returns a LogoutResponse with the same structure as BootstrapResponse.

Sample response:

The SDK supports all browsers supported in Salesforce Lightning Experience.