TritonLwc

Documentation for the TritonLwc Apex class that provides core logging functionality for Lightning Web Components.

Overview

The TritonLwc class provides the server-side implementation for Lightning Web Component logging. It handles the reception and processing of client-side logs, managing transaction context, and ensuring proper log persistence.

LWC Logging Methods

saveComponentLogs

@AuraEnabled
public static void saveComponentLogs(List<ComponentLog> componentLogs)

Creates logs from LWC components with automatic transaction management and context capture.

Field Mapping Reference

Core Fields

Builder Method
Component Source
Default
Description

category()

componentLog.category

LWC

Component classification

type()

componentLog.type/error.type

Frontend

Technical classification

area()

componentLog.area/componentInfo.name

LWC

Functional area

level()

componentLog.level

INFO

Log severity

summary()

componentLog.summary/error.message

-

Main log message

details()

componentLog.details + validation

-

Extended information

stackTrace()

componentLog.stack

-

Error stack trace

Context Fields

🔍 Component Context The system automatically captures rich component execution context:

{
  "operation": "componentName.functionName",
  "transactionId": "auto-generated or from component",
  "userId": "current user or specified",
  "createdTimestamp": "component time or server time",
  "duration": "execution time if provided"
}

🔗 Record Context The system supports linking logs to Salesforce records:

{
  "relatedObjects": ["recordId1", "recordId2"],
  "validationRules": "15 or 18 character IDs",
  "behavior": "Invalid IDs are filtered"
}

Automatic Behaviors

Smart Processing The system provides intelligent handling of log data:

  1. Transaction Management

    • Creates new transaction if none exists

    • Maintains transaction context across components

    • Correlates related logs

  2. Context Enrichment

    • Captures component hierarchy

    • Records runtime metrics

    • Preserves error context

  3. Data Validation

    • Validates all incoming fields

    • Provides sensible defaults

    • Maintains data integrity

Validation Rules

Required Field Validation

Field
Validation Rule
Default Behavior

Category

Must be valid enum

Falls back to LWC

Type

Must be valid enum

Falls back to Frontend

Area

Must be valid enum

Uses component name

Level

Must be valid enum

Falls back to INFO

ID Validation

📝 Record ID Processing The system validates record IDs by:

  1. Checking ID format (15 or 18 chars)

  2. Filtering invalid IDs

  3. Maintaining valid relationships

Error Handling

🛡️ Validation Strategy When validation issues occur:

  • Invalid values get appropriate defaults

  • Validation messages are added to details

  • Processing continues uninterrupted

Runtime Information

The system captures comprehensive runtime context:

Metric Type
Examples

Performance

Page load, DOM events, Paint times

Environment

User agent, Platform, Language

Network

Connection type, Speed, RTT

Memory

Heap usage, Limits

Device

Form factor, Screen dimensions

The TritonLwc class works with several wrapper classes:

Last updated