Priority Lab sync: state/address must display correctly (e.g. TX not Te)

Objective

  • Priority Lab / Breeze appointments created or updated from Attik must show correct address fields in the Priority Lab app, with US state shown as the two-letter value users expect (e.g. TX), not truncated garbage (e.g. Te from Texas).
  • Coordinators should be able to rely on sync without fixing addresses manually in Priority Lab after every job.

Background

  • Product feedback: some jobs show Te instead of TX in Priority Lab after Attik integration sync went live.
  • Outbound sync maps the inspection to a vendor form payload in buildPriorityLabPayload. State today is built from inspection.property.state by trimming, taking only the first two characters, then uppercasing—so a stored full name Texas becomes Te.
  • Two-letter values already stored (TX, CO) behave as intended in the same line of code.
  • property.state on inspections is a plain string in inspectionSchema (via PropertySchema); other parts of the product do not enforce abbreviation at write time, so full names can land in Mongo from booking, imports, or edits.
  • Decision needed: whether to normalize only in the Priority Lab payload, introduce shared normalization used elsewhere, or enforce two-letter state at entry—Product should align with Legal/ops on territories and edge cases.
  • Reports from SE of RIA, CHI and NHI jobs having no state entered at all.

Scope

Backend

  • buildPriorityLabPayload in attik-backend/src/util/functions/priorityLab/buildPriorityLabPayload.ts is where state (and address, city, zipcode) are assembled for CreateUpdateAppointmentPayload before the Priority Lab API call.
  • syncPriorityLabAppointment in attik-backend/src/util/functions/priorityLab/syncPriorityLabAppointment.ts invokes that builder during upserts; inspectionStream.ts and src/routes/inspection.ts (after save) enqueue work through queuePriorityLabJob in attik-backend/src/events/bullmq/priorityLabQueues.ts; manual sync uses POST /priority-lab/inspection/:id/sync in attik-backend/src/routes/priorityLab.ts.
  • priorityLabApi.ts defines the payload shape sent to the vendor—confirm any vendor constraints on state length or format if documentation exists.

Frontend

  • The inspection tools card PriorityLab.tsx (attik-frontend/src/app/tools/inspections/[id]/components/integrations/PriorityLab.tsx) surfaces sync status and manual resync; it does not build the address payload today. Changes are primarily backend unless UX copy should mention how state should be entered until normalization exists.

Tests

  • attik-backend/tests/unit/priorityLab.computeAndPayload.test.ts already covers buildPriorityLabPayload with two-letter states; extend with cases that reproduce the customer issue (full state name, mixed case) once behavior is defined.

References

  • attik-backend/src/util/functions/priorityLab/buildPriorityLabPayload.ts
  • attik-backend/src/util/functions/priorityLab/syncPriorityLabAppointment.ts
  • attik-backend/src/util/functions/priorityLab/priorityLabApi.ts
  • attik-backend/src/events/streamHandlers/inspectionStream.ts (Priority Lab enqueue)
  • attik-backend/src/routes/priorityLab.ts
  • attik-backend/tests/unit/priorityLab.computeAndPayload.test.ts
  • attik-frontend/src/app/tools/inspections/[id]/components/integrations/PriorityLab.tsx

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board
🏠

Main App

Date

18 days ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.