Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the option to automatically call the lightning-logger LWC #743

Merged
merged 15 commits into from
Aug 26, 2024

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Aug 23, 2024

Core Unlocked Package Changes

Resolved #702 2 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

… one corresponds to a specific Salesforce feature that's optionally used by Nebula Logger
…lesforce's lightning-logger LWC when logging via lightning components. This then creates a "Lightning Logger" event in Event Monitoring
@jongpie jongpie added Type: Enhancement New feature or request Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Layer: Logger Engine Items related to the core logging engine Feature: Scenario-Based Logging Items related to Logger.setScenario(), LoggerScenarioRule__mdt, etc. Salesforce Feature: Event Monitoring Items that integrate with/leverage features provided by Salesforce's Event Monitoring tool labels Aug 23, 2024
@jongpie jongpie temporarily deployed to Base Scratch Org August 23, 2024 18:58 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org August 23, 2024 18:58 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Chatter Scratch Org August 23, 2024 18:58 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Event Monitoring Scratch Org August 23, 2024 18:58 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Platform Cache Scratch Org August 23, 2024 18:58 — with GitHub Actions Failure
… lightning-logger, removed some problematic settings in some of the new scratch def files
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org August 23, 2024 19:17 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Chatter Scratch Org August 23, 2024 19:17 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org August 23, 2024 19:17 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org August 23, 2024 19:17 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Platform Cache Scratch Org August 23, 2024 19:17 — with GitHub Actions Failure
…r Spanish as the user's language

The new platform cache scratch def uses Japanese as the user's language, resulting in some profile queries to fail
@jongpie jongpie temporarily deployed to Base Scratch Org August 23, 2024 19:53 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Chatter Scratch Org August 23, 2024 19:53 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org August 23, 2024 19:53 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org August 23, 2024 19:53 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Platform Cache Scratch Org August 23, 2024 19:53 — with GitHub Actions Failure
…oid the dev hub's limit of 3 active scratch orgs

I'm keeping 1 of 3 available for myself for dev

Also stopped using the demo org for secondary scratch orgs - it has a very low limit of only 6 scratch org creations per day, so it's not reliable (Nebula Logger's dev hub has an increased daily limit)
…r, removed unnecessary access to FlowLogger in perm set LoggerLogCreator
@jongpie jongpie force-pushed the feature/lightning-logger-integration branch from a0fb6dc to c7622e5 Compare August 23, 2024 22:05
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org August 23, 2024 22:10 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org August 23, 2024 22:10 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org August 23, 2024 22:15 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Platform Cache Scratch Org August 23, 2024 22:17 — with GitHub Actions Inactive
@jongpie jongpie force-pushed the feature/lightning-logger-integration branch from 40d9775 to b63b3b6 Compare August 24, 2024 23:50
@jongpie jongpie had a problem deploying to Event Monitoring Scratch Org August 24, 2024 23:54 — with GitHub Actions Failure
@jongpie jongpie temporarily deployed to Base Scratch Org August 24, 2024 23:54 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org August 25, 2024 00:01 — with GitHub Actions Error
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org August 25, 2024 00:13 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org August 25, 2024 00:13 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Platform Cache Scratch Org August 25, 2024 00:20 — with GitHub Actions Inactive
….js and ComponentLogger.cls

Now browser details are 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
@jongpie jongpie force-pushed the feature/lightning-logger-integration branch from 3e76a52 to 75e026b Compare August 25, 2024 00:59
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org August 25, 2024 01:03 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org August 25, 2024 01:03 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org August 25, 2024 01:12 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Platform Cache Scratch Org August 25, 2024 01:15 — with GitHub Actions Failure
Copy link

codecov bot commented Aug 25, 2024

Codecov Report

Attention: Patch coverage is 97.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.16%. Comparing base (70cecec) to head (75e026b).

Files Patch % Lines
...e/main/logger-engine/lwc/logger/logEntryBuilder.js 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #743      +/-   ##
==========================================
- Coverage   93.18%   93.16%   -0.02%     
==========================================
  Files          67       67              
  Lines        6939     6935       -4     
  Branches      197      198       +1     
==========================================
- Hits         6466     6461       -5     
- Misses        445      446       +1     
  Partials       28       28              
Flag Coverage Δ
Apex 95.44% <100.00%> (+<0.01%) ⬆️
LWC 83.34% <92.30%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jongpie jongpie merged commit 2462fca into main Aug 26, 2024
1 check passed
@jongpie jongpie deleted the feature/lightning-logger-integration branch August 26, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops Items related to tooling, automation, and guidelines used for developing Nebula Logger Feature: Scenario-Based Logging Items related to Logger.setScenario(), LoggerScenarioRule__mdt, etc. Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type Layer: Logger Engine Items related to the core logging engine Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Salesforce Feature: Event Monitoring Items that integrate with/leverage features provided by Salesforce's Event Monitoring tool Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally integrate with the standard LWC lightning/logger
2 participants