-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(signals): bring cloud inbox custom events in line with desktop #65036
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 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
c2f3a0e
feat(llma): bring cloud inbox custom events in line with desktop
andrewm4894 dc60d97
chore(llma): address review - fire restore after persist, drop unused…
andrewm4894 cac9ce3
chore(llma): address review - drop free-form content from events, fix…
andrewm4894 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| import posthog from 'posthog-js' | ||
|
|
||
| import { | ||
| captureInboxReportAction, | ||
| captureInboxViewed, | ||
| captureSignalSourceConnected, | ||
| INBOX_EVENTS, | ||
| } from './inboxAnalytics' | ||
| import { SignalReport, SignalReportStatus } from './types' | ||
|
|
||
| jest.mock('posthog-js') | ||
|
|
||
| function lastCapture(event: string): Record<string, any> | undefined { | ||
| const calls = (posthog.capture as jest.Mock).mock.calls.filter(([name]) => name === event) | ||
| return calls.length > 0 ? calls[calls.length - 1][1] : undefined | ||
| } | ||
|
|
||
| function makeReport(overrides: Partial<SignalReport> = {}): SignalReport { | ||
| return { | ||
| id: 'r1', | ||
| title: 'Something broke', | ||
| summary: null, | ||
| status: SignalReportStatus.READY, | ||
| total_weight: 1, | ||
| signal_count: 1, | ||
| relevant_user_count: null, | ||
| created_at: '2026-06-20T00:00:00Z', | ||
| updated_at: '2026-06-20T00:00:00Z', | ||
| artefact_count: 0, | ||
| is_suggested_reviewer: false, | ||
| priority: 'P1', | ||
| actionability: 'immediately_actionable', | ||
| ...overrides, | ||
| } | ||
| } | ||
|
|
||
| describe('inboxAnalytics', () => { | ||
| beforeEach(() => { | ||
| ;(posthog.capture as jest.Mock).mockClear() | ||
| }) | ||
|
|
||
| it('stamps every event with the cloud client discriminator', () => { | ||
| captureInboxViewed({ | ||
| tab: 'reports', | ||
| reports: [], | ||
| totalCount: 0, | ||
| hasActiveFilters: false, | ||
| sourceProductFilter: [], | ||
| priorityFilter: [], | ||
| scope: 'for-you', | ||
| }) | ||
| expect(lastCapture(INBOX_EVENTS.VIEWED)?.inbox_client).toBe('cloud') | ||
| }) | ||
|
|
||
| it('breaks the visible reports down by priority and actionability', () => { | ||
| captureInboxViewed({ | ||
| tab: 'reports', | ||
| reports: [ | ||
| makeReport({ id: 'a', priority: 'P0', actionability: 'immediately_actionable' }), | ||
| makeReport({ id: 'b', priority: 'P1', actionability: 'requires_human_input' }), | ||
| makeReport({ id: 'c', priority: null, actionability: null }), | ||
| ], | ||
| totalCount: 3, | ||
| hasActiveFilters: true, | ||
| sourceProductFilter: ['error_tracking'], | ||
| priorityFilter: ['P0'], | ||
| scope: 'entire-project', | ||
| }) | ||
| const props = lastCapture(INBOX_EVENTS.VIEWED) | ||
| expect(props).toMatchObject({ | ||
| report_count: 3, | ||
| total_count: 3, | ||
| is_empty: false, | ||
| has_active_filters: true, | ||
| source_product_filter: ['error_tracking'], | ||
| priority_p0_count: 1, | ||
| priority_p1_count: 1, | ||
| priority_unknown_count: 1, | ||
| actionability_immediately_actionable_count: 1, | ||
| actionability_requires_human_input_count: 1, | ||
| actionability_unknown_count: 1, | ||
| }) | ||
| }) | ||
|
|
||
| it('emits a single-report action with the report context', () => { | ||
| captureInboxReportAction({ | ||
| report: makeReport(), | ||
| actionType: 'create_pr', | ||
| surface: 'detail_pane', | ||
| }) | ||
| expect(lastCapture(INBOX_EVENTS.REPORT_ACTION)).toMatchObject({ | ||
| report_id: 'r1', | ||
| action_type: 'create_pr', | ||
| surface: 'detail_pane', | ||
| is_bulk: false, | ||
| bulk_size: 1, | ||
| }) | ||
| }) | ||
|
|
||
| it('emits a bulk action with a null report and the selection size', () => { | ||
| captureInboxReportAction({ | ||
| actionType: 'dismiss', | ||
| surface: 'bulk_bar', | ||
| isBulk: true, | ||
| bulkSize: 4, | ||
| extra: { dismissal_reason: 'wontfix_irrelevant' }, | ||
| }) | ||
| expect(lastCapture(INBOX_EVENTS.REPORT_ACTION)).toMatchObject({ | ||
| report_id: null, | ||
| action_type: 'dismiss', | ||
| surface: 'bulk_bar', | ||
| is_bulk: true, | ||
| bulk_size: 4, | ||
| dismissal_reason: 'wontfix_irrelevant', | ||
| }) | ||
| }) | ||
|
|
||
| it('records a connected source with first-connection and wizard flags', () => { | ||
| captureSignalSourceConnected({ | ||
| sourceProduct: 'github', | ||
| sourceType: 'issue', | ||
| isFirstConnection: true, | ||
| viaSetupWizard: true, | ||
| }) | ||
| expect(lastCapture(INBOX_EVENTS.SOURCE_CONNECTED)).toMatchObject({ | ||
| source_product: 'github', | ||
| source_type: 'issue', | ||
| is_first_connection: true, | ||
| via_setup_wizard: true, | ||
| }) | ||
| }) | ||
| }) |
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.