For theย #MadeInItalyย series where I want to showcase amazingย artisanalย Italian products from our incredible Italian Ohana, todayโs guest post is delivered by Paolo Carrara, software developer, tech enthusiast, scrum master. After a Master’s degree in Software Engineering, he approached Salesforce ecosystem during his early career in a consulting firm and since then he’s been learning, coding, and thinking about new ways to improve his and his teamโs work. A huge fan of the Agile movement and an active collaborator of the Italian agile community. You can visit his page (watch out for a hidden easter egg) here.
Many time things donโt go as we planned; we certainly donโt wish so but we must be prepared in such occasions, and when problems happen, thereโs one just key factor: time.
Thatโs why I developed a tool that could help me get to the core problem quicker than whatever I was previously doing.
And that tool is SFDX Lens, a VS Code Extension available for free on the marketplace.
The typical scenario is this: you are happily developing the next new business logic in Salesforce when suddenly you get 3 different issues from 3 different users in your ticketing system, all marked with high priority. Ugh.
Now once youโve read the ticket to understand whatโs the problem you have to switch from your code to your QA environment, go to Setup > Debug Logs > New >
compile all the required fields .. oh no! you have just created the 10th trace flag for the same user that was in debug last week.
Anyway, now youโre ready and can (if possible) replicate the issue, switch back to VS Code and inspect the log
And you have to do it 2 other times.
Or, you can leverage SFDX Lensโs Command SFDX Lens: Debug user from Org. With this command, the extension lets you pick just 3 options:
- An Org from the ones configured in your VS Code
- An active user to debug
- An amount of time from 15, 30 and 60 minutes
Thatโs it.
The extension will take care of setting a trace flag for that user with the maximum amount of precision allowed for the trace flag (which is more or less FINEST to everything), a process that usually take 1-2 seconds, and then youโre ready to replicate the issue and get the log in VS Code.
>Can you ask your user to replicate the issue himself?
Even better, โlet me just activate the extensionโ, and 2 seconds after there you go, โgo aheadโ.
>Are you already connected to the QA environment?
Even better, you can skip point 1. With the command SFDX Lens: Debug user which creates a trace flag in the environment youโre connected to.
>Donโt want to search for the command in VSCode?
Thereโs a neat button for the command SFDX Lens: Debug user just in the activity bar below your code.
You donโt have to worry about trace flag pollution anymore, the extension ensures there will be just one trace flag per user (which is, the minimum required to set a trace flag)
Hereโs a demo:
Right, now you have the log in VSCode and itโs a monolith of 7500 rows so.. whatโs exactly happening here?
To address this question I often ask myself, Iโve developed a new command, right now in beta : SFDX Lens: Log Analysis (Beta)
This command helps splitting the log into its components, each displayed visually and proportionally to its duration, so now you can focus on a single execution event at a time
This is particularly useful even for performance tuning, now you can see how many times a trigger fires per execution for example.
Hereโs a demo:
Everything is made possible through the use of the @salesforce/core
package available here: https://github.com/forcedotcom/sfdx-core
Now the circle is complete between getting the debug logs and analyzing them without leaving your IDE.