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
297 changes: 159 additions & 138 deletions force-app/main/default/classes/Triton.cls

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions force-app/main/default/classes/TritonFlow.cls
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public with sharing class TritonFlow {
} catch (Exception e) {
flowDetails += '\nUnable to locate log level: ' + flowLog.level + '. Default INFO level will be used.';
}
Pharos.LogBuilder builder = Triton.makeBuilder();
pharos.LogBuilder builder = Triton.makeBuilder();
builder
.category(TritonTypes.Category.Flow.name())
.type(flowLog.type)
.area(flowLog.area)
.summary(flowLog.summary)
.details(flowDetails)
.transactionId(Triton.instance.TRANSACTION_ID)
.attribute(Triton.INTERVIEW_GUID, flowLog.interviewGUID)
.attribute(Triton.FLOW_API_NAME, flowLog.flowApiName)
.attribute(Triton.LOG_LEVEL, level.name());
.area(flowLog.area)
.attribute(Triton.FLOW_API_NAME, flowLog.flowApiName)
.attribute(Triton.INTERVIEW_GUID, flowLog.interviewGUID)
.attribute(Triton.LOG_LEVEL, level.name())
.category(TritonTypes.Category.Flow.name())
.details(flowDetails)
.summary(flowLog.summary)
.transactionId(Triton.instance.TRANSACTION_ID)
.type(flowLog.type);

