Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions code/core/src/core-server/utils/checklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ export async function initializeChecklist() {
);

store.onStateChange((state: StoreState, previousState: StoreState) => {
const entries = Object.entries(state.items);

// Split values into project-local (done) and user-local (accepted, skipped) persistence
const projectValues: Partial<StoreState['items']> = {};
const userValues: Partial<StoreState['items']> = {};
Object.entries(state.items).forEach(([id, { status, mutedAt }]) => {
entries.forEach(([id, { status, mutedAt }]) => {
if (status === 'done') {
projectValues[id as keyof StoreState['items']] = { status };
} else if (status === 'accepted' || status === 'skipped') {
Expand All @@ -83,12 +85,34 @@ export async function initializeChecklist() {
saveProjectState({ items: projectValues as StoreState['items'] });
saveUserState({ items: userValues, widget: state.widget });

const changedValues = Object.entries(state.items).filter(
([key, value]) => value !== previousState.items[key as keyof typeof state.items]
// Gather items that have changed state
const { mutedItems, statusItems } = entries.reduce(
(acc, [item, { mutedAt, status }]) => {
const prev = previousState.items[item as keyof typeof state.items];
if (mutedAt !== prev?.mutedAt) {
acc.mutedItems.push(item);
}
if (status !== prev?.status) {
acc.statusItems.push(item);
}
return acc;
},
{ mutedItems: [] as string[], statusItems: [] as string[] }
);
telemetry('onboarding-checklist', {
...(changedValues.length > 0 ? { items: Object.fromEntries(changedValues) } : {}),
...(!deepEqual(state.widget, previousState.widget) ? { widget: state.widget } : {}),
if (mutedItems.length > 0) {
telemetry('onboarding-checklist-muted', {
items: mutedItems,
completedItems: entries.reduce<string[]>((acc, [id, { status }]) => {
return status === 'done' || status === 'accepted' ? acc.concat([id]) : acc;
}, []),
skippedItems: entries.reduce<string[]>((acc, [id, { status }]) => {
return status === 'skipped' ? acc.concat([id]) : acc;
}, []),
});
}
statusItems.forEach((item) => {
const { status } = state.items[item as keyof typeof state.items];
telemetry('onboarding-checklist-status', { item, status });
});
});
} catch (err) {
Expand Down
8 changes: 1 addition & 7 deletions code/core/src/shared/checklist-store/checklistData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const checklistData = {
},
{
id: 'renderComponent',
label: 'Render a component',
label: 'Render your first component',
criteria: 'A story finished rendering successfully',
subscribe: ({ api, done }) =>
api.on(
Expand Down Expand Up @@ -281,7 +281,6 @@ export const Primary: Story = {
},
{
id: 'moreComponents',
after: ['renderComponent'],
label: 'Add 5 components',
content: ({ api }) => (
<>
Expand Down Expand Up @@ -323,7 +322,6 @@ export const Primary: Story = {
},
{
id: 'moreStories',
after: ['renderComponent'],
label: 'Add 20 stories',
content: ({ api }) => (
<>
Expand Down Expand Up @@ -380,7 +378,6 @@ export const Primary: Story = {
items: [
{
id: 'controls',
after: ['renderComponent'],
label: 'Change a story with Controls',
available: () => !!globalThis?.FEATURES?.controls,
criteria: 'Story args are updated',
Expand Down Expand Up @@ -423,7 +420,6 @@ export const Primary: Story = {
},
{
id: 'viewports',
after: ['renderComponent'],
label: 'Check responsiveness with Viewports',
available: () => !!globalThis?.FEATURES?.viewport,
criteria: 'Viewport global is updated',
Expand Down Expand Up @@ -468,7 +464,6 @@ export const Primary: Story = {
},
{
id: 'organizeStories',
after: ['renderComponent'],
label: 'Group your components',
criteria: 'A root node exists in the index',
subscribe: subscribeToIndex((entries) =>
Expand Down Expand Up @@ -672,7 +667,6 @@ export default {
},
{
id: 'writeInteractions',
after: ['renderComponent'],
label: 'Test functionality with interactions',
available: () => !!globalThis?.FEATURES?.interactions,
criteria: 'At least one story with a play or test function',
Expand Down
3 changes: 2 additions & 1 deletion code/core/src/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export type EventType =
| 'test-run'
| 'addon-onboarding'
| 'onboarding-survey'
| 'onboarding-checklist'
| 'onboarding-checklist-muted'
| 'onboarding-checklist-status'
| 'mocking'
| 'automigrate'
| 'migrate'
Expand Down
Loading