@salesforce-sentry/codemods
v1.0.1
Published
CLI to adopt the salesforce-sentry SDK in an SFDX project
Readme
@salesforce-sentry/codemods
CLI to adopt the salesforce-sentry SDK in an SFDX project.
Installation
npm install -g @salesforce-sentry/codemodsOr run without installing via npx:
npx @salesforce-sentry/codemods <command>Commands
All commands accept an optional path to the SFDX project root. Defaults to the current working directory.
setup
Interactive wizard that generates the files needed to wire up the SDK:
- An Apex config class extending
sentrysdk.SentryConfig - Its
.cls-meta.xml - A
sentrysdk__Sentry_Config.Default.md-meta.xmlcustom metadata record - A
Sentry.remoteSite-meta.xmlremote site setting
salesforce-sentry setup [project-path]You will be prompted for:
- DSN — your Sentry project DSN (
https://<key>@<host>/<projectId>) - Apex class name — defaults to
MySentryConfig - Sampling rate — 0–100, defaults to 100
- Integrations — multiselect from all available integrations
Generated files are written to the default package directory from sfdx-project.json. Deploy them with sf project deploy start.
adopt
Scans your SFDX project and instruments LWC components and Apex entry points with Sentry error capture. Shows a diff for each file and prompts before applying.
salesforce-sentry adopt [project-path]LWC components:
- Exposed components (
isExposed: true) → wrapped withSentryBoundaryMixin - Other components → wrapped with
SentryMixin
Apex entry points instrumented:
@AuraEnabledmethods → try/catch withcaptureException+AuraHandledException@InvocableMethod,@RemoteAction,@HttpGet/Post/Put/Delete/Patch→ try/catch withcaptureException+ rethrowSchedulable.execute,Queueable.execute,Database.Batchablestart/execute/finish → same
Already-instrumented files are skipped automatically.
validate
Checks that the SDK is correctly wired up in the project:
salesforce-sentry validate [project-path]Verifies:
sfdx-project.jsonexists- Exactly one
Sentry_Configmetadata record is enabled - DSN is set and valid
- Remote site setting matches the DSN host
- Apex config class exists on disk
- No uninstrumented LWC or Apex entry points remain
