diff --git a/README.md b/README.md index 8a40da763..7315148d5 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, OmniStudio, and integrations. -## Unlocked Package - v4.17.4 +## Unlocked Package - v4.17.5 -[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04tg70000004jmXAAQ) -[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04tg70000004jmXAAQ) +[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04tg70000006WjZAAU) +[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04tg70000006WjZAAU) [![View Documentation](./images/btn-view-documentation.png)](https://github.com/jongpie/NebulaLogger/wiki) -`sf package install --wait 20 --security-type AdminsOnly --package 04tg70000004jmXAAQ` +`sf package install --wait 20 --security-type AdminsOnly --package 04tg70000006WjZAAU` --- diff --git a/docs/apex/Log-Management/RelatedLogEntriesController.md b/docs/apex/Log-Management/RelatedLogEntriesController.md index d048343d2..de98f8d44 100644 --- a/docs/apex/Log-Management/RelatedLogEntriesController.md +++ b/docs/apex/Log-Management/RelatedLogEntriesController.md @@ -10,20 +10,21 @@ Controller class for the lightning web component `related-log-entries` ### Methods -#### `getQueryResult(Id recordId,String fieldSetName,Integer rowLimit,String sortByFieldName,String sortDirection,String search)` → `LogEntryQueryResult` +#### `getQueryResult(Id recordId,String fieldSetName,Integer rowLimit,String sortByFieldName,String sortDirection,String search,Boolean shouldEnableStrictSearch)` → `LogEntryQueryResult` Used by the component relatedLogEntries to get log entries for a particular record (based on record ID) ##### Parameters -| Param | Description | -| ----------------- | ---------------------------------------------------------------- | -| `recordId` | Used to filter LogEntry**c records where RecordId**c == recordId | -| `fieldSetName` | The API/developer name of the field set | -| `rowLimit` | The max number of rows to query | -| `sortByFieldName` | The field to sort by | -| `sortDirection` | The direction to sort by (asc or desc)) | -| `search` | An optional search term to filter by | +| Param | Description | +| -------------------------- | ------------------------------------------------------------------------------------ | +| `recordId` | The recordId to search for amidst all Log Entry fields | +| `fieldSetName` | The API/developer name of the field set | +| `rowLimit` | The max number of rows to query | +| `sortByFieldName` | The field to sort by | +| `sortDirection` | The direction to sort by (asc or desc) | +| `search` | An optional search term to filter by | +| `shouldEnableStrictSearch` | When true, used to filter returned LogEntry**c records where RecordId**c == recordId | ##### Return diff --git a/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls b/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls index 1120b1cfa..52df6555a 100644 --- a/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls +++ b/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls @@ -16,14 +16,14 @@ public with sharing class RelatedLogEntriesController { /** * @description Used by the component relatedLogEntries to get log entries for a particular record (based on record ID) - * @param recordId Used to filter LogEntry__c records where RecordId__c == recordId - * @param fieldSetName The API/developer name of the field set - * @param rowLimit The max number of rows to query - - * @param sortByFieldName The field to sort by - * @param sortDirection The direction to sort by (asc or desc)) - * @param search An optional search term to filter by - * @return The instance of LogEntryQueryResult, containing matching records and metadata + * @param recordId The recordId to search for amidst all Log Entry fields + * @param fieldSetName The API/developer name of the field set + * @param rowLimit The max number of rows to query + * @param sortByFieldName The field to sort by + * @param sortDirection The direction to sort by (asc or desc) + * @param search An optional search term to filter by + * @param shouldEnableStrictSearch When true, used to filter returned LogEntry__c records where RecordId__c == recordId + * @return The instance of LogEntryQueryResult, containing matching records and metadata */ @SuppressWarnings('PMD.ExcessiveParameterList') @AuraEnabled(cacheable=true) @@ -33,21 +33,29 @@ public with sharing class RelatedLogEntriesController { Integer rowLimit, String sortByFieldName, String sortDirection, - String search + String search, + Boolean shouldEnableStrictSearch ) { FieldSetMetadata fieldSetMetdata = new FieldSetMetadata(LOG_ENTRY_SOBJECT_TYPE, fieldSetName); String fieldsClause = getFieldsClause(fieldSetMetdata.fields); String orderByClause = getOrderByClause(sortByFieldName, sortDirection); - List records = search(recordId, search, fieldsClause, orderByClause, rowLimit); + List records = search(recordId, search, fieldsClause, orderByClause, rowLimit, shouldEnableStrictSearch); return new LogEntryQueryResult(fieldSetMetdata, records); } @SuppressWarnings('PMD.ExcessiveParameterList') - private static List search(Id recordId, String searchTerm, String fieldsClause, String orderByClause, Integer rowLimit) { + private static List search( + Id recordId, + String searchTerm, + String fieldsClause, + String orderByClause, + Integer rowLimit, + Boolean shouldEnableStrictSearch + ) { // SOSL can search for a 15-character ID, but for some reason, using the 18-character version returns no results (╯‵□′)╯︵┻━┻ - String fullSearchExpression = '*' + String.escapeSingleQuotes(String.valueOf(recordId).left(15)) + '*'; + String fullSearchExpression = '*' + String.escapeSingleQuotes(recordId.to15()) + '*'; if (String.isNotBlank(searchTerm)) { fullSearchExpression += ' AND *' + String.escapeSingleQuotes(searchTerm) + '*'; } @@ -57,10 +65,11 @@ public with sharing class RelatedLogEntriesController { fullSearchExpression, String.valueOf(Schema.LogEntry__c.SObjectType), fieldsClause, + shouldEnableStrictSearch ? 'WHERE RecordId__c = :recordId' : '', orderByClause, rowLimit }; - String logEntrySearch = String.format('FIND {0} IN ALL FIELDS RETURNING {1} ({2} ORDER BY {3} LIMIT {4})', searchTextReplacements); + String logEntrySearch = String.format('FIND {0} IN ALL FIELDS RETURNING {1} ({2} {3} ORDER BY {4} LIMIT {5})', searchTextReplacements); List matches = (List) System.Search.query(logEntrySearch).get(0); diff --git a/nebula-logger/core/main/log-management/lwc/relatedLogEntries/relatedLogEntries.html b/nebula-logger/core/main/log-management/lwc/relatedLogEntries/relatedLogEntries.html index 049ad02d5..2a34242cb 100644 --- a/nebula-logger/core/main/log-management/lwc/relatedLogEntries/relatedLogEntries.html +++ b/nebula-logger/core/main/log-management/lwc/relatedLogEntries/relatedLogEntries.html @@ -28,11 +28,17 @@

