Skip to content

feat(insights): investigate saved activation and return outcomes - #775

Merged
izadoesdev merged 6 commits into
stagingfrom
codex/activation-measurement-plan
Sep 9, 2026
Merged

feat(insights): investigate saved activation and return outcomes#775
izadoesdev merged 6 commits into
stagingfrom
codex/activation-measurement-plan

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 9, 2026

Copy link
Copy Markdown
Member

Saved business context could describe meaningful behavior without measuring whether the same identified profiles returned. Add an editable activation/return definition per website and feed independently measured, complete weekly cohorts into the existing investigation pipeline. For example, steady event volume can now coexist with a measured 140/200 → 60/200 return decline, with no invented cause or customer-churn claim.

Definitions share the organization settings/oRPC save, draft recovery, revision and restore flows; AI brief regeneration preserves them. Saves and restores reject stale or foreign website bindings. The UI uses shared components and event suggestions with manual editing. Existing organization metadata is the durable store; no migration or parallel agent engine is added.

Each week is queried independently so repeat activators can belong to both cohorts. Exact event selectors, eligible denominators, maturity bounds and event-level identity coverage remain explicit. Weak/incomplete comparisons are withheld; priorities and newer team replies still participate in selection. Cohort entities preserve valid product outcomes without weakening the raw-traffic publication guard. Query discovery exposes supported filters and accepts its documented canonical order.

Validation: repository lint, 33 typecheck tasks, full 27-task test pipeline, 608 Insights tests, 37 synthetic PostgreSQL service tests, 32 AI-context tests, 11 browser regressions, and desktop/mobile inspection. Real ClickHouse regression with 600 events/100 overlapping profiles reproduced a false 50% → 0% combined-window result and verified the independent-week 50% → 50% result.

Fresh live-model evaluation: three preserved trials, 72 case-arm runs. The selected source version delivers 8/8 material scheduled findings and suppresses all four candidate non-actionable/explained cases. This is synthetic aggregate replay through production model/agent/parser code, separate from SQL execution, and not a production ROI benchmark. Remaining limitations include small-sample wording, missing presentation qualifiers and verbose requested answers. Independent code and semantic reviews found no remaining blocker for this slice.

Builds on merged #774 and current staging; the obsolete schema proposal #751 is not a dependency. Scope: saved definitions, settings, context delivery and native cohort detection. AI-assisted implementation and independent agent reviews under maintainer authorization.

@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
databuddy-status Ready Ready Preview Sep 9, 2026 11:12am UTC
2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Sep 9, 2026 11:12am UTC
documentation Skipped Skipped Sep 9, 2026 11:12am UTC

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: dc45d8db-78c5-43c6-bae8-f68e3a405bb0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@unkey-deploy

unkey-deploy Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Sep 9, 2026 11:12am

@vercel
vercel Bot temporarily deployed to Preview – dashboard September 9, 2026 11:11 Inactive
@vercel
vercel Bot temporarily deployed to Preview – documentation September 9, 2026 11:11 Inactive
@izadoesdev
izadoesdev marked this pull request as ready for review September 9, 2026 11:16
@izadoesdev
izadoesdev merged commit 7624d83 into staging Sep 9, 2026
19 checks passed
@izadoesdev
izadoesdev deleted the codex/activation-measurement-plan branch September 9, 2026 11:16
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds organization-level activation/return definitions and integrates independently measured identified-profile retention cohorts into Insights.

  • Adds dashboard editing, draft recovery, history, restore, and event suggestions for measurement plans.
  • Persists plans in existing organization business-context metadata with revision and website-binding checks.
  • Adds the native identified-profile retention query, cohort validation, signal generation, prioritization, remeasurement, and AI context delivery.
  • Extends shared contracts and regression coverage across dashboard, services, query building, and investigation behavior.
  • Two lifecycle gaps remain: omitted plans bypass effective binding validation, and changed definitions can strand obsolete due investigations.

Confidence Score: 3/5

The PR is not yet safe to merge because stale plans can bypass save-time binding validation and edited definitions can leave obsolete investigations perpetually due; the explicit dashboard typography requirement must also be satisfied.

Two concrete lifecycle failures remain: omission-based saves persist unvalidated inherited bindings, and definition changes defer old retention cases without retiring them. The new dashboard component also violates an explicit repository typography rule.

Files Needing Attention: packages/services/src/organization-business-context.ts, apps/insights/src/measurement-plan.ts, apps/dashboard/app/(main)/organizations/components/measurement-plan-editor.tsx

Important Files Changed

Filename Overview
packages/services/src/organization-business-context.ts Persists and restores measurement plans with binding checks, but validates the input rather than inherited plans during omission-based saves.
apps/insights/src/measurement-plan.ts Implements independent retention cohorts and strong result validation, but leaves due cases stranded when their saved definition changes or disappears.
packages/ai/src/query/builders/retention.ts Defines a parameterized, private identified-profile retention query with explicit selectors, maturity, identity coverage, and fixed aggregation.
apps/insights/src/generation.ts Adds retention discovery, prioritization, and remeasurement to the investigation pipeline, including the deferred path involved in obsolete due cases.
apps/dashboard/app/(main)/organizations/components/measurement-plan-editor.tsx Adds shared-component-based plan editing and stale-binding repair, but misses required typography utility classes.
apps/dashboard/app/(main)/organizations/components/business-context-editor.tsx Integrates measurement plans into draft, validation, save, conflict, generation, and history workflows.
packages/shared/src/organization-business-context.ts Adds bounded measurement-plan schemas and shared formatting while retaining backward-compatible optional storage.
packages/ai/src/lib/organization-business-context.ts Delivers only plans whose website and domain remain within the caller's authorized website set.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Organization settings] --> B[Save measurement plan]
    B --> C[Organization metadata]
    C --> D[Load current website-bound plan]
    D --> E[Query previous cohort independently]
    D --> F[Query current cohort independently]
    E --> G[Validate complete identified-profile counts]
    F --> G
    G --> H[Create retention signal]
    H --> I[Portfolio selection]
    I --> J[Investigation agent]
    J --> K[Persist case and observation]
    C --> L[AI business-context delivery]
Loading

Reviews (1): Last reviewed commit: "Revert "fix(insights): finish from suffi..." | Re-trigger Greptile

Comment thread packages/services/src/organization-business-context.ts
Comment thread apps/insights/src/measurement-plan.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant