Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

---

Expand Down
19 changes: 10 additions & 9 deletions docs/apex/Log-Management/RelatedLogEntriesController.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<LogEntry__c> records = search(recordId, search, fieldsClause, orderByClause, rowLimit);
List<LogEntry__c> records = search(recordId, search, fieldsClause, orderByClause, rowLimit, shouldEnableStrictSearch);
return new LogEntryQueryResult(fieldSetMetdata, records);
}

@SuppressWarnings('PMD.ExcessiveParameterList')
private static List<LogEntry__c> search(Id recordId, String searchTerm, String fieldsClause, String orderByClause, Integer rowLimit) {
private static List<LogEntry__c> 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) + '*';
}
Expand All @@ -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<LogEntry__c> matches = (List<LogEntry__c>) System.Search.query(logEntrySearch).get(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ <h2 class="slds-card__header-title">
variant="label-hidden"
></lightning-input>
<lightning-button-icon icon-name="utility:refresh" onclick={refresh}></lightning-button-icon>
<lightning-input
type="checkbox"
checked={shouldEnableStrictSearch}
onchange={toggleEnableStrictSearch}
label="Filter To Only This Record"
></lightning-input>
</div>
</header>
</div>
<div class="slds-card__body">
<lightning-spinner if:true={isLoading} size="small"></lightning-spinner>
<lightning-spinner alternative-text="loading related log entries..." lwc:if={isLoading} size="small"></lightning-spinner>
<div class="slds-is-relative" if:true={queryResult}>
<lightning-datatable
key-field="id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class RelatedLogEntries extends LightningElement {
@api rowLimit;
@api search = '';
@api queryResult;
@api shouldEnableStrictSearch = false;

@track wiredResult;
@track isLoading = true;
Expand All @@ -42,12 +43,13 @@ export default class RelatedLogEntries extends LightningElement {
}

@wire(getQueryResult, {
recordId: '$recordId',
fieldSetName: '$fieldSetName',
recordId: '$recordId',
rowLimit: '$rowLimit',
search: '$search',
sortByFieldName: '$sortBy',
sortDirection: '$sortDirection',
search: '$search'
shouldEnableStrictSearch: '$shouldEnableStrictSearch'
})
wiredLogEntries(result) {
this.isLoading = true;
Expand All @@ -67,6 +69,11 @@ export default class RelatedLogEntries extends LightningElement {
this.isLoading = false;
}

toggleEnableStrictSearch() {
this.shouldEnableStrictSearch = !this.shouldEnableStrictSearch;
this.refresh();
}

// Parse the Apex results & add any UI-specific attributes based on field metadata
processResult(queryResult) {
if (queryResult.fieldSet === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<targetConfig targets="lightning__RecordPage">
<property name="fieldSetName" label="Log Entry Field Set" type="String" datasource="apex://LogEntryFieldSetPicklist" />
<property name="rowLimit" label="Max Number of Log Entries to Display" type="Integer" default="30" />
<property name="shouldEnableStrictSearch" label="Should Strict Search" type="Boolean" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
2 changes: 1 addition & 1 deletion nebula-logger/core/main/logger-engine/classes/Logger.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogEntryEventBuilder> LOG_ENTRIES_BUFFER = new List<LogEntryEventBuilder>();
private static final String MISSING_SCENARIO_ERROR_MESSAGE = 'No logger scenario specified. A scenario is required for logging in this org.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} `,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ private class RelatedLogEntriesController_Tests {
rowLimit,
sortByFieldName,
sortDirection,
searchTerm
searchTerm,
false
);

System.Assert.areEqual(fieldSetName, result.fieldSet.name);
Expand Down Expand Up @@ -83,14 +84,46 @@ private class RelatedLogEntriesController_Tests {
rowLimit,
sortByFieldName,
sortDirection,
searchTerm
searchTerm,
false
);

System.Assert.areEqual(fieldSetName, result.fieldSet.name);
System.Assert.areEqual(1, result.records.size());
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<Id>{ 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() + '__';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 4 additions & 3 deletions sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down