npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@salesforce/analytics-embedding-sdk

v1.0.0

Published

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.

Readme

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.

Install

npm install @salesforce/analytics-embedding-sdk --save

Usage

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

TypeScript

import {AnalyticsDashboard, initializeAnalyticsSdk, type AnalyticsSdkConfig} from '@salesforce/analytics-embedding-sdk';

const config: AnalyticsSdkConfig = {
   authCredential: "<%- auth-credential %>",
   orgUrl: "<%- org_url %>" // Must be Lightning URL
};
await initializeAnalyticsSdk(config);

// parentIdOrElement is the target container (ID or element) and idOrApiName is the identifier or API name of the component to embed.
const dashboard: AnalyticsDashboard = new AnalyticsDashboard({parentIdOrElement: 'embed-here', idOrApiName: 'My_Sales_Dashboard'});
dashboard.render();

JavaScript

import {initializeAnalyticsSdk, AnalyticsDashboard} from '@salesforce/analytics-embedding-sdk';

const config = {
   authCredential: "<%- auth-credential %>",
   orgUrl: "<%- org_url %>" // Must be Lightning URL
};
await initializeAnalyticsSdk(config);

// parentIdOrElement is the target container (ID or element) and idOrApiName is the identifier or API name of the component to embed.
const dashboard = new AnalyticsDashboard({parentIdOrElement: 'embed-here', idOrApiName: 'My_Sales_Dashboard'});
dashboard.render();

HTML

<!DOCTYPE html>
<html>
<head>
    <script type="module">
        import {initializeAnalyticsSdk} from '@salesforce/analytics-embedding-sdk';

        const config = {
            authCredential: "<%- auth-credential %>",
            orgUrl: "<%- org_url %>" // Must be Lightning URL
        };

        await initializeAnalyticsSdk({
            authCredential: "<%- auth-credential %>",
            orgUrl: "<%- org_url %>", // Must be Lightning URL
        });
    </script>
</head>
<body>
    <analytics-dashboard id-or-api-name="My_Sales_Dashboard" height="500px">
    </analytics-dashboard>
</body>
</html>

Multi-org Support

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

import {initializeAnalyticsSdk, AnalyticsDashboard, AnalyticsVisualization} from '@salesforce/analytics-embedding-sdk';

// Initialize with multiple orgs
const initPayload = {
	orgConfigs: [
		{
			orgUrl: 'https://org1.lightning.force.com', // Lightning URL required
			authCredential: 'https://org1-frontdoor.salesforce.com/...'
		},
		{
			orgUrl: 'https://org2.lightning.force.com', // Lightning URL required
			authCredential: 'https://org2-frontdoor.salesforce.com/...'
		}
	]
};

const response = await initializeAnalyticsSdk(initPayload);

// Embed components from different orgs - always specify orgUrl
const dashboard = new AnalyticsDashboard({
	parentIdOrElement: 'container1',
	idOrApiName: 'Dashboard1',
	orgUrl: 'https://org1.lightning.force.com' // Required for multi-org
});
dashboard.render();

const visualization = new AnalyticsVisualization({
	parentIdOrElement: 'container2',
	idOrApiName: 'Viz2',
	orgUrl: 'https://org2.lightning.force.com' // Different org
});
visualization.render();

Note:

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

Adding Orgs Dynamically

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

import {retryOrAddOrgs} from '@salesforce/analytics-embedding-sdk';

const newOrgs = [
	{
		orgUrl: 'https://org3.lightning.force.com', // Lightning URL required
		authCredential: 'https://org3-frontdoor.salesforce.com/...'
	},
	{
		orgUrl: 'https://org4.lightning.force.com', // Lightning URL required
		authCredential: 'https://org4-frontdoor.salesforce.com/...'
	}
];
const response = await retryOrAddOrgs(newOrgs);
console.log(response.status); // Check if orgs were added successfully

The retryOrAddOrgs function returns the same BootstrapResponse format as initializeAnalyticsSdk.

Response

The initializeAnalyticsSdk function returns a BootstrapResponse object:

const response = await initializeAnalyticsSdk(config);

// Response structure:
{
    "message": "Sdk Initialize Complete",
    "status": "Success",
    "orgStates": {
        "https://org1.lightning.force.com": {
            "state": "INITIALIZATION_SUCCESS",
            "reason": ""
        },
        "https://org2.lightning.force.com": {
            "state": "INITIALIZATION_SUCCESS",
            "reason": ""
        }
    }
}

console.log(response.status);  // Check initialization status
console.log(response.message); // Get detailed message

// For multi-org scenarios, check individual org states:
if (response.orgStates) {
    response.orgStates.forEach((state, orgUrl) => {
        console.log(`Org ${orgUrl}: ${state.state}`);
    });
}

Sample response:

{
	"message": "Sdk Initialize Complete",
	"status": "Success",
	"orgStates": {
		"https://org1.lightning.force.com": {
			"state": "INITIALIZATION_SUCCESS",
			"reason": ""
		},
		"https://org2.lightning.force.com": {
			"state": "INITIALIZATION_SUCCESS",
			"reason": ""
		}
	}
}

Status values:

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

Logout

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

import {logout} from '@salesforce/analytics-embedding-sdk';

// Logout from all orgs
const response = await logout();

// Logout from specific orgs
const response = await logout(['https://org1.lightning.force.com', 'https://org2.lightning.force.com']);

console.log(response.status); // 'Success', 'Partial Success', or 'Failure'
console.log(response.message); // Detailed logout message

Sample response:

{
	"message": "Log out for all orgs complete",
	"status": "Success",
	"orgStates": {
		"https://org1.lightning.force.com": {
			"state": "LOGGED_OUT",
			"reason": ""
		},
		"https://org2.lightning.force.com": {
			"state": "LOGGED_OUT",
			"reason": ""
		}
	}
}

Need Help

  • Visit https://developer.salesforce.com/docs/analytics/sdk/guide/sdk-overview.html

Supported Desktop and Laptop Browsers

The SDK supports all browsers supported in Salesforce Lightning Experience.