@aranova/tracking-next 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +48 -1
  2. package/dist/blog-server.js.map +1 -1
  3. package/dist/blog-server.mjs.map +1 -1
  4. package/dist/blog.js.map +1 -1
  5. package/dist/blog.mjs.map +1 -1
  6. package/dist/calendar-server.d.mts +1 -1
  7. package/dist/calendar-server.d.ts +1 -1
  8. package/dist/calendar-server.js.map +1 -1
  9. package/dist/calendar-server.mjs.map +1 -1
  10. package/dist/calendar.d.mts +14 -3
  11. package/dist/calendar.d.ts +14 -3
  12. package/dist/calendar.js +212 -18
  13. package/dist/calendar.js.map +1 -1
  14. package/dist/calendar.mjs +211 -18
  15. package/dist/calendar.mjs.map +1 -1
  16. package/dist/client.d.mts +9 -3
  17. package/dist/client.d.ts +9 -3
  18. package/dist/client.js +550 -194
  19. package/dist/client.js.map +1 -1
  20. package/dist/client.mjs +550 -194
  21. package/dist/client.mjs.map +1 -1
  22. package/dist/index.d.mts +10 -9
  23. package/dist/index.d.ts +10 -9
  24. package/dist/index.js +491 -284
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +490 -284
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/{ingest-typed-BdKmlouW.d.ts → ingest-typed-MBuMe9Pn.d.ts} +94 -2
  29. package/dist/{ingest-typed-Bo7WPmpU.d.mts → ingest-typed-UA13xTfI.d.mts} +94 -2
  30. package/dist/{phone-utils-CubQif9Z.d.mts → phone-utils-C0ds6cqZ.d.mts} +6 -0
  31. package/dist/{phone-utils-CubQif9Z.d.ts → phone-utils-C0ds6cqZ.d.ts} +6 -0
  32. package/dist/phone.d.mts +1 -1
  33. package/dist/phone.d.ts +1 -1
  34. package/dist/{sales-DG150g3o.d.ts → sales-DQC815f3.d.ts} +1 -1
  35. package/dist/{sales-D7KstKA-.d.mts → sales-w1reW_Y3.d.mts} +1 -1
  36. package/dist/sales.d.mts +2 -2
  37. package/dist/sales.d.ts +2 -2
  38. package/dist/sales.js +17 -1
  39. package/dist/sales.js.map +1 -1
  40. package/dist/sales.mjs +17 -1
  41. package/dist/sales.mjs.map +1 -1
  42. package/dist/server.d.mts +1 -1
  43. package/dist/server.d.ts +1 -1
  44. package/dist/{tracking-config-runtime-D7prdTE1.d.mts → tracking-config-runtime-C6H7ofmo.d.mts} +6 -0
  45. package/dist/{tracking-config-runtime-D7prdTE1.d.ts → tracking-config-runtime-C6H7ofmo.d.ts} +6 -0
  46. package/dist/{transport-I_cMSFQ6.d.mts → transport-BlXQZs9Z.d.mts} +120 -50
  47. package/dist/{transport-CDmGOiCq.d.ts → transport-CAZYrZbB.d.ts} +120 -50
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -407,7 +407,54 @@ its Origin allowlist is a browser-enforced header a script forges trivially. A j
407
407
  a database row you can delete; a junk **booking** puts an event on a real person's calendar
408
408
  and emails their contacts.
409
409
 
410
- `bookings.create()` returns a one-time `manage_token`. Put it in your confirmation email and
410
+ Doing your own work around a booking (validation, emails, a CRM)? Call the write client from
411
+ your own route instead of mounting the handler:
412
+
413
+ ```ts
414
+ // app/api/book/route.ts
415
+ import { createCalendarWriteClient } from "@aranova/tracking-next/calendar-server";
416
+ import { isCalendarError } from "@aranova/tracking-next/calendar";
417
+
418
+ const calendar = createCalendarWriteClient<AranovaCalendarKey>({
419
+ apiKey: process.env.ARANOVA_TRACKING_SECRET_KEY!,
420
+ endpoint: process.env.ARANOVA_TRACKING_ENDPOINT!,
421
+ });
422
+
423
+ const booking = await calendar.create({
424
+ calendar_key: "bookings",
425
+ start_at: "2026-10-14T13:00:00-04:00", // timed: start_at + duration_minutes (or end_at)
426
+ duration_minutes: 60,
427
+ // date: "2026-10-14", // all-day instead: a local date, no start/end/buffers
428
+ time_zone: "America/Toronto",
429
+ customer: { email, name, phone },
430
+ description: "<b>Arrive 1–2 PM</b>", // reaches Google exactly as sent
431
+ idempotency_key: submissionId,
432
+ metadata: body.attribution, // getBookingAttribution(), sent from the browser
433
+ });
434
+ ```
435
+
436
+ - **Forward the visit.** `getBookingAttribution()` (from `./calendar`, browser only) returns the
437
+ visit's `session_id`, `visitor_id`, `gclid`/`fbclid` and `utm_*`. It is what ties a booking to the
438
+ visitor's journey and form submission in the dashboard, and what missed-booking detection matches
439
+ on. It reads browser storage, so a custom route can't compute it: the browser sends it with the
440
+ form and the route passes it into `create({ metadata })`. `useBookingForm` merges it in for you
441
+ (your `metadata` keys win).
442
+
443
+ - **Overlaps are per calendar.** `ARANOVA_CALENDARS[].allowOverlaps` (from the CLI) says whether a
444
+ calendar accepts double bookings. When it is `false`, `create()` can throw `slot_unavailable`:
445
+ `isCalendarError(err, "slot_unavailable")`. Other codes: `calendar_not_connected`,
446
+ `calendar_disconnected`, `booking_not_found`, `booking_not_cancellable`,
447
+ `booking_not_reschedulable`, `manage_token_invalid`, `rate_limited`, `google_error`.
448
+ - **No server-side booking window.** Notice and how far ahead customers may book are your policy.
449
+ - **Your email can be the calendar invite.** The customer is always an attendee of the Google
450
+ event. Pass `send_invites: false` so Google sends nothing, then attach an ICS (`METHOD:REQUEST`)
451
+ with `UID` = `booking.ical_uid` and `ORGANIZER` = `booking.organizer_email`, so the customer's
452
+ copy is the same event as the calendar owner's. For `booking.all_day`, use
453
+ `DTSTART;VALUE=DATE`. `ical_uid` is null if Google hasn't confirmed the write; send a plain
454
+ confirmation then.
455
+ - **All-day bookings** are moved in Google Calendar, not through `reschedule()`.
456
+
457
+ `create()` returns a one-time `manage_token`. Put it in your confirmation email and
411
458
  send it as `X-Aranova-Manage-Token` to reschedule or cancel — it authorises exactly that one
412
459
  booking, which is why a public key alone still manages nothing.
413
460