Pharos Triton
  • 🔱About Pharos Triton
  • 🏁Installing Pharos Triton
  • Apex Logging Basics
  • Common Apex Usage Patters
    • Batch Logging
    • Integration Logs
    • Apex Rest Logging
    • Full Control with TritonBuilder
  • Beyond Apex
    • LWC
    • 🔄LWC Transaction Management
    • ⚡LWC and Apex
    • 💾Platform Cache for Transactions
    • Flows
    • 〰️LWC, Apex and Flows
  • 📖Methods Reference
    • 📔Apex
      • Triton
      • TritonBuilder
      • TritonTypes
      • TritonLwc
        • ComponentLog
        • Component
        • Error
        • RuntimeInfo
      • TritonFlow
        • FlowLog
      • TritonHelper
        • PostProcessingControlsBuilder
      • LogBuilder
    • LWC
      • Triton
      • TritonBuilder
      • TritonUtils
  • Help and Support
Powered by GitBook
On this page
  • Overview
  • Stack Trace Analysis
  • isNotTriton(stackTraceLine)
  • isLWCLine(stackTraceLine)
  • isComponentLine(stackTraceLine)
  • isAuraLine(stackTraceLine)
  • isAura([stack])
  • Transaction Management
  • generateTransactionId()
  • Runtime Information
  • captureRuntimeInfo()
  • Component Identification
  • extractComponentName(componentLine)
  • generateComponentId()
  • Performance Metrics
  • Network Information
  • Device Information
  1. Methods Reference
  2. LWC

TritonUtils

Overview

The TritonUtils module provides utility functions for stack trace analysis, transaction management, and runtime information capture in the Triton logging framework.

Stack Trace Analysis

isNotTriton(stackTraceLine)

  • Description: Checks if a stack trace line is from internal Triton files

  • Parameters:

    • stackTraceLine: {string} Line from stack trace to check

  • Returns: {boolean} True if the line is NOT from internal Triton files

  • Example:

const isUserCode = isNotTriton('at MyComponent.handleClick (/components/c/myComponent.js:15:10)');

isLWCLine(stackTraceLine)

  • Description: Determines if a stack trace line is from an LWC component

  • Parameters:

    • stackTraceLine: {string} Line from stack trace to check

  • Returns: {boolean} True if the line is from an LWC component

  • Example:

const isLWC = isLWCLine('at MyComponent.handleClick (/modules/c/myComponent.js:15:10)');

isComponentLine(stackTraceLine)

  • Description: Checks if a stack trace line is from a component (LWC or Aura)

  • Parameters:

    • stackTraceLine: {string} Line from stack trace to check

  • Returns: {boolean} True if the line is from a component

  • Example:

const isComponent = isComponentLine('at MyComponent.handleClick (/modules/c/myComponent.js:15:10)');

isAuraLine(stackTraceLine)

  • Description: Determines if a stack trace line is from an Aura component

  • Parameters:

    • stackTraceLine: {string} Line from stack trace to check

  • Returns: {boolean} True if the line is from an Aura component

  • Example:

const isAura = isAuraLine('at MyComponent.handleClick (/components/c/myComponent.js:15:10)');

isAura([stack])

  • Description: Determines if a stack trace is from an Aura component

  • Parameters:

    • stack: {string} Optional stack trace to analyze. If not provided, gets current stack trace

  • Returns: {boolean} True if the stack trace contains Aura component references

  • Example:

const isAuraComponent = isAura(new Error().stack);

Transaction Management

generateTransactionId()

  • Description: Generates a UUID v4 (random UUID)

  • Returns: {string} The generated UUID in format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx

  • Example:

const transactionId = generateTransactionId(); // e.g. "550e8400-e29b-41d4-a716-446655440000"

Runtime Information

captureRuntimeInfo()

  • Description: Captures comprehensive runtime information about the current environment

  • Returns: {Object} Object containing:

    • Environment info (userAgent, language, platform)

    • Viewport dimensions

    • Theme settings

    • Performance metrics

    • Network info

    • Device info

  • Example:

const runtimeInfo = captureRuntimeInfo();
console.log(runtimeInfo.viewportWidth); // e.g. 1920
console.log(runtimeInfo.platform); // e.g. "Windows"

Component Identification

extractComponentName(componentLine)

  • Description: Extracts the component name from a stack trace line

  • Parameters:

    • componentLine: {string} Stack trace line containing component info

  • Returns: {string} Component name or 'unknown-component' if not found

  • Example:

const componentName = extractComponentName('at MyComponent.handleClick (/modules/c/myComponent.js:15:10)');
// Returns: "myComponent"

generateComponentId()

  • Description: Extracts the component identifier from the current stack trace

  • Returns: {string} Component identifier

  • Example:

const componentId = generateComponentId(); // Returns current component name

Performance Metrics

The runtime information capture includes detailed performance metrics:

{
    pageLoadTime: number,      // Total page load time
    domInteractive: number,    // Time to interactive
    domContentLoaded: number,  // DOM content loaded time
    firstByte: number,         // Time to first byte
    serverTime: number,        // Server processing time
    firstPaint: number,        // First paint timing
    firstContentfulPaint: number, // First contentful paint timing
    memoryUsage: number,       // JS heap size
    memoryLimit: number        // JS heap limit
}

Network Information

The runtime information capture includes network details:

{
    connectionType: string,    // e.g. "4g", "wifi"
    connectionSpeed: number,   // Download speed in Mbps
    connectionRtt: number,     // Round trip time
    saveData: boolean,         // Data saver enabled
    isOnline: boolean         // Online status
}

Device Information

The runtime information capture includes device details:

{
    formFactor: "SMALL" | "MEDIUM" | "LARGE",
    screenWidth: number,
    screenHeight: number,
    orientation: string,
    platform: string,
    userAgent: string
}
PreviousTritonBuilderNextHelp and Support

Last updated 2 months ago

📖