Repository navigation
fix(automations): fire Linear triggers for every member, not only the one who connected #9180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,16 +105,26 @@ export async function processDelivery({ | |
| // Caught per connection, and the loop runs to the end regardless: one | ||
| // organization's broken token or missing workflow state must not cost the | ||
| // other sixteen their delivery. | ||
| const leadByOrganization = new Map<string, string>(); | ||
| for (const connection of subscribers) { | ||
| if (!leadByOrganization.has(connection.organizationId)) { | ||
| leadByOrganization.set(connection.organizationId, connection.id); | ||
| } | ||
| } | ||
| const leadIds = new Set(leadByOrganization.values()); | ||
|
Comment on lines
+108
to
+114
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the lead stable across redeliveries. If a new connection sorts before the original lead, a redelivery selects the new connection as lead. The new connection records a distinct automation event, so unpinned triggers can run again for the same Linear delivery. Connection IDs are random UUIDs, and
|
||
| const results: ConnectionResult[] = []; | ||
| for (const connection of subscribers) { | ||
| results.push( | ||
| await processForConnection(payload, deliveryId, connection).catch( | ||
| (error) => ({ | ||
| connectionId: connection.id, | ||
| outcome: "failed" as const, | ||
| error: errorMessage(error), | ||
| }), | ||
| ), | ||
| await processForConnection( | ||
| payload, | ||
| deliveryId, | ||
| connection, | ||
| leadIds.has(connection.id), | ||
| ).catch((error) => ({ | ||
| connectionId: connection.id, | ||
| outcome: "failed" as const, | ||
| error: errorMessage(error), | ||
| })), | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -130,6 +140,7 @@ async function processForConnection( | |
| payload: LinearWebhookPayload, | ||
| deliveryId: string | null, | ||
| connection: SelectConnection, | ||
| leadsOrganization: boolean, | ||
| ): Promise<ConnectionResult> { | ||
| // One webhookEvents row per (Linear event × Superset connection) so each | ||
| // tenant's processing status is independently retryable, and so a retried | ||
|
|
@@ -163,7 +174,13 @@ async function processForConnection( | |
|
|
||
| if (isEntityDelivery(payload)) { | ||
| try { | ||
| await ingest(payload, deliveryId, connection, webhookEvent.id); | ||
| await ingest( | ||
| payload, | ||
| deliveryId, | ||
| connection, | ||
| leadsOrganization, | ||
| webhookEvent.id, | ||
| ); | ||
| } catch (error) { | ||
| console.error( | ||
| "[linear/process-delivery] automation event failed:", | ||
|
|
@@ -204,6 +221,7 @@ async function ingest( | |
| delivery: LinearDelivery, | ||
| deliveryHeader: string | null, | ||
| connection: SelectConnection, | ||
| leadsOrganization: boolean, | ||
| webhookEventId: string, | ||
| ): Promise<void> { | ||
| const event = matchableFrom(delivery); | ||
|
|
@@ -224,6 +242,7 @@ async function ingest( | |
| event, | ||
| deliveryId, | ||
| connection, | ||
| leadsOrganization, | ||
| webhookEventId, | ||
| }), | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing
ownerUserIdalso broadensnotifyRoutinesOfEvent, but that function ignorespinnedOnly. With two Linear connections in one organization, an unpinned matching routine now fires from both connection events. Each event has a differenteventId, sofireRoutinecreates differentpromptIdvalues and sends both prompts to the Dev.Pass
pinnedOnlythrough routine matching and exclude unpinned routine triggers on non-lead events.Prompt To Fix With AI