@hogsend/engine 0.55.0 → 0.57.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.
- package/package.json +11 -11
- package/src/buckets/bucket-access.ts +5 -10
- package/src/buckets/check-membership.ts +91 -6
- package/src/index.ts +31 -1
- package/src/journeys/execute-journey-run.ts +56 -1
- package/src/journeys/journey-context.ts +59 -0
- package/src/lib/bucket-emit.test.ts +83 -2
- package/src/lib/bucket-emit.ts +16 -0
- package/src/lib/contacts.ts +1031 -141
- package/src/lib/crm-ingest.ts +9 -0
- package/src/lib/enrichment-ledger.ts +1 -1
- package/src/lib/feed.ts +64 -3
- package/src/lib/identity-service.ts +15 -2
- package/src/lib/ingestion.ts +191 -14
- package/src/lib/outbound.ts +3 -3
- package/src/lib/refine-chain.test.ts +83 -25
- package/src/lib/refine-chain.ts +124 -23
- package/src/lib/refine-traits.test.ts +74 -41
- package/src/lib/refine-traits.ts +107 -52
- package/src/lib/refine.ts +28 -27
- package/src/lib/tracking-events.ts +33 -6
- package/src/routes/admin/agent.ts +26 -0
- package/src/routes/admin/contacts.ts +65 -5
- package/src/routes/admin/identity.ts +197 -0
- package/src/routes/admin/index.ts +2 -0
- package/src/routes/contacts/index.ts +50 -7
- package/src/routes/events/index.ts +94 -6
- package/src/routes/feed/index.ts +36 -0
- package/src/routes/feed/recipient.ts +44 -2
- package/src/routes/lists/index.ts +21 -0
- package/src/routes/tracking/arrive.ts +42 -3
- package/src/worker.ts +18 -0
- package/src/workflows/bucket-backfill.ts +1 -1
- package/src/workflows/bucket-reconcile.ts +129 -4
- package/src/workflows/identity-alias-backfill.ts +448 -0
- package/src/workflows/import-contacts.ts +10 -0
- package/src/workflows/send-campaign.ts +31 -13
|
@@ -130,6 +130,16 @@ export const importContactsTask = hatchet.task({
|
|
|
130
130
|
userId: row.externalId,
|
|
131
131
|
email: row.email,
|
|
132
132
|
contactProperties: row.properties,
|
|
133
|
+
// PRD 06 T4 (L5 row 21): an operator import asserts identity by
|
|
134
|
+
// externalId/email only (the key guard above rejects rows with
|
|
135
|
+
// neither; `phone` attaches OUTSIDE the resolver, below) — so
|
|
136
|
+
// create-on-miss, no clamp, and the narrow `trustedKinds` is the
|
|
137
|
+
// honest statement. Enforced by T5.
|
|
138
|
+
policy: {
|
|
139
|
+
create: "on-miss",
|
|
140
|
+
allowMerge: "any",
|
|
141
|
+
trustedKinds: ["external", "email"],
|
|
142
|
+
},
|
|
133
143
|
}).then(async (result) => {
|
|
134
144
|
await attachPhone(db, result.id, row.phone);
|
|
135
145
|
return { index: i + idx, ok: true };
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
waveConditionSql,
|
|
20
20
|
} from "../campaigns/cohort-sql.js";
|
|
21
21
|
import { campaignSendKey } from "../lib/campaign-send-key.js";
|
|
22
|
-
import { normalizeEmail } from "../lib/contacts.js";
|
|
22
|
+
import { contactKeySql, normalizeEmail } from "../lib/contacts.js";
|
|
23
23
|
import { getDb } from "../lib/db.js";
|
|
24
24
|
import { getEmailService } from "../lib/email.js";
|
|
25
25
|
import { hatchet } from "../lib/hatchet.js";
|
|
@@ -973,18 +973,36 @@ async function* resolveBucketRecipients(
|
|
|
973
973
|
];
|
|
974
974
|
if (cursor) conditions.push(gt(bucketMemberships.id, cursor));
|
|
975
975
|
|
|
976
|
-
return
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
976
|
+
return (
|
|
977
|
+
db
|
|
978
|
+
.select({
|
|
979
|
+
id: bucketMemberships.id,
|
|
980
|
+
userId: bucketMemberships.userId,
|
|
981
|
+
membershipEmail: bucketMemberships.userEmail,
|
|
982
|
+
contactEmail: contacts.email,
|
|
983
|
+
})
|
|
984
|
+
.from(bucketMemberships)
|
|
985
|
+
// Join on the CANONICAL key, not `external_id` alone.
|
|
986
|
+
// `bucket_memberships.user_id` holds `coalesce(external_id,
|
|
987
|
+
// anonymous_id, id)`, so a contact with a NULL `external_id` — an
|
|
988
|
+
// email-only subscriber keyed on its uuid, or an anonymous visitor
|
|
989
|
+
// keyed on its `anonymous_id` — matched nothing here and was silently
|
|
990
|
+
// dropped from the audience. They were genuine active members of the
|
|
991
|
+
// bucket; they simply never received the campaign, and nothing
|
|
992
|
+
// surfaced it: a send report showing 40 of 40 delivered looks complete
|
|
993
|
+
// whether or not the audience was built correctly.
|
|
994
|
+
//
|
|
995
|
+
// Suppression is unaffected by widening this join. Every gate lives in
|
|
996
|
+
// the same `conditions` array applied to this query and is keyed on
|
|
997
|
+
// `recipientEmail` (`coalesce(membership email, contact email)`, lowered
|
|
998
|
+
// and trimmed), not on the join column — so a newly-visible member is
|
|
999
|
+
// filtered by the identical unsubscribed/suppressed `NOT EXISTS` as
|
|
1000
|
+
// everyone else, and the mailer re-checks preferences per send.
|
|
1001
|
+
.innerJoin(contacts, eq(contactKeySql(), bucketMemberships.userId))
|
|
1002
|
+
.where(and(...conditions))
|
|
1003
|
+
.orderBy(bucketMemberships.id)
|
|
1004
|
+
.limit(CHUNK_SIZE)
|
|
1005
|
+
);
|
|
988
1006
|
},
|
|
989
1007
|
cursorOf: (row) => row.id,
|
|
990
1008
|
map: (row) => {
|