mirror of
https://github.com/langgenius/dify.git
synced 2026-07-24 04:58:32 +08:00
Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { trackStepByStepTourEvent } from '../analytics'
|
|
|
|
const mockTrackEvent = vi.hoisted(() => vi.fn())
|
|
|
|
vi.mock('@/app/components/base/amplitude', () => ({
|
|
trackEvent: mockTrackEvent,
|
|
}))
|
|
|
|
describe('step-by-step tour analytics', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('tracks the unified event with scalar properties only', () => {
|
|
trackStepByStepTourEvent({
|
|
action: 'task_completed',
|
|
completed_task_count: 1,
|
|
home_outcome: 'lesson_app_created',
|
|
permission_variant: 'full',
|
|
task_id: 'home',
|
|
task_total: 4,
|
|
})
|
|
|
|
expect(mockTrackEvent).toHaveBeenCalledWith('step_tour', {
|
|
action: 'task_completed',
|
|
completed_task_count: 1,
|
|
home_outcome: 'lesson_app_created',
|
|
permission_variant: 'full',
|
|
task_id: 'home',
|
|
task_total: 4,
|
|
})
|
|
})
|
|
|
|
it('omits undefined optional properties', () => {
|
|
trackStepByStepTourEvent({ action: 'tour_enabled' })
|
|
|
|
expect(mockTrackEvent).toHaveBeenCalledWith('step_tour', { action: 'tour_enabled' })
|
|
})
|
|
})
|