class IncomingEntryBuilder

Builds an {IncomingEntry} from a request/response pair plus the per-request collector payload. This is pure entry construction: no response mutation, no recording. The recorder owns lineage/header/tag concerns and hands the result here.

Traits

Constants

protected RAW_BODY_LIMIT

Methods

array
redact(array $data, array $keys)

Redact the values of the given keys throughout the data.

array
redactSensitiveStoragePayload(array $payload)

Final storage pass for entry payloads. Earlier builders redact known request surfaces, but this keeps persisted entries private if a future collector path adds sensitive data before save.

array
redactRecursive(array $data, array $loweredKeys)

Redact the values of the given lowercase keys at every depth.

array
redactHeaders(array $headers)

Flatten the given headers, redacting the sensitive ones and the sensitive query parameters of URL headers.

array
normalizeSensitiveKeys(array $keys)

Normalize the configured sensitive keys to unique lowercase strings.

array
redactUrls(array $data, array $keys)

Redact sensitive query parameters from the URLs in the data.

string
redactUrl(string $url, array $keys)

Redact the values of sensitive query parameters. A parameter matches when its decoded name or any of its bracketed segments (e.g. filter[secret]) is a sensitive key. The query is not parsed and rebuilt, so every other byte of the URL is kept as recorded, and relative or malformed URLs are redacted the same way.

array
sanitizeForJsonEncoding(array $data)

Replace leaf values that cannot be stored as JSON with a marker.

bool
isJsonEncodable(mixed $value)

Determine if the value can be stored as JSON.

__construct(SourceLocator $sourceLocator)

Create a new incoming entry builder instance.

build(Request $request, Response $response, string $id, string|null $batchId, bool $isPrefetch)

Build the entry for the given request and response.

void
mergeCollectorPayload(IncomingEntry $entry, Request $request)

Merge the collector payload recorded while rendering into the entry.

array
redactPropValues(array $propValues)

Redact the recorded prop values.

string|null
stringValue(array $payload, string $key)

Get the given payload value when it is a string.

array|null
arrayValue(array $payload, string $key)

Get the given payload value when it is an array.

array|null
routePayload(array $payload)

Get the normalized route from the collector payload.

array|null
renderSourcePayload(array $payload)

Get the normalized render source from the collector payload.

RequestType
resolveRequestType(Request $request, Response $response, bool|null $isPrefetch = null)

Resolve the kind of request the entry records.

bool
renderedInertiaPage(Request $request)

A non-Inertia request that rendered an Inertia page (component present in the collector payload) is the app's initial page load. One that rendered no Inertia page is a plain HTTP request the app serves alongside Inertia.

string|null
resolveRedirectLocation(Response $response)

Resolve the location the response redirects to.

array
captureRequestBody(Request $request)

Capture the request body.

array
captureResponseBody(Request $request, Response $response)

Capture the response body.

array
captureInertiaResponseBody(mixed $responseBody)

Capture the page object of an Inertia response.

array
normalizeResponseBody(array $responseBody)

Cast the page object to the JSON the client received. Resolved props still hold live values here (a model, a date, the always-shared errors object), and the storage pass would replace those object leaves with a marker.

array
captureRawResponseBody(Response $response)

Capture the body of a non-Inertia response (plain JSON/text endpoints the app serves alongside Inertia). Binary, streamed, and oversized bodies are omitted.

bool
isTextualContentType(string $contentType)

Determine if the content type is textual.

array
captureBodyValue(mixed $value)

Capture the given body value when it can be encoded.

bool
isEncodable(mixed $value)

Confirm a value survives JSON encoding with the flags the repository persists it with. An un-encodable value would otherwise throw at save and drop the entry.

array
sanitizeForJson(array $data)

Replace individual leaf values that cannot be JSON encoded with a marker, keeping the surrounding structure intact. Prop values are shared verbatim by the app, so a single non-UTF-8 attribute must not fail the whole entry at save.

array
captureBodyString(string|null $body)

