From 6d9157016ecf311ef50191a3600f0bb0ddc2252c Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 1 Jul 2024 07:45:26 -0500 Subject: [PATCH 01/14] wip --- src/activation/useActivateMod.ts | 4 +- src/background/executor.test.ts | 4 +- .../removeModComponentForEveryTab.ts | 2 +- src/background/requests.ts | 4 +- .../effects/AddDynamicTextSnippet.test.ts | 6 +-- src/bricks/effects/AddDynamicTextSnippet.ts | 4 +- src/bricks/effects/AddQuickBarAction.test.ts | 8 +-- src/bricks/effects/AddQuickBarAction.tsx | 8 +-- src/bricks/effects/AddTextSnippets.test.ts | 2 +- src/bricks/effects/AddTextSnippets.ts | 4 +- src/bricks/effects/assignModVariable.test.ts | 4 +- src/bricks/effects/assignModVariable.ts | 2 +- src/bricks/effects/attachAutocomplete.test.ts | 2 +- src/bricks/effects/customEvent.test.ts | 2 +- src/bricks/effects/pageState.test.ts | 18 +++---- src/bricks/effects/pageState.ts | 4 +- src/bricks/effects/runSubTour.test.ts | 4 +- src/bricks/effects/runSubTour.ts | 4 +- src/bricks/effects/sidebarEffects.ts | 2 +- src/bricks/effects/tourEffect.ts | 7 ++- src/bricks/renderers/customForm.test.tsx | 4 +- src/bricks/renderers/customForm.tsx | 4 +- .../transformers/RunBrickByIdTransformer.ts | 2 +- .../RunMetadataTransformer.test.ts | 14 ++--- .../transformers/RunMetadataTransformer.ts | 8 +-- .../controlFlow/WithAsyncModVariable.test.ts | 4 +- .../controlFlow/WithAsyncModVariable.ts | 2 +- .../ephemeralForm/formTransformer.ts | 6 +-- .../DisplayTemporaryInfo.test.ts | 17 +++--- .../temporaryInfo/DisplayTemporaryInfo.ts | 2 +- .../temporaryInfo/EphemeralPanel.tsx | 8 +-- .../transformers/tourStep/tourStep.test.ts | 6 +-- src/bricks/transformers/tourStep/tourStep.ts | 2 +- src/components/logViewer/EntryRow.tsx | 2 +- src/components/logViewer/LogTable.stories.tsx | 10 ++-- src/contentScript/sidebarActivation.ts | 2 +- .../google/sheets/bricks/append.test.ts | 4 +- src/data/service/errorService.ts | 24 ++++----- .../pages/brickEditor/useLogContext.ts | 8 +-- .../pages/integrations/IntegrationsPage.tsx | 2 +- .../pages/mods/hooks/useActivateAction.ts | 4 +- .../pages/mods/hooks/useReactivateAction.ts | 13 ++--- .../pages/mods/hooks/useViewLogsAction.ts | 2 +- src/mods/hooks/useDeactivateAction.ts | 16 +++--- .../documentBuilder/render/ListElement.tsx | 2 +- src/pageEditor/hooks/useDeactivateMod.tsx | 2 +- .../useRemoveModComponentFromStorage.tsx | 2 +- src/pageEditor/hooks/useResetExtension.ts | 10 ++-- .../hooks/useSaveStandaloneModComponent.ts | 2 +- .../modals/addBrickModal/useAddBrick.ts | 2 +- src/pageEditor/panes/ModEditorPane.tsx | 2 +- .../sidebar/ActivatedModComponentListItem.tsx | 2 +- .../sidebar/DraftModComponentListItem.tsx | 2 +- .../tabs/editTab/useReportTraceError.ts | 2 +- src/pageEditor/toolbar/ReloadToolbar.tsx | 2 +- src/runtime/pipelineTests/trace.test.ts | 12 +++-- src/runtime/reducePipeline.ts | 18 +++---- src/sidebar/PanelBody.test.tsx | 12 ++--- src/sidebar/PanelBody.tsx | 2 +- src/sidebar/RendererComponent.test.tsx | 2 +- src/sidebar/Tabs.tsx | 14 ++--- src/sidebar/TemporaryPanelTabPane.tsx | 15 ++++-- src/sidebar/activateMod/ActivateModInputs.tsx | 4 +- .../button/buttonStarterBrick.ts | 4 +- .../contextMenu/contextMenuStarterBrick.ts | 4 +- src/starterBricks/helpers.ts | 10 ++-- .../sidebar/sidebarStarterBrick.ts | 4 +- src/starterBricks/tour/tourController.test.ts | 6 +-- src/starterBricks/types.ts | 2 +- src/store/extensionsSlice.ts | 4 +- src/telemetry/deployments.ts | 16 +++--- src/telemetry/events.ts | 18 +++++++ src/telemetry/logging.test.ts | 8 +-- src/telemetry/logging.ts | 18 +++---- src/telemetry/reportEvent.ts | 53 +++++++++++++++++-- src/testUtils/factories/logFactories.ts | 2 +- src/testUtils/factories/runtimeFactories.ts | 4 +- src/types/loggerTypes.ts | 20 +++---- src/types/sidebarTypes.ts | 4 +- 79 files changed, 313 insertions(+), 234 deletions(-) diff --git a/src/activation/useActivateMod.ts b/src/activation/useActivateMod.ts index 81637ffd7b..7b75c6814e 100644 --- a/src/activation/useActivateMod.ts +++ b/src/activation/useActivateMod.ts @@ -53,8 +53,8 @@ type ActivationSource = "marketplace" | "extensionConsole"; function selectActivateEventData(modDefinition: ModDefinition) { return { - blueprintId: modDefinition.metadata.id, - extensions: modDefinition.extensionPoints.map((x) => x.label), + modId: modDefinition.metadata.id, + modComponents: modDefinition.extensionPoints.map((x) => x.label), }; } diff --git a/src/background/executor.test.ts b/src/background/executor.test.ts index 11880684db..ae343d1640 100644 --- a/src/background/executor.test.ts +++ b/src/background/executor.test.ts @@ -43,11 +43,11 @@ const runBrickMock = jest.mocked(runBrick); const optionsFactory = define({ ctxt: () => ({}), messageContext: (i: number) => ({ - extensionId: uuidSequence(i), + modComponentId: uuidSequence(i), }), meta: derive( (options) => ({ - extensionId: options.messageContext!.extensionId, + extensionId: options.messageContext!.modComponentId, runId: null, branches: [], }), diff --git a/src/background/removeModComponentForEveryTab.ts b/src/background/removeModComponentForEveryTab.ts index 5f435c0a33..aded844090 100644 --- a/src/background/removeModComponentForEveryTab.ts +++ b/src/background/removeModComponentForEveryTab.ts @@ -39,5 +39,5 @@ export async function removeModComponentForEveryTab( }); await uninstallContextMenu({ extensionId: modComponentId }); await clearExtensionTraces(modComponentId); - await clearLog({ extensionId: modComponentId }); + await clearLog({ modComponentId: modComponentId }); } diff --git a/src/background/requests.ts b/src/background/requests.ts index 590c1b5e6b..886fe2acd1 100644 --- a/src/background/requests.ts +++ b/src/background/requests.ts @@ -347,8 +347,8 @@ async function getIntegrationMessageContext( } return { - serviceId: config.serviceId, - serviceVersion: resolvedIntegration?.version, + integrationId: config.serviceId, + integrationVersion: resolvedIntegration?.version, authId: config.id, }; } diff --git a/src/bricks/effects/AddDynamicTextSnippet.test.ts b/src/bricks/effects/AddDynamicTextSnippet.test.ts index 8a138d02e1..dfb3a38704 100644 --- a/src/bricks/effects/AddDynamicTextSnippet.test.ts +++ b/src/bricks/effects/AddDynamicTextSnippet.test.ts @@ -49,8 +49,8 @@ describe("AddDynamicTextSnippet", () => { async (shortcut) => { const extensionId = uuidv4(); const logger = new ConsoleLogger({ - extensionId, - blueprintId: registryIdFactory(), + modComponentId: extensionId, + modId: registryIdFactory(), }); const pipeline = { @@ -98,7 +98,7 @@ describe("AddDynamicTextSnippet", () => { "passes preview directly: %s", async (preview) => { const extensionId = uuidv4(); - const logger = new ConsoleLogger({ extensionId }); + const logger = new ConsoleLogger({ modComponentId: extensionId }); const pipeline = { id: brick.id, diff --git a/src/bricks/effects/AddDynamicTextSnippet.ts b/src/bricks/effects/AddDynamicTextSnippet.ts index d21dd84765..4ba067f37e 100644 --- a/src/bricks/effects/AddDynamicTextSnippet.ts +++ b/src/bricks/effects/AddDynamicTextSnippet.ts @@ -114,7 +114,7 @@ class AddDynamicTextSnippet extends EffectABC { return; } - if (logger.context.extensionId == null) { + if (logger.context.modComponentId == null) { throw new Error("Must be run in the context of a mod"); } @@ -122,7 +122,7 @@ class AddDynamicTextSnippet extends EffectABC { let counter = 0; platform.snippetShortcutMenu.register({ - componentId: logger.context.extensionId, + componentId: logger.context.modComponentId, context: logger.context, // Trim leading command key in shortcut to be resilient to user input shortcut: normalizeShortcut(shortcut), diff --git a/src/bricks/effects/AddQuickBarAction.test.ts b/src/bricks/effects/AddQuickBarAction.test.ts index 981c547665..c0e7ff78a0 100644 --- a/src/bricks/effects/AddQuickBarAction.test.ts +++ b/src/bricks/effects/AddQuickBarAction.test.ts @@ -27,8 +27,8 @@ const brick = new AddQuickBarAction(); const platform = platformMock; const logger = new ConsoleLogger({ - extensionId: uuidv4(), - extensionPointId: validateRegistryId("test/test"), + modComponentId: uuidv4(), + starterBrickId: validateRegistryId("test/test"), }); describe("AddQuickBarAction", () => { @@ -58,8 +58,8 @@ describe("AddQuickBarAction", () => { ); expect(platform.quickBar.addAction).toHaveBeenCalledWith({ id: expect.toBeString(), - extensionPointId: logger.context.extensionPointId, - extensionId: logger.context.extensionId, + extensionPointId: logger.context.starterBrickId, + extensionId: logger.context.modComponentId, name: "test", icon: expect.anything(), perform: expect.toBeFunction(), diff --git a/src/bricks/effects/AddQuickBarAction.tsx b/src/bricks/effects/AddQuickBarAction.tsx index 580af5eda7..520dc8b4c7 100644 --- a/src/bricks/effects/AddQuickBarAction.tsx +++ b/src/bricks/effects/AddQuickBarAction.tsx @@ -150,14 +150,14 @@ class AddQuickBarAction extends EffectABC { let counter = 0; // Expected parent id from QuickBarProviderExtensionPoint - const parentId = `provider-${logger.context.extensionId}`; + const parentId = `provider-${logger.context.modComponentId}`; const action: CustomAction = { // XXX: old actions will still appear in the quick bar unless the extension point clears out the old actions - id: `${logger.context.extensionId}-${title}`, + id: `${logger.context.modComponentId}-${title}`, // Additional metadata, for enabling clearing out old actions - extensionPointId: logger.context.extensionPointId, - extensionId: logger.context.extensionId, + extensionPointId: logger.context.starterBrickId, + extensionId: logger.context.modComponentId, // Can only provide a parent if the parent exists parent: quickBar.knownGeneratorRootIds.has(parentId) ? parentId diff --git a/src/bricks/effects/AddTextSnippets.test.ts b/src/bricks/effects/AddTextSnippets.test.ts index 497cdd1b3e..ed48309c35 100644 --- a/src/bricks/effects/AddTextSnippets.test.ts +++ b/src/bricks/effects/AddTextSnippets.test.ts @@ -53,7 +53,7 @@ describe("AddTextSnippets", () => { title: "Test", preview: "test text", handler: expect.toBeFunction(), - componentId: options.logger.context.extensionId, + componentId: options.logger.context.modComponentId, context: options.logger.context, }, ]); diff --git a/src/bricks/effects/AddTextSnippets.ts b/src/bricks/effects/AddTextSnippets.ts index b085210439..4059dca9b9 100644 --- a/src/bricks/effects/AddTextSnippets.ts +++ b/src/bricks/effects/AddTextSnippets.ts @@ -115,13 +115,13 @@ class AddTextSnippets extends EffectABC { return; } - if (logger.context.extensionId == null) { + if (logger.context.modComponentId == null) { throw new Error("Must be run in the context of a mod component"); } for (const { shortcut, title, text } of snippets) { platform.snippetShortcutMenu.register({ - componentId: logger.context.extensionId, + componentId: logger.context.modComponentId, context: logger.context, shortcut: normalizeShortcut(shortcut), title, diff --git a/src/bricks/effects/assignModVariable.test.ts b/src/bricks/effects/assignModVariable.test.ts index c4b2363f5b..a11342c30c 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({ - extensionId: modComponentId, - blueprintId: modId, + modComponentId: modComponentId, + modId: modId, }); const brickOptions = brickOptionsFactory({ logger }); diff --git a/src/bricks/effects/assignModVariable.ts b/src/bricks/effects/assignModVariable.ts index 922df3c7a5..9d314b81a1 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 { blueprintId: modId, extensionId: modComponentId } = logger.context; + const { modId: modId, modComponentId: modComponentId } = logger.context; setState({ namespace: StateNamespaces.MOD, diff --git a/src/bricks/effects/attachAutocomplete.test.ts b/src/bricks/effects/attachAutocomplete.test.ts index 23b62827f9..4b223d196f 100644 --- a/src/bricks/effects/attachAutocomplete.test.ts +++ b/src/bricks/effects/attachAutocomplete.test.ts @@ -24,7 +24,7 @@ import { brickOptionsFactory } from "@/testUtils/factories/runtimeFactories"; const brick = new AttachAutocomplete(); const logger = new ConsoleLogger({ - extensionId: uuidSequence(0), + modComponentId: uuidSequence(0), }); describe("AttachAutocomplete", () => { diff --git a/src/bricks/effects/customEvent.test.ts b/src/bricks/effects/customEvent.test.ts index 19baad147e..17db0f9be4 100644 --- a/src/bricks/effects/customEvent.test.ts +++ b/src/bricks/effects/customEvent.test.ts @@ -24,7 +24,7 @@ import { brickOptionsFactory } from "@/testUtils/factories/runtimeFactories"; const brick = new CustomEventEffect(); const logger = new ConsoleLogger({ - extensionId: uuidSequence(0), + modComponentId: uuidSequence(0), }); describe("CustomEventEffect", () => { diff --git a/src/bricks/effects/pageState.test.ts b/src/bricks/effects/pageState.test.ts index 1e1935abfe..c7fecce72d 100644 --- a/src/bricks/effects/pageState.test.ts +++ b/src/bricks/effects/pageState.test.ts @@ -34,8 +34,8 @@ describe("@pixiebrix/state/get", () => { test("default to blueprint state", async () => { const brick = new GetPageState(); const logger = new ConsoleLogger({ - extensionId: uuidv4(), - blueprintId: validateRegistryId("test/123"), + modComponentId: uuidv4(), + modId: validateRegistryId("test/123"), }); await brick.transform( unsafeAssumeValidArg({}), @@ -53,8 +53,8 @@ describe("@pixiebrix/state/set", () => { test("shallow merge", async () => { const brick = new SetPageState(); const logger = new ConsoleLogger({ - extensionId: uuidv4(), - blueprintId: validateRegistryId("test/123"), + modComponentId: uuidv4(), + modId: validateRegistryId("test/123"), }); let result = await brick.transform( @@ -78,8 +78,8 @@ describe("@pixiebrix/state/set", () => { const brick = new SetPageState(); const logger = new ConsoleLogger({ - extensionId: uuidv4(), - blueprintId: validateRegistryId("test/123"), + modComponentId: uuidv4(), + modId: validateRegistryId("test/123"), }); const original = { @@ -164,8 +164,8 @@ describe("set and get", () => { const setState = new SetPageState(); const getState = new GetPageState(); const logger = new ConsoleLogger({ - extensionId: uuidv4(), - blueprintId: validateRegistryId("test/123"), + modComponentId: uuidv4(), + modId: validateRegistryId("test/123"), }); await setState.transform( @@ -196,7 +196,7 @@ describe("set and get", () => { const setState = new SetPageState(); const getState = new GetPageState(); const logger = new ConsoleLogger({ - extensionId: uuidv4(), + modComponentId: uuidv4(), }); await setState.transform( diff --git a/src/bricks/effects/pageState.ts b/src/bricks/effects/pageState.ts index 85cfa2324c..34312352c6 100644 --- a/src/bricks/effects/pageState.ts +++ b/src/bricks/effects/pageState.ts @@ -150,7 +150,7 @@ export class SetPageState extends TransformerABC { }>, { logger, platform }: BrickOptions, ): Promise { - const { blueprintId, extensionId } = logger.context; + const { modId: blueprintId, modComponentId: extensionId } = logger.context; return platform.state.setState({ namespace, @@ -205,7 +205,7 @@ export class GetPageState extends TransformerABC { }: BrickArgs<{ namespace?: StateNamespace }>, { logger, platform }: BrickOptions, ): Promise { - const { blueprintId: modId, extensionId: modComponentId } = logger.context; + const { modId: modId, modComponentId: modComponentId } = logger.context; return platform.state.getState({ namespace, diff --git a/src/bricks/effects/runSubTour.test.ts b/src/bricks/effects/runSubTour.test.ts index af4316249f..b3b620f15f 100644 --- a/src/bricks/effects/runSubTour.test.ts +++ b/src/bricks/effects/runSubTour.test.ts @@ -56,7 +56,9 @@ describe("runSubTour", () => { const promise = brick.run( unsafeAssumeValidArg({ tour: "Test Extension" }), - brickOptionsFactory({ logger: new ConsoleLogger({ blueprintId }) }), + brickOptionsFactory({ + logger: new ConsoleLogger({ modId: blueprintId }), + }), ); await tick(); diff --git a/src/bricks/effects/runSubTour.ts b/src/bricks/effects/runSubTour.ts index c2f9867d6c..f31a158f93 100644 --- a/src/bricks/effects/runSubTour.ts +++ b/src/bricks/effects/runSubTour.ts @@ -45,7 +45,7 @@ export class RunSubTourEffect extends EffectABC { { tour }: BrickArgs<{ tour: string }>, { logger }: BrickOptions, ): Promise { - if (logger.context.blueprintId == null) { + if (logger.context.modId == null) { throw new BusinessError("Can only run sub-tours in the same mod"); } @@ -53,7 +53,7 @@ export class RunSubTourEffect extends EffectABC { // manually running a tour will cancel all tours in progress (see tourController.ts) await runSubTour({ tour, - blueprintId: logger.context.blueprintId, + blueprintId: logger.context.modId, }); } } diff --git a/src/bricks/effects/sidebarEffects.ts b/src/bricks/effects/sidebarEffects.ts index e4b755aa92..6b4677ac33 100644 --- a/src/bricks/effects/sidebarEffects.ts +++ b/src/bricks/effects/sidebarEffects.ts @@ -79,7 +79,7 @@ export class ShowSidebar extends EffectABC { sidebarController.updateSidebar({ force: forcePanel, panelHeading, - blueprintId: logger.context.blueprintId, + blueprintId: logger.context.modId, }), ); } diff --git a/src/bricks/effects/tourEffect.ts b/src/bricks/effects/tourEffect.ts index b99bfc8965..ab7b7bf5e3 100644 --- a/src/bricks/effects/tourEffect.ts +++ b/src/bricks/effects/tourEffect.ts @@ -139,7 +139,12 @@ export class TourEffect extends EffectABC { ); } - const { extensionId, label, extensionLabel, blueprintId } = logger.context; + const { + modComponentId: extensionId, + label, + modComponentLabel: extensionLabel, + modId: blueprintId, + } = logger.context; const nonce = uuidv4(); const abortController = new AbortController(); const stylesheetLink = await injectStylesheet(stylesheetUrl); diff --git a/src/bricks/renderers/customForm.test.tsx b/src/bricks/renderers/customForm.test.tsx index 58b0b3bc25..95da28e61e 100644 --- a/src/bricks/renderers/customForm.test.tsx +++ b/src/bricks/renderers/customForm.test.tsx @@ -352,8 +352,8 @@ describe("CustomFormRenderer", () => { expect( getState({ namespace: StateNamespaces.MOD, - modComponentId: options.logger.context.extensionId, - modId: options.logger.context.blueprintId, + modComponentId: options.logger.context.modComponentId, + modId: options.logger.context.modId, }), ).toStrictEqual({ name: value, diff --git a/src/bricks/renderers/customForm.tsx b/src/bricks/renderers/customForm.tsx index 07374f2344..4296793dfa 100644 --- a/src/bricks/renderers/customForm.tsx +++ b/src/bricks/renderers/customForm.tsx @@ -284,7 +284,7 @@ export class CustomFormRenderer extends RendererABC { }>, { logger, runPipeline, platform }: BrickOptions, ): Promise { - if (logger.context.extensionId == null) { + if (logger.context.modComponentId == null) { throw new Error("extensionId is required"); } @@ -311,7 +311,7 @@ export class CustomFormRenderer extends RendererABC { assumeNotNullish_UNSAFE(recordId); } - const { blueprintId, extensionId } = logger.context; + const { modId: blueprintId, modComponentId: extensionId } = logger.context; const initialData = await getInitialData(storage, recordId, { blueprintId, diff --git a/src/bricks/transformers/RunBrickByIdTransformer.ts b/src/bricks/transformers/RunBrickByIdTransformer.ts index 799cf716a8..fd3e4b44f7 100644 --- a/src/bricks/transformers/RunBrickByIdTransformer.ts +++ b/src/bricks/transformers/RunBrickByIdTransformer.ts @@ -95,7 +95,7 @@ class RunBrickByIdTransformer extends TransformerABC { const { logger, ...otherOptions } = options; return brick.run(rawArguments as BrickArgs, { - logger: logger.childLogger({ blockId: brick.id }), + logger: logger.childLogger({ brickId: brick.id }), ...otherOptions, }); } diff --git a/src/bricks/transformers/RunMetadataTransformer.test.ts b/src/bricks/transformers/RunMetadataTransformer.test.ts index 73b794f5a5..04fb3af324 100644 --- a/src/bricks/transformers/RunMetadataTransformer.test.ts +++ b/src/bricks/transformers/RunMetadataTransformer.test.ts @@ -31,7 +31,7 @@ describe("RunMetadataTransformer", () => { it("returns standalone mod metadata", async () => { const extensionId = autoUUIDSequence(); const logger = new ConsoleLogger({ - extensionId, + modComponentId: extensionId, }); const result = await brick.run( @@ -53,9 +53,9 @@ describe("RunMetadataTransformer", () => { const extensionId = autoUUIDSequence(); const registryId = registryIdFactory(); const logger = new ConsoleLogger({ - extensionId, - blueprintId: registryId, - blueprintVersion: "1.0.0" as SemVerString, + modComponentId: extensionId, + modId: registryId, + modVersion: "1.0.0" as SemVerString, }); const result = await brick.run( @@ -83,9 +83,9 @@ describe("RunMetadataTransformer", () => { const runId = autoUUIDSequence(); const logger = new ConsoleLogger({ - extensionId, - blueprintId: registryId, - blueprintVersion: "1.0.0" as SemVerString, + modComponentId: extensionId, + modId: registryId, + modVersion: "1.0.0" as SemVerString, deploymentId, }); diff --git a/src/bricks/transformers/RunMetadataTransformer.ts b/src/bricks/transformers/RunMetadataTransformer.ts index a1264d2eff..34cdf865a8 100644 --- a/src/bricks/transformers/RunMetadataTransformer.ts +++ b/src/bricks/transformers/RunMetadataTransformer.ts @@ -110,14 +110,14 @@ class RunMetadataTransformer extends TransformerABC { return { mod: - context.blueprintId == null + context.modId == null ? null : { - id: context.blueprintId, - version: context.blueprintVersion, + id: context.modId, + version: context.modVersion, }, deploymentId: context.deploymentId ?? null, - modComponentId: context.extensionId ?? null, + modComponentId: context.modComponentId ?? null, runId: meta.runId, }; } diff --git a/src/bricks/transformers/controlFlow/WithAsyncModVariable.test.ts b/src/bricks/transformers/controlFlow/WithAsyncModVariable.test.ts index 3e275a63e2..b4557030ed 100644 --- a/src/bricks/transformers/controlFlow/WithAsyncModVariable.test.ts +++ b/src/bricks/transformers/controlFlow/WithAsyncModVariable.test.ts @@ -67,8 +67,8 @@ const extensionId = autoUUIDSequence(); const blueprintId = registryIdFactory(); const logger = new ConsoleLogger({ - extensionId, - blueprintId, + modComponentId: extensionId, + modId: blueprintId, }); function expectPageState(expectedState: UnknownObject) { diff --git a/src/bricks/transformers/controlFlow/WithAsyncModVariable.ts b/src/bricks/transformers/controlFlow/WithAsyncModVariable.ts index e1026d941a..f575b7af85 100644 --- a/src/bricks/transformers/controlFlow/WithAsyncModVariable.ts +++ b/src/bricks/transformers/controlFlow/WithAsyncModVariable.ts @@ -180,7 +180,7 @@ export class WithAsyncModVariable extends TransformerABC { { logger, runPipeline }: BrickOptions, ) { const requestId = uuidv4(); - const { blueprintId, extensionId } = logger.context; + const { modId: blueprintId, modComponentId: extensionId } = logger.context; if (isNullOrBlank(stateKey)) { throw new PropError( diff --git a/src/bricks/transformers/ephemeralForm/formTransformer.ts b/src/bricks/transformers/ephemeralForm/formTransformer.ts index 894b3cfa42..eee9e80436 100644 --- a/src/bricks/transformers/ephemeralForm/formTransformer.ts +++ b/src/bricks/transformers/ephemeralForm/formTransformer.ts @@ -135,14 +135,14 @@ export class FormTransformer extends TransformerABC { controller.abort(); }); - if (logger.context.extensionId == null) { + if (logger.context.modComponentId == null) { throw new Error(`${this.name} must be run in a mod context`); } try { return await platform.form(formDefinition, controller, { - componentId: logger.context.extensionId, - modId: logger.context.blueprintId, + componentId: logger.context.modComponentId, + modId: logger.context.modId, }); } finally { controller.abort(); diff --git a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts index 5f92bb2fac..3c3c20eddb 100644 --- a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts +++ b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts @@ -106,7 +106,10 @@ describe("DisplayTemporaryInfo", () => { await reducePipeline(pipeline, simpleInput({}), { ...testOptions("v3"), - logger: new ConsoleLogger({ extensionId, blueprintId }), + logger: new ConsoleLogger({ + modComponentId: extensionId, + modId: blueprintId, + }), }); // Show function will be called with a "loading" payload @@ -184,7 +187,7 @@ describe("DisplayTemporaryInfo", () => { const options = { ...testOptions("v3"), logger: new ConsoleLogger({ - extensionId, + modComponentId: extensionId, }), }; @@ -225,7 +228,7 @@ describe("DisplayTemporaryInfo", () => { const options = { ...testOptions("v3"), logger: new ConsoleLogger({ - extensionId, + modComponentId: extensionId, }), }; @@ -251,7 +254,7 @@ describe("DisplayTemporaryInfo", () => { const options = { ...testOptions("v3"), logger: new ConsoleLogger({ - extensionId, + modComponentId: extensionId, }), }; @@ -280,7 +283,7 @@ describe("DisplayTemporaryInfo", () => { const options = { ...testOptions("v3"), logger: new ConsoleLogger({ - extensionId, + modComponentId: extensionId, }), }; @@ -319,7 +322,7 @@ describe("DisplayTemporaryInfo", () => { const options = { ...testOptions("v3"), logger: new ConsoleLogger({ - extensionId, + modComponentId: extensionId, }), }; @@ -366,7 +369,7 @@ describe("DisplayTemporaryInfo", () => { const options = { ...testOptions("v3"), logger: new ConsoleLogger({ - extensionId, + modComponentId: extensionId, }), }; diff --git a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.ts b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.ts index d0015a87b4..52d7beade9 100644 --- a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.ts +++ b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.ts @@ -102,7 +102,7 @@ class DisplayTemporaryInfo extends TransformerABC { }>, { logger: { - context: { extensionId, blueprintId }, + context: { modComponentId: extensionId, modId: blueprintId }, }, root = document, platform, diff --git a/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx b/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx index 113d051dfe..84ab0a66d3 100644 --- a/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx +++ b/src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx @@ -175,8 +175,8 @@ const EphemeralPanel: React.FC = () => { isRootPanel={false} payload={entry.payload} context={{ - extensionId: entry.extensionId, - blueprintId: entry.blueprintId, + modComponentId: entry.extensionId, + modId: entry.blueprintId, }} onAction={(action) => { resolveTemporaryPanel(target, panelNonce, action); @@ -220,8 +220,8 @@ const EphemeralPanel: React.FC = () => { isRootPanel={false} payload={entry.payload} context={{ - extensionId: entry.extensionId, - blueprintId: entry.blueprintId, + modComponentId: entry.extensionId, + modId: entry.blueprintId, }} onAction={(action) => { resolveTemporaryPanel(target, panelNonce, action); diff --git a/src/bricks/transformers/tourStep/tourStep.test.ts b/src/bricks/transformers/tourStep/tourStep.test.ts index 7d897ff54e..06635f1687 100644 --- a/src/bricks/transformers/tourStep/tourStep.test.ts +++ b/src/bricks/transformers/tourStep/tourStep.test.ts @@ -50,8 +50,8 @@ jest.mock("@/contentScript/popoverDom", () => ({ })); const logger = new ConsoleLogger({ - extensionId: uuidv4(), - blueprintId: validateRegistryId("test/tour"), + modComponentId: uuidv4(), + modId: validateRegistryId("test/tour"), }); const brick = new TourStepTransformer(); @@ -70,7 +70,7 @@ function startTour() { id: extensionId, label: "Test Tour", }, - { abortController, context: { extensionId } }, + { abortController, context: { modComponentId: extensionId } }, ); return { nonce, abortController }; diff --git a/src/bricks/transformers/tourStep/tourStep.ts b/src/bricks/transformers/tourStep/tourStep.ts index c45fff28fa..390121ce01 100644 --- a/src/bricks/transformers/tourStep/tourStep.ts +++ b/src/bricks/transformers/tourStep/tourStep.ts @@ -328,7 +328,7 @@ class TourStepTransformer extends TransformerABC { { abortSignal, logger: { - context: { extensionId, blueprintId }, + context: { modComponentId: extensionId, modId: blueprintId }, }, platform, runRendererPipeline, diff --git a/src/components/logViewer/EntryRow.tsx b/src/components/logViewer/EntryRow.tsx index 312c05f665..54b74c6e9a 100644 --- a/src/components/logViewer/EntryRow.tsx +++ b/src/components/logViewer/EntryRow.tsx @@ -87,7 +87,7 @@ const EntryRow: React.FunctionComponent<{ entry: LogEntry }> = ({ entry }) => { {dateFormat.format(new Date(Number(entry.timestamp)))} {entry.level.toUpperCase()} {entry.context?.label} - {entry.context?.blockId ?? entry.context?.serviceId ?? ""} + {entry.context?.brickId ?? entry.context?.integrationId ?? ""} {entry.message} {expanded && expandable && ( diff --git a/src/components/logViewer/LogTable.stories.tsx b/src/components/logViewer/LogTable.stories.tsx index 11feae1a7c..1450618242 100644 --- a/src/components/logViewer/LogTable.stories.tsx +++ b/src/components/logViewer/LogTable.stories.tsx @@ -63,7 +63,7 @@ const DEBUG_MESSAGE: LogEntry = { message: "Sample debug message", level: "debug", context: { - blockId, + brickId: blockId, }, }; @@ -74,7 +74,7 @@ const ERROR_MESSAGE: LogEntry = { level: "error", context: { // Just the context that will show up in the table - blockId, + brickId: blockId, }, error: serializeError(new Error("Simple error")), }; @@ -86,7 +86,7 @@ const NESTED_ERROR_MESSAGE: LogEntry = { level: "error", context: { // Just the context that will show up in the table - blockId, + brickId: blockId, }, error: serializeError( new Error("Simple error", { @@ -125,13 +125,13 @@ const CONTEXT_ERROR_MESSAGE: LogEntry = { level: "error", context: { // Just the context that will show up in the table - blockId, + brickId: blockId, }, error: serializeError( new ContextError("Invalid inputs for brick", { cause: validationError, context: { - blockId, + brickId: blockId, }, }), ), diff --git a/src/contentScript/sidebarActivation.ts b/src/contentScript/sidebarActivation.ts index 30ef8c040e..21d6646900 100644 --- a/src/contentScript/sidebarActivation.ts +++ b/src/contentScript/sidebarActivation.ts @@ -88,7 +88,7 @@ function addActivateModsListener(): void { reportEvent(Events.START_MOD_ACTIVATE, { // For legacy, report the first mod id - blueprintId: modIds, + modId: modIds[0], modIds, screen: "marketplace", reinstall: modIds.some((x) => activatedModIds.has(x)), diff --git a/src/contrib/google/sheets/bricks/append.test.ts b/src/contrib/google/sheets/bricks/append.test.ts index a503efb399..9e30c23d37 100644 --- a/src/contrib/google/sheets/bricks/append.test.ts +++ b/src/contrib/google/sheets/bricks/append.test.ts @@ -183,8 +183,8 @@ describe("checkAllValueHeadersExist", () => { }); const logger = new ConsoleLogger({ - extensionId: uuidv4(), - extensionPointId: validateRegistryId("test/test"), + modComponentId: uuidv4(), + starterBrickId: validateRegistryId("test/test"), }); const GOOGLE_PKCE_SERVICE_ID = validateRegistryId("google/oauth2-pkce"); diff --git a/src/data/service/errorService.ts b/src/data/service/errorService.ts index 7e622fe6e6..8357fb01b6 100644 --- a/src/data/service/errorService.ts +++ b/src/data/service/errorService.ts @@ -135,7 +135,7 @@ export async function reportToErrorService( "reportToErrorService should only be called from the background page", ); - if (flatContext.extensionId == null) { + if (flatContext.modComponentId == null) { // Only report errors that occurred within a user-defined extension/blueprint. Other errors only go to Application error telemetry. // (They're problems with our software.) return; @@ -159,8 +159,8 @@ export async function reportToErrorService( class_name: error.name, message, deployment: flatContext.deploymentId, - extension_uuid: flatContext.extensionId, - extension_label: flatContext.extensionLabel, + extension_uuid: flatContext.modComponentId, + extension_label: flatContext.modComponentLabel, step_label: flatContext.label, user_agent: window.navigator.userAgent, user_agent_extension_version: extensionVersion, @@ -172,24 +172,24 @@ export async function reportToErrorService( // For blueprint_version/service_version/brick_version the server can't handle null value. Must leave the property // off completely. - if (flatContext.blueprintId && flatContext.blueprintVersion) { + if (flatContext.modId && flatContext.modVersion) { payload.blueprint_version = { - id: flatContext.blueprintId, - version: flatContext.blueprintVersion, + id: flatContext.modId, + version: flatContext.modVersion, }; } - if (flatContext.serviceId && flatContext.serviceVersion) { + if (flatContext.integrationId && flatContext.integrationVersion) { payload.service_version = { - id: flatContext.serviceId, - version: flatContext.serviceVersion, + id: flatContext.integrationId, + version: flatContext.integrationVersion, }; } - if (flatContext.blockId && flatContext.blockVersion) { + if (flatContext.brickId && flatContext.brickVersion) { payload.brick_version = { - id: flatContext.blockId, - version: flatContext.blockVersion, + id: flatContext.brickId, + version: flatContext.brickVersion, }; } diff --git a/src/extensionConsole/pages/brickEditor/useLogContext.ts b/src/extensionConsole/pages/brickEditor/useLogContext.ts index 136ba276d2..3e1a4fccf8 100644 --- a/src/extensionConsole/pages/brickEditor/useLogContext.ts +++ b/src/extensionConsole/pages/brickEditor/useLogContext.ts @@ -55,23 +55,23 @@ function useLogContext(config: string | null) { let messageContext: MessageContext | null; switch (json.kind) { case DefinitionKinds.INTEGRATION: { - messageContext = { serviceId: id }; + messageContext = { integrationId: id }; break; } case DefinitionKinds.STARTER_BRICK: { - messageContext = { extensionPointId: id }; + messageContext = { starterBrickId: id }; break; } case DefinitionKinds.BRICK: case DefinitionKinds.READER: { - messageContext = { blockId: id }; + messageContext = { brickId: id }; break; } case DefinitionKinds.MOD: { - messageContext = { blueprintId: id }; + messageContext = { modId: id }; break; } diff --git a/src/extensionConsole/pages/integrations/IntegrationsPage.tsx b/src/extensionConsole/pages/integrations/IntegrationsPage.tsx index 841156df27..e92691540a 100644 --- a/src/extensionConsole/pages/integrations/IntegrationsPage.tsx +++ b/src/extensionConsole/pages/integrations/IntegrationsPage.tsx @@ -331,7 +331,7 @@ const IntegrationsPage: React.VFC = () => { (integration: Integration) => { // TODO: This is possibly being reported in the wrong place? Should this be when a new config is SAVED instead? reportEvent(Events.INTEGRATION_ADD, { - serviceId: integration.id, + integrationId: integration.id, }); if (integration.isAuthorizationGrant) { diff --git a/src/extensionConsole/pages/mods/hooks/useActivateAction.ts b/src/extensionConsole/pages/mods/hooks/useActivateAction.ts index 6e3feb3dcc..914049a6e2 100644 --- a/src/extensionConsole/pages/mods/hooks/useActivateAction.ts +++ b/src/extensionConsole/pages/mods/hooks/useActivateAction.ts @@ -29,7 +29,7 @@ function useActivateAction(modViewItem: ModViewItem): (() => void) | null { const activate = () => { if (isModDefinition(mod)) { reportEvent(Events.START_MOD_ACTIVATE, { - blueprintId: mod.metadata.id, + modId: mod.metadata.id, screen: "extensionConsole", reinstall: false, }); @@ -37,7 +37,7 @@ function useActivateAction(modViewItem: ModViewItem): (() => void) | null { dispatch(push(getActivateModHashRoute(mod.metadata.id))); } else { reportEvent(Events.START_MOD_ACTIVATE, { - blueprintId: null, + modId: null, screen: "extensionConsole", reinstall: false, }); diff --git a/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts b/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts index 8589b06e0e..ed0976348d 100644 --- a/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts +++ b/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts @@ -36,23 +36,18 @@ const useReactivateAction = (modViewItem: ModViewItem): (() => void) | null => { const reactivate = () => { if (hasModDefinition) { - const blueprintId = isModDefinition(mod) - ? mod.metadata.id - : mod._recipe?.id; + const modId = isModDefinition(mod) ? mod.metadata.id : mod._recipe?.id; - assertNotNullish( - blueprintId, - "blueprintId is required to reactivate mod", - ); + assertNotNullish(modId, "blueprintId is required to reactivate mod"); reportEvent(Events.START_MOD_ACTIVATE, { - blueprintId, + modId, screen: "extensionConsole", reinstall: true, }); const reactivatePath = `marketplace/activate/${encodeURIComponent( - blueprintId, + modId, )}?reinstall=1`; dispatch(push(reactivatePath)); diff --git a/src/extensionConsole/pages/mods/hooks/useViewLogsAction.ts b/src/extensionConsole/pages/mods/hooks/useViewLogsAction.ts index c88cb7c215..57fae95069 100644 --- a/src/extensionConsole/pages/mods/hooks/useViewLogsAction.ts +++ b/src/extensionConsole/pages/mods/hooks/useViewLogsAction.ts @@ -32,7 +32,7 @@ function useViewLogsAction(modViewItem: ModViewItem): (() => void) | null { messageContext: isModDefinition(mod) ? { label: getLabel(mod), - blueprintId: mod.metadata.id, + modId: mod.metadata.id, } : selectModComponentContext(mod), }), diff --git a/src/mods/hooks/useDeactivateAction.ts b/src/mods/hooks/useDeactivateAction.ts index 54fd1c78fb..f214f21bfa 100644 --- a/src/mods/hooks/useDeactivateAction.ts +++ b/src/mods/hooks/useDeactivateAction.ts @@ -50,26 +50,26 @@ function useDeactivateAction(modViewItem: ModViewItem): (() => void) | null { [mod], ); - const extensionsFromMod = useSelector(memoizedExtensionsSelector); + const modComponentsFromMod = useSelector(memoizedExtensionsSelector); const deactivate = useUserAction( async () => { if (isModDefinition(mod)) { - const blueprintId = mod.metadata.id; - await uninstallMod(blueprintId, extensionsFromMod, dispatch); + const modId = mod.metadata.id; + await uninstallMod(modId, modComponentsFromMod, dispatch); reportEvent(Events.MOD_REMOVE, { - blueprintId, + modId, }); } else { await uninstallModComponents( - extensionsFromMod.map(({ id }) => id), + modComponentsFromMod.map(({ id }) => id), dispatch, ); - for (const extension of extensionsFromMod) { + for (const modComponent of modComponentsFromMod) { reportEvent(Events.MOD_COMPONENT_REMOVE, { - extensionId: extension.id, + modComponentId: modComponent.id, }); } } @@ -78,7 +78,7 @@ function useDeactivateAction(modViewItem: ModViewItem): (() => void) | null { successMessage: `Deactivated mod: ${getLabel(mod)}`, errorMessage: `Error deactivating mod: ${getLabel(mod)}`, }, - [mod, extensionsFromMod], + [mod, modComponentsFromMod], ); return isActive && !isRestricted ? deactivate : null; diff --git a/src/pageEditor/documentBuilder/render/ListElement.tsx b/src/pageEditor/documentBuilder/render/ListElement.tsx index 5828cb9749..cbdc96dd61 100644 --- a/src/pageEditor/documentBuilder/render/ListElement.tsx +++ b/src/pageEditor/documentBuilder/render/ListElement.tsx @@ -93,7 +93,7 @@ const ListElementInternal: React.FC = ({ config: config.__value__, context: elementContext.options.ctxt, options: apiVersionOptions("v3"), - modId: documentContext.options.logger.context.blueprintId, + modId: documentContext.options.logger.context.modId, }, )) as DocumentBuilderElement; } else { diff --git a/src/pageEditor/hooks/useDeactivateMod.tsx b/src/pageEditor/hooks/useDeactivateMod.tsx index 3aa13ad0da..4db8325d38 100644 --- a/src/pageEditor/hooks/useDeactivateMod.tsx +++ b/src/pageEditor/hooks/useDeactivateMod.tsx @@ -69,7 +69,7 @@ function useDeactivateMod(): (useDeactivateConfig: Config) => Promise { ); void clearLog({ - blueprintId: modId, + modId: modId, }); dispatch(actions.removeModData(modId)); diff --git a/src/pageEditor/hooks/useRemoveModComponentFromStorage.tsx b/src/pageEditor/hooks/useRemoveModComponentFromStorage.tsx index 61f7cdaae9..48b69908fc 100644 --- a/src/pageEditor/hooks/useRemoveModComponentFromStorage.tsx +++ b/src/pageEditor/hooks/useRemoveModComponentFromStorage.tsx @@ -97,7 +97,7 @@ export function useRemoveModComponentFromStorage(): ( reportEvent(Events.PAGE_EDITOR_REMOVE, { sessionId, - extensionId: modComponentId, + modComponentId, }); try { diff --git a/src/pageEditor/hooks/useResetExtension.ts b/src/pageEditor/hooks/useResetExtension.ts index 247011fef2..d5f73c9d67 100644 --- a/src/pageEditor/hooks/useResetExtension.ts +++ b/src/pageEditor/hooks/useResetExtension.ts @@ -43,7 +43,7 @@ function useResetExtension(): (useResetConfig: Config) => Promise { const { showConfirmation } = useModals(); return useCallback( - async ({ extensionId, shouldShowConfirmation = true }) => { + async ({ extensionId: modComponentId, shouldShowConfirmation = true }) => { if (shouldShowConfirmation) { const confirm = await showConfirmation({ title: "Reset Brick?", @@ -58,13 +58,13 @@ function useResetExtension(): (useResetConfig: Config) => Promise { reportEvent(Events.PAGE_EDITOR_RESET, { sessionId, - extensionId, + modComponentId, }); try { - const extension = installed.find((x) => x.id === extensionId); + const extension = installed.find((x) => x.id === modComponentId); if (extension == null) { - dispatch(actions.removeModComponentFormState(extensionId)); + dispatch(actions.removeModComponentFormState(modComponentId)); } else { const formState = await modComponentToFormState(extension); initModOptionsIfNeeded(formState, compact(mods)); @@ -72,7 +72,7 @@ function useResetExtension(): (useResetConfig: Config) => Promise { } } catch (error) { reportError(error); - dispatch(actions.adapterError({ uuid: extensionId, error })); + dispatch(actions.adapterError({ uuid: modComponentId, error })); } }, [dispatch, mods, sessionId, installed, showConfirmation], diff --git a/src/pageEditor/hooks/useSaveStandaloneModComponent.ts b/src/pageEditor/hooks/useSaveStandaloneModComponent.ts index 5f226efa7a..51547994b8 100644 --- a/src/pageEditor/hooks/useSaveStandaloneModComponent.ts +++ b/src/pageEditor/hooks/useSaveStandaloneModComponent.ts @@ -55,7 +55,7 @@ function useSaveStandaloneModComponent(): ExtensionSaver { } else { reportEvent(Events.PAGE_EDITOR_STANDALONE_MOD_COMPONENT_UPDATE, { sessionId, - extensionId: modComponentFormState.uuid, + modComponentId: modComponentFormState.uuid, }); } } finally { diff --git a/src/pageEditor/modals/addBrickModal/useAddBrick.ts b/src/pageEditor/modals/addBrickModal/useAddBrick.ts index 6346a83ecd..8f1b689fc1 100644 --- a/src/pageEditor/modals/addBrickModal/useAddBrick.ts +++ b/src/pageEditor/modals/addBrickModal/useAddBrick.ts @@ -158,7 +158,7 @@ function useAddBrick(): AddBrick { reportEvent(Events.BRICK_ADD, { brickId: brick.id, sessionId, - extensionId: activeExtension.uuid, + modComponentId: activeExtension.uuid, source: "PageEditor-BrickSearchModal", }); }, diff --git a/src/pageEditor/panes/ModEditorPane.tsx b/src/pageEditor/panes/ModEditorPane.tsx index d42e64c6c4..d16a20041e 100644 --- a/src/pageEditor/panes/ModEditorPane.tsx +++ b/src/pageEditor/panes/ModEditorPane.tsx @@ -45,7 +45,7 @@ const ModEditorPane: React.VFC = () => { useEffect(() => { const messageContext: MessageContext = { - blueprintId: activeModId, + modId: activeModId, }; dispatch(logActions.setContext(messageContext)); }, [dispatch, activeModId]); diff --git a/src/pageEditor/sidebar/ActivatedModComponentListItem.tsx b/src/pageEditor/sidebar/ActivatedModComponentListItem.tsx index 1ef6aff307..b473b30281 100644 --- a/src/pageEditor/sidebar/ActivatedModComponentListItem.tsx +++ b/src/pageEditor/sidebar/ActivatedModComponentListItem.tsx @@ -87,7 +87,7 @@ const ActivatedModComponentListItem: React.FunctionComponent<{ try { reportEvent(Events.PAGE_EDITOR_OPEN, { sessionId, - extensionId: modComponent.id, + modComponentId: modComponent.id, }); const modComponentFormState = diff --git a/src/pageEditor/sidebar/DraftModComponentListItem.tsx b/src/pageEditor/sidebar/DraftModComponentListItem.tsx index 59bdbf3543..a2c956151c 100644 --- a/src/pageEditor/sidebar/DraftModComponentListItem.tsx +++ b/src/pageEditor/sidebar/DraftModComponentListItem.tsx @@ -164,7 +164,7 @@ const DraftModComponentListItem: React.FunctionComponent< onClick={async () => { reportEvent(Events.PAGE_EDITOR_OPEN, { sessionId, - extensionId: modComponentFormState.uuid, + modComponentId: modComponentFormState.uuid, }); dispatch(actions.setActiveModComponentId(modComponentFormState.uuid)); diff --git a/src/pageEditor/tabs/editTab/useReportTraceError.ts b/src/pageEditor/tabs/editTab/useReportTraceError.ts index 02078ed40b..5b7cf9177c 100644 --- a/src/pageEditor/tabs/editTab/useReportTraceError.ts +++ b/src/pageEditor/tabs/editTab/useReportTraceError.ts @@ -37,7 +37,7 @@ function useReportTraceError(): void { if (traceError && runId && runId !== prevRunId) { reportEvent(Events.PAGE_EDITOR_MOD_COMPONENT_ERROR, { sessionId, - extensionId: traceError.extensionId, + modComponentId: traceError.extensionId, }); } } diff --git a/src/pageEditor/toolbar/ReloadToolbar.tsx b/src/pageEditor/toolbar/ReloadToolbar.tsx index 59ec7d36e5..1b0bd1bff2 100644 --- a/src/pageEditor/toolbar/ReloadToolbar.tsx +++ b/src/pageEditor/toolbar/ReloadToolbar.tsx @@ -125,7 +125,7 @@ const ReloadToolbar: React.FunctionComponent<{ // Report before the run to report even if the run errors reportEvent(Events.PAGE_EDITOR_MANUAL_RUN, { sessionId, - extensionId: modComponentFormState.uuid, + modComponentId: modComponentFormState.uuid, }); await run(); diff --git a/src/runtime/pipelineTests/trace.test.ts b/src/runtime/pipelineTests/trace.test.ts index c8750301d9..5ede82ed19 100644 --- a/src/runtime/pipelineTests/trace.test.ts +++ b/src/runtime/pipelineTests/trace.test.ts @@ -235,7 +235,9 @@ describe("Trace normal execution", () => { instanceId, }; - const logger = new ConsoleLogger().childLogger({ extensionId }); + const logger = new ConsoleLogger().childLogger({ + modComponentId: extensionId, + }); await reducePipeline(blockConfig, simpleInput({ inputArg: "hello" }), { ...testOptions("v2"), @@ -300,7 +302,9 @@ describe("Trace normal execution", () => { }, ]; - const logger = new ConsoleLogger().childLogger({ extensionId }); + const logger = new ConsoleLogger().childLogger({ + modComponentId: extensionId, + }); await reducePipeline(blockConfig, simpleInput({ inputArg: "hello" }), { ...testOptions("v2"), @@ -353,7 +357,9 @@ describe("Trace normal execution", () => { }, ]; - const logger = new ConsoleLogger().childLogger({ extensionId }); + const logger = new ConsoleLogger().childLogger({ + modComponentId: extensionId, + }); await expect(async () => { await reducePipeline(blockConfig, simpleInput({ inputArg: "hello" }), { diff --git a/src/runtime/reducePipeline.ts b/src/runtime/reducePipeline.ts index cbebecd482..715ef0e0f1 100644 --- a/src/runtime/reducePipeline.ts +++ b/src/runtime/reducePipeline.ts @@ -570,7 +570,7 @@ async function runBrick( if (selectTraceEnabled(trace)) { getPlatform().debugger.traces.exit({ ...trace, - extensionId: logger.context.extensionId, + extensionId: logger.context.modComponentId, blockId: brick.id, isFinal: true, isRenderer: true, @@ -615,7 +615,7 @@ async function applyReduceDefaults({ const logger = providedLogger ?? new ConsoleLogger(); return { - extensionId: extensionId ?? logger.context.extensionId, + extensionId: extensionId ?? logger.context.modComponentId, validateInput: true, headless: false, // Default to the `apiVersion: v1, v2` data passing behavior and renderer behavior @@ -662,7 +662,7 @@ export async function brickReducer( runId, // Be defensive if the call site doesn't provide an extensionId // See: https://github.com/pixiebrix/pixiebrix-extension/issues/3751 - extensionId: extensionId ?? logger.context.extensionId, + extensionId: extensionId ?? logger.context.modComponentId, blockInstanceId: brickConfig.instanceId, branches, }, @@ -833,7 +833,7 @@ function throwBrickError( getPlatform().debugger.traces.exit({ runId, branches, - extensionId: logger.context.extensionId, + extensionId: logger.context.modComponentId, blockId: brickConfig.id, blockInstanceId: brickConfig.instanceId, error: serializeError(error), @@ -888,8 +888,8 @@ async function getBrickLogger( } return pipelineLogger.childLogger({ - blockId: brickConfig.id, - blockVersion: version, + brickId: brickConfig.id, + brickVersion: version, // Use the most customized name for the step label: brickConfig.label ?? @@ -909,7 +909,7 @@ export async function reduceModComponentPipeline( if (platform.capabilities.includes("debugger")) { try { - const { extensionId } = pipelineLogger.context; + const { modComponentId: extensionId } = pipelineLogger.context; if (extensionId) { // `await` promise to avoid race condition where the calls here delete entries from this call to reducePipeline @@ -962,7 +962,7 @@ export async function reducePipeline( isLastBlock: index === pipelineArray.length - 1, previousOutput: output, context: extendModVariableContext(localVariableContext, { - modId: pipelineLogger.context.blueprintId, + modId: pipelineLogger.context.modId, options, // Mod variable is updated when each block is run update: true, @@ -1035,7 +1035,7 @@ async function reducePipelineExpression( previousOutput: legacyOutput, // Assume @input and @options are present context: extendModVariableContext(context as BrickArgsContext, { - modId: pipelineLogger.context.blueprintId, + modId: pipelineLogger.context.modId, options, // Update mod variable when each block is run update: true, diff --git a/src/sidebar/PanelBody.test.tsx b/src/sidebar/PanelBody.test.tsx index 0de4c159de..ac0d89383e 100644 --- a/src/sidebar/PanelBody.test.tsx +++ b/src/sidebar/PanelBody.test.tsx @@ -50,7 +50,7 @@ describe("PanelBody", () => { , ); @@ -70,7 +70,7 @@ describe("PanelBody", () => { , ); @@ -90,7 +90,7 @@ describe("PanelBody", () => { , ); @@ -114,7 +114,7 @@ describe("PanelBody", () => { , ); @@ -141,7 +141,7 @@ describe("PanelBody", () => { , ); @@ -215,7 +215,7 @@ describe("PanelBody", () => { , ); diff --git a/src/sidebar/PanelBody.tsx b/src/sidebar/PanelBody.tsx index 12fb4a602f..d436d51ee4 100644 --- a/src/sidebar/PanelBody.tsx +++ b/src/sidebar/PanelBody.tsx @@ -182,7 +182,7 @@ const PanelBody: React.FunctionComponent<{ const logger = platform.logger.childLogger({ ...context, - blockId, + brickId: blockId, }); const branches = tracePath ? mapPathToTraceBranches(tracePath) : []; diff --git a/src/sidebar/RendererComponent.test.tsx b/src/sidebar/RendererComponent.test.tsx index 02335da2c0..db92d3bb3c 100644 --- a/src/sidebar/RendererComponent.test.tsx +++ b/src/sidebar/RendererComponent.test.tsx @@ -63,7 +63,7 @@ describe("RendererComponent", () => { const props = { body: [config], options: brickOptionsFactory({ - logger: new ConsoleLogger({ extensionId }), + logger: new ConsoleLogger({ modComponentId: extensionId }), meta: { runId, extensionId, diff --git a/src/sidebar/Tabs.tsx b/src/sidebar/Tabs.tsx index 0f8a8cdcac..62c961d801 100644 --- a/src/sidebar/Tabs.tsx +++ b/src/sidebar/Tabs.tsx @@ -316,8 +316,8 @@ const Tabs: React.FC = () => { onError={() => { reportEvent(Events.VIEW_ERROR, { panelType: panel.type, - extensionId: panel.extensionId, - blueprintId: panel.blueprintId, + modComponentId: panel.extensionId, + modId: panel.blueprintId, }); }} > @@ -336,9 +336,9 @@ const Tabs: React.FC = () => { payload={panel.payload} onAction={permanentSidebarPanelAction} context={{ - extensionId: panel.extensionId, - extensionPointId: panel.extensionPointId, - blueprintId: panel.blueprintId, + modComponentId: panel.extensionId, + starterBrickId: panel.extensionPointId, + modId: panel.blueprintId, }} /> @@ -355,8 +355,8 @@ const Tabs: React.FC = () => { onError={() => { reportEvent(Events.VIEW_ERROR, { panelType: form.type, - extensionId: form.extensionId, - blueprintId: form.blueprintId, + modComponentId: form.extensionId, + modId: form.blueprintId, }); }} > diff --git a/src/sidebar/TemporaryPanelTabPane.tsx b/src/sidebar/TemporaryPanelTabPane.tsx index f04f64d7a7..a0c277d38d 100644 --- a/src/sidebar/TemporaryPanelTabPane.tsx +++ b/src/sidebar/TemporaryPanelTabPane.tsx @@ -50,7 +50,12 @@ export const TemporaryPanelTabPane: React.FC<{ }, [dispatch, panel.nonce], ); - const { type, extensionId, blueprintId, payload } = panel; + const { + type, + extensionId: modComponentId, + blueprintId: modId, + payload, + } = panel; return ( { reportEvent(Events.VIEW_ERROR, { panelType: type, - extensionId, - blueprintId, + modComponentId, + modId, }); }} > @@ -75,8 +80,8 @@ export const TemporaryPanelTabPane: React.FC<{ isRootPanel={false} payload={payload} context={{ - extensionId, - blueprintId, + modComponentId, + modId, }} onAction={onAction} /> diff --git a/src/sidebar/activateMod/ActivateModInputs.tsx b/src/sidebar/activateMod/ActivateModInputs.tsx index c52ef0006a..58dcfc5f17 100644 --- a/src/sidebar/activateMod/ActivateModInputs.tsx +++ b/src/sidebar/activateMod/ActivateModInputs.tsx @@ -160,7 +160,7 @@ const ActivateModInputs: React.FC = ({ variant="outline-danger" onClick={() => { reportEvent(Events.MOD_ACTIVATION_CANCEL, { - recipeId: normalizedMod?.metadata?.id, + modId: normalizedMod?.metadata?.id, }); onClickCancel(); }} @@ -171,7 +171,7 @@ const ActivateModInputs: React.FC = ({ type="submit" onClick={() => { reportEvent(Events.MOD_ACTIVATION_SUBMIT, { - recipeId: normalizedMod?.metadata?.id, + modId: normalizedMod?.metadata?.id, }); return true; }} diff --git a/src/starterBricks/button/buttonStarterBrick.ts b/src/starterBricks/button/buttonStarterBrick.ts index 2ac081032d..1c388c90ab 100644 --- a/src/starterBricks/button/buttonStarterBrick.ts +++ b/src/starterBricks/button/buttonStarterBrick.ts @@ -759,8 +759,8 @@ export abstract class ButtonStarterBrickABC extends StarterBrickABC { markTourStart( nonce, { id: modComponentId, label: "Ad-hoc", _recipe: undefined }, - { abortController, context: { extensionId: modComponentId } }, + { abortController, context: { modComponentId: modComponentId } }, ); expect(isTourInProgress()).toBe(true); - markTourEnd(nonce, { context: { extensionId: modComponentId } }); + markTourEnd(nonce, { context: { modComponentId: modComponentId } }); expect(isTourInProgress()).toBe(false); }); @@ -54,7 +54,7 @@ describe("tourController", () => { markTourStart( nonce, { id: modComponentId, label: "Ad-hoc", _recipe: undefined }, - { abortController, context: { extensionId: modComponentId } }, + { abortController, context: { modComponentId: modComponentId } }, ); expect(isTourInProgress()).toBe(true); diff --git a/src/starterBricks/types.ts b/src/starterBricks/types.ts index e51f5a0ebf..dc47457afd 100644 --- a/src/starterBricks/types.ts +++ b/src/starterBricks/types.ts @@ -226,7 +226,7 @@ export abstract class StarterBrickABC this.description = metadata.description; this.instanceNonce = uuidv4(); this.logger = this.platform.logger.childLogger({ - extensionPointId: this.id, + starterBrickId: this.id, }); } diff --git a/src/store/extensionsSlice.ts b/src/store/extensionsSlice.ts index a98d8d40ef..19cdd5e85c 100644 --- a/src/store/extensionsSlice.ts +++ b/src/store/extensionsSlice.ts @@ -174,8 +174,8 @@ const extensionsSlice = createSlice({ } reportEvent(Events.MOD_ACTIVATE, { - blueprintId: modDefinition.metadata.id, - blueprintVersion: modDefinition.metadata.version, + modId: modDefinition.metadata.id, + modVersion: modDefinition.metadata.version, deploymentId: deployment?.id, screen, reinstall: isReactivate, diff --git a/src/telemetry/deployments.ts b/src/telemetry/deployments.ts index eb05edadd7..19d61693b0 100644 --- a/src/telemetry/deployments.ts +++ b/src/telemetry/deployments.ts @@ -18,26 +18,26 @@ export function selectEventData( if (modComponent._deployment) { return { label: modComponent.label, - extensionId: modComponent.id, + modComponentId: modComponent.id, deploymentId: modComponent._deployment?.id, - extensionPointId: isRegistryId(modComponent.extensionPointId) + starterBrickId: isRegistryId(modComponent.extensionPointId) ? modComponent.extensionPointId : undefined, - blueprintId: modComponent._recipe?.id, - blueprintVersion: modComponent._recipe?.version, + modId: modComponent._recipe?.id, + modVersion: modComponent._recipe?.version, }; } if (modComponent._recipe) { return { label: modComponent.label, - extensionId: modComponent.id, - blueprintId: modComponent._recipe?.id, - blueprintVersion: modComponent._recipe?.version, + modComponentId: modComponent.id, + modId: modComponent._recipe?.id, + modVersion: modComponent._recipe?.version, }; } return { - extensionId: modComponent.id, + modComponentId: modComponent.id, }; } diff --git a/src/telemetry/events.ts b/src/telemetry/events.ts index 9428dd7f46..80040b69e6 100644 --- a/src/telemetry/events.ts +++ b/src/telemetry/events.ts @@ -168,3 +168,21 @@ export const Events = { } as const; export type Event = (typeof Events)[keyof typeof Events]; + +export const reservedKeys = [ + "blockId", + "blockVersion", + "blueprintId", + "blueprintVersion", + "extensionId", + "extensionLabel", + "extensionPointId", + "extensions", + "recipeId", + "serviceId", + "serviceVersion", +] as const; + +export type ReservedKeys = { + [K in (typeof reservedKeys)[number]]?: unknown; +}; diff --git a/src/telemetry/logging.test.ts b/src/telemetry/logging.test.ts index f6f199d0dc..d63e8601c9 100644 --- a/src/telemetry/logging.test.ts +++ b/src/telemetry/logging.test.ts @@ -95,13 +95,13 @@ describe("logging", () => { await appendEntry( logEntryFactory({ - context: messageContextFactory({ blueprintId }), + context: messageContextFactory({ modId: blueprintId }), }), ); await appendEntry(logEntryFactory()); - await clearLog({ blueprintId }); + await clearLog({ modId: blueprintId }); await expect(count()).resolves.toBe(1); }); @@ -124,13 +124,13 @@ describe("logging", () => { await appendEntry( logEntryFactory({ - context: messageContextFactory({ blueprintId }), + context: messageContextFactory({ modId: blueprintId }), }), ); await appendEntry(logEntryFactory()); - await expect(getLogEntries({ blueprintId })).resolves.toStrictEqual([ + await expect(getLogEntries({ modId: blueprintId })).resolves.toStrictEqual([ expect.objectContaining({ context: expect.objectContaining({ blueprintId }), }), diff --git a/src/telemetry/logging.ts b/src/telemetry/logging.ts index 199b4b1232..a318e35e54 100644 --- a/src/telemetry/logging.ts +++ b/src/telemetry/logging.ts @@ -103,10 +103,10 @@ type IndexKey = keyof Except< | "deploymentId" | "label" | "pageName" - | "blueprintVersion" - | "blockVersion" - | "serviceVersion" - | "extensionLabel" + | "modVersion" + | "brickVersion" + | "integrationVersion" + | "modComponentLabel" | "platformName" | "url" | "connectionType" @@ -114,11 +114,11 @@ type IndexKey = keyof Except< >; const INDEX_KEYS = [ - "extensionId", - "blueprintId", - "blockId", - "extensionPointId", - "serviceId", + "modComponentId", + "modId", + "brickId", + "starterBrickId", + "integrationId", "authId", ] as const satisfies IndexKey[]; diff --git a/src/telemetry/reportEvent.ts b/src/telemetry/reportEvent.ts index f0fb6fa4d0..84d013f757 100644 --- a/src/telemetry/reportEvent.ts +++ b/src/telemetry/reportEvent.ts @@ -16,7 +16,7 @@ */ import { backgroundTarget as bg, getNotifier } from "webext-messenger"; -import { type Event } from "@/telemetry/events"; +import { type Event, type ReservedKeys } from "@/telemetry/events"; import { expectContext } from "@/utils/expectContext"; expectContext( @@ -27,15 +27,60 @@ expectContext( // Private method. Do not move to api.ts const _record = getNotifier("RECORD_EVENT", bg); +function transformEventData(data: UnknownObject): UnknownObject { + if (data.brickId) { + data.blockId = data.brickId; + } + + if (data.brickVersion) { + data.blockVersion = data.brickVersion; + } + + if (data.integrationId) { + data.serviceId = data.integrationId; + } + + if (data.integrationVersion) { + data.serviceVersion = data.integrationVersion; + } + + if (data.modId) { + data.blueprintId = data.modId; + data.recipeId = data.modId; + } + + if (data.modVersion) { + data.blueprintVersion = data.modVersion; + } + + if (data.modComponentId) { + data.extensionId = data.modComponentId; + } + + if (data.modComponentLabel) { + data.extensionLabel = data.modComponentLabel; + } + + if (data.modComponents) { + data.extensions = data.modComponents; + } + + if (data.starterBrickId) { + data.extensionPointId = data.starterBrickId; + } + + return data; +} + /** * Report an event to the PixieBrix telemetry service, if the user doesn't have DNT set. * @see selectEventData */ -export default function reportEvent( +export default function reportEvent( event: Event, - data: UnknownObject = {}, + data: TData extends ReservedKeys ? never : TData = {} as never, ): void { // eslint-disable-next-line prefer-rest-params -- Needs `arguments` to avoid printing the default console.debug(...arguments); - _record({ event, data }); + _record({ event, data: transformEventData(data) }); } diff --git a/src/testUtils/factories/logFactories.ts b/src/testUtils/factories/logFactories.ts index ede6d243a1..df5df91521 100644 --- a/src/testUtils/factories/logFactories.ts +++ b/src/testUtils/factories/logFactories.ts @@ -24,7 +24,7 @@ import { import { type MessageContext } from "@/types/loggerTypes"; export const messageContextFactory = define({ - extensionId: uuidSequence, + modComponentId: uuidSequence, }); export const logEntryFactory = define({ diff --git a/src/testUtils/factories/runtimeFactories.ts b/src/testUtils/factories/runtimeFactories.ts index f8a3d66c0d..7c97d17197 100644 --- a/src/testUtils/factories/runtimeFactories.ts +++ b/src/testUtils/factories/runtimeFactories.ts @@ -35,7 +35,7 @@ export const brickOptionsFactory = define({ platform: () => contentScriptPlatform, logger: (i: number) => new ConsoleLogger({ - extensionId: uuidSequence(i), + modComponentId: uuidSequence(i), }), root: (_i: number) => document, runPipeline: (_i: number) => @@ -47,7 +47,7 @@ export const brickOptionsFactory = define({ meta: derive( (options) => ({ runId: null, - extensionId: options.logger?.context.extensionId, + extensionId: options.logger?.context.modComponentId, branches: [], }), "logger", diff --git a/src/types/loggerTypes.ts b/src/types/loggerTypes.ts index c424e887d8..c72afc0462 100644 --- a/src/types/loggerTypes.ts +++ b/src/types/loggerTypes.ts @@ -28,24 +28,24 @@ export type MessageContext = { * A human-readable label, e.g., provided via a `label:` directive to help identify the step context when there's * multiple blocks with the same id being used. * - * @see MessageContext.extensionLabel + * @see MessageContext.modComponentLabel */ readonly label?: string; readonly deploymentId?: UUID; - readonly blueprintId?: RegistryId; - readonly blueprintVersion?: SemVerString; - readonly extensionPointId?: RegistryId; - readonly blockId?: RegistryId; - readonly blockVersion?: SemVerString; - readonly extensionId?: UUID; + readonly modId?: RegistryId; + readonly modVersion?: SemVerString; + readonly starterBrickId?: RegistryId; + readonly brickId?: RegistryId; + readonly brickVersion?: SemVerString; + readonly modComponentId?: UUID; /** * The human-readable label for the extension. Used to identify the extension when reporting telemetry from a * blueprint. (Each extension install has a different UUID) * @since 1.6.2 */ - readonly extensionLabel?: string; - readonly serviceId?: RegistryId; - readonly serviceVersion?: SemVerString; + readonly modComponentLabel?: string; + readonly integrationId?: RegistryId; + readonly integrationVersion?: SemVerString; readonly authId?: UUID; readonly pageName?: ContextName | "unknown"; readonly url?: string; diff --git a/src/types/sidebarTypes.ts b/src/types/sidebarTypes.ts index 144cbe8ab0..5b38929da6 100644 --- a/src/types/sidebarTypes.ts +++ b/src/types/sidebarTypes.ts @@ -71,8 +71,8 @@ export function isRendererErrorPayload( * Context for panel, with fields required for functionality marked as required. */ export type PanelContext = MessageContext & { - extensionId: UUID; - blueprintId: RegistryId | null; + modComponentId: UUID; + modId: RegistryId | null; }; /** From 44cdc096bd4695dd370fa5c0ad610a9360d3df81 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 1 Jul 2024 15:27:08 -0500 Subject: [PATCH 02/14] fix remaining ts errors --- src/background/deploymentUpdater.ts | 2 +- src/background/messenger/registration.ts | 6 +++--- src/bricks/effects/tourEffect.ts | 4 ++-- src/pageEditor/hooks/useResetModComponent.ts | 2 +- src/sidebar/Tabs.tsx | 2 +- src/telemetry/events.ts | 1 + src/telemetry/logging.ts | 20 ++++++++++---------- src/telemetry/reportEvent.ts | 12 ++++++++---- 8 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/background/deploymentUpdater.ts b/src/background/deploymentUpdater.ts index cb956b1284..5b60b68870 100644 --- a/src/background/deploymentUpdater.ts +++ b/src/background/deploymentUpdater.ts @@ -169,7 +169,7 @@ export async function deactivateAllDeployedMods(): Promise { optionsState, }); - reportEvent("DeploymentDeactivateAll", { + reportEvent(Events.DEPLOYMENT_DEACTIVATE_ALL, { auto: true, deployments: modComponentsToDeactivate.map((x) => x._deployment.id), }); diff --git a/src/background/messenger/registration.ts b/src/background/messenger/registration.ts index 0122e00c84..88123bd662 100644 --- a/src/background/messenger/registration.ts +++ b/src/background/messenger/registration.ts @@ -41,7 +41,7 @@ import * as registry from "@/registry/packageRegistry"; import serviceRegistry from "@/integrations/registry"; import { getUserData } from "@/auth/authStorage"; import { - clearExtensionDebugLogs, + clearModComponentDebugLogs, clearLog, clearLogs, recordError, @@ -108,7 +108,7 @@ declare global { RECORD_ERROR: typeof recordError; CLEAR_LOGS: typeof clearLogs; CLEAR_LOG: typeof clearLog; - CLEAR_EXTENSION_DEBUG_LOGS: typeof clearExtensionDebugLogs; + CLEAR_EXTENSION_DEBUG_LOGS: typeof clearModComponentDebugLogs; LOCATE_SERVICES_FOR_ID: typeof locator.locateAllForService; LOCATE_SERVICE: typeof locator.locate; @@ -181,7 +181,7 @@ export default function registerMessenger(): void { RECORD_ERROR: recordError, CLEAR_LOGS: clearLogs, CLEAR_LOG: clearLog, - CLEAR_EXTENSION_DEBUG_LOGS: clearExtensionDebugLogs, + CLEAR_EXTENSION_DEBUG_LOGS: clearModComponentDebugLogs, LOCATE_SERVICES_FOR_ID: locator.locateAllForService.bind(locator), LOCATE_SERVICE: locator.locate.bind(locator), diff --git a/src/bricks/effects/tourEffect.ts b/src/bricks/effects/tourEffect.ts index c98aa3d3be..40bdd57577 100644 --- a/src/bricks/effects/tourEffect.ts +++ b/src/bricks/effects/tourEffect.ts @@ -133,7 +133,7 @@ export class TourEffect extends EffectABC { ); } - const { extensionId } = logger.context; + const { modComponentId } = logger.context; const abortController = new AbortController(); const stylesheetLink = await injectStylesheet(stylesheetUrl); @@ -166,7 +166,7 @@ export class TourEffect extends EffectABC { ); } - assertNotNullish(extensionId, "extensionId is required to run a tour"); + assertNotNullish(modComponentId, "extensionId is required to run a tour"); const tour = introJs() .setOptions({ diff --git a/src/pageEditor/hooks/useResetModComponent.ts b/src/pageEditor/hooks/useResetModComponent.ts index 7f601bcc4b..b217f2a807 100644 --- a/src/pageEditor/hooks/useResetModComponent.ts +++ b/src/pageEditor/hooks/useResetModComponent.ts @@ -58,7 +58,7 @@ function useResetModComponent(): (useResetConfig: Config) => Promise { reportEvent(Events.PAGE_EDITOR_RESET, { sessionId, - extensionId: modComponentId, + modComponentId, }); try { diff --git a/src/sidebar/Tabs.tsx b/src/sidebar/Tabs.tsx index 62c961d801..17ea8fab7c 100644 --- a/src/sidebar/Tabs.tsx +++ b/src/sidebar/Tabs.tsx @@ -392,7 +392,7 @@ const Tabs: React.FC = () => { reportEvent(Events.VIEW_ERROR, { panelType: "activate", // For backward compatability, provide a single modId to the recipeToActivate property - recipeToActivate: modActivationPanel.mods[0].modId, + modToActivate: modActivationPanel.mods[0].modId, modCount: modActivationPanel.mods.length, modIds: modActivationPanel.mods.map((x) => x.modId), }); diff --git a/src/telemetry/events.ts b/src/telemetry/events.ts index 80040b69e6..77dcaf7895 100644 --- a/src/telemetry/events.ts +++ b/src/telemetry/events.ts @@ -179,6 +179,7 @@ export const reservedKeys = [ "extensionPointId", "extensions", "recipeId", + "recipeToActivate", "serviceId", "serviceVersion", ] as const; diff --git a/src/telemetry/logging.ts b/src/telemetry/logging.ts index a318e35e54..c53c56c0b5 100644 --- a/src/telemetry/logging.ts +++ b/src/telemetry/logging.ts @@ -88,11 +88,11 @@ interface LogDB extends DBSchema { value: LogEntry; key: string; indexes: { - extensionId: string; - blueprintId: string; - blockId: string; - extensionPointId: string; - serviceId: string; + modComponentId: string; + modId: string; + brickId: string; + starterBrickId: string; + integrationId: string; authId: string; }; }; @@ -496,17 +496,17 @@ export async function setLoggingConfig(config: LoggingConfig): Promise { } /** - * Clear all debug and trace level logs for the given extension. + * Clear all debug and trace level logs for the given mod component. */ -export async function clearExtensionDebugLogs( - extensionId: UUID, +export async function clearModComponentDebugLogs( + modComponentId: UUID, ): Promise { const db = await openLoggingDB(); try { const tx = db.transaction(ENTRY_OBJECT_STORE, "readwrite"); - const index = tx.store.index("extensionId"); - for await (const cursor of index.iterate(extensionId)) { + const index = tx.store.index("modComponentId"); + for await (const cursor of index.iterate(modComponentId)) { if (cursor.value.level === "debug" || cursor.value.level === "trace") { await cursor.delete(); } diff --git a/src/telemetry/reportEvent.ts b/src/telemetry/reportEvent.ts index 84d013f757..f92d36d61e 100644 --- a/src/telemetry/reportEvent.ts +++ b/src/telemetry/reportEvent.ts @@ -49,10 +49,6 @@ function transformEventData(data: UnknownObject): UnknownObject { data.recipeId = data.modId; } - if (data.modVersion) { - data.blueprintVersion = data.modVersion; - } - if (data.modComponentId) { data.extensionId = data.modComponentId; } @@ -65,6 +61,14 @@ function transformEventData(data: UnknownObject): UnknownObject { data.extensions = data.modComponents; } + if (data.modToActivate) { + data.recipeToActivate = data.modToActivate; + } + + if (data.modVersion) { + data.blueprintVersion = data.modVersion; + } + if (data.starterBrickId) { data.extensionPointId = data.starterBrickId; } From 18d7fe61d41d4a59ddfc92e17081b5f139961c90 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 1 Jul 2024 15:29:38 -0500 Subject: [PATCH 03/14] block/service -> brick/integration --- src/components/logViewer/LogTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/logViewer/LogTable.tsx b/src/components/logViewer/LogTable.tsx index 4e3b8cb973..42d2b02575 100644 --- a/src/components/logViewer/LogTable.tsx +++ b/src/components/logViewer/LogTable.tsx @@ -32,7 +32,7 @@ const LogTable: React.FunctionComponent<{ Timestamp Level Label - Block/Service + Brick/Integration Message/Error From d452a0b4d0791eaac7b93f1413e912fb479b3620 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 8 Jul 2024 13:06:08 -0500 Subject: [PATCH 04/14] fix merge issues --- src/__snapshots__/Storyshots.test.js.snap | 6 ++-- .../removeModComponentForEveryTab.ts | 2 +- .../effects/AddDynamicTextSnippet.test.ts | 8 ++--- src/bricks/effects/assignModVariable.test.ts | 4 +-- src/bricks/effects/assignModVariable.ts | 2 +- src/bricks/effects/pageState.ts | 2 +- src/bricks/effects/tourEffect.ts | 5 ++- src/bricks/renderers/customForm.tsx | 2 +- .../DisplayTemporaryInfo.test.ts | 10 +++--- .../temporaryInfo/EphemeralPanel.tsx | 7 ++-- .../IntegrationDependencyWidget.tsx | 10 +++++- .../__snapshots__/LogCard.test.tsx.snap | 2 +- src/mods/hooks/useDeactivateAction.ts | 4 +-- src/pageEditor/hooks/useDeactivateMod.tsx | 2 +- src/sidebar/Tabs.tsx | 4 ++- src/sidebar/TemporaryPanelTabPane.tsx | 2 +- .../trigger/triggerStarterBrick.test.ts | 2 +- src/telemetry/logging.test.ts | 18 +++++----- src/telemetry/telemetryHelpers.test.ts | 12 +++---- src/testUtils/factories/runtimeFactories.ts | 5 +-- src/types/sidebarTypes.ts | 1 - src/utils/modUtils.ts | 33 ++++++++++--------- 22 files changed, 81 insertions(+), 62 deletions(-) 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, }; } From 3aeb5ff3097816d6e4438d92d954935c10c88846 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 8 Jul 2024 13:21:58 -0500 Subject: [PATCH 05/14] renaming --- .../RunMetadataTransformer.test.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/bricks/transformers/RunMetadataTransformer.test.ts b/src/bricks/transformers/RunMetadataTransformer.test.ts index 04fb3af324..7a6e5e7f23 100644 --- a/src/bricks/transformers/RunMetadataTransformer.test.ts +++ b/src/bricks/transformers/RunMetadataTransformer.test.ts @@ -29,9 +29,9 @@ const brick = new RunMetadataTransformer(); describe("RunMetadataTransformer", () => { it("returns standalone mod metadata", async () => { - const extensionId = autoUUIDSequence(); + const modComponentId = autoUUIDSequence(); const logger = new ConsoleLogger({ - modComponentId: extensionId, + modComponentId, }); const result = await brick.run( @@ -42,7 +42,7 @@ describe("RunMetadataTransformer", () => { ); expect(result).toEqual({ - modComponentId: extensionId, + modComponentId, deploymentId: null, mod: null, runId: null, @@ -50,11 +50,11 @@ describe("RunMetadataTransformer", () => { }); it("returns packaged mod metadata", async () => { - const extensionId = autoUUIDSequence(); - const registryId = registryIdFactory(); + const modComponentId = autoUUIDSequence(); + const modId = registryIdFactory(); const logger = new ConsoleLogger({ - modComponentId: extensionId, - modId: registryId, + modComponentId, + modId, modVersion: "1.0.0" as SemVerString, }); @@ -66,10 +66,10 @@ describe("RunMetadataTransformer", () => { ); expect(result).toEqual({ - modComponentId: extensionId, + modComponentId, deploymentId: null, mod: { - id: registryId, + id: modId, version: "1.0.0", }, runId: null, @@ -77,14 +77,14 @@ describe("RunMetadataTransformer", () => { }); it("returns deployed mod metadata", async () => { - const extensionId = autoUUIDSequence(); + const modComponentId = autoUUIDSequence(); const deploymentId = autoUUIDSequence(); - const registryId = registryIdFactory(); + const modId = registryIdFactory(); const runId = autoUUIDSequence(); const logger = new ConsoleLogger({ - modComponentId: extensionId, - modId: registryId, + modComponentId, + modId, modVersion: "1.0.0" as SemVerString, deploymentId, }); @@ -95,17 +95,17 @@ describe("RunMetadataTransformer", () => { logger, meta: { runId, - extensionId, + extensionId: modComponentId, branches: [], }, }), ); expect(result).toEqual({ - modComponentId: extensionId, + modComponentId, deploymentId, mod: { - id: registryId, + id: modId, version: "1.0.0", }, runId, From 5fe5c410ed6f91182d7863ff90def13c34de2310 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 8 Jul 2024 13:28:27 -0500 Subject: [PATCH 06/14] renaming --- src/sidebar/PanelBody.test.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sidebar/PanelBody.test.tsx b/src/sidebar/PanelBody.test.tsx index ac0d89383e..01b7c0421e 100644 --- a/src/sidebar/PanelBody.test.tsx +++ b/src/sidebar/PanelBody.test.tsx @@ -30,8 +30,8 @@ import { } from "@/types/rendererTypes"; import { screen } from "shadow-dom-testing-library"; -const extensionId = uuidv4(); -const blueprintId = registryIdFactory(); +const modComponentId = uuidv4(); +const modId = registryIdFactory(); describe("PanelBody", () => { beforeAll(() => { @@ -43,14 +43,14 @@ describe("PanelBody", () => { key: uuidv4(), error: serializeError(new Error("test error")), runId: uuidv4(), - extensionId, + extensionId: modComponentId, }; const { asFragment } = render( , ); @@ -63,14 +63,14 @@ describe("PanelBody", () => { key: uuidv4(), error: serializeError(new BusinessError("test error")), runId: uuidv4(), - extensionId, + extensionId: modComponentId, }; const { asFragment } = render( , ); @@ -83,14 +83,14 @@ describe("PanelBody", () => { key: uuidv4(), error: serializeError(new CancelError("test error")), runId: uuidv4(), - extensionId, + extensionId: modComponentId, }; const { asFragment } = render( , ); @@ -102,7 +102,7 @@ describe("PanelBody", () => { const payload: RendererRunPayload = { key: uuidv4(), runId: uuidv4(), - extensionId, + extensionId: modComponentId, blockId: validateRegistryId("@pixiebrix/html"), args: { html: "

Test

", @@ -114,7 +114,7 @@ describe("PanelBody", () => { , ); @@ -129,7 +129,7 @@ describe("PanelBody", () => { const payload: RendererRunPayload = { key: uuidv4(), runId: uuidv4(), - extensionId, + extensionId: modComponentId, blockId: validateRegistryId("@pixiebrix/html"), args: { html: "

Test

", @@ -141,7 +141,7 @@ describe("PanelBody", () => { , ); @@ -157,7 +157,7 @@ describe("PanelBody", () => { const payload: RendererRunPayload = { key: uuidv4(), runId: uuidv4(), - extensionId, + extensionId: modComponentId, blockId: validateRegistryId("@pixiebrix/document"), args: { body: [ @@ -215,7 +215,7 @@ describe("PanelBody", () => { , ); From 6991d35f2a2e6b5da5a24f8ba200ddf04cdd269c Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 8 Jul 2024 13:49:35 -0500 Subject: [PATCH 07/14] fix tests --- src/testUtils/factories/runtimeFactories.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/testUtils/factories/runtimeFactories.ts b/src/testUtils/factories/runtimeFactories.ts index e799575bf3..a093b4a774 100644 --- a/src/testUtils/factories/runtimeFactories.ts +++ b/src/testUtils/factories/runtimeFactories.ts @@ -20,6 +20,7 @@ import { define, derive } from "cooky-cutter"; import ConsoleLogger from "@/utils/ConsoleLogger"; import contentScriptPlatform from "@/contentScript/contentScriptPlatform"; import { modComponentRefFactory } from "@/testUtils/factories/modComponentFactories"; +import { mapModComponentRefToMessageContext } from "@/utils/modUtils"; /** * Factory for BrickOptions to pass to Brick.run method. @@ -34,13 +35,11 @@ export const brickOptionsFactory = define({ }, platform: (_i: number) => contentScriptPlatform, logger(_i: number) { - const { blueprintId, extensionId, ...rest } = modComponentRefFactory(); + const modComponentRef = modComponentRefFactory(); // MessageContext expects undefined instead of null for blueprintId - return new ConsoleLogger({ - ...rest, - modComponentId: extensionId, - modId: blueprintId ?? undefined, - }); + return new ConsoleLogger( + mapModComponentRefToMessageContext(modComponentRef), + ); }, root: (_i: number) => document, runPipeline: (_i: number) => From 0a8acccb5c4ddd36a12bdd1705cb730e5fbc4a93 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Mon, 8 Jul 2024 15:08:11 -0500 Subject: [PATCH 08/14] remove unused export --- src/telemetry/events.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/telemetry/events.ts b/src/telemetry/events.ts index 77dcaf7895..b89c4908b7 100644 --- a/src/telemetry/events.ts +++ b/src/telemetry/events.ts @@ -169,7 +169,7 @@ export const Events = { export type Event = (typeof Events)[keyof typeof Events]; -export const reservedKeys = [ +const RESERVED_KEYS = [ "blockId", "blockVersion", "blueprintId", @@ -185,5 +185,5 @@ export const reservedKeys = [ ] as const; export type ReservedKeys = { - [K in (typeof reservedKeys)[number]]?: unknown; + [K in (typeof RESERVED_KEYS)[number]]?: unknown; }; From 482f52abaf0cb6c47b93a7dce497975ca6344615 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Tue, 9 Jul 2024 08:54:15 -0500 Subject: [PATCH 09/14] improve typing --- src/telemetry/events.ts | 6 ++++-- src/telemetry/reportEvent.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/telemetry/events.ts b/src/telemetry/events.ts index b89c4908b7..b707750773 100644 --- a/src/telemetry/events.ts +++ b/src/telemetry/events.ts @@ -184,6 +184,8 @@ const RESERVED_KEYS = [ "serviceVersion", ] as const; -export type ReservedKeys = { - [K in (typeof RESERVED_KEYS)[number]]?: unknown; +type ReservedKeys = { + [K in (typeof RESERVED_KEYS)[number]]?: never; }; + +export type ReportEventData = UnknownObject & ReservedKeys; diff --git a/src/telemetry/reportEvent.ts b/src/telemetry/reportEvent.ts index f92d36d61e..5ef66d7c2d 100644 --- a/src/telemetry/reportEvent.ts +++ b/src/telemetry/reportEvent.ts @@ -16,7 +16,7 @@ */ import { backgroundTarget as bg, getNotifier } from "webext-messenger"; -import { type Event, type ReservedKeys } from "@/telemetry/events"; +import { type Event, type ReportEventData } from "@/telemetry/events"; import { expectContext } from "@/utils/expectContext"; expectContext( @@ -82,7 +82,7 @@ function transformEventData(data: UnknownObject): UnknownObject { */ export default function reportEvent( event: Event, - data: TData extends ReservedKeys ? never : TData = {} as never, + data: ReportEventData = {}, ): void { // eslint-disable-next-line prefer-rest-params -- Needs `arguments` to avoid printing the default console.debug(...arguments); From 3bd672df65d8a0bd2fd9e9abcd4973ff978e1121 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Tue, 9 Jul 2024 09:02:45 -0500 Subject: [PATCH 10/14] refactoring --- src/background/telemetry.test.ts | 8 ++-- src/background/telemetry.ts | 4 +- src/hooks/useUserAction.ts | 4 +- src/telemetry/events.ts | 23 ----------- src/telemetry/initErrorReporter.ts | 2 +- src/telemetry/reportEvent.ts | 59 ++++----------------------- src/telemetry/telemetryHelpers.ts | 64 ++++++++++++++++++++++++------ src/telemetry/telemetryTypes.ts | 54 +++++++++++++++++++++++++ src/tinyPages/offscreen.ts | 2 +- 9 files changed, 123 insertions(+), 97 deletions(-) create mode 100644 src/telemetry/telemetryTypes.ts diff --git a/src/background/telemetry.test.ts b/src/background/telemetry.test.ts index db43b94de7..771afb6008 100644 --- a/src/background/telemetry.test.ts +++ b/src/background/telemetry.test.ts @@ -21,7 +21,7 @@ import { TEST_flushAll, } from "@/background/telemetry"; import { appApiMock } from "@/testUtils/appApiMock"; -import { type Event } from "@/telemetry/events"; +import { type TelemetryEvent } from "@/telemetry/telemetryTypes"; const EXPECTED_RUNTIME_ID = "abc123"; const expectedManifestValues = { @@ -53,13 +53,13 @@ beforeEach(async () => { describe("recordEvent", () => { test("runs", async () => { - await recordEvent({ event: "TestEvent" as Event, data: {} }); + await recordEvent({ event: "TestEvent" as TelemetryEvent, data: {} }); const events = await flushEvents(); expect(events).toHaveLength(1); }); test("includes expected default properties", async () => { - const testEvent = { event: "TestEvent" as Event, data: {} }; + const testEvent = { event: "TestEvent" as TelemetryEvent, data: {} }; await recordEvent(testEvent); const events = await flushEvents(); expect(events[0]).toMatchObject({ @@ -76,7 +76,7 @@ describe("recordEvent", () => { test("successfully persists concurrent telemetry events to local storage", async () => { // Easiest way to test race condition without having to mock const recordTestEvents = Array.from({ length: 100 }, async () => - recordEvent({ event: "TestEvent" as Event, data: {} }), + recordEvent({ event: "TestEvent" as TelemetryEvent, data: {} }), ); await Promise.all(recordTestEvents); diff --git a/src/background/telemetry.ts b/src/background/telemetry.ts index 797cee2082..4e1018dac4 100644 --- a/src/background/telemetry.ts +++ b/src/background/telemetry.ts @@ -30,7 +30,7 @@ import { count as logSize } from "@/telemetry/logging"; import { count as traceSize } from "@/telemetry/trace"; import { getUUID } from "@/telemetry/telemetryHelpers"; import { getExtensionVersion, getTabsWithAccess } from "@/utils/extensionUtils"; -import { type Event } from "@/telemetry/events"; +import { type TelemetryEvent } from "@/telemetry/telemetryTypes"; const EVENT_BUFFER_DEBOUNCE_MS = 2000; const EVENT_BUFFER_MAX_MS = 10_000; @@ -333,7 +333,7 @@ export async function recordEvent({ event, data = {}, }: { - event: Event; + event: TelemetryEvent; data: UnknownObject | undefined; }): Promise { if (await allowsTrack()) { diff --git a/src/hooks/useUserAction.ts b/src/hooks/useUserAction.ts index 7636474575..668e5f1b35 100644 --- a/src/hooks/useUserAction.ts +++ b/src/hooks/useUserAction.ts @@ -17,12 +17,12 @@ import { type DependencyList, useCallback } from "react"; import notify from "@/utils/notify"; -import { type Event } from "@/telemetry/events"; +import { type TelemetryEvent } from "@/telemetry/telemetryTypes"; import { CancelError } from "@/errors/businessErrors"; import reportEvent from "@/telemetry/reportEvent"; type Options = { - event?: Event; + event?: TelemetryEvent; errorMessage?: string; successMessage?: string; }; diff --git a/src/telemetry/events.ts b/src/telemetry/events.ts index b707750773..15bd4ab1cb 100644 --- a/src/telemetry/events.ts +++ b/src/telemetry/events.ts @@ -166,26 +166,3 @@ export const Events = { SHORTCUT_SNIPPET_RUN: "TextCommandRun", } as const; - -export type Event = (typeof Events)[keyof typeof Events]; - -const RESERVED_KEYS = [ - "blockId", - "blockVersion", - "blueprintId", - "blueprintVersion", - "extensionId", - "extensionLabel", - "extensionPointId", - "extensions", - "recipeId", - "recipeToActivate", - "serviceId", - "serviceVersion", -] as const; - -type ReservedKeys = { - [K in (typeof RESERVED_KEYS)[number]]?: never; -}; - -export type ReportEventData = UnknownObject & ReservedKeys; diff --git a/src/telemetry/initErrorReporter.ts b/src/telemetry/initErrorReporter.ts index 47e1ffb7ac..047ccc7867 100644 --- a/src/telemetry/initErrorReporter.ts +++ b/src/telemetry/initErrorReporter.ts @@ -25,8 +25,8 @@ import type { LogsEvent } from "@datadog/browser-logs/src/logsEvent.types"; import { cleanDatadogVersionName, mapAppUserToTelemetryUser, - type TelemetryUser, } from "@/telemetry/telemetryHelpers"; +import { type TelemetryUser } from "@/telemetry/telemetryTypes"; // eslint-disable-next-line prefer-destructuring -- process.env const ENVIRONMENT = process.env.ENVIRONMENT; diff --git a/src/telemetry/reportEvent.ts b/src/telemetry/reportEvent.ts index 5ef66d7c2d..632928c98b 100644 --- a/src/telemetry/reportEvent.ts +++ b/src/telemetry/reportEvent.ts @@ -16,8 +16,12 @@ */ import { backgroundTarget as bg, getNotifier } from "webext-messenger"; -import { type Event, type ReportEventData } from "@/telemetry/events"; import { expectContext } from "@/utils/expectContext"; +import { + type TelemetryEvent, + type ReportEventData, +} from "@/telemetry/telemetryTypes"; +import { mapEventDataToDeprecatedTerminology } from "@/telemetry/telemetryHelpers"; expectContext( "extension", @@ -27,64 +31,15 @@ expectContext( // Private method. Do not move to api.ts const _record = getNotifier("RECORD_EVENT", bg); -function transformEventData(data: UnknownObject): UnknownObject { - if (data.brickId) { - data.blockId = data.brickId; - } - - if (data.brickVersion) { - data.blockVersion = data.brickVersion; - } - - if (data.integrationId) { - data.serviceId = data.integrationId; - } - - if (data.integrationVersion) { - data.serviceVersion = data.integrationVersion; - } - - if (data.modId) { - data.blueprintId = data.modId; - data.recipeId = data.modId; - } - - if (data.modComponentId) { - data.extensionId = data.modComponentId; - } - - if (data.modComponentLabel) { - data.extensionLabel = data.modComponentLabel; - } - - if (data.modComponents) { - data.extensions = data.modComponents; - } - - if (data.modToActivate) { - data.recipeToActivate = data.modToActivate; - } - - if (data.modVersion) { - data.blueprintVersion = data.modVersion; - } - - if (data.starterBrickId) { - data.extensionPointId = data.starterBrickId; - } - - return data; -} - /** * Report an event to the PixieBrix telemetry service, if the user doesn't have DNT set. * @see selectEventData */ export default function reportEvent( - event: Event, + event: TelemetryEvent, data: ReportEventData = {}, ): void { // eslint-disable-next-line prefer-rest-params -- Needs `arguments` to avoid printing the default console.debug(...arguments); - _record({ event, data: transformEventData(data) }); + _record({ event, data: mapEventDataToDeprecatedTerminology(data) }); } diff --git a/src/telemetry/telemetryHelpers.ts b/src/telemetry/telemetryHelpers.ts index dca63053a8..11113af186 100644 --- a/src/telemetry/telemetryHelpers.ts +++ b/src/telemetry/telemetryHelpers.ts @@ -16,23 +16,12 @@ */ import type { UserData } from "@/auth/authTypes"; +import { type TelemetryUser } from "@/telemetry/telemetryTypes"; import { uuidv4 } from "@/types/helpers"; import type { UUID } from "@/types/stringTypes"; import { once } from "lodash"; import { StorageItem } from "webext-storage"; -/** - * The Person model for application error telemetry. - */ -export type TelemetryUser = { - /** - * User id or browser distinct id, if the user is anonymous. - */ - id: UUID; - email?: string; - organizationId?: UUID | null; -}; - export const uuidStorage = new StorageItem("USER_UUID"); /** @@ -97,3 +86,54 @@ export async function mapAppUserToTelemetryUser( organizationId: telemetryOrganizationId ?? organizationId, }; } + +export function mapEventDataToDeprecatedTerminology( + data: UnknownObject, +): UnknownObject { + if (data.brickId) { + data.blockId = data.brickId; + } + + if (data.brickVersion) { + data.blockVersion = data.brickVersion; + } + + if (data.integrationId) { + data.serviceId = data.integrationId; + } + + if (data.integrationVersion) { + data.serviceVersion = data.integrationVersion; + } + + if (data.modId) { + data.blueprintId = data.modId; + data.recipeId = data.modId; + } + + if (data.modComponentId) { + data.extensionId = data.modComponentId; + } + + if (data.modComponentLabel) { + data.extensionLabel = data.modComponentLabel; + } + + if (data.modComponents) { + data.extensions = data.modComponents; + } + + if (data.modToActivate) { + data.recipeToActivate = data.modToActivate; + } + + if (data.modVersion) { + data.blueprintVersion = data.modVersion; + } + + if (data.starterBrickId) { + data.extensionPointId = data.starterBrickId; + } + + return data; +} diff --git a/src/telemetry/telemetryTypes.ts b/src/telemetry/telemetryTypes.ts new file mode 100644 index 0000000000..673463fd63 --- /dev/null +++ b/src/telemetry/telemetryTypes.ts @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2024 PixieBrix, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { type Events } from "@/telemetry/events"; +import { type UUID } from "@/types/stringTypes"; + +/** + * The Person model for application error telemetry. + */ +export type TelemetryUser = { + /** + * User id or browser distinct id, if the user is anonymous. + */ + id: UUID; + email?: string; + organizationId?: UUID | null; +}; + +export type TelemetryEvent = (typeof Events)[keyof typeof Events]; + +const RESERVED_KEYS = [ + "blockId", + "blockVersion", + "blueprintId", + "blueprintVersion", + "extensionId", + "extensionLabel", + "extensionPointId", + "extensions", + "recipeId", + "recipeToActivate", + "serviceId", + "serviceVersion", +] as const; + +type ReservedKeys = { + [K in (typeof RESERVED_KEYS)[number]]?: never; +}; + +export type ReportEventData = UnknownObject & ReservedKeys; diff --git a/src/tinyPages/offscreen.ts b/src/tinyPages/offscreen.ts index f5e4c57243..581c587d3f 100644 --- a/src/tinyPages/offscreen.ts +++ b/src/tinyPages/offscreen.ts @@ -16,7 +16,7 @@ */ import type { MessageContext } from "@/types/loggerTypes"; -import { type TelemetryUser } from "@/telemetry/telemetryHelpers"; +import { type TelemetryUser } from "@/telemetry/telemetryTypes"; import { type SemVerString } from "@/types/registryTypes"; import { type SerializedError } from "@/types/messengerTypes"; import { deserializeError } from "serialize-error"; From e35fefabe378c66e5570997e1556a1cd26a0118b Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Tue, 9 Jul 2024 09:36:19 -0500 Subject: [PATCH 11/14] bump logging database number --- src/telemetry/logging.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/telemetry/logging.ts b/src/telemetry/logging.ts index c53c56c0b5..41e379d12d 100644 --- a/src/telemetry/logging.ts +++ b/src/telemetry/logging.ts @@ -51,7 +51,7 @@ import { const DATABASE_NAME = "LOG"; const ENTRY_OBJECT_STORE = "entries"; -const DB_VERSION_NUMBER = 3; +const DB_VERSION_NUMBER = 4; /** * Maximum number of most recent logs to keep in the database. A low-enough number that performance should not be * impacted due to the number of entries. From 532b73613b95e3e76a3dfb5a29e86744230fd705 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Tue, 9 Jul 2024 09:38:29 -0500 Subject: [PATCH 12/14] add telemetryTypes to tsconfig.strictNullChecks --- src/tsconfig.strictNullChecks.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index a345ef7211..c36a221a22 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -1431,6 +1431,7 @@ "./telemetry/reportUncaughtErrors.ts", "./telemetry/telemetryHelpers.test.ts", "./telemetry/telemetryHelpers.ts", + "./telemetry/telemetryTypes.ts", "./telemetry/trace.ts", "./telemetry/traceHelpers.test.ts", "./telemetry/traceHelpers.ts", From bddeca38d86c6e21f63b5417ef51c9984ba710bd Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Tue, 9 Jul 2024 13:03:22 -0500 Subject: [PATCH 13/14] pr review related changes --- src/background/messenger/api.ts | 2 +- src/background/messenger/registration.ts | 4 ++-- src/bricks/effects/pageState.ts | 6 +++--- .../pages/mods/hooks/useReactivateAction.ts | 2 +- src/utils/modUtils.ts | 2 ++ 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/background/messenger/api.ts b/src/background/messenger/api.ts index 153c4c1b02..e5f53f1d9d 100644 --- a/src/background/messenger/api.ts +++ b/src/background/messenger/api.ts @@ -70,7 +70,7 @@ export const recordLog = getNotifier("RECORD_LOG", bg); export const clearLogs = getMethod("CLEAR_LOGS", bg); export const clearLog = getMethod("CLEAR_LOG", bg); export const clearExtensionDebugLogs = getMethod( - "CLEAR_EXTENSION_DEBUG_LOGS", + "CLEAR_MOD_COMPONENT_DEBUG_LOGS", bg, ); diff --git a/src/background/messenger/registration.ts b/src/background/messenger/registration.ts index a40edeb586..857ea76d46 100644 --- a/src/background/messenger/registration.ts +++ b/src/background/messenger/registration.ts @@ -110,7 +110,7 @@ declare global { RECORD_ERROR: typeof recordError; CLEAR_LOGS: typeof clearLogs; CLEAR_LOG: typeof clearLog; - CLEAR_EXTENSION_DEBUG_LOGS: typeof clearModComponentDebugLogs; + CLEAR_MOD_COMPONENT_DEBUG_LOGS: typeof clearModComponentDebugLogs; INTEGRATION_REGISTRY_CLEAR: typeof integrationRegistry.clear; LOCATOR_FIND_ALL_SANITIZED_CONFIGS_FOR_INTEGRATION: typeof integrationConfigLocator.findAllSanitizedConfigsForIntegration; @@ -183,7 +183,7 @@ export default function registerMessenger(): void { RECORD_ERROR: recordError, CLEAR_LOGS: clearLogs, CLEAR_LOG: clearLog, - CLEAR_EXTENSION_DEBUG_LOGS: clearModComponentDebugLogs, + CLEAR_MOD_COMPONENT_DEBUG_LOGS: clearModComponentDebugLogs, INTEGRATION_REGISTRY_CLEAR: integrationRegistry.clear.bind(integrationRegistry), diff --git a/src/bricks/effects/pageState.ts b/src/bricks/effects/pageState.ts index 4990676ded..ad61a7ade0 100644 --- a/src/bricks/effects/pageState.ts +++ b/src/bricks/effects/pageState.ts @@ -150,15 +150,15 @@ export class SetPageState extends TransformerABC { }>, { logger, platform }: BrickOptions, ): Promise { - const { modId: blueprintId, modComponentId: extensionId } = logger.context; + const { modId, modComponentId } = logger.context; return platform.state.setState({ namespace, data, mergeStrategy, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- TODO: https://github.com/pixiebrix/pixiebrix-extension/issues/7891 - modComponentId: extensionId!, - modId: blueprintId, + modComponentId: modComponentId!, + modId, }); } } diff --git a/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts b/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts index ed0976348d..fa936a3374 100644 --- a/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts +++ b/src/extensionConsole/pages/mods/hooks/useReactivateAction.ts @@ -38,7 +38,7 @@ const useReactivateAction = (modViewItem: ModViewItem): (() => void) | null => { if (hasModDefinition) { const modId = isModDefinition(mod) ? mod.metadata.id : mod._recipe?.id; - assertNotNullish(modId, "blueprintId is required to reactivate mod"); + assertNotNullish(modId, "modId is required to reactivate mod"); reportEvent(Events.START_MOD_ACTIVATE, { modId, diff --git a/src/utils/modUtils.ts b/src/utils/modUtils.ts index bb33ce1cc1..1c990234df 100644 --- a/src/utils/modUtils.ts +++ b/src/utils/modUtils.ts @@ -94,6 +94,8 @@ export function mapModComponentToMessageContext( /** * Returns the message context for a ModComponentRef. For use with passing to reportEvent * @see selectEventData + * + * TODO: Once we update the shape of ModComponentRef, we need to audit unnecessary usage of this function */ export function mapModComponentRefToMessageContext( modComponentRef: ModComponentRef, From 545e1c7ded50812b074281d88445f544237f733a Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Tue, 9 Jul 2024 13:11:56 -0500 Subject: [PATCH 14/14] improve type name --- src/telemetry/telemetryTypes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/telemetry/telemetryTypes.ts b/src/telemetry/telemetryTypes.ts index 673463fd63..1a0ea3dc43 100644 --- a/src/telemetry/telemetryTypes.ts +++ b/src/telemetry/telemetryTypes.ts @@ -47,8 +47,8 @@ const RESERVED_KEYS = [ "serviceVersion", ] as const; -type ReservedKeys = { +type BanReservedKeys = { [K in (typeof RESERVED_KEYS)[number]]?: never; }; -export type ReportEventData = UnknownObject & ReservedKeys; +export type ReportEventData = UnknownObject & BanReservedKeys;