-
-
Notifications
You must be signed in to change notification settings - Fork 134
feat(cli): add warning for direct updates without delta uploads #3369
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
Open
riderx
wants to merge
1
commit into
main
Choose a base branch
from
add-warning-cli-rollout2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
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
45 changes: 45 additions & 0 deletions
45
supabase/functions/_backend/utils/direct_update_without_delta_tracking.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,45 @@ | ||
| import type { BentoTrackingPayload } from './tracking.ts' | ||
|
|
||
| /** | ||
| * CLI `bundle upload` emits this when CapacitorUpdater instant/direct updates | ||
| * are enabled but the upload is not using delta (`--no-delta`, declined | ||
| * prompt, or delta unavailable). PostHog already records it; this helper | ||
| * builds the Bento payload so org admins can get a lifecycle automation / email. | ||
| */ | ||
| export const DIRECT_UPDATE_WITHOUT_DELTA_EVENT = 'Direct Update Without Delta' | ||
| export const DIRECT_UPDATE_WITHOUT_DELTA_BENTO_EVENT = 'direct_update_without_delta' | ||
|
|
||
| export interface DirectUpdateWithoutDeltaBentoInput { | ||
| event: string | ||
| orgId: string | undefined | ||
| appId: string | undefined | ||
| orgName?: string | ||
| appName?: string | ||
| tags?: Record<string, string | number | boolean> | ||
| } | ||
|
|
||
| /** | ||
| * Pure: emit a Bento signal when a direct-update app is uploaded without | ||
| * delta files. Returns undefined when the event name does not match or | ||
| * org/app context is missing. | ||
| */ | ||
| export function buildDirectUpdateWithoutDeltaBentoEvent(input: DirectUpdateWithoutDeltaBentoInput): BentoTrackingPayload | undefined { | ||
| if (input.event !== DIRECT_UPDATE_WITHOUT_DELTA_EVENT) | ||
| return undefined | ||
| if (!input.orgId || !input.appId) | ||
| return undefined | ||
|
|
||
| return { | ||
| cron: '* * * * *', | ||
| event: DIRECT_UPDATE_WITHOUT_DELTA_BENTO_EVENT, | ||
| preferenceKey: 'direct_update_without_delta', | ||
| uniqId: `${DIRECT_UPDATE_WITHOUT_DELTA_BENTO_EVENT}:${input.appId}`, | ||
| data: { | ||
| org_id: input.orgId, | ||
| org_name: input.orgName ?? '', | ||
| app_id: input.appId, | ||
| app_name: input.appName ?? '', | ||
| ...(typeof input.tags?.external === 'boolean' ? { external: input.tags.external } : {}), | ||
| }, | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { DIRECT_UPDATE_WITHOUT_DELTA_BENTO_EVENT, DIRECT_UPDATE_WITHOUT_DELTA_EVENT, buildDirectUpdateWithoutDeltaBentoEvent } from '../supabase/functions/_backend/utils/direct_update_without_delta_tracking.ts' | ||
|
|
||
| const base = { | ||
| event: DIRECT_UPDATE_WITHOUT_DELTA_EVENT, | ||
| orgId: 'org-1', | ||
| appId: 'com.demo.app', | ||
| orgName: 'Demo Org', | ||
| appName: 'Demo', | ||
| } | ||
|
|
||
| describe('buildDirectUpdateWithoutDeltaBentoEvent', () => { | ||
| it.concurrent('builds a Bento payload for Direct Update Without Delta', () => { | ||
| expect(buildDirectUpdateWithoutDeltaBentoEvent(base)).toEqual({ | ||
| cron: '* * * * *', | ||
| event: DIRECT_UPDATE_WITHOUT_DELTA_BENTO_EVENT, | ||
| preferenceKey: 'direct_update_without_delta', | ||
| uniqId: 'direct_update_without_delta:com.demo.app', | ||
| data: { | ||
| org_id: 'org-1', | ||
| org_name: 'Demo Org', | ||
| app_id: 'com.demo.app', | ||
| app_name: 'Demo', | ||
| }, | ||
| }) | ||
| }) | ||
|
|
||
| it.concurrent('includes the external tag when present', () => { | ||
| const result = buildDirectUpdateWithoutDeltaBentoEvent({ ...base, tags: { external: true } }) | ||
| expect(result?.data.external).toBe(true) | ||
| }) | ||
|
|
||
| it.concurrent('returns undefined for other event names', () => { | ||
| expect(buildDirectUpdateWithoutDeltaBentoEvent({ ...base, event: 'App Too Large' })).toBeUndefined() | ||
| }) | ||
|
|
||
| it.concurrent('returns undefined when org or app id is missing', () => { | ||
| expect(buildDirectUpdateWithoutDeltaBentoEvent({ ...base, orgId: undefined })).toBeUndefined() | ||
| expect(buildDirectUpdateWithoutDeltaBentoEvent({ ...base, appId: undefined })).toBeUndefined() | ||
| }) | ||
|
|
||
| it.concurrent('defaults missing org and app names to empty strings', () => { | ||
| const result = buildDirectUpdateWithoutDeltaBentoEvent({ | ||
| event: DIRECT_UPDATE_WITHOUT_DELTA_EVENT, | ||
| orgId: 'org-1', | ||
| appId: 'com.demo.app', | ||
| }) | ||
| expect(result?.data.org_name).toBe('') | ||
| expect(result?.data.app_name).toBe('') | ||
| }) | ||
| }) |
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.
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.
options.externalforcesoptions.delta = falsejust above (line 1734–1735: "not available with external URLs"), then this still warns and tells the operator tobundle upload --delta.That advice cannot work for
--external/ S3 uploads. The Bento/PostHog event (Direct Update Without Delta,channel: 'app-error') will also fire on every external upload of a direct-update app, including CI.Skip the warn when delta is impossible (
options.externalor!fileConfig.partialUpload), e.g. pass that intoshouldWarnDirectUpdateWithoutDelta.warnDirectUpdateWithoutDeltaalsoawait sendEvent(...)with no try/catch. Other upload telemetry is best-effort; if this throw lands, a warning aborts the bundle. Swallow sendEvent errors here.