• Starts a new console group that will contain related log messages. Groups with the same label are automatically deduplicated rather than creating nested groups. Group state is tracked by LogCollector so group hierarchy is preserved in capture.

    Parameters

    • label: string

      The label for the group. Used for deduplication and display.

    • collapsed: boolean = true

      If true, creates a collapsed group (default: true).

    Returns void

    export function startGroup(label: string, collapsed = true): void {
    // If the current top group has the same label, increment its ref count and
    // don't call console.group again to avoid nested identical groups.
    const top = groupStack.at(-1);
    if (top?.label === label) {
    top.count++;
    return;
    }

    const entry: GroupEntry = {
    label,
    count: 1,
    opened: false,
    };
    try {
    if (collapsed) {
    console.groupCollapsed(label);
    } else {
    console.group(label);
    }
    entry.opened = true;
    } catch {
    // ignore if console grouping isn't supported
    entry.opened = false;
    }

    groupStack.push(entry);
    }