Let us know so we can improve!
Enumeration: EventName
Enum representing the SDK events to listen for on embedded components.
Events triggered by component functions to handle with addEventListener().
-
COMPONENT_LOADED: Event received when a component loads completely, including all metadata, filters, and layouts. -
UPDATED_FILTERS: Event received when the filters for a component are updated. -
UPDATED_TIME_RANGE: Event received when the time range for anAnalyticsMetriccomponent is updated. -
UPDATED_SELECTIONS: Event received when the selections for anAnalyticsVisualizationcomponent are updated. -
RECEIVED_FILTERS: Event received when the list of applied filters for a component is loaded. -
RECEIVED_PAGES: Event received when a list of page labels for anAnalyticsDashboardcomponent is loaded. -
RECEIVED_METADATA: Event received with metadata of the analytics component (Dashboard, Visualization). -
RECEIVED_SELECTIONS: Event received when the list of applied selections for anAnalyticsVisualizationis loaded. -
RECEIVED_LAYOUT: Event received when the layout for anAnalyticsMetriccomponent is loaded. -
RECEIVED_DATASOURCES: Event received when thedatasourcesof theAnalyticsDashboardcomponent is loaded. -
RECEIVED_FIELDS: Event received with fields associated with the analytics component. -
RECEIVED_FILTER_FIELD_VALUES: Event received with filter field values associated with a field of the analytics component. -
RECEIVED_INTERACTION_DETAILS: Event received withinteractionDetailsassociated with the analytics component. -
DEFAULT: Event received when an enumerated event name isn’t specified. -
ERROR: Event received for global SDK and component errors.
Usage
1//JavaScript
2// Importing required modules and libraries from the Tableau Next Embedding SDK
3import {initializeAnalyticsSdk, AnalyticsDashboard, analyticsEventTarget} from '@salesforce/analytics-embedding-sdk';
4
5//Listening to global ERROR event, such as SDK or component initialization failures.
6analyticsEventTarget.addEventListener(EventName.ERROR, (errorEvent) => {
7 //Error details (such as error code and message) are available in the event object
8 console.log("Recieved a global error event", errorEvent)
9});
10
11//Configuration object for initializing the Tableau Next Embedding SDK
12await initializeAnalyticsSdk({
13 //The frontdoor URL required for authentication
14 authCredential: "<%- authCredential %>",
15 //The Salesforce org URL that hosts the Analytics component to embed.
16 orgUrl: '<%- org-url %>'
17});
18
19const analyticsDashboard = new AnalyticsDashboard({
20 //The parent ID or element to render the component in
21 parentIdOrElement: '<%- parent-element %>',
22 //The ID or API name of the component to embed
23 idOrApiName: '<%- dashboard-id-or-api-name %>'
24});
25
26//Listening to ERROR event
27analyticsDashboard.addEventListener(EventName.ERROR, () => {
28 console.log("Received error");
29});
30
31//Listening to COMPONENT_LOADED event triggered when the component gets loaded
32analyticsDashboard.addEventListener(EventName.COMPONENT_LOADED, () => {
33 console.log("Component Loaded");
34});
35
36//Event received when the filters for a component are updated.
37analyticsDashboard.addEventListener(EventName.UPDATED_FILTERS, () => {
38 console.log("Event received for filter change");
39});
40
41//Event received when the list of applied filters for a component is loaded.
42analyticsDashboard.addEventListener(EventName.RECEIVED_FILTERS, () => {
43 console.log("Received filters list using event");
44});
45
46//Event received when a list of page labels for an AnalyticsDashboard component is loaded.
47analyticsDashboard.addEventListener(EventName.RECEIVED_PAGES, () => {
48 console.log("Received page labels list using event");
49});
50
51//Event received with metadata of the analytics component ( Dashboard, Visualization).
52analyticsDashboard.addEventListener(EventName.RECEIVED_METADATA, () => {
53 console.log("Metadata received");
54});
55
56//Event received when the datasources of the analytics dashboard is loaded.
57analyticsDashboard.addEventListener(EventName.RECEIVED_DATASOURCES, () => {
58 console.log("Datasources received");
59});
60
61//Event received with fields associated with the analytics component.
62analyticsDashboard.addEventListener(EventName.RECEIVED_FIELDS, () => {
63 console.log("Fields received");
64});
65
66//Event received with filter field values associated with a field of the analytics component.
67analyticsDashboard.addEventListener(EventName.RECEIVED_FILTER_FIELD_VALUES, () => {
68 console.log("Received filter field values");
69});
70
71//Event received with interactionDetails associated with the analytics component.
72analyticsDashboard.addEventListener(EventName.RECEIVED_INTERACTION_DETAILS, () => {
73 console.log("InteractionDetails received");
74});
75
76//Renders the dashboard in the parent HTML element
77analyticsDashboard.render();1//TypeScript
2// Importing required modules and libraries from the Tableau Next Embedding SDK
3import {
4 AnalyticsDashboard,
5 initializeAnalyticsSdk,
6 analyticsEventTarget,
7 type DashboardProps,
8 type AnalyticsSdkConfig
9} from '@salesforce/analytics-embedding-sdk';
10
11//Listening to global ERROR event, such as SDK or component initialization failures.
12analyticsEventTarget.addEventListener(EventName.ERROR, (errorEvent) => {
13 //Error details (such as error code and message) are available in the event object
14 console.log("Received a global error event", errorEvent)
15});
16
17//Configuration object for initializing the Tableau Next Embedding SDK
18const config: AnalyticsSdkConfig = {
19 //The frontdoor URL required for authentication
20 authCredential: "<%- authCredential %>",
21 //The Salesforce org URL that hosts the Analytics component to embed.
22 orgUrl: "<%- org-url %>"
23};
24//Initializes the Tableau Next Embedding SDK with the provided configuration and returns a promise that resolves on successful initialization.
25await initializeAnalyticsSdk(config);
26
27// Defines the properties required for configuring a dashboard component.
28const dashboardProps: DashboardProps = {
29 //The parent ID or element to render the component in
30 parentIdOrElement: '<%- parent-element %>',
31 //The ID or API name of the component to embed
32 idOrApiName: '<%- dashboard-id-or-api-name %>'
33};
34
35//A web component for embedding an analytics dashboard
36const analyticsDashboard: AnalyticsDashboard = new AnalyticsDashboard(dashboardProps);
37
38//Listening to component specific ERROR event
39analyticsDashboard.addEventListener(EventName.ERROR, (event) => {
40 //Error details (such as error code and message) are available in the event object
41 console.log("Received error", event);
42});
43
44//Listening to COMPONENT_LOADED event triggered when the component gets loaded
45analyticsDashboard.addEventListener(EventName.COMPONENT_LOADED, (event) => {
46 console.log("Component Loaded", event);
47});
48
49//Event received when the filters for a component are updated.
50analyticsDashboard.addEventListener(EventName.UPDATED_FILTERS, (event) => {
51 console.log("Event received for filter change: ", event);
52});
53
54//Event received when the list of applied filters for a component is loaded.
55analyticsDashboard.addEventListener(EventName.RECEIVED_FILTERS, (event) => {
56 console.log("Received filters list using event: ", event.detail);
57});
58
59//Event received when a list of page labels for an AnalyticsDashboard component is loaded.
60analyticsDashboard.addEventListener(EventName.RECEIVED_PAGES, (event) => {
61 console.log("Received page labels list using event: ", event.detail);
62});
63
64/Event received with metadata of the analytics component ( Dashboard, Visualization).
65analyticsDashboard.addEventListener(EventName.RECEIVED_METADATA, (event) => { /
66 console.log("Metadata received: ", event.detail);
67});
68
69//Event received when the datasources of the analytics dashboard is loaded.
70analyticsDashboard.addEventListener(EventName.RECEIVED_DATASOURCES, (event) => {
71 console.log("Datasources received: ", event.detail);
72});
73
74//Event received with fields associated with the analytics component.
75analyticsDashboard.addEventListener(EventName.RECEIVED_FIELDS, (event) => {
76 console.log("Fields received: ", event.detail);
77});
78
79//Event received with filter field values associated with a field of the analytics component.
80analyticsDashboard.addEventListener(EventName.RECEIVED_FILTER_FIELD_VALUES, (event) => {
81 console.log("Received filter field values: ", event.detail);
82});
83
84//Event received with interactionDetails associated with the analytics component.
85analyticsDashboard.addEventListener(EventName.RECEIVED_INTERACTION_DETAILS, (event) => {
86 console.log("InteractionDetails received: ", event.detail);
87});
88
89//Renders the dashboard in the parent HTML element
90analyticsDashboard.render();Enumeration Members
COMPONENT_LOADED
COMPONENT_LOADED:
"ComponentLoaded"
DEFAULT
DEFAULT:
"DEFAULT"
ERROR
ERROR:
"Error"
RECEIVED_DATASOURCES
RECEIVED_DATASOURCES:
"ReceivedDatasources"
RECEIVED_FIELDS
RECEIVED_FIELDS:
"ReceivedFields"
RECEIVED_FILTERS
RECEIVED_FILTERS:
"ReceivedFilters"
RECEIVED_FILTER_FIELD_VALUES
RECEIVED_FILTER_FIELD_VALUES:
"ReceivedFilterFieldValues"
RECEIVED_INTERACTION_DETAILS
RECEIVED_INTERACTION_DETAILS:
"ReceivedInteractionDetails"
RECEIVED_LAYOUT
RECEIVED_LAYOUT:
"ReceivedLayout"
RECEIVED_METADATA
RECEIVED_METADATA:
"ReceivedMetadata"
RECEIVED_PAGES
RECEIVED_PAGES:
"ReceivedPages"
RECEIVED_SELECTIONS
RECEIVED_SELECTIONS:
"ReceivedSelections"
RECEIVED_TIME_RANGE
RECEIVED_TIME_RANGE:
"ReceivedTimeRange"
UPDATED_FILTERS
UPDATED_FILTERS:
"UpdatedFilters"
UPDATED_SELECTIONS
UPDATED_SELECTIONS:
"UpdatedSelections"
UPDATED_TIME_RANGE
UPDATED_TIME_RANGE:
"UpdatedTimeRange"
Let us know so we can improve!