Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

notification: take the chart vocabulary from the module that owns it

Carl-Gerhard Lindesvärd180c258b73b7
diff --git a/ISSUES.md b/ISSUES.md
index e6cf13f21..a27ae4db4 100644
--- a/ISSUES.md
+++ b/ISSUES.md
@@ -66,11 +66,9 @@ That file was a dated log of work that landed, not a to-do list. Four of its
devDependencies, and `verification/golden/queue-keys/`, whose directory is
gone). These are what was left, each re-checked against the tree on 2026-09-28:
-- **`tooling/gates/conformance/rules.test.ts` runs in no suite.** The root
- `test` script is core + db + api + seed + start + `vitest run`; `tooling/` is
- in neither list, so the conformance gate's own regression tests only run by
- hand (`cd tooling/gates/conformance && bun test` → 19 pass, 0 fail). Wiring
- it in is one entry in the root `package.json`.
+- ~~**`tooling/gates/conformance/rules.test.ts` runs in no suite.**~~ Fixed
+ 2026-09-29: the root `test` script now ends with
+ `bun test tooling/gates/conformance` (19 pass, 0 fail).
- **The conformance R14 residue scan does not reach `packages/`.**
`tooling/gates/conformance/cli.ts` builds `residueFiles` from `packages/core`,
`apps/api` and `apps/start` only, so the one surviving `NEXT_PUBLIC_`
@@ -93,16 +91,15 @@ gone). These are what was left, each re-checked against the tree on 2026-09-28:
### Found while cleaning comments (2026-09-28)
-- **`notification.constants.ts` duplicates three schemas from
- `report.constants.ts`.** `zChartEvent`, `zChartEventFilter` and
- `zChartEventSegment` are local copies whose operator and value-type enums are
- inlined as literal tuples rather than derived from `operators` /
- `filterValueTypes`. Verified on 2026-09-28: both enum sets are identical
- (15 operators, 5 value types) and `report.constants.ts` does not import
- `notification.constants.ts`, so there is no cycle — the copies can be
- collapsed onto the report module's. The file's own TODO asked for exactly
- this once `report.constants.ts` existed, which it now does. Left as a
- refactor rather than done inside a comment pass.
+- ~~**`notification.constants.ts` duplicates three schemas from
+ `report.constants.ts`.**~~ Fixed 2026-09-29: the local `zChartEvent`,
+ `zChartEventFilter` and `zChartEventSegment` copies, and the three inlined
+ enum tuples behind them, are gone; the file imports `zChartEvent` from the
+ report module instead. All three enum sets were confirmed identical
+ (15 operators, 5 value types, 10 segments) and the report schema was
+ confirmed to parse a notification-shaped payload before the swap.
+ `constants-stay-isomorphic` still passes, since a `*.constants.ts` may
+ import another. 107 lines removed.
Everything else below is still open.
diff --git a/package.json b/package.json
index 76b8f1b95..9928540c4 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,7 @@
"vue": "3.5.25"
},
"scripts": {
- "test": "bun run --filter @openpanel/core test && bun run --filter @openpanel/db test && bun run --filter @openpanel/api test && bun run --filter @openpanel/seed test && bun run --filter start test && vitest run",
+ "test": "bun run --filter @openpanel/core test && bun run --filter @openpanel/db test && bun run --filter @openpanel/api test && bun run --filter @openpanel/seed test && bun run --filter start test && vitest run && bun test tooling/gates/conformance",
"gen:bots": "bun run --filter @openpanel/core gen:bots",
"gen:referrers": "bun run --filter @openpanel/core gen:referrers",
"dock:up": "docker compose up -d",
diff --git a/packages/core/src/modules/notification/notification.constants.ts b/packages/core/src/modules/notification/notification.constants.ts
index 70a090a09..bdda72bba 100644
--- a/packages/core/src/modules/notification/notification.constants.ts
+++ b/packages/core/src/modules/notification/notification.constants.ts
@@ -1,109 +1,7 @@
-// `zChartEvent` / `zChartEventFilter` / `zChartEventSegment` are diverged local
-// copies of report.constants.ts's, with the operator and value-type enums
-// inlined as literal tuples instead of derived from `operators` /
-// `filterValueTypes`. The enum sets are identical, so the copies can be
-// collapsed onto report.constants.ts — see ISSUES.md.
+// The event/filter vocabulary comes from the report module, which owns it.
import { z } from 'zod';
-
-const CHART_EVENT_FILTER_OPERATORS = [
- 'is',
- 'isNot',
- 'contains',
- 'doesNotContain',
- 'startsWith',
- 'endsWith',
- 'regex',
- 'isNull',
- 'isNotNull',
- 'gt',
- 'lt',
- 'gte',
- 'lte',
- 'inCohort',
- 'notInCohort',
-] as const;
-
-const CHART_EVENT_FILTER_VALUE_TYPES = [
- 'string',
- 'number',
- 'date',
- 'datetime',
- 'boolean',
-] as const;
-
-const CHART_EVENT_SEGMENTS = [
- 'event',
- 'user',
- 'session',
- 'group',
- 'user_average',
- 'one_event_per_user',
- 'property_sum',
- 'property_average',
- 'property_max',
- 'property_min',
-] as const;
-
-const zChartEventFilter = z.object({
- id: z.string().optional().describe('Unique identifier for the filter'),
- name: z.string().describe('The property name to filter on'),
- operator: z
- .enum(CHART_EVENT_FILTER_OPERATORS)
- .describe('The operator to use for the filter'),
- value: z
- .array(z.string().or(z.number()).or(z.boolean()).or(z.null()))
- .describe('The values to filter on'),
- type: z
- .enum(CHART_EVENT_FILTER_VALUE_TYPES)
- .optional()
- .describe(
- 'Cast type for the column/value in equality & comparison operators ' +
- '(string/number/date/datetime/boolean). Absent = legacy behavior.'
- ),
- cohortId: z
- .string()
- .optional()
- .describe(
- 'DEPRECATED: legacy single-cohort id, kept for saved reports. ' +
- 'New code reads cohortIds via getCohortIds(filter).'
- ),
- cohortIds: z
- .array(z.string())
- .optional()
- .describe(
- 'Cohort IDs for inCohort/notInCohort. Multiple ids OR-match ' +
- '(matches profiles in any of the listed cohorts).'
- ),
-});
-
-const zChartEventSegment = z
- .enum(CHART_EVENT_SEGMENTS)
- .default('event')
- .describe('Defines how the event data should be segmented or aggregated');
-
-const zChartEvent = z.object({
- id: z
- .string()
- .optional()
- .describe('Unique identifier for the chart event configuration'),
- name: z.string().describe('The name of the event as tracked in the system'),
- displayName: z
- .string()
- .optional()
- .describe('A user-friendly name for display purposes'),
- property: z
- .string()
- .optional()
- .describe(
- 'Optional property of the event used for specific segment calculations (e.g., value for property_sum/average)'
- ),
- segment: zChartEventSegment,
- filters: z
- .array(zChartEventFilter)
- .default([])
- .describe('Filters applied specifically to this event'),
-});
+import { zChartEvent } from '../report/report.constants';
export const zNotificationRuleEventConfig = z.object({
type: z.literal('events'),