The label for the group. Used for deduplication and display.
If true, creates a collapsed group (default: true).
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);
}
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.