This entrypoint is intended for Salesforce Lightning and LWC applications using the rum-salesforce-lightning.js
bundle. The SDK forces the Salesforce-specific RUM settings required for this environment:
trackViewsManually: trueprofilingSampleRate: 0sessionReplaySampleRate: 0
import { LightningElement, api, wire } from 'lwc'
import { NavigationMixin, CurrentPageReference } from 'lightning/navigation'
import rumSalesforceLightning from '@salesforce/resourceUrl/rum_salesforce_lightning'
import { loadScript } from 'lightning/platformResourceLoader'
export default class DatadogInit extends NavigationMixin(LightningElement) {
@api applicationId
@api clientToken
@api site
@api service
@api env
connectedCallback() {
this.loadDatadogRum()
}
@wire(CurrentPageReference)
handleCurrentPageReference(pageReference) {
if (!pageReference) {
return
}
this.loadDatadogRum().then(() => {
this.startPageReference(pageReference)
})
}
startPageReference(pageReference) {
window.DD_RUM?.startSalesforceView?.({
pageReference,
baseUrl: window.location.origin || window.location.href,
generateUrl: (pageReferenceToGenerate) => this[NavigationMixin.GenerateUrl](pageReferenceToGenerate),
})
}
loadDatadogRum() {
return loadScript(this, rumSalesforceLightning).then(() => {
window.DD_RUM.initSalesforce({
applicationId: this.applicationId,
clientToken: this.clientToken,
site: this.site,
service: this.service,
env: this.env,
})
})
}
}| Feature | Supported |
|---|---|
| View Events | |
| Initial View | ✅ |
| Manual Tracking | ✅ |
| Navigation Timings | ✅ |
| Web Vitals | ✅ |
| Automatic Tracking | ✅ |
| Loading Time | ✅ |
| Resource Events | |
| Fetch Resources | ✅ |
| XHR Resources | ✅ |
| Other Resources | ✅ |
| APM Correlation | ✅ |
| Action Events | |
| Custom Actions | ✅ |
| Click Actions | ✅ |
| Frustration Signals | ✅ |
| Selectors | ✅ |
| Action Name | ✅ |
| Loading Time | ✅ |
| Error Events | |
| Console Error | ✅ |
| Custom Errors | ✅ |
| Runtime Errors | ✅ |
onUnhandledRejection |
❌ |
| CSP Violation | ❌ |
| Other | |
| Vital Events | ✅ |
| Long Task Events | ✅ |
| Session Replay | ❌ |
- Loading time depends on page activity detection, which may not work fully in Salesforce Lightning due to shadow DOM restrictions on page lifecycle signals.
- Cross-origin restrictions in the Lightning shell may hide full request URLs; APM correlation headers and action names derived from URLs may be incomplete.
- Due to shadow boundaries, the SDK might receive the component host as
event.targetinstead of the actual clicked element. - Direct synchronous errors can reach the SDK through
window.onerror, but in the Lightning shell they may be redacted as "Script error." with no original error object, URL, line, or stack available to the SDK.