-
-
Notifications
You must be signed in to change notification settings - Fork 128
feat: notify orgs of incompatible bundles + combined compatibility analytics #2372
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b2b1854
feat: notify orgs of incompatible bundles + combined compatibility an…
WcaleNieWolny 76b895a
fix: dedupe incompatible-bundle Bento alert permanently per version
WcaleNieWolny 98c45d2
refactor: extract toIdString helper in bundle-incompatible event hand…
WcaleNieWolny 5ebb567
fix(cli): guard bundle compatibility telemetry so it can't break the …
WcaleNieWolny f66bc29
fix(cli): skip Bundle Incompatible event when command can't resolve v…
WcaleNieWolny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
supabase/functions/_backend/utils/bundle_compatibility_recovery.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import type { BentoTrackingPayload } from './tracking.ts' | ||
|
|
||
| /** | ||
| * The CLI emits a `Bundle Incompatible` tracking event whenever a bundle's | ||
| * native dependencies don't match the version currently live on the target | ||
| * channel. It fires from two flows: | ||
| * - `bundle upload` (after the new version is created), and | ||
| * - the standalone `capgo bundle compatibility` command. | ||
| * | ||
| * We turn that into a Bento signal event so a lifecycle automation can react | ||
| * (e.g. nudge the org toward a native rebuild / Capgo Builder). Delivery and | ||
| * email gating are handled by `sendNotifToOrgMembers` via the dedicated | ||
| * `bundle_incompatible` preference key. Mirrors `buildBuilderOnboardingBentoEvent`. | ||
| */ | ||
| export const BUNDLE_INCOMPATIBLE_EVENT = 'Bundle Incompatible' | ||
|
|
||
| export interface BundleCompatibilityBentoInput { | ||
| /** The incoming tracking event name (must be 'Bundle Incompatible'). */ | ||
| event: string | ||
| orgId: string | undefined | ||
| appId: string | undefined | ||
| /** Channel the bundle was checked against. */ | ||
| channel: string | undefined | ||
| /** Which flow detected the incompatibility: 'upload' | 'command'. */ | ||
| source: string | undefined | ||
| /** | ||
| * New bundle being uploaded. Empty for the standalone command, which uploads | ||
| * nothing — only the upload flow has a freshly created version. | ||
| */ | ||
| versionNewId: string | undefined | ||
| versionNewName: string | undefined | ||
| /** Version currently live on the channel that the bundle was compared against. */ | ||
| versionOldId: string | undefined | ||
| versionOldName: string | undefined | ||
| orgName: string | undefined | ||
| appName: string | undefined | ||
| } | ||
|
|
||
| /** | ||
| * Pure: decide whether this event should emit a Bento signal and build its | ||
| * payload. Returns undefined when nothing should be emitted (wrong event name, | ||
| * or missing org/app context). | ||
| */ | ||
| export function buildBundleCompatibilityBentoEvent(input: BundleCompatibilityBentoInput): BentoTrackingPayload | undefined { | ||
| if (input.event !== BUNDLE_INCOMPATIBLE_EVENT) | ||
| return undefined | ||
| if (!input.orgId || !input.appId) | ||
| return undefined | ||
|
|
||
| const source = input.source ?? 'unknown' | ||
| const channel = input.channel ?? '' | ||
| const versionNewName = input.versionNewName ?? '' | ||
| const versionOldName = input.versionOldName ?? '' | ||
|
|
||
| return { | ||
| event: 'bundle_incompatible', | ||
| // Dedicated key — independent from other bundle/OTA email preferences. | ||
| preferenceKey: 'bundle_incompatible', | ||
| // Permanent per app+channel+version claim (no reopening cron window): repeated | ||
| // incompatible uploads / `bundle compatibility` checks of the SAME version must | ||
| // not re-email org admins. A genuinely new version has a different uniqId and | ||
| // notifies on its own; the old version is the fallback for the command flow | ||
| // (which uploads no new bundle). | ||
| once: true, | ||
| uniqId: `bundle_incompatible:${input.appId}:${channel}:${versionNewName || versionOldName}`, | ||
| data: { | ||
| org_id: input.orgId, | ||
| org_name: input.orgName ?? '', | ||
| app_id: input.appId, | ||
| app_name: input.appName ?? '', | ||
| channel, | ||
| source, | ||
| version_new_id: input.versionNewId ?? '', | ||
| version_new_name: versionNewName, | ||
| version_old_id: input.versionOldId ?? '', | ||
| version_old_name: versionOldName, | ||
| }, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.