if (String.isNotBlank(flowLog.additionalFields)) {
try {
Expand Down
126 changes: 125 additions & 1 deletion force-app/main/default/classes/TritonHelper.cls
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
*/
public with sharing class TritonHelper {

public static final Map<String, TritonTypes.Level> NEBULA_LEVEL_MAP = new Map<String, TritonTypes.Level> {
'ERROR' => TritonTypes.Level.ERROR,
'WARNING' => TritonTypes.Level.WARNING,
'INFO' => TritonTypes.Level.INFO,
'DEBUG' => TritonTypes.Level.DEBUG,
'FINE' => TritonTypes.Level.FINE,
'FINER' => TritonTypes.Level.FINER,
'FINEST' => TritonTypes.Level.FINEST
};

/**
* Creates a key for log level based on:
* @param category -- log category field
Expand Down Expand Up @@ -211,5 +221,119 @@ public with sharing class TritonHelper {
controls.put(TOTAL_ACTIVE_SESSION_KEY, value);
return this;
}
}
}

/*
{
"attributes": {
"type": "LogEntryEvent__e"
},
"LoggingLevel__c": "ERROR",
"LoggingLevelOrdinal__c": 8,
"OriginType__c": "Apex",
"TriggerIsExecuting__c": false,
"TriggerOperationType__c": null,
"TriggerSObjectType__c": null,
"LimitsAggregateQueriesMax__c": 300,
"LimitsAsyncCallsMax__c": 200,
"LimitsCalloutsMax__c": 100,
"LimitsCpuTimeMax__c": 10000,
"LimitsDmlRowsMax__c": 10000,
"LimitsDmlStatementsMax__c": 150,
"LimitsEmailInvocationsMax__c": 10,
"LimitsFutureCallsMax__c": 50,
"LimitsHeapSizeMax__c": 6000000,
"LimitsMobilePushApexCallsMax__c": 10,
"LimitsPublishImmediateDmlStatementsMax__c": 150,
"LimitsQueueableJobsMax__c": 50,
"LimitsSoqlQueriesMax__c": 100,
"LimitsSoqlQueryLocatorRowsMax__c": 10000,
"LimitsSoqlQueryRowsMax__c": 50000,
"LimitsSoslSearchesMax__c": 20,
"LimitsAggregateQueriesUsed__c": 0,
"LimitsAsyncCallsUsed__c": 0,
"LimitsCalloutsUsed__c": 0,
"LimitsCpuTimeUsed__c": 15,
"LimitsDmlRowsUsed__c": 0,
"LimitsDmlStatementsUsed__c": 0,
"LimitsEmailInvocationsUsed__c": 0,
"LimitsFutureCallsUsed__c": 0,
"LimitsMobilePushApexCallsUsed__c": 0,
"LimitsQueueableJobsUsed__c": 0,
"LimitsPublishImmediateDmlStatementsUsed__c": 0,
"LimitsSoqlQueriesUsed__c": 0,
"LimitsSoqlQueryLocatorRowsUsed__c": 0,
"LimitsSoqlQueryRowsUsed__c": 0,
"LimitsSoslSearchesUsed__c": 0,
"LimitsHeapSizeUsed__c": 11096,
"EpochTimestamp__c": 1729808545107,
"Timestamp__c": "2024-10-24T22:22:25.107+0000",
"TimestampString__c": "1729808545107",
"OriginLocation__c": "AnonymousBlock",
"OriginSourceActionName__c": null,
"OriginSourceApiName__c": null,
"OriginSourceMetadataType__c": "AnonymousBlock",
"StackTrace__c": "AnonymousBlock: line 1, column 1",
"ApiVersion__c": "v62.0",
"EntryScenario__c": null,
"LoggerVersionNumber__c": "v4.14.14",
"OrganizationApiVersion__c": "v62.0",
"OrganizationDomainUrl__c": "https://onepagecom-dev-ed.develop.my.salesforce.com",
"RequestId__c": "SLB:82a3dd3d1b131f12001ebe3d2ec20012",
"SystemMode__c": "ANONYMOUS",
"TransactionEntryNumber__c": 1,
"TransactionId__c": "04584565-91f3-489c-9106-629b45ce1bfb",
"UserLoggingLevel__c": "FINEST",
"UserLoggingLevelOrdinal__c": 2,
"Message__c": "error message",
"MessageMasked__c": false,
"MessageTruncated__c": false,
"Locale__c": "en_US",
"LoggedById__c": "005ak000002TGoDAAW",
"LoggedByUsername__c": "[email protected]",
"ProfileId__c": "00eak000002XMLbAAO",
"ThemeDisplayed__c": "Theme3",
"TimeZoneId__c": "America/Los_Angeles",
"TimeZoneName__c": "(GMT-07:00) Pacific Daylight Time (America/Los_Angeles)",
"UserRoleId__c": null,
"UserType__c": "Standard",
"LoginApplication__c": "Browser",
"LoginBrowser__c": "Chrome 129",
"LoginHistoryId__c": "0Yaak00000BbJ3SCAV",
"LoginPlatform__c": "Mac OSX",
"LoginType__c": "Application",
"LogoutUrl__c": null,
"ParentSessionId__c": "0Akak00000EegmPCAR",
"SessionId__c": "0Akak00000EjZI0CAN",
"SessionSecurityLevel__c": "STANDARD",
"SessionType__c": "UI",
"SourceIp__c": "107.141.175.191",
"LoggedByFederationIdentifier__c": null,
"ProfileName__c": "System Administrator",
"UserLicenseDefinitionKey__c": "SFDC",
"UserLicenseId__c": "100ak000005YRSjAAO",
"UserLicenseName__c": "Salesforce",
"UserRoleName__c": null,
"OrganizationEnvironmentType__c": "Production",
"OrganizationId__c": "00Dak000003lUSLEA2",
"OrganizationInstanceName__c": "USA840",
"OrganizationName__c": "N/A",
"OrganizationNamespacePrefix__c": null,
"OrganizationType__c": "Developer Edition"
}

code sample:
public static void saveLog(String saveMethodName) {


for (LogEntryEventBuilder logEntryEventBuilder : LOG_ENTRIES_BUFFER) {
if (logEntryEventBuilder.shouldSave()) {
Triton.addNebulaLog(JSON.serialize(logEntryEventBuilder.getLogEntryEvent()));
}
}

if (Triton_Nebula_Integration__mdt.getInstance('Triton').Deactivate_Nebula__c) {
return;
}
*/
}
73 changes: 47 additions & 26 deletions force-app/main/default/classes/TritonLwc.cls
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,53 @@ public with sharing class TritonLwc {
Triton logInstance = Triton.instance;
for (ComponentLog componentLog : componentLogs) {
logInstance.add(
Triton.makeBuilder()
//category will be fetched from the componentLog
.category(String.isNotBlank(componentLog.category) ? componentLog.category : componentLog.component.category)
//type will be fetched from the componentLog directly, of from the error. If neither are set, Frontend will be used
.type(String.isNotBlank(componentLog.type) ? componentLog.type :
componentLog.error != null ? componentLog.error.type : TritonTypes.Type.Frontend.name())
//area will be fetched from the componentLog directly if set. Otherwise component name will be used
.area(String.isNotBlank(componentLog.area) ? componentLog.area : componentLog.component.name)
//summary will be fetched from the componentLog directly if set. Otherwise, error message will be used if provided.
.summary(String.isNotBlank(componentLog.summary) ? componentLog.summary :
componentLog.error != null ? componentLog.error.message : null)
.stackTrace(componentLog.stack)
.details(componentLog.details)
//transaction id will be used from the componentLog, or a new transaction id will be generated
.transactionId(String.isNotBlank(componentLog.transactionId) ? componentLog.transactionId : logInstance.TRANSACTION_ID)
.attribute(Triton.USER_ID, componentLog.userId)
//apex name will be set to component.function or component.action
.attribute(Triton.APEX_NAME, componentLog.component.name + '.' +
(String.isNotBlank(componentLog.component.function) ? componentLog.component.function : componentLog.component.action))
.attribute(Triton.RELATED_ID, componentLog.recordId)
//created timestamp will be either set from the componentLog if provided, otherwise current timestamp will be used
.attribute(Triton.CREATED_TIMESTAMP, componentLog.createdTimestamp != null ? Double.valueOf(componentLog.createdTimestamp) : Double.valueOf(System.now().getTime()))
//log level will be taken from the componentLog if provided, otherwise INFO will be used
.attribute(Triton.LOG_LEVEL, String.isNotBlank(componentLog.level) ? componentLog.level : TritonTypes.Level.INFO.name())
.attribute(Triton.DURATION, componentLog.duration)
.build());
Triton.makeBuilder()
//area will be fetched from the componentLog directly if set. Otherwise component name will be used
.area(String.isNotBlank(componentLog.area) ? componentLog.area : componentLog.component.name)
//apex name will be set to component.function or component.action
.attribute(
Triton.APEX_NAME,
componentLog.component.name + '.' +
(String.isNotBlank(componentLog.component.function) ?
componentLog.component.function :
componentLog.component.action
)
)
//created timestamp will be either set from the componentLog if provided, otherwise current timestamp will be used
.attribute(
Triton.CREATED_TIMESTAMP,
componentLog.createdTimestamp != null ?
Double.valueOf(componentLog.createdTimestamp) :
Double.valueOf(System.now().getTime())
)
.attribute(Triton.DURATION, componentLog.duration)
//log level will be taken from the componentLog if provided, otherwise INFO will be used
.attribute(
Triton.LOG_LEVEL,
String.isNotBlank(componentLog.level) ? componentLog.level : TritonTypes.Level.INFO.name()
)
.attribute(Triton.RELATED_ID, componentLog.recordId)
.attribute(Triton.USER_ID, componentLog.userId)
//category will be fetched from the componentLog
.category(String.isNotBlank(componentLog.category) ? componentLog.category : componentLog.component.category)
.details(componentLog.details)
.stackTrace(componentLog.stack)
//summary will be fetched from the componentLog directly if set. Otherwise, error message will be used if provided.
.summary(String.isNotBlank(componentLog.summary) ?
componentLog.summary :
componentLog.error != null ? componentLog.error.message : null
)
//transaction id will be used from the componentLog, or a new transaction id will be generated
.transactionId(String.isNotBlank(componentLog.transactionId) ?
componentLog.transactionId : logInstance.TRANSACTION_ID
)
//type will be fetched from the componentLog directly, of from the error. If neither are set, Frontend will be used
.type(String.isNotBlank(componentLog.type) ?
componentLog.type :
componentLog.error != null ? componentLog.error.type : TritonTypes.Type.Frontend.name()
)
.build()
);
}
logInstance.flush();
}
Expand Down
1 change: 0 additions & 1 deletion force-app/main/default/classes/TritonTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ private class TritonTest {
System.assert(log.pharos__Details__c.contains('failed to parse json input'), 'Additional fields parse error should be present');
}


public static final String TEST_ENDPOINT = 'https://test.endpoint';

public static Map<String, HttpCalloutMock> createEndpoint2TestResp() {
Expand Down
1 change: 1 addition & 0 deletions force-app/main/default/classes/TritonTypes.cls
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public with sharing class TritonTypes {
*/
public enum Category {
Apex,
Error,
Flow,
Warning,
Event,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Triton</label>
<protected>false</protected>
<values>
<field>Deactivate_Nebula__c</field>
<value xsi:type="xsd:boolean">false</value>
</values>
</CustomMetadata>