diff --git a/README.md b/README.md index cd22d3eb6..57169894d 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,15 @@ The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects. -## Unlocked Package - v4.13.6 +## Unlocked Package - v4.13.7 -[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001MkGxQAK) -[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001MkGxQAK) +[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001MkHRQA0) +[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001MkHRQA0) [![View Documentation](./images/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/) -`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001MkGxQAK` +`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001MkHRQA0` -`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001MkGxQAK` +`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001MkHRQA0` --- diff --git a/docs/lightning-components/LogEntryBuilder.md b/docs/lightning-components/LogEntryBuilder.md index ce66c3108..9d6f79d5e 100644 --- a/docs/lightning-components/LogEntryBuilder.md +++ b/docs/lightning-components/LogEntryBuilder.md @@ -9,6 +9,7 @@ - [.setMessage(message)](#LogEntryBuilder+setMessage) [LogEntryBuilder](#LogEntryBuilder) - [.setRecordId(recordId)](#LogEntryBuilder+setRecordId) [LogEntryBuilder](#LogEntryBuilder) - [.setRecord(record)](#LogEntryBuilder+setRecord) [LogEntryBuilder](#LogEntryBuilder) + - [.setScenario(scenario)](#LogEntryBuilder+setScenario) [LogEntryBuilder](#LogEntryBuilder) - [.setError(error)](#LogEntryBuilder+setError) [LogEntryBuilder](#LogEntryBuilder) - [.addTag(tag)](#LogEntryBuilder+addTag) [LogEntryBuilder](#LogEntryBuilder) - [.addTags(tags)](#LogEntryBuilder+addTags) [LogEntryBuilder](#LogEntryBuilder) @@ -65,6 +66,19 @@ Sets the log entry event's record fields | ------ | ------------------- | ----------------------------------------------------------------------------------------------------- | | record | Object | The `SObject` record related to the entry. The JSON of the record is automatically added to the entry | + + +### logEntryBuilder.setScenario(scenario) [LogEntryBuilder](#LogEntryBuilder) + +Sets the log entry event's scenario field + +**Kind**: instance method of [LogEntryBuilder](#LogEntryBuilder) +**Returns**: [LogEntryBuilder](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods + +| Param | Type | Description | +| -------- | ------------------- | --------------------------------------------------- | +| scenario | String | The string to use to set the entry's scenario field | + ### logEntryBuilder.setError(error) [LogEntryBuilder](#LogEntryBuilder) diff --git a/nebula-logger/core/main/logger-engine/classes/Logger.cls b/nebula-logger/core/main/logger-engine/classes/Logger.cls index 14039a8fe..9836a1a4a 100644 --- a/nebula-logger/core/main/logger-engine/classes/Logger.cls +++ b/nebula-logger/core/main/logger-engine/classes/Logger.cls @@ -15,7 +15,7 @@ global with sharing class Logger { // There's no reliable way to get the version number dynamically in Apex @TestVisible - private static final String CURRENT_VERSION_NUMBER = 'v4.13.6'; + private static final String CURRENT_VERSION_NUMBER = 'v4.13.7'; private static final System.LoggingLevel FALLBACK_LOGGING_LEVEL = System.LoggingLevel.DEBUG; private static final List LOG_ENTRIES_BUFFER = new List(); private static final String MISSING_SCENARIO_ERROR_MESSAGE = 'No logger scenario specified. A scenario is required for logging in this org.'; diff --git a/nebula-logger/core/main/logger-engine/lwc/logger/__tests__/logger.test.js b/nebula-logger/core/main/logger-engine/lwc/logger/__tests__/logger.test.js index 1313b90b2..df65df7a6 100644 --- a/nebula-logger/core/main/logger-engine/lwc/logger/__tests__/logger.test.js +++ b/nebula-logger/core/main/logger-engine/lwc/logger/__tests__/logger.test.js @@ -43,16 +43,10 @@ describe('logger lwc import tests', () => { const logger = await createLogger(); const scenario = 'some scenario'; const message = 'some message'; + const firstLogEntry = logger.finest(message).getComponentLogEntry(); - await flushPromises(); - expect(firstLogEntry.scenario).toBeNull(); - expect(logger.getBufferSize()).toEqual(1); + logger.setScenario(scenario); const secondLogEntry = logger.info(message).getComponentLogEntry(); - await flushPromises(); - expect(secondLogEntry.scenario).toBeNull(); - expect(logger.getBufferSize()).toEqual(2); - - await logger.setScenario(scenario); expect(firstLogEntry.scenario).toEqual(scenario); expect(secondLogEntry.scenario).toEqual(scenario); @@ -519,16 +513,12 @@ describe('logger lwc legacy markup tests', () => { const logger = createElement('c-logger', { is: Logger }); document.body.appendChild(logger); await flushPromises(); + const scenario = 'some scenario'; const message = 'some message'; - const firstLogEntry = await logger.finest(message).getComponentLogEntry(); - expect(firstLogEntry.scenario).toBeNull(); - expect(logger.getBufferSize()).toEqual(1); - const secondLogEntry = await logger.info(message).getComponentLogEntry(); - expect(secondLogEntry.scenario).toBeNull(); - expect(logger.getBufferSize()).toEqual(2); - const scenario = 'another scenario'; + const firstLogEntry = logger.finest(message).getComponentLogEntry(); logger.setScenario(scenario); + const secondLogEntry = logger.info(message).getComponentLogEntry(); expect(firstLogEntry.scenario).toEqual(scenario); expect(secondLogEntry.scenario).toEqual(scenario); diff --git a/nebula-logger/core/main/logger-engine/lwc/logger/logEntryBuilder.js b/nebula-logger/core/main/logger-engine/lwc/logger/logEntryBuilder.js index def59c0d3..7658188d9 100644 --- a/nebula-logger/core/main/logger-engine/lwc/logger/logEntryBuilder.js +++ b/nebula-logger/core/main/logger-engine/lwc/logger/logEntryBuilder.js @@ -4,7 +4,7 @@ //------------------------------------------------------------------------------------------------// import FORM_FACTOR from '@salesforce/client/formFactor'; -const CURRENT_VERSION_NUMBER = 'v4.13.6'; +const CURRENT_VERSION_NUMBER = 'v4.13.7'; // JavaScript equivalent to the Apex class ComponentLogger.ComponentLogEntry const ComponentLogEntry = class { @@ -78,6 +78,16 @@ const LogEntryBuilder = class { return this; } + /** + * @description Sets the log entry event's scenario field + * @param {String} scenario The string to use to set the entry's scenario field + * @return {LogEntryBuilder} The same instance of `LogEntryBuilder`, useful for chaining methods + */ + setScenario(scenario) { + this.#componentLogEntry.scenario = scenario; + return this; + } + /** * @description Sets the log entry event's exception fields * @param {Error} error The instance of a JavaScript `Error` object to use, or an Apex HTTP error to use diff --git a/nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js b/nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js index 1cca7a5e8..2da776a8c 100644 --- a/nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js +++ b/nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js @@ -113,12 +113,9 @@ const LoggerService = class { } _newEntry(loggingLevel, message) { - // Builder is returned immediately but console log will be determined after loading settings from server const logEntryBuilder = newLogEntry(loggingLevel, this.#settings?.isConsoleLoggingEnabled); logEntryBuilder.setMessage(message); - if (this.#scenario) { - logEntryBuilder.scenario = this.#scenario; - } + logEntryBuilder.setScenario(this.#scenario); if (this._meetsUserLoggingLevel(loggingLevel)) { this.#componentLogEntries.push(logEntryBuilder.getComponentLogEntry()); } diff --git a/package.json b/package.json index f9eb3544f..998c42b7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nebula-logger", - "version": "4.13.6", + "version": "4.13.7", "description": "The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.", "author": "Jonathan Gillespie", "license": "MIT", diff --git a/sfdx-project.json b/sfdx-project.json index a21c403a3..2393414c4 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -14,9 +14,9 @@ "path": "./nebula-logger/core", "definitionFile": "./config/scratch-orgs/base-scratch-def.json", "scopeProfiles": true, - "versionNumber": "4.13.6.NEXT", - "versionName": "View Log Entry Metadata Custom Permission", - "versionDescription": "Added new custom permission CanViewLogEntryMetadata so that users without query access to ApexClass and ApexTrigger can still see the source code in the LWC logEntryMetadataViewer", + "versionNumber": "4.13.7.NEXT", + "versionName": "Fixed function setScenario() in logger LWC", + "versionDescription": "Fixed an issue in the logger LWC's function setScenario() where the value was sometimes (often?) incorrectly set to null", "releaseNotesUrl": "https://github.com/jongpie/NebulaLogger/releases", "unpackagedMetadata": { "path": "./nebula-logger/extra-tests" @@ -174,6 +174,7 @@ "Nebula Logger - Core@4.13.4-logger-parameter-comments": "04t5Y000001MkFBQA0", "Nebula Logger - Core@4.13.5-performance-improvements": "04t5Y000001MkGnQAK", "Nebula Logger - Core@4.13.6-view-log-entry-metadata-custom-permission": "04t5Y000001MkGxQAK", + "Nebula Logger - Core@4.13.7-fixed-function-setscenario()-in-logger-lwc": "04t5Y000001MkHRQA0", "Nebula Logger - Core Plugin - Async Failure Additions": "0Ho5Y000000blO4SAI", "Nebula Logger - Core Plugin - Async Failure Additions@1.0.0": "04t5Y0000015lhiQAA", "Nebula Logger - Core Plugin - Async Failure Additions@1.0.1": "04t5Y0000015lhsQAA",