variant="label-hidden" > +
- +
+ diff --git a/nebula-logger/core/main/logger-engine/classes/Logger.cls b/nebula-logger/core/main/logger-engine/classes/Logger.cls index 27c2ca577..48f6088ec 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.17.4'; + private static final String CURRENT_VERSION_NUMBER = 'v4.17.5'; 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/loggerService.js b/nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js index 1c72aedff..e0ae82826 100644 --- a/nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js +++ b/nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js @@ -10,7 +10,7 @@ import LoggerServiceTaskQueue from './loggerServiceTaskQueue'; import getSettings from '@salesforce/apex/ComponentLogger.getSettings'; import saveComponentLogEntries from '@salesforce/apex/ComponentLogger.saveComponentLogEntries'; -const CURRENT_VERSION_NUMBER = 'v4.17.4'; +const CURRENT_VERSION_NUMBER = 'v4.17.5'; const CONSOLE_OUTPUT_CONFIG = { messagePrefix: `%c Nebula Logger ${CURRENT_VERSION_NUMBER} `, diff --git a/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls b/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls index a5fb86813..7fb4b9417 100644 --- a/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls @@ -54,7 +54,8 @@ private class RelatedLogEntriesController_Tests { rowLimit, sortByFieldName, sortDirection, - searchTerm + searchTerm, + false ); System.Assert.areEqual(fieldSetName, result.fieldSet.name); @@ -83,7 +84,8 @@ private class RelatedLogEntriesController_Tests { rowLimit, sortByFieldName, sortDirection, - searchTerm + searchTerm, + false ); System.Assert.areEqual(fieldSetName, result.fieldSet.name); @@ -91,6 +93,37 @@ private class RelatedLogEntriesController_Tests { System.Assert.areEqual(logEntryWithSearchTerm.Id, result.records[0].Id); } + @IsTest + static void it_should_return_no_matching_logEntryQueryResult_when_search_term_provided_and_strict_mode_enabled() { + String fieldSetName = getFieldSetName(); + Integer rowLimit = 10; + String sortByFieldName = 'Name'; + String sortDirection = 'ASC'; + String searchTerm = 'my searchTerm term'; + Log__c log = [SELECT Id FROM Log__c]; + LogEntry__c logEntryWithSearchTerm = new LogEntry__c(Log__c = log.Id, Message__c = searchTerm, RecordId__c = TARGET_RECORD_ID); + insert logEntryWithSearchTerm; + + // TODO revisit how SOSL is tested - having to use setFixedSearchResults() means we're not really truly testing + // that the SOSL search query is working (other than confirming that the query string can be executed successfully), + // the test will just return the records specified + System.Test.setFixedSearchResults(new List{ logEntryWithSearchTerm.Id }); + Boolean shouldEnableStrictSearch = true; + RelatedLogEntriesController.LogEntryQueryResult result = RelatedLogEntriesController.getQueryResult( + // explicitly don't pass the same recordId to ensure that strict search is performed in WHERE clause + LoggerMockDataCreator.createId(Schema.User.SObjectType), + fieldSetName, + rowLimit, + sortByFieldName, + sortDirection, + searchTerm, + shouldEnableStrictSearch + ); + + System.Assert.areEqual(fieldSetName, result.fieldSet.name); + System.Assert.areEqual(0, result.records.size()); + } + static String getFieldSetName() { Schema.FieldSet fieldSet = Schema.SObjectType.LogEntry__c.fieldSets.getMap().values().get(0); String fieldSetNamespacePrefix = String.isBlank(fieldSet.getNamespace()) ? '' : fieldSet.getNamespace() + '__'; diff --git a/package.json b/package.json index 174ebbd53..f22ab8d7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nebula-logger", - "version": "4.17.4", + "version": "4.17.5", "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 1d099d6bc..338a5a991 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -9,9 +9,9 @@ "path": "./nebula-logger/core", "definitionFile": "./config/scratch-orgs/base-scratch-def.json", "scopeProfiles": true, - "versionNumber": "4.17.4.NEXT", - "versionName": "LoggerEmailSender_Tests Fix for New Platform Requirement of Verified Email Domains", - "versionDescription": "Updated LoggerEmailSender_Tests to first update the current user's email address to be a (fake) gmail.com address to avoid issues with the new & breaking-change that requires most email domains to be verified (even in tests)", + "versionNumber": "4.17.5.NEXT", + "versionName": "Adds new flag to relatedLogEntries LWC for strict search based on recordId", + "versionDescription": "Adds new flag to relatedLogEntries LWC component allowing flexipages and on the component itself filtering of log entries down to only entries associated with the record in question", "postInstallUrl": "https://github.com/jongpie/NebulaLogger/wiki", "releaseNotesUrl": "https://github.com/jongpie/NebulaLogger/releases", "unpackagedMetadata": { @@ -226,6 +226,7 @@ "Nebula Logger - Core@4.17.2-bugfix:-modal-close-buttons-not-rendered-correctly": "04tg700000015gnAAA", "Nebula Logger - Core@4.17.3-relatedlogentries-lwc-improvements": "04tg70000001IMHAA2", "Nebula Logger - Core@4.17.4-loggeremailsender_tests-fix-for-new-platform-requirement-of-verified-email-domains": "04tg70000004jmXAAQ", + "Nebula Logger - Core@4.17.5-adds-new-flag-to-relatedlogentries-lwc-for-strict-search-based-on-recordid": "04tg70000006WjZAAU", "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",