Implementation Patterns
Real-world implementation patterns for Triton logging across different Salesforce contexts including triggers, batches, queueables, and flows.
Where to Insert Logs
Triggers (Handler)
public with sharing class AccountTriggerHandler {
public static void beforeUpdate(List<Account> newList, Map<Id, Account> oldMap) {
Triton.instance.startTransaction();
Triton.instance.setTemplate(
Triton.makeBuilder()
.category(TritonTypes.Category.Apex)
.type(TritonTypes.Type.AccountTrigger)
.area(TritonTypes.Area.Accounts)
.createdTimestamp()
);
Set<Id> scopeIds = new Map<Id, Account>(newList).keySet();
Triton.instance.log(
Triton.instance.fromTemplate()
.level(TritonTypes.Level.INFO)
.summary('Account before update')
.details('count=' + scopeIds.size() + ', op=' + Trigger.operationType)
.relatedObjects(scopeIds)
);
}
}Queueable
Batchable
LWC β With @wire
@wireLWC β Imperative
Flow
Integration Patterns
REST API Controllers
Scheduled Jobs
Best Practices Summary
Last updated