Skip to content

Commit

Permalink
Depreated LogEntryEvent__e.ApiVersion__c and replaced it with LogEntr…
Browse files Browse the repository at this point in the history
…yEvent__e.OrganizationApiVersion__c, finished some backend changes for several related field deprecations
  • Loading branch information
jongpie committed Jun 1, 2023
1 parent 9640014 commit 128fdc7
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
}

Log__c log = new Log__c(
// TODO Log__c.ApiReleaseNumber__c and Log__c.ApiReleaseVersion__c are both deprecated,
// in a future release, remove these reference (and delete the fields)
ApiReleaseNumber__c = recentLogWithApiReleaseDetails?.ApiReleaseNumber__c,
ApiReleaseVersion__c = recentLogWithApiReleaseDetails?.ApiReleaseVersion__c,
// TODO Log__c.ApiVersion__c and LogEntryEvent__e.ApiVersion__c are both deprecated,
// in a future release, remove this reference (and delete the fields)
ApiVersion__c = logEntryEvent.ApiVersion__c,
ImpersonatedBy__c = logEntryEvent.ImpersonatedById__c,
Locale__c = logEntryEvent.Locale__c,
Expand All @@ -162,12 +166,15 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
NetworkName__c = logEntryEvent.NetworkName__c,
NetworkSelfRegistrationUrl__c = logEntryEvent.NetworkSelfRegistrationUrl__c,
NetworkUrlPathPrefix__c = logEntryEvent.NetworkUrlPathPrefix__c,
OrganizationApiVersion__c = logEntryEvent.OrganizationApiVersion__c,
OrganizationDomainUrl__c = logEntryEvent.OrganizationDomainUrl__c,
OrganizationEnvironmentType__c = logEntryEvent.OrganizationEnvironmentType__c,
OrganizationId__c = logEntryEvent.OrganizationId__c,
OrganizationInstanceName__c = logEntryEvent.OrganizationInstanceName__c,
OrganizationName__c = logEntryEvent.OrganizationName__c,
OrganizationNamespacePrefix__c = logEntryEvent.OrganizationNamespacePrefix__c,
OrganizationReleaseNumber__c = recentLogWithApiReleaseDetails?.OrganizationReleaseNumber__c,
OrganizationReleaseVersion__c = recentLogWithApiReleaseDetails?.OrganizationReleaseVersion__c,
OrganizationType__c = logEntryEvent.OrganizationType__c,
OwnerId = this.determineLogOwnerId(logEntryEvent),
ParentLogTransactionId__c = logEntryEvent.ParentLogTransactionId__c,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public without sharing virtual class LogManagementDataSelector {
Datetime fourHoursAgo = System.now().addMinutes(-4 * 60);

List<Log__c> logs = [
SELECT Id, ApiReleaseNumber__c, ApiReleaseVersion__c
SELECT Id, ApiReleaseNumber__c, ApiReleaseVersion__c, OrganizationReleaseNumber__c, OrganizationReleaseVersion__c
FROM Log__c
WHERE CreatedDate >= :fourHoursAgo AND CreatedDate = TODAY AND ApiReleaseNumber__c != NULL
ORDER BY CreatedDate DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const MOCK_ENVIRONMENT_DETAILS = {
loggerVersionNumber: 'v4.10.4',
organizationApiVersion: 'v57.0',
organizationCreatedByUsername: '[email protected]',
organizationEnvironment: 'sandbox',
organizationFormattedCreatedDate: '5/22/2023, 2:09 PM',
organizationId: '00D8G000000E1S9UAK',
organizationInstanceLocation: 'NA',
Expand Down Expand Up @@ -77,7 +76,6 @@ describe('c-logger-home-header', () => {
'environment-organizationId': MOCK_ENVIRONMENT_DETAILS.organizationId,
'environment-organizationName': MOCK_ENVIRONMENT_DETAILS.organizationName,
'environment-organizationType': MOCK_ENVIRONMENT_DETAILS.organizationType,
'environment-organizationEnvironment': MOCK_ENVIRONMENT_DETAILS.organizationEnvironment,
'environment-organizationInstanceName': MOCK_ENVIRONMENT_DETAILS.organizationInstanceName,
'environment-organizationInstanceLocation': MOCK_ENVIRONMENT_DETAILS.organizationInstanceLocation,
'environment-organizationInstanceProducts': MOCK_ENVIRONMENT_DETAILS.organizationInstanceProducts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ <h3 class="slds-section__title slds-theme_shade">
value={environment.organizationType}
variant="label-inline"
></lightning-input>
<lightning-input
data-id="environment-organizationEnvironment"
label="Environment"
read-only
type="url"
value={environment.organizationEnvironment}
variant="label-inline"
></lightning-input>
<lightning-input
data-id="environment-organizationInstanceName"
label="Instance Name"
Expand Down
1 change: 1 addition & 0 deletions nebula-logger/core/main/logger-engine/classes/Logger.cls
Original file line number Diff line number Diff line change
Expand Up @@ -3195,6 +3195,7 @@ global with sharing class Logger {
logEntryEvent.ApiVersion__c = getOrganizationApiVersion();
logEntryEvent.EntryScenario__c = currentEntryScenario;
logEntryEvent.LoggerVersionNumber__c = CURRENT_VERSION_NUMBER;
logEntryEvent.OrganizationApiVersion__c = getOrganizationApiVersion();
logEntryEvent.OrganizationDomainUrl__c = ORGANIZATION_DOMAIN_URL;
logEntryEvent.RequestId__c = REQUEST_ID;
logEntryEvent.SystemMode__c = getCurrentQuiddity()?.name();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>ApiVersion__c</fullName>
<businessStatus>Active</businessStatus>
<businessStatus>DeprecateCandidate</businessStatus>
<complianceGroup>None</complianceGroup>
<externalId>false</externalId>
<isFilteringDisabled>false</isFilteringDisabled>
<isNameField>false</isNameField>
<isSortingDisabled>false</isSortingDisabled>
<label>API Version</label>
<label>DEPRECATED: API Version</label>
<length>5</length>
<required>false</required>
<securityClassification>Confidential</securityClassification>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>OrganizationApiVersion__c</fullName>
<businessStatus>Active</businessStatus>
<complianceGroup>None</complianceGroup>
<externalId>false</externalId>
<isFilteringDisabled>false</isFilteringDisabled>
<isNameField>false</isNameField>
<isSortingDisabled>false</isSortingDisabled>
<label>Organization API Version</label>
<length>5</length>
<required>false</required>
<securityClassification>Confidential</securityClassification>
<type>Text</type>
<unique>false</unique>
</CustomField>
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,13 @@ private class LogEntryEventHandler_Tests {
LoggerTestConfigurator.setupMockSObjectHandlerConfigurations();
LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.Log__c.SObjectType).IsEnabled__c = false;
LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.LogEntry__c.SObjectType).IsEnabled__c = false;
Log__c recentLog = new Log__c(ApiReleaseNumber__c = 'QWERTY', ApiReleaseVersion__c = 'ASDF', TransactionId__c = 'ABC-XYZ');
Log__c recentLog = new Log__c(
ApiReleaseNumber__c = 'QWERTY',
ApiReleaseVersion__c = 'ASDF',
OrganizationReleaseNumber__c = 'POIUY',
OrganizationReleaseVersion__c = 'LKJH',
TransactionId__c = 'ABC-XYZ'
);
insert recentLog;
insert new LogEntry__c(Log__c = recentLog.Id, Timestamp__c = System.now().addHours(-1));
LoggerParameter__mdt mockCallStatusApiParameter = new LoggerParameter__mdt(DeveloperName = 'CallStatusApi', Value__c = 'true');
Expand All @@ -1064,6 +1070,8 @@ private class LogEntryEventHandler_Tests {
LogEntry__c logEntry = log.LogEntries__r.get(0);
System.Assert.areEqual(recentLog.ApiReleaseNumber__c, log.ApiReleaseNumber__c);
System.Assert.areEqual(recentLog.ApiReleaseVersion__c, log.ApiReleaseVersion__c);
System.Assert.areEqual(recentLog.OrganizationReleaseNumber__c, log.OrganizationReleaseNumber__c);
System.Assert.areEqual(recentLog.OrganizationReleaseVersion__c, log.OrganizationReleaseVersion__c);
validateLogFields(logEntryEvent, log);
validateLogEntryFields(logEntryEvent, logEntry);
}
Expand Down Expand Up @@ -1103,6 +1111,8 @@ private class LogEntryEventHandler_Tests {
System.Assert.areEqual(logEntryEvent.TransactionId__c, log.TransactionId__c);
System.Assert.isNull(log.ApiReleaseNumber__c);
System.Assert.isNull(log.ApiReleaseVersion__c);
System.Assert.isNull(log.OrganizationReleaseNumber__c);
System.Assert.isNull(log.OrganizationReleaseVersion__c);
validateLogFields(logEntryEvent, log);
validateLogEntryFields(logEntryEvent, logEntry);
}
Expand Down Expand Up @@ -1364,6 +1374,7 @@ private class LogEntryEventHandler_Tests {
System.Assert.areEqual(logEntryEvent.LogoutUrl__c, log.LogoutUrl__c, 'log.LogoutUrl__c was not properly set');
System.Assert.areEqual(logEntryEvent.NetworkId__c, log.NetworkId__c, 'log.NetworkId__c was not properly set');
System.Assert.areEqual(logOwnerId, log.OwnerId, 'log.OwnerId was not properly set');
System.Assert.areEqual(logEntryEvent.OrganizationApiVersion__c, log.OrganizationApiVersion__c, 'log.OrganizationApiVersion__c was not properly set');
System.Assert.areEqual(logEntryEvent.ParentLogTransactionId__c, log.ParentLogTransactionId__c, 'log.ParentLogTransactionId__c was not properly set');
System.Assert.areEqual(logEntryEvent.ProfileId__c, log.ProfileId__c, 'log.ProfileId__c was not properly set');
System.Assert.areEqual(logEntryEvent.ProfileName__c, log.ProfileName__c, 'log.ProfileName__c was not properly set');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,29 @@ private class LogManagementDataSelector_Tests {
static void it_returns_cached_recent_log_with_api_release_details() {
LoggerTestConfigurator.setupMockSObjectHandlerConfigurations();
LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.Log__c.SObjectType).IsEnabled__c = false;
Log__c olderLog = new Log__c(ApiReleaseNumber__c = 'QWERTY', ApiReleaseVersion__c = 'ASDF', TransactionId__c = 'ABC');
Log__c expectedLog = new Log__c(ApiReleaseNumber__c = 'QWERTY', ApiReleaseVersion__c = 'ASDF', TransactionId__c = 'XYZ');
Log__c olderLog = new Log__c(
ApiReleaseNumber__c = 'QWERTY',
ApiReleaseVersion__c = 'ASDF',
OrganizationReleaseNumber__c = 'QWERTY',
OrganizationReleaseVersion__c = 'ASDF',
TransactionId__c = 'ABC'
);
Log__c expectedLog = new Log__c(
ApiReleaseNumber__c = 'QWERTY',
ApiReleaseVersion__c = 'ASDF',
OrganizationReleaseNumber__c = 'QWERTY',
OrganizationReleaseVersion__c = 'ASDF',
TransactionId__c = 'XYZ'
);
insert new List<Log__c>{ olderLog, expectedLog };
System.Test.setCreatedDate(olderLog.Id, System.now().addMinutes(-5));
System.Assert.areEqual(1, System.Limits.getQueries());

for (Integer i = 0; i < 5; i++) {
for (Integer i = 0; i < 3; i++) {
Log__c returnedLog = LogManagementDataSelector.getInstance().getCachedRecentLogWithApiReleaseDetails();

System.Assert.areEqual(expectedLog.Id, returnedLog.Id);
System.Assert.areEqual(JSON.serialize(expectedLog), JSON.serialize(expectedLog));
}

System.Assert.areEqual(2, System.Limits.getQueries());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ private class Logger_Tests {

@IsTest
static void it_should_set_transaction_details() {
for (Integer i = 0; i < 10; i++) {
LogEntryEventBuilder builder = Logger.info('my log entry');
for (Integer i = 0; i < 3; i++) {
LogEntryEventBuilder builder = Logger.info('my log entry for index ' + i);

System.Assert.isNotNull(builder.getLogEntryEvent().LoggerVersionNumber__c);
System.Assert.areEqual(Logger.CURRENT_VERSION_NUMBER, builder.getLogEntryEvent().LoggerVersionNumber__c);
System.Assert.areEqual(Logger.getVersionNumber(), builder.getLogEntryEvent().LoggerVersionNumber__c);
System.Assert.areEqual(Logger.getScenario(), builder.getLogEntryEvent().EntryScenario__c);
System.Assert.areEqual(Logger.getOrganizationApiVersion(), builder.getLogEntryEvent().OrganizationApiVersion__c);
System.Assert.areEqual(System.URL.getOrgDomainUrl()?.toExternalForm(), builder.getLogEntryEvent().OrganizationDomainUrl__c);
System.Assert.areEqual(Logger.getParentLogTransactionId(), builder.getLogEntryEvent().ParentLogTransactionId__c);
System.Assert.areEqual(System.Request.getCurrent().getRequestId(), builder.getLogEntryEvent().RequestId__c);
Expand Down

0 comments on commit 128fdc7

Please sign in to comment.