@sentry/remix
Version:
Official Sentry SDK for Remix
33 lines (30 loc) • 1.17 kB
JavaScript
import { REMIX_ACTION_FORM_DATA_KEY_BASE } from '@sentry/conventions/attributes';
import { _INTERNAL_filterKeyValueData } from '@sentry/core';
function resolveFormDataCapture(client) {
if (!client) {
return void 0;
}
const keys = client.getOptions().captureActionFormDataKeys;
if (keys) {
return { keys };
}
return client.getDataCollectionOptions().httpBodies.includes("incomingRequest") ? { keys: void 0 } : void 0;
}
function applyFormDataAttributes(span, formData, { keys }) {
const collected = {};
formData.forEach((value, key) => {
const mapped = keys ? keys[key] : true;
if (!mapped) {
return;
}
const attributeName = typeof mapped === "string" ? mapped : key;
const reported = typeof value === "string" ? value : value.name || "[non-string value]";
const filtered = _INTERNAL_filterKeyValueData({ [key]: reported }, true);
collected[attributeName] = filtered[key];
});
for (const [key, value] of Object.entries(collected)) {
span.setAttribute(`${REMIX_ACTION_FORM_DATA_KEY_BASE}.${key}`, value);
}
}
export { applyFormDataAttributes, resolveFormDataCapture };
//# sourceMappingURL=formData.js.map