Skip to content

Commit

Permalink
tracy: AJAX debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 2, 2024
1 parent e0cd017 commit 1580a59
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
33 changes: 30 additions & 3 deletions tracy/cs/recipes.texy
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,37 @@ Spuštění je přímočaré, pokud však máte na webové stránce pomalu nač
```


AJAX a přesměrování
===================
Ladění AJAXový požadavků
========================

Tracy umí zobrazit Debug bar a Bluescreeny pro AJAXové požadavky a přesměrovaní. Tracy si vytváří vlastní session, data uchovává ve vlastních dočasných souborech a používá cookie `tracy-session`.
Tracy automaticky zachycuje AJAXové požadavky vytvořené pomocí jQuery nebo nativního API `fetch`. Požadavky jsou v liště Tracy zobrazeny jako další řádky, což umožňuje snadné a pohodlné ladění AJAXu.

Pokud nechcete AJAXové požadavky zachycovat automaticky, můžete tuto funkci zakázat nastavením JavaScriptové proměnné:

```js
window.TracyAutoRefresh = false;
```

Pro ruční monitorování specifických AJAX požadavků můžete přidejte HTTP hlavičku `X-Tracy-Ajax` s hodnotou, kterou vrátí `Tracy.getAjaxHeader()`. Zde je příklad použití API `fetch`:

```js
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
'X-Tracy-Ajax': Tracy.getAjaxHeader(),
}
})
```

Tento přístup umožňuje selektivní ladění AJAX požadavků.


Datové úložiště
===============

Tracy umí zobrazit panely v Tracy baru a Bluescreeny pro AJAXové požadavky a přesměrovaní. Tracy si vytváří vlastní session, data uchovává ve vlastních dočasných souborech a používá cookie `tracy-session`.

Tracy lze nakonfigurovat také tak, aby používala nativní PHP session, kterou nastartujeme ještě před zapnutím Tracy:

Expand Down
33 changes: 30 additions & 3 deletions tracy/en/recipes.texy
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,37 @@ The solution is to place `<?php Tracy\Debugger::renderLoader() ?>` into your tem
```


AJAX and Redirected Requests
============================
Debugging AJAX Requests
=======================

Tracy automatically captures AJAX requests made using jQuery or the native `fetch` API. These requests are displayed as additional rows in the Tracy bar, enabling easy and convenient AJAX debugging.

If you do not want to capture AJAX requests automatically, you can disable this feature by setting the JavaScript variable:

```js
window.TracyAutoRefresh = false;
```

For manual monitoring of specific AJAX requests, add the HTTP header `X-Tracy-Ajax` with the value returned by `Tracy.getAjaxHeader()`. Here is an example of using the `fetch` API:

```js
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
'X-Tracy-Ajax': Tracy.getAjaxHeader(),
}
})
```

This approach allows for selective debugging of AJAX requests.


Data Storage
============

Tracy can display Debug bar and Bluescreens for AJAX requests and redirects. Tracy creates its own sessions, stores data in its own temporary files, and uses a `tracy-session` cookie.
Tracy can display Tracy bar panels and Bluescreens for AJAX requests and redirects. Tracy creates its own sessions, stores data in its own temporary files, and uses a `tracy-session` cookie.

Tracy can also be configured to use a native PHP session, which is started before Tracy is turned on:

Expand Down

0 comments on commit 1580a59

Please sign in to comment.