Member Junction
    Preparing search index...

    Generic, abstract base class for any scenario where we want to use a Singleton pattern. This base class abstracts away the complexity of ensuring a truly global singleton instance across multiple code paths in a deployed application. It uses a Global Object Store to ensure that only one instance of the class exists in the application even if the class has code imported into multiple execution paths (which is not optimal, of course, but can occur in some situations).

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    Methods

    • Adds one entry to a session's buffer. For a session this process holds, the entry's serialized size counts against maxBytes, and an entry that would pass it is refused. When the session's buffered bytes pass SESSION_FLUSH_THRESHOLD_BYTES, a background save starts.

      Parameters

      • sessionId: string
      • source: "Client" | "Server"
      • contentKind:
            | "App"
            | "Errors"
            | "Health"
            | "Logs"
            | "Network"
            | "SQL"
            | "Spans"
            | "Telemetry"
            | "Timeline"
      • entry: Record<string, unknown>

      Returns void

    • Parameters

      Returns Promise<
          {
              archiveBytes: Uint8Array;
              bundleData: DiagnosticBundleData;
              manifest: Record<string, unknown>;
              scrubReport: {
                  credentialsScrubbedCount: number;
                  customPatternsAppliedCount: number;
                  sqlLiteralsNormalizedCount: number;
              };
              sha256: string;
          },
      >

    • Takes a session's unsaved chunks out of memory, compressed and numbered: first the chunks an earlier save could not write (with their sequence numbers), then the current buffers.

      Parameters

      • sessionId: string

      Returns {
          compressedData: Buffer;
          contentKind:
              | "App"
              | "Errors"
              | "Health"
              | "Logs"
              | "Network"
              | "SQL"
              | "Spans"
              | "Telemetry"
              | "Timeline";
          entryCount: number;
          firstEntryAt: Date;
          lastEntryAt: Date;
          sequence: number;
          serializedBytes: number;
          source: "Client"
          | "Server";
      }[]

      • compressedData: Buffer
      • contentKind:
            | "App"
            | "Errors"
            | "Health"
            | "Logs"
            | "Network"
            | "SQL"
            | "Spans"
            | "Telemetry"
            | "Timeline"
      • entryCount: number
      • firstEntryAt: Date
      • lastEntryAt: Date
      • sequence: number
      • serializedBytes: number

        Serialized bytes of the chunk's entries, as counted at append time.

      • source: "Client" | "Server"
    • The Global Object Store is a place to store global objects that need to be shared across the application. Depending on the execution environment, this could be the window object in a browser, or the global object in a node environment, or something else in other contexts. The key here is that in some cases static variables are not truly shared because it is possible that a given class might have copies of its code in multiple paths in a deployed application. This approach ensures that no matter how many code copies might exist, there is only one instance of the object in question by using the Global Object Store.

      Returns GlobalObjectStore

    • Starts the session manager. The capture hooks (log sink, SQL observer and, unless enableConsoleTap is false, the console tap) are installed later by SyncCaptureHooks, only while capture is enabled and a session is held.

      Parameters

      • Optionaloptions: { enableConsoleTap?: boolean; enablePolling?: boolean }

      Returns void

    • Wraps console.log, console.warn and console.error so direct console calls inside a session are captured. The wrappers are made once and reused: removing the tap puts back a method that still holds the wrapper, and a method that another library wrapped later keeps the wrapper, which records nothing until the tap is installed again.

      Returns void

    • Parameters

      • sessionId: string
      • source: "Client" | "Server"
      • contentKind:
            | "App"
            | "Errors"
            | "Health"
            | "Logs"
            | "Network"
            | "SQL"
            | "Spans"
            | "Telemetry"
            | "Timeline"

      Returns number

    • Installs the capture hooks while Diagnostics.Capture.Enabled is on and this process holds at least one session, and removes them otherwise. Without the hooks, logs, SQL and console output cost nothing extra. The expiry sweep runs while any session is held.

      Returns void

    • Returns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store. If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used. NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest level class name will be used.

      Type Parameters

      Parameters

      • this: new () => T
      • OptionalclassName: string

      Returns T