@hogsend/db 0.22.0 → 0.23.1

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.
@@ -190,6 +190,13 @@
190
190
  "when": 1781382218591,
191
191
  "tag": "0026_warm_freak",
192
192
  "breakpoints": true
193
+ },
194
+ {
195
+ "idx": 27,
196
+ "version": "7",
197
+ "when": 1781546768414,
198
+ "tag": "0027_wealthy_aqueduct",
199
+ "breakpoints": true
193
200
  }
194
201
  ]
195
202
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hogsend/db",
3
- "version": "0.22.0",
3
+ "version": "0.23.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,9 +14,23 @@ export const trackedLinks = pgTable(
14
14
  "tracked_links",
15
15
  {
16
16
  id: uuid("id").defaultRandom().primaryKey(),
17
- emailSendId: uuid("email_send_id")
18
- .notNull()
19
- .references(() => emailSends.id, { onDelete: "cascade" }),
17
+ // NULLABLE since the identity-stitching minor: a tracked link no longer has
18
+ // to belong to an email send. Broadcast/non-email links (Discord, referral,
19
+ // ad-hoc `createTrackedLink`) carry NULL here. Email-link inserts keep
20
+ // populating it; the FK + index are unchanged.
21
+ emailSendId: uuid("email_send_id").references(() => emailSends.id, {
22
+ onDelete: "cascade",
23
+ }),
24
+ // Subject of a stitch-bearing NON-email link: the canonical contact key the
25
+ // click should fold the visitor's anon session into. NULL for broadcast
26
+ // links (Discord/referral default) — broadcast links are tracked for click
27
+ // counts but carry no identity. Email links resolve their subject from the
28
+ // `email_sends` row instead, so this stays NULL for them too.
29
+ distinctId: text("distinct_id"),
30
+ // Where the link originated: "email" | "discord" | "link". Drives the click
31
+ // route's per-hit outbound emit (email links emit `email.clicked`; non-email
32
+ // links emit `link.clicked`). NULL on legacy/email rows.
33
+ source: text("source"),
20
34
  originalUrl: text("original_url").notNull(),
21
35
  clickCount: integer("click_count").notNull().default(0),
22
36
  // Semantic link metadata, lifted from the template's data-hs-* attributes