buggregator / frontend

Buggregator UI
https://buggregator.dev/
13 stars 8 forks source link

Implement Variable Labels from Var-Dumper Context in Frontend UI #154

Closed butschster closed 1 month ago

butschster commented 1 month ago

Currently, when using the dump() function to output multiple variables, it's not immediately clear which dump corresponds to which variable if no labels are provided. This can be particularly confusing when debugging complex data structures or when multiple dumps are present on the same page.

Feature Request: Enhance the frontend UI to display variable labels from the var-dumper context, making it easier to identify the relationship between the dumps and the variables.

Consider the scenario where two variables are dumped without explicit labels:

dump($foo, $bar);

In the current setup, $foo and $bar would be assigned default numeric labels such as 1 and 2. The corresponding JSON payload might look like this:

{
  "uuid": "018ff255-37b1-7146-a984-53528d523f70",
  "project": null,
  "type": "var-dump",
  "payload": {
    "context": {...},
    "payload": {
      "label": "2",
      "type": "string",
      "value": "Here is a random phrase"
    }
  },
  "timestamp": 1717757622.194
}

However, if named labels are used:

dump(label1: $foo, label2: $bar);

The JSON payload should reflect these labels, aiding in clearer debugging:

{
  "uuid": "018ff255-37b1-7146-a984-53528d523f70",
  "project": null,
  "type": "var-dump",
  "payload": {
    "context": {...},
    "payload": {
      "label": "label2",
      "type": "string",
      "value": "Here is a random phrase"
    }
  },
  "timestamp": 1717757622.194
}

It would be great to put a label in a dump event

image

Benefits: Improves clarity and traceability of variable dumps.

roxblnfk commented 1 month ago

Looks solved