From bd1aefa87333971dbb4929ab98f512639e75aeaa Mon Sep 17 00:00:00 2001 From: uid11 Date: Wed, 27 May 2026 00:01:56 +0300 Subject: [PATCH] PRO-18147 fix: map additional payload in `step` via `mapLogPayloadInReport` --- src/step.ts | 4 ++-- src/utils/step/index.ts | 2 ++ src/utils/step/updateStepPayload.ts | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/utils/step/updateStepPayload.ts diff --git a/src/step.ts b/src/step.ts index 1d58094f..fa91de3d 100644 --- a/src/step.ts +++ b/src/step.ts @@ -4,7 +4,7 @@ import {setCustomInspectOnFunction} from './utils/fn'; import {generalLog} from './utils/generalLog'; import {logAndGetLogEvent} from './utils/log'; import {setReadonlyProperty} from './utils/object'; -import {processStepError, runStepBody} from './utils/step'; +import {processStepError, runStepBody, updateStepPayload} from './utils/step'; import type { LogEvent, @@ -87,7 +87,7 @@ export const step = async ( setReadonlyProperty(logEvent, 'endTime', endTime); if (payload !== undefined) { - setReadonlyProperty(logEvent, 'payload', {...logEvent.payload, ...payload}); + updateStepPayload(logEvent, payload); } generalLog(`Step "${name}" completed`, { diff --git a/src/utils/step/index.ts b/src/utils/step/index.ts index 8f0bce63..09b49786 100644 --- a/src/utils/step/index.ts +++ b/src/utils/step/index.ts @@ -4,3 +4,5 @@ export {getTopStep} from './getTopStep'; export {processStepError} from './processStepError'; /** @internal */ export {runStepBody} from './runStepBody'; +/** @internal */ +export {updateStepPayload} from './updateStepPayload'; diff --git a/src/utils/step/updateStepPayload.ts b/src/utils/step/updateStepPayload.ts new file mode 100644 index 00000000..fa7b6cc3 --- /dev/null +++ b/src/utils/step/updateStepPayload.ts @@ -0,0 +1,18 @@ +import {getFullPackConfig} from '../config'; +import {setReadonlyProperty} from '../object'; + +import type {LogEvent, LogPayload} from '../../types/internal'; + +/** + * Updates `step` log payload with the values returned by the step body. + * @internal + */ +export const updateStepPayload = (logEvent: LogEvent, additionalPayload: LogPayload): void => { + const {mapLogPayloadInReport} = getFullPackConfig(); + + const payloadInReport = mapLogPayloadInReport(logEvent.message, additionalPayload, logEvent.type); + + if (payloadInReport !== undefined && payloadInReport !== 'skipLog') { + setReadonlyProperty(logEvent, 'payload', {...logEvent.payload, ...payloadInReport}); + } +};