From b70b94560edf4a83b15d72f3bec683281bea11c1 Mon Sep 17 00:00:00 2001 From: mikee-b <112516913+mikee-b@users.noreply.github.com> Date: Tue, 12 May 2026 11:35:49 -0400 Subject: [PATCH] chore(integrations/linear): Added some logs (#15185) --- integrations/linear/integration.definition.ts | 2 +- integrations/linear/src/handler.ts | 7 ++++++ integrations/linear/src/setup.ts | 23 +++++++++++++++---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/integrations/linear/integration.definition.ts b/integrations/linear/integration.definition.ts index 02c988cd5f0..ee0d5e162b2 100644 --- a/integrations/linear/integration.definition.ts +++ b/integrations/linear/integration.definition.ts @@ -9,7 +9,7 @@ import listable from './bp_modules/listable' import { actions, channels, events, configuration, configurations, user, states, entities } from './definitions' export const INTEGRATION_NAME = 'linear' -export const INTEGRATION_VERSION = '2.3.0' +export const INTEGRATION_VERSION = '2.4.0' export default new IntegrationDefinition({ name: INTEGRATION_NAME, diff --git a/integrations/linear/src/handler.ts b/integrations/linear/src/handler.ts index 0b021db4010..32ed6b7063d 100644 --- a/integrations/linear/src/handler.ts +++ b/integrations/linear/src/handler.ts @@ -15,7 +15,14 @@ const LINEAR_WEBHOOK_TS_FIELD = 'webhookTimestamp' export const handler: bp.IntegrationProps['handler'] = async (props) => { const { req, ctx, client, logger } = props + logger + .forBot() + .debug( + `Linear handler invoked (method="${req.method ?? ''}", path="${req.path ?? ''}", hasBody=${Boolean(req.body)})` + ) + if (req.path === '/oauth') { + logger.forBot().info('Linear OAuth callback received') return await handleOauth(props).catch((err) => { logger.forBot().error('Error while processing OAuth', err.response?.data || err.message) throw err diff --git a/integrations/linear/src/setup.ts b/integrations/linear/src/setup.ts index 9bc530c0e95..b6cb0effc7b 100644 --- a/integrations/linear/src/setup.ts +++ b/integrations/linear/src/setup.ts @@ -6,28 +6,43 @@ const _isWebhookManuallyRegistered = (ctx: bp.HandlerProps['ctx']) => ctx.configurationType === 'apiKey' && ctx.configuration.webhookSigningSecret export const register: bp.IntegrationProps['register'] = async ({ client, ctx, logger }) => { - logger.forBot().info('Registering integration...') + const manuallyRegistered = _isWebhookManuallyRegistered(ctx) + logger.forBot().info('Registering Linear integration.') + const linearClient = await LinearOauthClient.create({ client, ctx }) - if (!_isWebhookManuallyRegistered(ctx)) { + + if (!manuallyRegistered) { const webhookUrl = `${process.env.BP_WEBHOOK_URL}/${ctx.webhookId}` + logger.forBot().info('Registering Linear webhook') try { await registerWebhook({ linearClient, logger, url: webhookUrl }) + logger.forBot().info('Linear webhook registered') } catch (thrown) { const errorMessage = thrown instanceof Error ? thrown.message : String(thrown) throw new RuntimeError(`Failed to register webhook: ${errorMessage}`) } + } else { + logger + .forBot() + .info('Skipping automatic Linear webhook registration: webhookSigningSecret is set in apiKey configuration.') } - logger.forBot().info('Integration registered successfully.') + logger.forBot().info(`Linear integration registered successfully (integrationId="${ctx.integrationId}").`) } export const unregister: bp.IntegrationProps['unregister'] = async ({ client, ctx, logger }) => { - if (_isWebhookManuallyRegistered(ctx)) { + const manuallyRegistered = _isWebhookManuallyRegistered(ctx) + logger.forBot().info('Unregistering Linear integration.') + + if (manuallyRegistered) { + logger.forBot().info('Skipping Linear webhook unregistration: webhook was manually registered.') return } try { const linearClient = await LinearOauthClient.create({ client, ctx }) const webhookUrl = `${process.env.BP_WEBHOOK_URL}/${ctx.webhookId}` + logger.forBot().info('Unregistering Linear webhook.') await unregisterWebhook({ linearClient, logger, url: webhookUrl }) + logger.forBot().info('Linear webhook unregistration step completed.') } catch (thrown) { const errorMessage = thrown instanceof Error ? thrown.message : String(thrown) logger.forBot().warn('Failed to unregister webhook:', errorMessage)