Capture the given body string when it is valid UTF-8.

array
summarizeUploads(array $input)

Replace uploaded files with a lightweight summary so binary contents are never serialized into an entry.

array
summarizeUpload(UploadedFile $file)

Summarize the given uploaded file.

array|null
renderSourceFromRoute(Request $request)

Resolve the render source for route-defined renders (Route::inertia), which have no user-space render call site. The definition location is captured onto the route defaults by the Route::inertia() macro when the route is registered.

bool
routeIsEmpty(array $route)

Determine if the route carries no information.

array|null
routeFromRequest(Request $request)

Get the normalized route from the request.

float
elapsedMs(Request $request)

Get the milliseconds elapsed since the request started.

array
redactKeys()

Get the keys whose values are redacted.

Details

protected array redact(array $data, array $keys)

Redact the values of the given keys throughout the data.

Parameters

array $data
array $keys

Return Value

array

protected array redactSensitiveStoragePayload(array $payload)

Final storage pass for entry payloads. Earlier builders redact known request surfaces, but this keeps persisted entries private if a future collector path adds sensitive data before save.

Parameters

array $payload

Return Value

array

protected array redactRecursive(array $data, array $loweredKeys)

Redact the values of the given lowercase keys at every depth.

Parameters

array $data
array $loweredKeys

Return Value

array

in RedactsSensitiveData at line 101
protected array redactHeaders(array $headers)

Flatten the given headers, redacting the sensitive ones and the sensitive query parameters of URL headers.

Parameters

array $headers

Return Value

array

in RedactsSensitiveData at line 127
protected array normalizeSensitiveKeys(array $keys)

Normalize the configured sensitive keys to unique lowercase strings.

Parameters

array $keys

Return Value

array

in RedactsSensitiveData at line 149
protected array redactUrls(array $data, array $keys)

Redact sensitive query parameters from the URLs in the data.

Parameters

array $data
array $keys

Return Value

array

in RedactsSensitiveData at line 181
protected string redactUrl(string $url, array $keys)

Redact the values of sensitive query parameters. A parameter matches when its decoded name or any of its bracketed segments (e.g. filter[secret]) is a sensitive key. The query is not parsed and rebuilt, so every other byte of the URL is kept as recorded, and relative or malformed URLs are redacted the same way.

Parameters

string $url
array $keys

Return Value

string

in RedactsSensitiveData at line 210
protected array sanitizeForJsonEncoding(array $data)

Replace leaf values that cannot be stored as JSON with a marker.

Parameters

array $data

Return Value

array

in RedactsSensitiveData at line 226
protected bool isJsonEncodable(mixed $value)

Determine if the value can be stored as JSON.

Parameters

mixed $value

Return Value

bool

at line 28
__construct(SourceLocator $sourceLocator)

Create a new incoming entry builder instance.

Parameters

SourceLocator $sourceLocator

at line 35
IncomingEntry build(Request $request, Response $response, string $id, string|null $batchId, bool $isPrefetch)

Build the entry for the given request and response.

Parameters

Request $request
Response $response
string $id
string|null $batchId
bool $isPrefetch

Return Value

IncomingEntry

at line 71
protected void mergeCollectorPayload(IncomingEntry $entry, Request $request)

Merge the collector payload recorded while rendering into the entry.

Parameters

IncomingEntry $entry
Request $request

Return Value

void

at line 102
protected array redactPropValues(array $propValues)

Redact the recorded prop values.

Nested props are recorded under their dotted path, so a value is redacted when any segment of its path is a sensitive key.

Parameters

array $propValues

Return Value

array

at line 121
protected string|null stringValue(array $payload, string $key)

Get the given payload value when it is a string.

Parameters

array $payload
string $key

Return Value

string|null

at line 134
protected array|null arrayValue(array $payload, string $key)

Get the given payload value when it is an array.

Parameters

array $payload
string $key

Return Value

array|null

at line 147
protected array|null routePayload(array $payload)

