diff --git a/src/__snapshots__/Storyshots.test.js.snap b/src/__snapshots__/Storyshots.test.js.snap index 21fd613bbe..5f91f2f3ee 100644 --- a/src/__snapshots__/Storyshots.test.js.snap +++ b/src/__snapshots__/Storyshots.test.js.snap @@ -2976,7 +2976,7 @@ exports[`Storyshots Editor/LogTable No Entries 1`] = ` Label - Block/Service + Brick/Integration Message/Error @@ -3038,7 +3038,7 @@ exports[`Storyshots Editor/LogTable No Entries For Level 1`] = ` Label - Block/Service + Brick/Integration Message/Error @@ -3100,7 +3100,7 @@ exports[`Storyshots Editor/LogTable Populated 1`] = ` Label - Block/Service + Brick/Integration Message/Error diff --git a/src/background/removeModComponentForEveryTab.ts b/src/background/removeModComponentForEveryTab.ts index d8d5ff6334..e414a3b70b 100644 --- a/src/background/removeModComponentForEveryTab.ts +++ b/src/background/removeModComponentForEveryTab.ts @@ -39,5 +39,5 @@ export async function removeModComponentForEveryTab( }); await uninstallContextMenu({ extensionId: modComponentId }); await clearModComponentTraces(modComponentId); - await clearLog({ modComponentId: modComponentId }); + await clearLog({ modComponentId }); } diff --git a/src/bricks/effects/AddDynamicTextSnippet.test.ts b/src/bricks/effects/AddDynamicTextSnippet.test.ts index 380cc2c553..13f66c009c 100644 --- a/src/bricks/effects/AddDynamicTextSnippet.test.ts +++ b/src/bricks/effects/AddDynamicTextSnippet.test.ts @@ -81,8 +81,8 @@ describe("AddDynamicTextSnippet", () => { componentId: extensionId, context: { ...logger.context, - blockId: brick.id, - blockVersion: expect.toBeString(), + brickId: brick.id, + brickVersion: expect.toBeString(), label: brick.name, }, }, @@ -127,8 +127,8 @@ describe("AddDynamicTextSnippet", () => { componentId: extensionId, context: { ...logger.context, - blockId: brick.id, - blockVersion: expect.toBeString(), + brickId: brick.id, + brickVersion: expect.toBeString(), label: brick.name, }, }, diff --git a/src/bricks/effects/assignModVariable.test.ts b/src/bricks/effects/assignModVariable.test.ts index a11342c30c..778ce1b70a 100644 --- a/src/bricks/effects/assignModVariable.test.ts +++ b/src/bricks/effects/assignModVariable.test.ts @@ -35,8 +35,8 @@ const modId = validateRegistryId("test/123"); const brick = new AssignModVariable(); const logger = new ConsoleLogger({ - modComponentId: modComponentId, - modId: modId, + modComponentId, + modId, }); const brickOptions = brickOptionsFactory({ logger }); diff --git a/src/bricks/effects/assignModVariable.ts b/src/bricks/effects/assignModVariable.ts index 9d314b81a1..15a319a6e0 100644 --- a/src/bricks/effects/assignModVariable.ts +++ b/src/bricks/effects/assignModVariable.ts @@ -96,7 +96,7 @@ class AssignModVariable extends EffectABC { }>, { logger }: BrickOptions, ): Promise { - const { modId: modId, modComponentId: modComponentId } = logger.context; + const { modId, modComponentId } = logger.context; setState({ namespace: StateNamespaces.MOD, diff --git a/src/bricks/effects/pageState.ts b/src/bricks/effects/pageState.ts index 34312352c6..4990676ded 100644 --- a/src/bricks/effects/pageState.ts +++ b/src/bricks/effects/pageState.ts @@ -205,7 +205,7 @@ export class GetPageState extends TransformerABC { }: BrickArgs<{ namespace?: StateNamespace }>, { logger, platform }: BrickOptions, ): Promise { - const { modId: modId, modComponentId: modComponentId } = logger.context; + const { modId, modComponentId } = logger.context; return platform.state.getState({ namespace, diff --git a/src/bricks/effects/tourEffect.ts b/src/bricks/effects/tourEffect.ts index 40bdd57577..4a3b0b1816 100644 --- a/src/bricks/effects/tourEffect.ts +++ b/src/bricks/effects/tourEffect.ts @@ -166,7 +166,10 @@ export class TourEffect extends EffectABC { ); } - assertNotNullish(modComponentId, "extensionId is required to run a tour"); + assertNotNullish( + modComponentId, + "modComponentId is required to run a tour", + ); const tour = introJs() .setOptions({ diff --git a/src/bricks/renderers/customForm.tsx b/src/bricks/renderers/customForm.tsx index 4296793dfa..421e3e610b 100644 --- a/src/bricks/renderers/customForm.tsx +++ b/src/bricks/renderers/customForm.tsx @@ -285,7 +285,7 @@ export class CustomFormRenderer extends RendererABC { { logger, runPipeline, platform }: BrickOptions, ): Promise { if (logger.context.modComponentId == null) { - throw new Error("extensionId is required"); + throw new Error("modComponentId is required"); } // Redundant with the JSON Schema input validation for `required`. But keeping here for clarity diff --git a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts index f1a91a9564..526b7f6a11 100644 --- a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts +++ b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts @@ -352,10 +352,12 @@ describe("DisplayTemporaryInfo", () => { const options = { ...testOptions("v3"), logger: new ConsoleLogger( - modComponentRefFactory({ - extensionId, - blueprintId: null, - }), + mapModComponentRefToMessageContext( + modComponentRefFactory({ + extensionId, + blueprintId: null, + }), + ), ), }; diff --git a/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx b/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx index c8b26f8d40..453ccd8c35 100644 --- a/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx +++ b/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx @@ -35,6 +35,7 @@ import { type PanelButton } from "@/types/sidebarTypes"; import { ClosePanelAction } from "@/bricks/errors"; import styles from "./EphemeralPanel.module.scss"; import useReportError from "@/hooks/useReportError"; +import { mapModComponentRefToMessageContext } from "@/utils/modUtils"; type Mode = "modal" | "popover"; @@ -174,7 +175,9 @@ const EphemeralPanel: React.FC = () => { { resolveTemporaryPanel(target, panelNonce, action); }} @@ -216,7 +219,7 @@ const EphemeralPanel: React.FC = () => { { resolveTemporaryPanel(target, panelNonce, action); }} diff --git a/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx b/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx index dccafaab18..2babbb2aa9 100644 --- a/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx +++ b/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx @@ -177,12 +177,20 @@ function clearIntegrationSelection( const NO_AUTH_OPTIONS = freeze([]); +type SelectedEventPayload = { + integration_id?: RegistryId; + is_user_action?: boolean; + auth_label?: string; + auth_sharing_type?: string; + auth_is_local?: boolean; +}; + // The only reason these inputs are optional is for tests, need to investigate better mocking instead // @see BotOptions.test.ts const makeSelectedEventPayload = ( authOption?: AuthOption, isUserAction?: boolean, -) => { +): SelectedEventPayload => { if (!authOption) { return {}; } diff --git a/src/components/logViewer/__snapshots__/LogCard.test.tsx.snap b/src/components/logViewer/__snapshots__/LogCard.test.tsx.snap index 03b1d6bd29..afc73526c2 100644 --- a/src/components/logViewer/__snapshots__/LogCard.test.tsx.snap +++ b/src/components/logViewer/__snapshots__/LogCard.test.tsx.snap @@ -117,7 +117,7 @@ exports[`renders empty table 1`] = ` Label - Block/Service + Brick/Integration Message/Error diff --git a/src/mods/hooks/useDeactivateAction.ts b/src/mods/hooks/useDeactivateAction.ts index 1b2595b3b0..a7ef950487 100644 --- a/src/mods/hooks/useDeactivateAction.ts +++ b/src/mods/hooks/useDeactivateAction.ts @@ -62,7 +62,7 @@ function useDeactivateAction(modViewItem: ModViewItem): (() => void) | null { await deactivateMod(modId, modComponentsFromMod, dispatch); reportEvent(Events.MOD_REMOVE, { - blueprintId: modId, + modId, }); } else { await deactivateModComponents( @@ -72,7 +72,7 @@ function useDeactivateAction(modViewItem: ModViewItem): (() => void) | null { for (const modComponent of modComponentsFromMod) { reportEvent(Events.MOD_COMPONENT_REMOVE, { - extensionId: modComponent.id, + modComponentId: modComponent.id, }); } } diff --git a/src/pageEditor/hooks/useDeactivateMod.tsx b/src/pageEditor/hooks/useDeactivateMod.tsx index 2f990f4843..319d7dc375 100644 --- a/src/pageEditor/hooks/useDeactivateMod.tsx +++ b/src/pageEditor/hooks/useDeactivateMod.tsx @@ -69,7 +69,7 @@ function useDeactivateMod(): (useDeactivateConfig: Config) => Promise { ); void clearLog({ - modId: modId, + modId, }); dispatch(actions.removeModData(modId)); diff --git a/src/sidebar/Tabs.tsx b/src/sidebar/Tabs.tsx index 7dbcb257d8..0f1c7ec0f5 100644 --- a/src/sidebar/Tabs.tsx +++ b/src/sidebar/Tabs.tsx @@ -338,7 +338,9 @@ const Tabs: React.FC = () => { isRootPanel payload={panel.payload} onAction={permanentSidebarPanelAction} - context={panel.modComponentRef} + context={mapModComponentRefToMessageContext( + panel.modComponentRef, + )} /> diff --git a/src/sidebar/TemporaryPanelTabPane.tsx b/src/sidebar/TemporaryPanelTabPane.tsx index 4a1c14dedc..bb583be2d1 100644 --- a/src/sidebar/TemporaryPanelTabPane.tsx +++ b/src/sidebar/TemporaryPanelTabPane.tsx @@ -75,7 +75,7 @@ export const TemporaryPanelTabPane: React.FC<{ diff --git a/src/starterBricks/trigger/triggerStarterBrick.test.ts b/src/starterBricks/trigger/triggerStarterBrick.test.ts index daa3743b7f..ce683eb936 100644 --- a/src/starterBricks/trigger/triggerStarterBrick.test.ts +++ b/src/starterBricks/trigger/triggerStarterBrick.test.ts @@ -581,7 +581,7 @@ describe("triggerStarterBrick", () => { // Does not report successful event only once expect(reportEventMock).toHaveBeenCalledExactlyOnceWith("TriggerRun", { - extensionId: modComponent.id, + modComponentId: modComponent.id, }); // Reports an error once diff --git a/src/telemetry/logging.test.ts b/src/telemetry/logging.test.ts index d63e8601c9..7f191cd8f9 100644 --- a/src/telemetry/logging.test.ts +++ b/src/telemetry/logging.test.ts @@ -90,18 +90,18 @@ describe("logging", () => { await expect(count()).resolves.toBe(0); }); - test("clearLog by blueprint id", async () => { - const blueprintId = registryIdFactory(); + test("clearLog by mod id", async () => { + const modId = registryIdFactory(); await appendEntry( logEntryFactory({ - context: messageContextFactory({ modId: blueprintId }), + context: messageContextFactory({ modId }), }), ); await appendEntry(logEntryFactory()); - await clearLog({ modId: blueprintId }); + await clearLog({ modId }); await expect(count()).resolves.toBe(1); }); @@ -119,20 +119,20 @@ describe("logging", () => { // Increase timeout so test isn't flakey on CI due to slow append operation }, 20_000); - test("getLogEntries by blueprintId", async () => { - const blueprintId = registryIdFactory(); + test("getLogEntries by modId", async () => { + const modId = registryIdFactory(); await appendEntry( logEntryFactory({ - context: messageContextFactory({ modId: blueprintId }), + context: messageContextFactory({ modId }), }), ); await appendEntry(logEntryFactory()); - await expect(getLogEntries({ modId: blueprintId })).resolves.toStrictEqual([ + await expect(getLogEntries({ modId })).resolves.toStrictEqual([ expect.objectContaining({ - context: expect.objectContaining({ blueprintId }), + context: expect.objectContaining({ modId }), }), ]); }); diff --git a/src/telemetry/telemetryHelpers.test.ts b/src/telemetry/telemetryHelpers.test.ts index c4e63903cc..50a3c3a829 100644 --- a/src/telemetry/telemetryHelpers.test.ts +++ b/src/telemetry/telemetryHelpers.test.ts @@ -45,9 +45,9 @@ describe("mapModComponentRefToEventData", () => { it("maps fields", () => { const value = modComponentRefFactory(); expect(mapModComponentRefToMessageContext(value)).toStrictEqual({ - extensionId: value.extensionId, - blueprintId: value.blueprintId, - extensionPointId: value.extensionPointId, + modComponentId: value.extensionId, + modId: value.blueprintId, + starterBrickId: value.extensionPointId, }); }); @@ -56,9 +56,9 @@ describe("mapModComponentRefToEventData", () => { blueprintId: null, }); expect(mapModComponentRefToMessageContext(value)).toStrictEqual({ - extensionId: value.extensionId, - blueprintId: undefined, - extensionPointId: value.extensionPointId, + modComponentId: value.extensionId, + modId: undefined, + starterBrickId: value.extensionPointId, }); }); diff --git a/src/testUtils/factories/runtimeFactories.ts b/src/testUtils/factories/runtimeFactories.ts index 4a8a393694..e799575bf3 100644 --- a/src/testUtils/factories/runtimeFactories.ts +++ b/src/testUtils/factories/runtimeFactories.ts @@ -34,11 +34,12 @@ export const brickOptionsFactory = define({ }, platform: (_i: number) => contentScriptPlatform, logger(_i: number) { - const { blueprintId, ...rest } = modComponentRefFactory(); + const { blueprintId, extensionId, ...rest } = modComponentRefFactory(); // MessageContext expects undefined instead of null for blueprintId return new ConsoleLogger({ ...rest, - blueprintId: blueprintId ?? undefined, + modComponentId: extensionId, + modId: blueprintId ?? undefined, }); }, root: (_i: number) => document, diff --git a/src/types/sidebarTypes.ts b/src/types/sidebarTypes.ts index aa1f7744a8..f9b104938e 100644 --- a/src/types/sidebarTypes.ts +++ b/src/types/sidebarTypes.ts @@ -73,7 +73,6 @@ export function isRendererErrorPayload( */ export type PanelContext = MessageContext & { modComponentId: UUID; - modId: RegistryId | null; }; /** diff --git a/src/utils/modUtils.ts b/src/utils/modUtils.ts index bef5f98f86..bb33ce1cc1 100644 --- a/src/utils/modUtils.ts +++ b/src/utils/modUtils.ts @@ -56,6 +56,7 @@ import { produce } from "immer"; import { isStarterBrickDefinitionLike } from "@/starterBricks/types"; import { normalizeStarterBrickDefinitionProp } from "@/starterBricks/starterBrickUtils"; import { type MessageContext } from "@/types/loggerTypes"; +import { type SetRequired } from "type-fest"; /** * Returns the ModComponentRef for a given mod component. @@ -81,12 +82,12 @@ export function mapModComponentToMessageContext( return { // The step label will be re-assigned later in reducePipeline label: modComponent.label ?? undefined, - extensionLabel: modComponent.label ?? undefined, - extensionId: modComponent.id, - extensionPointId: modComponent.extensionPointId, + modComponentLabel: modComponent.label ?? undefined, + modComponentId: modComponent.id, + starterBrickId: modComponent.extensionPointId, deploymentId: modComponent._deployment?.id, - blueprintId: modComponent._recipe?.id, - blueprintVersion: modComponent._recipe?.version, + modId: modComponent._recipe?.id, + modVersion: modComponent._recipe?.version, }; } @@ -96,13 +97,13 @@ export function mapModComponentToMessageContext( */ export function mapModComponentRefToMessageContext( modComponentRef: ModComponentRef, -): MessageContext { +): SetRequired { // Fields are currently named the same. In the future, the fields might temporarily diverge. return { - extensionId: modComponentRef.extensionId, - extensionPointId: modComponentRef.extensionPointId, + modComponentId: modComponentRef.extensionId, + starterBrickId: modComponentRef.extensionPointId, // MessageContext expects undefined instead of null/undefined - blueprintId: modComponentRef.blueprintId ?? undefined, + modId: modComponentRef.blueprintId ?? undefined, }; } @@ -118,18 +119,18 @@ export function mapMessageContextToModComponentRef( context: MessageContext, ): ModComponentRef { assertNotNullish( - context.extensionId, - "extensionId is required for ModComponentRef", + context.modComponentId, + "modComponentId is required for ModComponentRef", ); assertNotNullish( - context.extensionPointId, - "extensionPointId is required for ModComponentRef", + context.starterBrickId, + "starterBrickId is required for ModComponentRef", ); return { - extensionId: context.extensionId, - blueprintId: context.blueprintId, - extensionPointId: context.extensionPointId, + extensionId: context.modComponentId, + blueprintId: context.modId, + extensionPointId: context.starterBrickId, }; }