Skip to content

Optionally Auto-Call lightning-logger LWC

Compare
Choose a tag to compare
@jongpie jongpie released this 26 Aug 14:59
· 17 commits to main since this release
2462fca

Core Unlocked Package Changes

Resolved #702 by adding the optional ability to automatically call Salesforce's lightning-logger LWC when logging via lightning components. This then creates a "Lightning Logger" event in Event Monitoring. These events & the lightning-logger LWC were made generally available (GA) in Salesforce's Spring '24 release.

Important Note: for this new feature to work...

  1. Event Monitoring is required & must be enabled in your org
  2. The "Lightning Logger" events must be enabled for your org within Event Monitoring's settings
  3. Nebula Logger's configuration will need to be updated in your org to enable it either org-wide or for specific users (details below)

Another Important Note: for orgs without Event Monitoring (or with Event Monitoring disabled), essentially nothing will actually happen when this feature is enabled in Nebula Logger in your orgs. It's a fully optional feature specifically for orgs that do have Event Monitoring.

For orgs with Event Monitoring setup:

  • To enable this in Nebula Logger org-wide, or for a particular profile/user, set the new settings field LoggerSettings__c.IsJavaScriptLightningLoggerEnabled__c to true (default is false)

    image

  • To enable this in Nebula Logger for a particular scenario (using scenario-based logging), set the new scenario rule field LoggerScenarioRule__mdt.IsJavaScriptLightningLoggerEnabled__c to true (default is null)

    image

  • Once lightning-logger has been enabled in Nebula Logger, the JavaScript representation of Nebula Logger's log entry will be logged using lightning-logger. From there, Salesforce will do 2 things:

    1. New lightning-logger console statements will automatically be added your browser's console (just after Nebula Logger's own console statements).

      image

    2. New "Lightning Logger" events will automatically be added in Event Monitoring. You can view these events under SetupEvent MonitoringEvent Log File Browser

      image

A few small scope creep items that are also included:

  • Finished some code cleanup leftover from v4.13.15 in logEntryBuilder.js and ComponentLogger.cls
    • Now browser details are internally represented as an object in both JS and Apex, and some old deprecated properties have been removed
    • Also added some extra jest tests to validate that the browser details are being properly set
  • Fixed a small bug in a Logger where a System.debug() statement for scenario-based logging was using the wrong variable
  • Updated LoggerLogCreator permission set to remove unnecessary access to the Apex class FlowLogger

Dev/Pipeline Changes

  • Added a new bash script to automate setting up a new dev scratch org

  • Upgraded to v4 of the codecov action in build.yml

  • Upgraded to sf rc v2.56.6 to use the new --concise flag on sf apex test run

  • Removed an old/duplicate Experience Cloud site that was used by the pipeline

  • Added Apex class access to 2 Experience Cloud Guest User profiles to simplify manual testing efforts

  • Created additional scratch def files & added them to build.yml - each one corresponds to a specific Salesforce feature that's optionally used by Nebula Logger, including a new one for Event Monitoring, to test the usage of lighting-logger. The pipeline only creates 2 at a time to avoid the dev hub's limit for active scratch orgs.

    1. Base scratch org. This is an existing scratch def used by the pipeline. All optional features are disabled in this scratch org.
    2. Event Monitoring scratch org. This is used to test the new integration with the LWC lightning-logger, which stores data in Event Monitoring.
    3. Experience Cloud scratch org. This is an existing scratch def used by the pipeline to validate functionality when an Experience Cloud site has been setup in an org.
    4. Platform Cache scratch org. This is used to test optionally using Platform Cache to cache some of Nebula Logger's SOQL queries to improve performance. Previously, the Experience Cloud scratch org (above) was also used to test platform cache, but now there is a standalone scratch def just for testing platform cache (and the Experience Cloud scratch org no longer has platform cache enabled).

    image

    image

Installation Info

Core Unlocked Package - no namespace

Full Changelog: v4.14.3...v4.14.4