Skip to content

Commit

Permalink
Added tracking of logging user's federation identifier (#682)
Browse files Browse the repository at this point in the history
* Added new long textarea (512) fields LoggedByFederationIdentifier__c on LogEntryEvent__e and Log__c to track the value of Schema.User.FederationIdentifier for the logging user

* Added new field Log__c.HasLoggedByFederationIdentifier__c to make it easier to filter/identify records where the user's federation ID has been populated

* Added field-level security (FLS) for the new Log__c fields to the permission sets LoggerAdmin, LoggerLogViewer, and LoggerEndUser

* Added new field Log__c.LoggedByFederationIdentifier__c to the flexipage LogRecordPage - it conditionally shows, based on the value of the other new field, Log__c.HasLoggedByFederationIdentifier__c

* Renamed the Big Object index LogEntryArchiveIndex.indexe-meta.xml to LogEntryArchiveIndex.index-meta.xml (indexe --> index)

* Deleted several old scripts in package.json and in the directory ./scripts/build

* Upgraded package dependencies & regenerated package-lock.json

* Tweaked config in .prettierrc

* Updated GitHub Actions in build.yml to use v4 (compatible with Node 20)
  • Loading branch information
jongpie committed Apr 29, 2024
1 parent 18b4b52 commit 4d56ecb
Show file tree
Hide file tree
Showing 31 changed files with 33,779 additions and 24,654 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -99,11 +99,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -131,11 +131,11 @@ jobs:
environment: 'Base Scratch Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
run: npm run test:apex:nocoverage -- --synchronous

- name: 'Delete Base Scratch Org'
run: npm run org:delete:noprompt
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}

experience-cloud-scratch-org-tests:
Expand All @@ -193,11 +193,11 @@ jobs:
environment: 'Experience Cloud Scratch Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
flags: Apex

- name: 'Delete Experience Cloud Scratch Org'
run: npm run org:delete:noprompt
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}

create-managed-package-beta:
Expand All @@ -265,13 +265,13 @@ jobs:
environment: 'Demo Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -306,13 +306,13 @@ jobs:
environment: 'Demo Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -377,11 +377,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down
8 changes: 2 additions & 6 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@
"plugins": ["prettier-plugin-apex", "@prettier/plugin-xml"],
"overrides": [
{
"files": "*.{cls, apex}",
"files": "*.{apex,cls,trigger}",
"options": { "parser": "apex" }
},
{
"files": "**/lwc/**/*.html",
"options": { "parser": "lwc" }
},
{
"files": "*.{cmp,page,component}",
"files": "*.{cmp,page}",
"options": { "parser": "html" }
},
{
"files": "*.{md}",
"options": { "parser": "markdown" }
}
]
}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.10
## Unlocked Package - v4.13.11

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

`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000027L04QAE`
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000027L98QAE`

`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y0000027L04QAE`
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y0000027L98QAE`

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
ImpersonatedBy__c = logEntryEvent.ImpersonatedById__c,
Locale__c = logEntryEvent.Locale__c,
LoggedBy__c = logEntryEvent.LoggedById__c,
LoggedByFederationIdentifier__c = logEntryEvent.LoggedByFederationIdentifier__c,
LoggedByUsername__c = logEntryEvent.LoggedByUsername__c,
LoggerVersionNumber__c = logEntryEvent.LoggerVersionNumber__c,
LoginApplication__c = logEntryEvent.LoginApplication__c,
Expand Down Expand Up @@ -695,6 +696,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
}

