Skip to content

Conversation

@alejandro-runner
Copy link
Member

@alejandro-runner alejandro-runner commented Feb 6, 2026

Summary

When the same dish is listed in multiple submenus (one row per submenu in the Menu Items sheet), the importer now emits one kind 30402 event per row with a distinct d-tag so events do not collide.

Changes

  • computeItemDTag(name, menu, section, fallbackIndex): Builds d-tag from slugify(name) and, when menu/section exist, appends - and slugify([section, menu].filter(Boolean).join("-")). Fallback to item-${fallbackIndex + 1} when name slug is empty.
  • uniquifyDTags(baseDTags): Returns an array where duplicate base d-tags get -2, -3, … suffix so all are unique.
  • Precompute baseDTags and finalDTags in buildSpreadsheetPreviewEvents; use index-based loops with finalDTags[i] for both product events and collection membership.
  • Remove dTagByItemName; each row gets its own 30402 event identity.
  • Unit tests (menuSpreadsheet.test.ts): same item in different submenus → two 30402 events with distinct d-tags; identical rows → distinct d-tags with -2 suffix; single row without menu/section → one event with slug(name) d-tag.

Result

Scenario Before After
Two rows: same item in Sandos and The 'Unch Part 2 events, both d: bigfoot-burger (collision) 2 events, e.g. d: bigfoot-burger-sandos and d: bigfoot-burger-the-unch-part
Two identical rows (same name, same menu, same section) 2 events, same d-tag 2 events, second gets -2 suffix

Closes #306
Closes #307

alejandro-runner and others added 2 commits February 6, 2026 08:57
…submenus

- Add computeItemDTag(name, menu, section, fallbackIndex) to derive d-tag
  from name + menu/section context so duplicate rows get distinct addresses.
- Add uniquifyDTags() to suffix -2, -3 on duplicate base d-tags.
- Precompute baseDTags and finalDTags; use index-based loops with
  finalDTags[i] for product events and collection membership.
- Remove dTagByItemName; each row now gets its own 30402 event identity.

Closes #306

Co-authored-by: Cursor <cursoragent@cursor.com>
- Same item in different submenus: two 30402 events with distinct d-tags.
- Identical (name, menu, section) rows: two events, second gets -2 suffix.
- Single row without menu/section: one event with slug(name) d-tag.

Closes #307

Co-authored-by: Cursor <cursoragent@cursor.com>
@alejandro-runner alejandro-runner merged commit 4c1dada into main Feb 6, 2026
2 checks passed
@alejandro-runner alejandro-runner deleted the feature/306-spreadsheet-distinct-dtags branch February 6, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for menu spreadsheet d-tag generation (duplicate rows) Menu spreadsheet: distinct d-tags per row (same item in different submenus)

1 participant