Skip to content

Commit 18b4b52

Browse files
authored
Bugfix: session data is not populated when logging in LWC (#679)
* Fixed #678 by updating LoggerEngineDataSelector to not filter 'ParentId = null' when querying AuthSession - sessions for LWCs have a ParentId value set, so the filter previously prevented any data from being returned from AuthSession * Added a small enhancement to store the ParentId of the AuthSession record in new fields LogEntryEvent__e.ParentSessionId__c and Log__c.ParentSessionId__c * Improved & expanded upon some test methods in LogEntryEventBuilder_Tests and LogEntryEventHandler_Tests
1 parent fcb3b43 commit 18b4b52

19 files changed

Lines changed: 179 additions & 45 deletions

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.
77

8-
## Unlocked Package - v4.13.9
8+
## Unlocked Package - v4.13.10
99

10-
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001MkHqQAK)
11-
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001MkHqQAK)
10+
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000027L04QAE)
11+
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000027L04QAE)
1212
[![View Documentation](./images/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/)
1313

14-
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001MkHqQAK`
14+
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000027L04QAE`
1515

16-
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001MkHqQAK`
16+
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y0000027L04QAE`
1717

1818
---
1919

nebula-logger/core/main/log-management/classes/LogEntryEventHandler.cls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
182182
OrganizationType__c = logEntryEvent.OrganizationType__c,
183183
OwnerId = this.determineLogOwnerId(logEntryEvent),
184184
ParentLogTransactionId__c = logEntryEvent.ParentLogTransactionId__c,
185+
ParentSessionId__c = logEntryEvent.ParentSessionId__c,
185186
ProfileId__c = logEntryEvent.ProfileId__c,
186187
ProfileName__c = logEntryEvent.ProfileName__c,
187188
RequestId__c = logEntryEvent.RequestId__c,
@@ -613,6 +614,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
613614
log.LoginPlatform__c = matchingAuthSessionProxy.LoginHistory.Platform;
614615
log.LoginType__c = matchingAuthSessionProxy.LoginType;
615616
log.LogoutUrl__c = matchingAuthSessionProxy.LogoutUrl;
617+
log.ParentSessionId__c = matchingAuthSessionProxy.ParentId;
616618
log.SessionId__c = matchingAuthSessionProxy.Id;
617619
log.SessionSecurityLevel__c = matchingAuthSessionProxy.SessionSecurityLevel;
618620
log.SessionType__c = matchingAuthSessionProxy.SessionType;

nebula-logger/core/main/log-management/flexipages/LogRecordPage.flexipage-meta.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,22 @@
616616
<type>Facet</type>
617617
</flexiPageRegions>
618618
<flexiPageRegions>
619+
<itemInstances>
620+
<fieldInstance>
621+
<fieldInstanceProperties>
622+
<name>uiBehavior</name>
623+
<value>readonly</value>
624+
</fieldInstanceProperties>
625+
<fieldItem>Record.ParentSessionId__c</fieldItem>
626+
<identifier>RecordParentSessionId_cField</identifier>
627+
<visibilityRule>
628+
<criteria>
629+
<leftValue>{!Record.ParentSessionId__c}</leftValue>
630+
<operator>NE</operator>
631+
</criteria>
632+
</visibilityRule>
633+
</fieldInstance>
634+
</itemInstances>
619635
<itemInstances>
620636
<fieldInstance>
621637
<fieldInstanceProperties>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<fullName>ParentSessionId__c</fullName>
4+
<businessStatus>Active</businessStatus>
5+
<complianceGroup>PII;GDPR;CCPA</complianceGroup>
6+
<externalId>false</externalId>
7+
<label>Parent Session ID</label>
8+
<length>120</length>
9+
<required>false</required>
10+
<securityClassification>Confidential</securityClassification>
11+
<trackFeedHistory>false</trackFeedHistory>
12+
<trackHistory>false</trackHistory>
13+
<trackTrending>false</trackTrending>
14+
<type>Text</type>
15+
<unique>false</unique>
16+
</CustomField>

nebula-logger/core/main/log-management/permissionsets/LoggerAdmin.permissionset-meta.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,11 @@
14161416
<field>Log__c.ParentLog__c</field>
14171417
<readable>true</readable>
14181418
</fieldPermissions>
1419+
<fieldPermissions>
1420+
<editable>false</editable>
1421+
<field>Log__c.ParentSessionId__c</field>
1422+
<readable>true</readable>
1423+
</fieldPermissions>
14191424
<fieldPermissions>
14201425
<editable>true</editable>
14211426
<field>Log__c.Priority__c</field>

nebula-logger/core/main/log-management/permissionsets/LoggerEndUser.permissionset-meta.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,11 @@
927927
<field>Log__c.ParentLog__c</field>
928928
<readable>true</readable>
929929
</fieldPermissions>
930+
<fieldPermissions>
931+
<editable>false</editable>
932+
<field>Log__c.ParentSessionId__c</field>
933+
<readable>true</readable>
934+
</fieldPermissions>
930935
<fieldPermissions>
931936
<editable>false</editable>
932937
<field>Log__c.ProfileId__c</field>

nebula-logger/core/main/log-management/permissionsets/LoggerLogViewer.permissionset-meta.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,11 @@
13361336
<field>Log__c.ParentLog__c</field>
13371337
<readable>true</readable>
13381338
</fieldPermissions>
1339+
<fieldPermissions>
1340+
<editable>false</editable>
1341+
<field>Log__c.ParentSessionId__c</field>
1342+
<readable>true</readable>
1343+
</fieldPermissions>
13391344
<fieldPermissions>
13401345
<editable>false</editable>
13411346
<field>Log__c.Priority__c</field>

nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ global with sharing class LogEntryEventBuilder {
869869
logEntryEvent.LoginPlatform__c = CACHED_AUTH_SESSION_PROXY.LoginHistory.Platform;
870870
logEntryEvent.LoginType__c = CACHED_AUTH_SESSION_PROXY.LoginType;
871871
logEntryEvent.LogoutUrl__c = CACHED_AUTH_SESSION_PROXY.LogoutUrl;
872+
logEntryEvent.ParentSessionId__c = CACHED_AUTH_SESSION_PROXY.ParentId;
872873
logEntryEvent.SessionId__c = CACHED_AUTH_SESSION_PROXY.Id;
873874
logEntryEvent.SessionSecurityLevel__c = CACHED_AUTH_SESSION_PROXY.SessionSecurityLevel;
874875
logEntryEvent.SessionType__c = CACHED_AUTH_SESSION_PROXY.SessionType;

nebula-logger/core/main/logger-engine/classes/Logger.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
global with sharing class Logger {
1616
// There's no reliable way to get the version number dynamically in Apex
1717
@TestVisible
18-
private static final String CURRENT_VERSION_NUMBER = 'v4.13.9';
18+
private static final String CURRENT_VERSION_NUMBER = 'v4.13.10';
1919
private static final System.LoggingLevel FALLBACK_LOGGING_LEVEL = System.LoggingLevel.DEBUG;
2020
private static final List<LogEntryEventBuilder> LOG_ENTRIES_BUFFER = new List<LogEntryEventBuilder>();
2121
private static final String MISSING_SCENARIO_ERROR_MESSAGE = 'No logger scenario specified. A scenario is required for logging in this org.';

nebula-logger/core/main/logger-engine/classes/LoggerEngineDataSelector.cls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ public without sharing virtual class LoggerEngineDataSelector {
5050
LoginHistory.Platform,
5151
LoginHistory.UserId,
5252
LogoutUrl,
53+
ParentId,
5354
SessionSecurityLevel,
5455
SessionType,
5556
SourceIp,
5657
UsersId
5758
FROM AuthSession
58-
WHERE UsersId IN :userIds AND IsCurrent = TRUE AND ParentId = NULL
59+
WHERE UsersId IN :userIds AND IsCurrent = TRUE
60+
ORDER BY ParentId NULLS FIRST
5961
]) {
6062
LoggerSObjectProxy.AuthSession authSessionProxy = new LoggerSObjectProxy.AuthSession(authSession);
6163
userIdToAuthSessionProxy.put(authSessionProxy.UsersId, authSessionProxy);

0 commit comments

Comments
 (0)