Migrating from 1.x
Move your Apex from the Triton 1.x singleton to the 2.0 static, builder-first API — the method-by-method mapping and the one behavioral gotcha to audit.
Triton 2.0 is a breaking release, but the migration is mostly mechanical: the concepts you already know all carry over, they just wear different clothes. This page is the one place we talk about "1.x vs 2.0" — everywhere else in the docs, 2.0 is simply Triton. Read this once, run the find-and-replace, audit the one behavioral change that actually bites, and you're done.
The one idea that changed
In 1.x, you logged through a singleton: Triton.instance. That instance held the shared state of your transaction — the buffer, the transaction id, your template — so everything you logged accumulated in one place.
In 2.0, there's no instance. You call the Triton class directly, and you describe each log with a builder:
// 1.x
Triton.instance.error(TritonTypes.Area.Accounts, e);
// 2.0
Triton.error(Triton.t.area(TritonTypes.Area.Accounts).exception(e));Here's the reassuring part: all that shared state didn't go anywhere. The buffer, the transaction id, and the template are still shared for the life of the Apex transaction — they just live as static members on the Triton class now instead of on a singleton instance. Apex statics last exactly one transaction, so you get the same "one logger, shared context" guarantee the singleton gave you, with nothing to fetch and nothing to pass around. When the transaction ends, the statics reset — no bleed between transactions.
So the shift is really two moves you'll make on every call:
Drop
.instance— callTritonstatically.Move the log's details onto a builder —
Triton.t(a fresh clone of your template) orTriton.makeBuilder()(a plain builder, pre-set to theApexcategory), then chain.area(...),.summary(...),.exception(...), and friends.
Triton.tis shorthand forTriton.fromTemplate(). Each call hands back a fresh clone of your template with the current transaction id already stamped on it.
Method mapping
Most 1.x calls map cleanly onto a 2.0 builder expression. The pattern is always the same: pick the level method, build from Triton.t, and move the old positional arguments onto builder methods.
Triton.instance.error(area, e)
Triton.logNow(Triton.t.area(area).exception(e))
Triton.instance.addError(area, e)
Triton.error(Triton.t.area(area).exception(e))
Triton.instance.error(area, e, relatedObjectIds)
Triton.logNow(Triton.t.area(area).exception(e).relatedObjects(relatedObjectIds))
Triton.instance.addError(area, e, relatedObjectIds)
Triton.error(Triton.t.area(area).exception(e).relatedObjects(relatedObjectIds))
Triton.instance.error(type, area, summary, details)
Triton.logNow(Triton.t.type(type).area(area).summary(summary).details(details).error())
Triton.instance.addError(type, area, summary, details)
Triton.error(Triton.t.type(type).area(area).summary(summary).details(details))
Triton.instance.warning(type, area, summary, details)
Triton.logNow(Triton.t.type(type).area(area).summary(summary).details(details).warning())
Triton.instance.addWarning(type, area, summary, details)
Triton.warning(Triton.t.type(type).area(area).summary(summary).details(details))
Triton.instance.debug(type, area, summary, details)
Triton.logNow(Triton.t.type(type).area(area).summary(summary).details(details).debug())
Triton.instance.addDebug(type, area, summary, details)
Triton.debug(Triton.t.type(type).area(area).summary(summary).details(details))
Triton.instance.debug(type, area, summary, details, duration)
Triton.logNow(Triton.t.type(type).area(area).summary(summary).details(details).duration(duration).debug())
Triton.instance.addDebug(type, area, summary, details, duration)
Triton.debug(Triton.t.type(type).area(area).summary(summary).details(details).duration(duration))
Triton.instance.event(level, type, area, summary, details)
Triton.logNow(Triton.t.type(type).area(area).summary(summary).details(details).level(level))
Triton.instance.addEvent(level, type, area, summary, details)
Triton.log(Triton.t.type(type).area(area).summary(summary).details(details).level(level))
Triton.instance.event(type, area, summary, details)
Triton.logNow(Triton.t.type(type).area(area).summary(summary).details(details).info())
Triton.instance.addEvent(type, area, summary, details)
Triton.info(Triton.t.type(type).area(area).summary(summary).details(details))
Triton.instance.dmlResult(area, results)
Triton.logNow(Triton.t.area(area).dmlResults(results))
Triton.instance.addDMLResult(area, results)
Triton.error(Triton.t.area(area).dmlResults(results))
Triton.instance.integrationError(area, e, request, response)
Triton.logNow(Triton.t.area(area).exception(e).integrationPayload(request, response))
Triton.instance.addIntegrationError(area, e, request, response)
Triton.error(Triton.t.area(area).exception(e).integrationPayload(request, response))
Triton.instance.integrationError(type, area, summary, details, request, response)
Triton.logNow(Triton.t.type(type).area(area).summary(summary).details(details).integrationPayload(request, response).error())
Triton.instance.addIntegrationError(type, area, summary, details, request, response)
Triton.error(Triton.t.type(type).area(area).summary(summary).details(details).integrationPayload(request, response))
Triton.instance.log(builder)
Triton.logNow(builder) — 1.x log published immediately
Triton.instance.addLog(builder)
Triton.log(builder)
Triton.instance.setTemplate(builder)
Triton.setTemplate(builder)
Triton.instance.fromTemplate()
Triton.fromTemplate() (or just Triton.t)
Triton.instance.flush()
Triton.flush()
Triton.instance.flushTop()
Triton.flushTop()
Triton.instance.withCache()
Triton.withCache() — returns void in 2.0, so split any call chained off it
Triton.instance.TRANSACTION_ID
Triton.TRANSACTION_ID
Triton.instance.logs
Triton.logs (test assertions only)
Triton.instance.startTransaction()
Triton.startTransaction()
Triton.instance.resumeTransaction(id)
Triton.resumeTransaction(id)
Triton.instance.stopTransaction()
Triton.stopTransaction()
A few rows deserve a note:
Http and REST payloads share one mapping. Each 1.x integration-error overload exists twice, once taking
HttpRequest/HttpResponseand once takingRestRequest/RestResponse.integrationPayload(...)accepts either pair, so the rewrite is the same.The six-argument
integrationErrorflushed everything. In 1.x it published the whole buffer, not just its own log.Triton.logNow(...)publishes only that log, so add aTriton.flush()after it if you relied on the rest going out too.The DML rows are correct as written. Like 1.x,
dmlResults(...)emits nothing when every row succeeded — whichever method you pass it to — so the rewrite needs no failure check around it.Match the overload, not just the name. Most 1.x logging methods are overloaded, and the overloads map differently. If a call's exact shape isn't in this table, map it by hand from the 1.x method body rather than guessing from the name.
The transaction and template methods are the easy ones — same names, just without .instance. The logging methods are where the shape changes, and where the one real gotcha lives.
The event rows deserve a word: event/addEvent map to a Level, not a category. In 1.x they stamped an Event category on the log; in 2.0 that category is gone, so the mapping simply omits .category(...) and lets the builder's Apex default apply — these are Apex APIs, so categorize by the call site, and set .category(...) only when that call site genuinely bridges another technology. The level follows the overload: the forms that took a level keep it via .level(level), the four-argument forms (no level) become INFO, and the bare event published immediately, so it goes to Triton.logNow(...) like the other bare methods. The same goes for any legacy severity-shaped categorization: a "debug" log is a DEBUG-Level log (Triton.debug(...)), a "warning" is Triton.warning(...) — the addWarning/addDebug rows above already land there.
Post-processing isn't carried across. The 1.x warning, debug, and event methods asked Pharos for a narrower post-processing set — stack trace, user info, and related objects. 2.0 sets no post-processing controls on Apex logs, so they get the Pharos defaults. To keep the narrower set on a rewritten call, append .postProcessing(Triton.makePostProcessingBuilder().stackTrace(true).userInfo(true).relatedObjects(true)).
The behavioral change to audit for
This is the part that can quietly change what your code does, so read it carefully.
In 1.x, the method name decided when the log published:
Bare methods —
error(...),warning(...),debug(...),event(...),dmlResult(...),integrationError(...), andlog(...)— published immediately.add*methods —addError(...),addWarning(...),addDebug(...)— buffered, waiting for aflush().
In 2.0, the level methods all buffer. Triton.error(...), Triton.warning(...), Triton.info(...), and the rest add to the buffer and wait for a flush. You opt into immediate publishing explicitly with Triton.logNow(...).
That inversion is why the mapping table sends the old bare methods (error, warning, …) to Triton.logNow(...) and the old add* methods to the level methods (Triton.error, …).
The flip side is a nice win: buffering is now the default, so routine progress logs batch up cheaply and you only pay the platform-event cost when you deliberately flush. See Buffering, Flushing & Deferred Publishing for the full model.
If you vendor Triton as source
If the Triton*.cls files live in your repository rather than arriving as a package, upgrading the library is part of the migration: 2.0 removes Triton.instance, so the library and every caller have to land together. Settle three things first:
Keep your org-local enum values. Diff your
TritonTypesagainst the 2.0 one and re-add any values you'd added; a wholesale copy drops them, and every reference stops compiling. Going forward, keep new values in your ownStringconstants (see Use real enum values).Migrate the branch that holds every caller. In a repository with a promotion pipeline, the integration branch can be well ahead of the default branch.
Keep Jest tests out of deploys. Add
**/__tests__/**and**/__mocks__/**to your project's.forceignore. Triton's own repository ignores them, but a.forceignoreonly governs its own project.
Prefer .exception(e) over hand-set fields
In 1.x it was common to spell out an error's type, summary, and stack trace by hand. In 2.0, let the builder do it. .exception(e) pulls the type from the exception (falling back to Backend), sets the level to ERROR, copies the message into the summary, captures the stack trace and details, and flags the log for issue creation — all in one call:
While you're migrating, this is a good moment to collapse those hand-built error logs down to .exception(e). Fewer lines, and you pick up issue-creation flagging for free. Same idea for bulk DML: reach for .dmlResults(results) instead of assembling failure summaries yourself.
Use real enum values
Migrating is a good time to make sure every Category, Type, and Area you pass is an actual TritonTypes enum value rather than an ad-hoc string that drifted in over time. Consistent values are the whole point of the taxonomy — filters and dashboards only line up when everyone uses the same names.
The shipped TritonTypes.Area values are:
OpportunityManagement · LeadConversion · Community · RestAPI · Accounts · LWC · Flow
So use the real thing:
Area and Type are meant to grow with your org — but don't extend the shipped enums to do it. If you were passing ad-hoc strings like 'InvoiceSync', promote them to public static final String constants in your own classes and pass those; editing TritonTypes.cls gets clobbered on every Triton upgrade. See Custom Classifications for the upgrade-safe pattern, and Enums for the built-in value sets.
LWC changes to check
The method mapping and the migrate-to-2.0 skill cover Apex only. Check your LWCs, Flow XML, and Log_Level__mdt rules by hand:
Removed
CATEGORYkeys.CATEGORY.WARNING,.DEBUG, and.EVENTare gone and evaluate toundefined. The log still lands — re-categorized toLWC, with a note in Details — but express severity through the log level instead.Area values. The
AREAconstants now hold the Apex names (AREA.ACCOUNTSis'Accounts', not'ACCOUNTS'). Code that compares area strings needs updating; code that only passes the constants to.area(...)doesn't. Custom area strings are now kept as sent rather than recorded asLWC.logNow()andflush()no longer reject. A failed flush keeps its logs for the next one, so a.catch(...)on these calls never runs. Keep your own error handling on your own code path.exception(error)setsERRORon any builder, so those logs now open an issue. Chain.level(...)after it if a caught error isn't worth one.Profiling records log at
FINEand below (failures atERROR). ALog_Level__mdtrule atINFOor stricter for LWC logs now drops the backend-call, interaction, and mark spans it used to keep atINFO.Flow Log actions and
Log_Level__mdtrules that name a removed category — see the warnings under Use real enum values, and theLog_Level__mdtitem in the 2.0 upgrade notes.
Migration checklist
Replace
Triton.instance.<method>(...)with the static, builder-first equivalents from the mapping table above.Audit old bare methods (
error,warning,debug, …) that relied on immediate publishing — send them toTriton.logNow(...)or ensure aflush()covers them.Confirm
flush()coverage. Now that level methods buffer, make sure every code path that logs also flushes — end of a trigger handler, end of a batchexecute, infinallyblocks.Collapse hand-built error logs to
.exception(e), and bulk-DML logs to.dmlResults(...).Set a template early with
Triton.setTemplate(...)and log fromTriton.t, so shared fields like category and area stop repeating.Swap ad-hoc strings for stable values — the built-in
TritonTypesenums where they fit, and your ownString-constant classes (see Custom Classifications) for org-specific Type/Area values. Don't edit the shipped enums.Re-assign the permission sets (
Triton_Read/Triton_Write) after deploying so the new fields are visible — see the 2.0 release notes.Check LWCs, Flows, and
Log_Level__mdtrules by hand — see LWC changes to check.
Once you're through the list, delete this page from your mental model: everything else in the docs is written for 2.0, and 2.0 is just Triton now. Start with Core Concepts.
Last updated