diff --git a/src/backend/common/AbstractComponent.ts b/src/backend/common/AbstractComponent.ts index b074f758..c880feea 100644 --- a/src/backend/common/AbstractComponent.ts +++ b/src/backend/common/AbstractComponent.ts @@ -338,7 +338,7 @@ export default abstract class AbstractComponent extends AbstractInitializable { } } steps.forEach((s, index) => { - const existingStepIndex = transformedPlay.meta.lifecycle.steps.findIndex(x => x.name === 'hookType' && x.source === this.getIdentifier()); + const existingStepIndex = transformedPlay.meta.lifecycle.steps.findIndex(x => x.stageName === s.stageName && x.stageType && s.stageType && x.hook === s.hook && x.source === this.getIdentifier()); if(existingStepIndex !== -1) { transformedPlay.meta.lifecycle.steps[existingStepIndex] = s; } else { @@ -347,10 +347,10 @@ export default abstract class AbstractComponent extends AbstractInitializable { if(shouldLog === 'all') { if(s.patch === undefined) { - historyToDiff.push({name: `${s.source}-${s.name}`}); + historyToDiff.push({name: `${s.source}-${s.hook}-${s.stageType}-${s.stageName}`}); } else { const patched = patchObject(historyToDiff[historyToDiff.length - 1].data, s.patch); - historyToDiff.push({name: `${s.source}-${s.name}${s.cached ? ' (Cached)' : ''}`, data: patched}); + historyToDiff.push({name: `${s.source}-${s.hook}-${s.stageType}-${s.stageName} ${s.cached ? ' (Cached)' : ''}`, data: patched}); } } }); @@ -413,9 +413,11 @@ export default abstract class AbstractComponent extends AbstractInitializable { } = opts; const stepName = `${hookType} - ${hookItem.type} - ${hookItem.name}` - const existingStepIndex = playTruth.meta.lifecycle.steps.findIndex(x => x.name === stepName && x.source === this.getIdentifier()); + const existingStepIndex = playTruth.meta.lifecycle.steps.findIndex(x => x.hook === hookType && hookItem.name === x.stageName && x.stageType === hookItem.type && x.source === this.getIdentifier()); const step: LifecycleStep = existingStepIndex !== -1 && playTruth.meta.lifecycle.steps[existingStepIndex] !== undefined ? playTruth.meta.lifecycle.steps[existingStepIndex] : { - name: stepName, + stageName: hookItem.name, + hook: hookType, + stageType: hookItem.type, source: this.getIdentifier(), createdAt: dayjs().toString() } @@ -433,6 +435,8 @@ export default abstract class AbstractComponent extends AbstractInitializable { } } + step.stageName = stageName; + if (err !== undefined) { const merged = mergeSimpleError(err); step.error = merged; diff --git a/src/core/Atomic.ts b/src/core/Atomic.ts index 4d612229..50e241e3 100644 --- a/src/core/Atomic.ts +++ b/src/core/Atomic.ts @@ -5,7 +5,7 @@ import { AdditionalTrackInfoResponse } from "../backend/common/vendor/listenbrai import { MarkOptional } from "ts-essentials"; import { ErrorObject } from "serialize-error"; import { PlayPlatformIdStr } from "../backend/common/infrastructure/Atomic.js"; -import { FlowControlTerm } from "../backend/common/infrastructure/Transform.js"; +import { FlowControlTerm, TransformHook } from "../backend/common/infrastructure/Transform.js"; import { Changeset } from "json-diff-ts"; export interface SourceStatusData { @@ -319,7 +319,9 @@ export interface PlayLifecycle { } export interface LifecycleStep { - name: string + stageName: string + stageType: string + hook: TransformHook source: string cached?: boolean returnPartial?: boolean diff --git a/src/core/tests/utils/fixtures.ts b/src/core/tests/utils/fixtures.ts index fea80656..e06ba679 100644 --- a/src/core/tests/utils/fixtures.ts +++ b/src/core/tests/utils/fixtures.ts @@ -11,6 +11,7 @@ import { UpstreamError } from '../../../backend/common/errors/UpstreamError.js'; import { playToListenPayload } from '../../../backend/common/vendor/listenbrainz/lzUtils.js'; import { mergeSimpleError, SimpleError, SkipTransformStageError, StagePrerequisiteError } from '../../../backend/common/errors/MSErrors.js'; import dayjs, { Dayjs } from 'dayjs'; +import { TransformHook } from '../../../backend/common/infrastructure/Transform.js'; export interface ScrobbleMatchOptions { match?: boolean @@ -172,7 +173,9 @@ export const generateLifecycleStep = (play: PlayObject, opts: GenerateLifecycleO const inputs = faker.helpers.multiple(() => generateLifecycleInput(), { count: inputCount ?? { min: 0, max: 2 } }); const step: LifecycleStep = { - name, + hook: name as TransformHook, + stageType: faker.helpers.arrayElement(['musicbrainz','native','user']), + stageName: faker.word.noun({length: {min: 1, max: 3}}), source, flowResult: 'continue', inputs,