Get the normalized route from the collector payload.

Parameters

array $payload

Return Value

array|null

at line 179
protected array|null renderSourcePayload(array $payload)

Get the normalized render source from the collector payload.

Parameters

array $payload

Return Value

array|null

at line 196
protected RequestType resolveRequestType(Request $request, Response $response, bool|null $isPrefetch = null)

Resolve the kind of request the entry records.

Parameters

Request $request
Response $response
bool|null $isPrefetch

Return Value

RequestType

at line 232
protected bool renderedInertiaPage(Request $request)

A non-Inertia request that rendered an Inertia page (component present in the collector payload) is the app's initial page load. One that rendered no Inertia page is a plain HTTP request the app serves alongside Inertia.

Parameters

Request $request

Return Value

bool

at line 245
protected string|null resolveRedirectLocation(Response $response)

Resolve the location the response redirects to.

Parameters

Response $response

Return Value

string|null

at line 269
protected array captureRequestBody(Request $request)

Capture the request body.

Parameters

Request $request

Return Value

array

at line 299
protected array captureResponseBody(Request $request, Response $response)

Capture the response body.

Parameters

Request $request
Response $response

Return Value

array

at line 315
protected array captureInertiaResponseBody(mixed $responseBody)

Capture the page object of an Inertia response.

Parameters

mixed $responseBody

Return Value

array

at line 340
protected array normalizeResponseBody(array $responseBody)

Cast the page object to the JSON the client received. Resolved props still hold live values here (a model, a date, the always-shared errors object), and the storage pass would replace those object leaves with a marker.

Parameters

array $responseBody

Return Value

array

at line 359
protected array captureRawResponseBody(Response $response)

Capture the body of a non-Inertia response (plain JSON/text endpoints the app serves alongside Inertia). Binary, streamed, and oversized bodies are omitted.

Parameters

Response $response

Return Value

array

at line 395
protected bool isTextualContentType(string $contentType)

Determine if the content type is textual.

Parameters

string $contentType

Return Value

bool

at line 411
protected array captureBodyValue(mixed $value)

Capture the given body value when it can be encoded.

Parameters

mixed $value

Return Value

array

at line 424
protected bool isEncodable(mixed $value)

Confirm a value survives JSON encoding with the flags the repository persists it with. An un-encodable value would otherwise throw at save and drop the entry.

Parameters

mixed $value

Return Value

bool

at line 437
protected array sanitizeForJson(array $data)

Replace individual leaf values that cannot be JSON encoded with a marker, keeping the surrounding structure intact. Prop values are shared verbatim by the app, so a single non-UTF-8 attribute must not fail the whole entry at save.

Parameters

array $data

Return Value

array

at line 455
protected array captureBodyString(string|null $body)

Capture the given body string when it is valid UTF-8.

Parameters

string|null $body

Return Value

array

at line 475
protected array summarizeUploads(array $input)

Replace uploaded files with a lightweight summary so binary contents are never serialized into an entry.

Parameters

array $input

Return Value

array

at line 493
protected array summarizeUpload(UploadedFile $file)

Summarize the given uploaded file.

Parameters

UploadedFile $file

Return Value

array

at line 509
protected array|null renderSourceFromRoute(Request $request)

Resolve the render source for route-defined renders (Route::inertia), which have no user-space render call site. The definition location is captured onto the route defaults by the Route::inertia() macro when the route is registered.

Parameters

Request $request

Return Value

array|null

at line 525
protected bool routeIsEmpty(array $route)

Determine if the route carries no information.

Parameters

array $route

Return Value

bool

at line 538
protected array|null routeFromRequest(Request $request)

Get the normalized route from the request.

Parameters

Request $request

Return Value

array|null

at line 567
protected float elapsedMs(Request $request)

Get the milliseconds elapsed since the request started.

Parameters

Request $request

Return Value

float

at line 583
protected array redactKeys()

Get the keys whose values are redacted.

Return Value

array