Schema.User matchingUser = userIdToUser.get(log.LoggedBy__c);
log.LoggedByFederationIdentifier__c = matchingUser.FederationIdentifier;
log.LoggedByUsername__c = matchingUser.Username;
log.ProfileName__c = matchingUser.Profile.Name;
log.UserLicenseDefinitionKey__c = matchingUser.Profile.UserLicense.LicenseDefinitionKey;
Expand Down
10 changes: 2 additions & 8 deletions nebula-logger/core/main/log-management/classes/LogHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public without sharing class LogHandler extends LoggerSObjectHandler {
this.logs = (List<Log__c>) triggerNew;
this.loggerScenariosById = queryLoggerScenarios(this.logs);

this.setHasCommentsField();
this.setClosedStatusFields();
this.setOrganizationLimits();
// The log OwnerId field should support being manually changed, so only auto-set it on insert
Expand All @@ -54,7 +53,6 @@ public without sharing class LogHandler extends LoggerSObjectHandler {
this.logs = (List<Log__c>) triggerNewMap.values();
this.oldLogsById = (Map<Id, Log__c>) triggerOldMap;

this.setHasCommentsField();
this.setClosedStatusFields();
// Priority logic relies on roll-up fields, so only run on update (after log entries are inserted)
this.setPriority();
Expand All @@ -68,12 +66,6 @@ public without sharing class LogHandler extends LoggerSObjectHandler {
this.shareLogsWithLoggingUsers();
}

private void setHasCommentsField() {
for (Log__c log : this.logs) {
log.HasComments__c = String.isNotBlank(log.Comments__c);
}
}

private void setClosedStatusFields() {
Map<String, LogStatus__mdt> logStatusNameToStatus = loadActiveLogStatuses();
for (Log__c log : this.logs) {
Expand Down Expand Up @@ -222,6 +214,8 @@ public without sharing class LogHandler extends LoggerSObjectHandler {

private void setCheckboxFields() {
for (Log__c log : this.logs) {
log.HasComments__c = log.Comments__c != null;
log.HasLoggedByFederationIdentifier__c = log.LoggedByFederationIdentifier__c != null;
log.HasOrganizationLimits__c = log.OrganizationLimits__c != null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,23 @@
<identifier>RecordLoggedByUsernameLink__cField</identifier>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
<name>uiBehavior</name>
<value>readonly</value>
</fieldInstanceProperties>
<fieldItem>Record.LoggedByFederationIdentifier__c</fieldItem>
<identifier>RecordLoggedByFederationIdentifier_cField</identifier>
<visibilityRule>
<criteria>
<leftValue>{!Record.HasLoggedByFederationIdentifier__c}</leftValue>
<operator>EQUAL</operator>
<rightValue>true</rightValue>
</criteria>
</visibilityRule>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>HasLoggedByFederationIdentifier__c</fullName>
<businessStatus>Active</businessStatus>
<complianceGroup>None</complianceGroup>
<defaultValue>false</defaultValue>
<externalId>false</externalId>
<label>Has User Federation Identifier</label>
<securityClassification>Confidential</securityClassification>
<trackFeedHistory>false</trackFeedHistory>
<trackHistory>false</trackHistory>
<trackTrending>false</trackTrending>
<type>Checkbox</type>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>LoggedByFederationIdentifier__c</fullName>
<businessStatus>Active</businessStatus>
<complianceGroup>PII;GDPR;CCPA</complianceGroup>
<externalId>false</externalId>
<label>User Federation Identifier</label>
<length>512</length>
<securityClassification>Confidential</securityClassification>
<trackHistory>false</trackHistory>
<trackTrending>false</trackTrending>
<type>LongTextArea</type>
<visibleLines>3</visibleLines>
</CustomField>
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,11 @@
<field>Log__c.HasComments__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasLoggedByFederationIdentifier__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasOrganizationLimits__c</field>
Expand Down Expand Up @@ -1241,6 +1246,11 @@
<field>Log__c.LogRetentionDate__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.LoggedByFederationIdentifier__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.LoggedByUsernameLink__c</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,11 @@
<field>Log__c.EndTime__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasLoggedByFederationIdentifier__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasOrganizationLimits__c</field>
Expand Down Expand Up @@ -772,6 +777,11 @@
<field>Log__c.LogRetentionDate__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.LoggedByFederationIdentifier__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.LoggedByUsernameLink__c</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,11 @@
<field>Log__c.HasComments__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasLoggedByFederationIdentifier__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasOrganizationLimits__c</field>
Expand Down Expand Up @@ -1161,6 +1166,11 @@
<field>Log__c.LogRetentionDate__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.LoggedByFederationIdentifier__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.LoggedByUsernameLink__c</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ global with sharing class LogEntryEventBuilder {
return;
}

logEntryEvent.LoggedByFederationIdentifier__c = CACHED_USER.FederationIdentifier;
logEntryEvent.LoggedByUsername__c = CACHED_USER.Username;
logEntryEvent.ProfileName__c = CACHED_USER.Profile.Name;
logEntryEvent.UserLicenseDefinitionKey__c = CACHED_USER.Profile.UserLicense.LicenseDefinitionKey;
Expand Down
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.13.10';
private static final String CURRENT_VERSION_NUMBER = 'v4.13.11';
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 @@ -241,7 +241,15 @@ public without sharing virtual class LoggerEngineDataSelector {

return new Map<Id, Schema.User>(
[
SELECT Id, Profile.Name, Profile.UserLicenseId, Profile.UserLicense.LicenseDefinitionKey, Profile.UserLicense.Name, Username, UserRole.Name
SELECT
FederationIdentifier,
Id,
Profile.Name,
Profile.UserLicenseId,
Profile.UserLicense.LicenseDefinitionKey,
Profile.UserLicense.Name,
Username,
UserRole.Name
FROM User
WHERE Id IN :userIds
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//------------------------------------------------------------------------------------------------//
import FORM_FACTOR from '@salesforce/client/formFactor';

const CURRENT_VERSION_NUMBER = 'v4.13.10';
const CURRENT_VERSION_NUMBER = 'v4.13.11';

// JavaScript equivalent to the Apex class ComponentLogger.ComponentLogEntry
const ComponentLogEntry = class {
Expand Down

0 comments on commit 4d56ecb

Please sign in to comment.