@hogsend/engine 0.46.1 → 0.51.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/README.md +6 -0
- package/package.json +13 -10
- package/src/campaigns/cohort-sql.ts +8 -9
- package/src/connectors/presets/index.ts +8 -2
- package/src/container.ts +150 -8
- package/src/destinations/define-destination.ts +2 -2
- package/src/destinations/presets/posthog.ts +7 -0
- package/src/destinations/presets/segment.ts +5 -0
- package/src/env.ts +38 -0
- package/src/flags/reconcile.ts +200 -0
- package/src/index.ts +79 -0
- package/src/journeys/authoring.ts +32 -0
- package/src/journeys/define-journey.ts +45 -40
- package/src/journeys/execute-journey-run.ts +73 -32
- package/src/journeys/journey-boundary.ts +76 -0
- package/src/journeys/journey-context.ts +128 -70
- package/src/journeys/journey-task-factory.ts +31 -0
- package/src/journeys/journey-task-runtime.ts +31 -0
- package/src/journeys/journey-version.test.ts +236 -0
- package/src/journeys/journey-version.ts +158 -0
- package/src/journeys/record-once.ts +28 -2
- package/src/lib/campaign-send-key.ts +9 -18
- package/src/lib/connector-actions.test.ts +36 -0
- package/src/lib/connector-actions.ts +42 -4
- package/src/lib/contacts.ts +49 -0
- package/src/lib/conversions.test.ts +33 -0
- package/src/lib/conversions.ts +9 -1
- package/src/lib/crm-deals.ts +1 -1
- package/src/lib/crm-ingest.ts +1 -1
- package/src/lib/email.ts +23 -2
- package/src/lib/enrollment-policy.ts +51 -0
- package/src/lib/event-names.ts +7 -1
- package/src/lib/feed.ts +55 -3
- package/src/lib/flags-registry.ts +48 -0
- package/src/lib/flags.ts +498 -0
- package/src/lib/frequency-cap.ts +4 -2
- package/src/lib/funnel-progress.ts +1 -1
- package/src/lib/fx.ts +374 -0
- package/src/lib/global-control-readout.ts +166 -0
- package/src/lib/groups.ts +362 -0
- package/src/lib/holdout.ts +1 -1
- package/src/lib/ingestion.ts +38 -0
- package/src/lib/journey-lift.ts +142 -0
- package/src/lib/journey-suppress.ts +4 -2
- package/src/lib/lift-stats.ts +2 -2
- package/src/lib/operator-settings.ts +71 -0
- package/src/lib/outbound.ts +147 -0
- package/src/lib/preferences.ts +6 -80
- package/src/lib/recipient-preferences.ts +53 -0
- package/src/lib/sms.ts +21 -2
- package/src/lib/stable-stringify.test.ts +42 -0
- package/src/lib/stable-stringify.ts +23 -0
- package/src/lib/tracked.ts +9 -2
- package/src/lib/variant.ts +99 -0
- package/src/lib/webhook-signing.ts +16 -1
- package/src/lists/registry.ts +6 -2
- package/src/lists/subscription.ts +13 -0
- package/src/routes/admin/attribution.ts +1 -2
- package/src/routes/admin/campaigns.ts +84 -45
- package/src/routes/admin/contacts.ts +53 -4
- package/src/routes/admin/conversions.ts +138 -1
- package/src/routes/admin/deals.ts +43 -34
- package/src/routes/admin/emails.ts +4 -6
- package/src/routes/admin/events.ts +128 -1
- package/src/routes/admin/flags.ts +369 -0
- package/src/routes/admin/groups.ts +900 -0
- package/src/routes/admin/impact-schemas.ts +44 -0
- package/src/routes/admin/impact-wire.test.ts +181 -0
- package/src/routes/admin/impact.ts +486 -0
- package/src/routes/admin/index.ts +12 -0
- package/src/routes/admin/journey-impact.ts +446 -0
- package/src/routes/admin/journeys.ts +70 -100
- package/src/routes/admin/settings.ts +145 -0
- package/src/routes/admin/targeting.ts +259 -0
- package/src/routes/events/index.ts +11 -0
- package/src/routes/flags/index.ts +120 -0
- package/src/routes/groups/index.ts +417 -0
- package/src/routes/index.ts +23 -1
- package/src/testing.ts +25 -0
- package/src/webhook-sources/presets/index.ts +5 -1
- package/src/webhook-sources/presets/intercom.ts +230 -0
- package/src/webhook-sources/presets/segment.ts +56 -4
- package/src/worker.ts +3 -0
- package/src/workflows/bucket-backfill.ts +1 -14
- package/src/workflows/crm-reconcile.ts +1 -1
- package/src/workflows/impact-digest.ts +761 -0
- package/src/workflows/journey-blueprint-interpreter.ts +18 -1
- package/src/middleware/auth.ts +0 -24
|
@@ -33,11 +33,13 @@ import {
|
|
|
33
33
|
} from "../journeys/execute-journey-run.js";
|
|
34
34
|
import { TERMINAL_STATUSES } from "../journeys/journey-context.js";
|
|
35
35
|
import { logTransition } from "../journeys/journey-log.js";
|
|
36
|
+
import { computeJourneyVersionHash } from "../journeys/journey-version.js";
|
|
36
37
|
import { sendConnectorAction } from "../lib/connector-actions.js";
|
|
37
38
|
import { getDb } from "../lib/db.js";
|
|
38
39
|
import { sendEmail } from "../lib/email.js";
|
|
39
40
|
import { hatchet } from "../lib/hatchet.js";
|
|
40
41
|
import { createLogger } from "../lib/logger.js";
|
|
42
|
+
import { stableStringify } from "../lib/stable-stringify.js";
|
|
41
43
|
|
|
42
44
|
const logger = createLogger(process.env.LOG_LEVEL);
|
|
43
45
|
|
|
@@ -57,7 +59,7 @@ export function blueprintMetaFromRow(row: JourneyBlueprintRow): JourneyMeta {
|
|
|
57
59
|
const triggerWhere = (row.triggerWhere ?? undefined) as
|
|
58
60
|
| PropertyCondition[]
|
|
59
61
|
| undefined;
|
|
60
|
-
|
|
62
|
+
const base: JourneyMeta = {
|
|
61
63
|
id: row.id,
|
|
62
64
|
name: row.name,
|
|
63
65
|
...(row.description ? { description: row.description } : {}),
|
|
@@ -77,6 +79,21 @@ export function blueprintMetaFromRow(row: JourneyBlueprintRow): JourneyMeta {
|
|
|
77
79
|
// JourneyMeta.suppress (the boundary maps it to suppressMs: 0).
|
|
78
80
|
suppress: (row.suppress ?? {}) as DurationObject,
|
|
79
81
|
};
|
|
82
|
+
// Impact experiments (Decision A): blueprint enrollments stamp a
|
|
83
|
+
// graph-content hash with v{row.version} as the label. The run always
|
|
84
|
+
// executes the CURRENT graph and hashes this same current row, so the
|
|
85
|
+
// stamp reflects the content that ran. stableStringify(row.graph) is
|
|
86
|
+
// key-order-stable — jsonb round-trip reordering cannot fork the hash.
|
|
87
|
+
// (The context.__blueprintVersion dispatch-time pin is a different
|
|
88
|
+
// question and stays untouched.)
|
|
89
|
+
return {
|
|
90
|
+
...base,
|
|
91
|
+
version: `v${row.version}`,
|
|
92
|
+
versionHash: computeJourneyVersionHash({
|
|
93
|
+
meta: base,
|
|
94
|
+
body: stableStringify(row.graph),
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
80
97
|
}
|
|
81
98
|
|
|
82
99
|
/**
|
package/src/middleware/auth.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Context } from "hono";
|
|
2
|
-
import { createMiddleware } from "hono/factory";
|
|
3
|
-
import type { AppEnv } from "../app.js";
|
|
4
|
-
|
|
5
|
-
async function resolveSession(c: Context<AppEnv>) {
|
|
6
|
-
const { auth } = c.get("container");
|
|
7
|
-
const session = await auth.api.getSession({ headers: c.req.raw.headers });
|
|
8
|
-
c.set("user", session?.user ?? null);
|
|
9
|
-
c.set("session", session?.session ?? null);
|
|
10
|
-
return session;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const sessionMiddleware = createMiddleware<AppEnv>(async (c, next) => {
|
|
14
|
-
await resolveSession(c);
|
|
15
|
-
return next();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export const requireAuth = createMiddleware<AppEnv>(async (c, next) => {
|
|
19
|
-
const session = await resolveSession(c);
|
|
20
|
-
if (!session) {
|
|
21
|
-
return c.json({ error: "Unauthorized" }, 401);
|
|
22
|
-
}
|
|
23
|
-
return next();
|
|
24
|
-
});
|