Skip to content

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

ralph(M15-004): R6: the 204 db/ch/redis handle loaders die by using the deps the caller already holds - v1-compat's wrapper class (b), convertible one module at a time

ralph6890e265bc26
diff --git a/apps/api/e2e/legacy-job-proof.ts b/apps/api/e2e/legacy-job-proof.ts
index 4227508dc..388202f56 100644
--- a/apps/api/e2e/legacy-job-proof.ts
+++ b/apps/api/e2e/legacy-job-proof.ts
@@ -276,6 +276,8 @@ async function main() {
const buffers = createBuffers({
createLogger: (name) => logger.child({ name }),
isCronPaused: async () => false,
+ // Never flushed: this proof asserts BullMQ keys, not ClickHouse rows.
+ ch: undefined as unknown as AppDeps['ch'],
});
const deps: AppDeps = {
diff --git a/apps/api/scripts/test.ts b/apps/api/scripts/test.ts
index 5492dfcc3..b1fc9c13d 100644
--- a/apps/api/scripts/test.ts
+++ b/apps/api/scripts/test.ts
@@ -1,11 +1,11 @@
-import { type IClickhouseEvent, createEvent } from '@openpanel/core';
+import type { IClickhouseEvent } from '@openpanel/core';
import { ch, formatClickhouseDate } from '@openpanel/db';
import { v4 as uuid } from 'uuid';
async function main() {
const startDate = new Date('2025-01-01T00:00:00Z');
const endDate = new Date();
- const eventsPerDay = 25000;
+ const eventsPerDay = 25_000;
const variance = 3000;
// Event names to randomly choose from
@@ -36,7 +36,7 @@ async function main() {
device_id: `device_${Math.floor(Math.random() * 1000)}`,
profile_id: `profile_${Math.floor(Math.random() * 1000)}`,
project_id: 'testing',
- session_id: `session_${Math.floor(Math.random() * 10000)}`,
+ session_id: `session_${Math.floor(Math.random() * 10_000)}`,
properties: {
hash: 'test-hash',
'query.utm_source': 'test',
@@ -75,7 +75,7 @@ async function main() {
// Log progress
console.log(
- `Created ${dailyEvents} events for ${currentDate.toISOString().split('T')[0]}`,
+ `Created ${dailyEvents} events for ${currentDate.toISOString().split('T')[0]}`
);
}
}
diff --git a/packages/core/src/buffers/base-buffer.ts b/packages/core/src/buffers/base-buffer.ts
index 2dfe051c8..3032e04ca 100644
--- a/packages/core/src/buffers/base-buffer.ts
+++ b/packages/core/src/buffers/base-buffer.ts
@@ -6,13 +6,6 @@ import type { ServiceDeps } from '../services';
import { type ChQueryInput, type ChScope, chQuery } from '../shared/ch-query';
import { generateSecureId } from '../shared/id';
-// GENUINE CYCLE, kept lazy: v1-compat.ts -> services.ts -> (every service) ->
-// this module. The fallback only fires for `BufferDeps` built without a `ch`
-// — see that field's comment.
-function loadCompatCh(): Promise<ServiceDeps['ch']> {
- return import('../v1-compat').then((m) => m.compatCh());
-}
-
/**
* What a buffer needs from the boot scope. Buffers are built once by
* `createBuffers(deps)` and hung on `AppDeps` — never module singletons, so a
@@ -29,18 +22,13 @@ export interface BufferDeps {
* The boot scope's ClickHouse client — the same round-robin/retry proxy
* every service reaches as `deps.ch`. M10-009: the buffers used to lazily
* `import('@openpanel/db/src/clickhouse/client')` for it, which constructed
- * a second client (and a second pino transport) outside any scope.
- *
- * OPTIONAL, deliberately: `@openpanel/queue`'s process-wide buffer
- * singleton used to be the pre-`AppDeps` caller with no client to hand
- * in; that caller was deleted with the package (M11-004), but
- * `apps/api/e2e/legacy-job-proof.ts` — a BullMQ-keys-only proof that never
- * flushes to ClickHouse — builds `BufferDeps` the same way, so the field
- * and the fallback stay. When it is absent, `resolveCh()` reaches the boot
- * scope through the declared v1-compat seam — which, once `main.ts` has
- * registered, is the very same client, not a second one.
+ * a second client (and a second pino transport) outside any scope. M15-004
+ * made it required: the one caller that had none
+ * (`apps/api/e2e/legacy-job-proof.ts`, a BullMQ-keys-only proof that never
+ * flushes to ClickHouse) already passes the field, so the v1-compat fallback
+ * behind it had no live path left.
*/
- ch?: ServiceDeps['ch'];
+ ch: ServiceDeps['ch'];
/**
* Asked before every flush. ADR-005's `ProducerHandle.bullQueues` escape
* hatch, narrowed to the one thing the buffers ask BullMQ directly: pausing
@@ -126,13 +114,13 @@ export class BaseBuffer {
} = {};
/** The scope's ClickHouse client, for a subclass's insert path. */
- protected async resolveCh(): Promise<ServiceDeps['ch']> {
- return this.deps.ch ?? (await loadCompatCh());
+ protected resolveCh(): ServiceDeps['ch'] {
+ return this.deps.ch;
}
/** `chQuery` bound to this buffer's client and its own logger. */
protected async chQuery<T extends object>(query: ChQueryInput): Promise<T[]> {
- const scope: ChScope = { ch: await this.resolveCh(), logger: this.logger };
+ const scope: ChScope = { ch: this.resolveCh(), logger: this.logger };
return chQuery<T>(scope, query);
}
diff --git a/packages/core/src/buffers/bot-buffer.ts b/packages/core/src/buffers/bot-buffer.ts
index 7270f07c8..2707f83bb 100644
--- a/packages/core/src/buffers/bot-buffer.ts
+++ b/packages/core/src/buffers/bot-buffer.ts
@@ -60,7 +60,7 @@ export class BotBuffer extends BaseBuffer {
// Raw passthrough: each Redis entry is already a valid JSONEachRow
// line. Streaming raw strings skips JSON.parse + the client's
// re-stringify on the hot path.
- const ch = await this.resolveCh();
+ const ch = this.resolveCh();
const chStart = performance.now();
await ch.insert({
table: TABLE_NAMES.events_bots,
diff --git a/packages/core/src/buffers/event-buffer.ts b/packages/core/src/buffers/event-buffer.ts
index ec435db96..18ae870c9 100644
--- a/packages/core/src/buffers/event-buffer.ts
+++ b/packages/core/src/buffers/event-buffer.ts
@@ -225,7 +225,7 @@ export class EventBuffer extends BaseBuffer {
}
}
- const ch = await this.resolveCh();
+ const ch = this.resolveCh();
const chStart = performance.now();
await this.parallelLimit(
this.chunks(queueEvents, this.chunkSize),
diff --git a/packages/core/src/buffers/group-buffer.ts b/packages/core/src/buffers/group-buffer.ts
index 241c65256..86dada5d2 100644
--- a/packages/core/src/buffers/group-buffer.ts
+++ b/packages/core/src/buffers/group-buffer.ts
@@ -175,7 +175,7 @@ export class GroupBuffer extends BaseBuffer {
// Raw passthrough: each Redis entry is already a valid JSONEachRow
// line. Streaming raw strings to CH skips JSON.parse + the client's
// re-stringify on the hot path.
- const ch = await this.resolveCh();
+ const ch = this.resolveCh();
const chStart = performance.now();
await this.parallelLimit(this.chunks(items, this.chunkSize), (chunk) =>
ch.insert({
diff --git a/packages/core/src/buffers/profile-backfill-buffer.ts b/packages/core/src/buffers/profile-backfill-buffer.ts
index 24a0ec438..8828d2708 100644
--- a/packages/core/src/buffers/profile-backfill-buffer.ts
+++ b/packages/core/src/buffers/profile-backfill-buffer.ts
@@ -69,7 +69,7 @@ export class ProfileBackfillBuffer extends BaseBuffer {
}
const entries = Array.from(seen.values());
- const ch = await this.resolveCh();
+ const ch = this.resolveCh();
const table = getReplicatedTableName(TABLE_NAMES.events);
const chunks = this.chunks(entries, CHUNK_SIZE);
diff --git a/packages/core/src/buffers/profile-buffer.ts b/packages/core/src/buffers/profile-buffer.ts
index be9f8bc0a..b57e3400b 100644
--- a/packages/core/src/buffers/profile-buffer.ts
+++ b/packages/core/src/buffers/profile-buffer.ts
@@ -365,7 +365,7 @@ export class ProfileBuffer extends BaseBuffer {
}
}
- const ch = await this.resolveCh();
+ const ch = this.resolveCh();
const chStart = performance.now();
await this.parallelLimit(this.chunks(toInsert, this.chunkSize), (chunk) =>
ch.insert({
diff --git a/packages/core/src/buffers/replay-buffer.ts b/packages/core/src/buffers/replay-buffer.ts
index 0ee98cbb6..f030eb723 100644
--- a/packages/core/src/buffers/replay-buffer.ts
+++ b/packages/core/src/buffers/replay-buffer.ts
@@ -76,7 +76,7 @@ export class ReplayBuffer extends BaseBuffer {
// raw strings to CH skips JSON.parse × N on the worker AND the
// client's internal JSON.stringify × N — significant because each
// rrweb chunk's `payload` is 10–100KB.
- const ch = await this.resolveCh();
+ const ch = this.resolveCh();
const chStart = performance.now();
await this.parallelLimit(this.chunks(items, this.chunkSize), (chunk) =>
ch.insert({
diff --git a/packages/core/src/buffers/session-buffer.ts b/packages/core/src/buffers/session-buffer.ts
index 06e5a9527..ab0449b7a 100644
--- a/packages/core/src/buffers/session-buffer.ts
+++ b/packages/core/src/buffers/session-buffer.ts
@@ -566,7 +566,7 @@ export class SessionBuffer extends BaseBuffer {
? this.squashSessionsByVersion(parsed)
: parsed;
- const ch = await this.resolveCh();
+ const ch = this.resolveCh();
for (const chunk of this.chunks(sessions, this.chunkSize)) {
await ch.insert({
table: TABLE_NAMES.sessions,
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index ee7644bb5..b3110e71c 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -1089,77 +1089,41 @@ export {
safeFetchStream,
} from './shared/safe-fetch';
export { assertSafeUrl, createPinnedLookup } from './shared/ssrf';
-// The V1 compat seam (v1-compat.ts): the bare, deps-free spellings of every
-// module whose functions gained a `ServiceDeps` first parameter, kept for
-// `packages/trpc`'s still-live routers and the mcp/assistant tool runtimes,
-// which have no `Ctx` to carry `ServiceDeps`. Everything with a `Ctx` uses
-// `ctx.services.*` instead. Deleted whole with `packages/trpc` at P10.
+// What is left of the V1 compat seam (v1-compat.ts). M15-004 deleted its 204
+// deps-threading wrappers — every caller passes the `ServiceDeps` it already
+// holds now — so what remains here is the sibling-service half, which needs a
+// service graph rather than a connection and dies with R3's `services()`
+// accessor, plus `compatDb` / `compatPrisma` / `compatChHelpers`. See that
+// file's header for why each of the three is still standing.
export {
AggregateChartEngine,
- adjustProfileProperty,
applySaveDiscount,
- backfillSessionsToProduction,
buildFunnelBase,
ChartEngine,
- cancelOrganizationDeletion,
cancelProjectDeletion,
cancelSubscription,
- canSkipOnboarding,
checkout,
- cleanupSessionStartEndEvents,
- cleanupStagingData,
- cleanupStaleInsights,
clearClientByIdCache,
clearProjectByIdCache,
- compatCh,
compatDb,
- completeGscOAuthCallback,
- completeSlackOAuthCallback,
- computeCohort,
- connectUserToOrganization,
- countCohort,
- createBotEvent,
createClientForOrganization,
createDashboard,
- createEvent,
- createGroup,
- createOnboardingProject,
- createOrUpdateNotificationRule,
- createOrUpdateSlackIntegration,
createProjectForOrganization,
createReference,
createReport,
- createSessionsStartEndEvents,
createShareDashboard,
createShareOverview,
createShareReport,
deleteClientForOrganization,
- deleteCohortMembership,
deleteConversation,
deleteDashboard,
- deleteFromClickhouse,
- deleteGroup,
- deleteIntegration,
- deleteNotificationRule,
- deleteOrganization,
deleteProjectForOrganization,
- deleteProjects,
deleteReference,
deleteReport,
deleteUserAccount,
- deliverNotification,
- disableTotp,
- disconnectGscConnection,
duplicateReport,
- enableTotp,
executeAggregateChart,
executeChart,
- extendSessionCookie,
- findGroupsCore,
- findProfilesCore,
- generateGapBasedSessionIds,
- getAnalyticsOverviewCore,
- getBotEventsPage,
getChartBucketProfiles,
getChartPropertyValues,
getChartReferences,
@@ -1168,96 +1132,19 @@ export {
getClientForOrganization,
getClientsByOrganizationId,
getClientsByProjectId,
- getCohortCount,
- getCohortEventsPerDay,
- getCohortMemberEvents,
- getCohortMemberRoutes,
- getCohortMembers,
getConversationById,
getConversion,
getConversionChart,
- getConversionEventNames,
- getConversionListPage,
getDashboardById,
getDashboardByIdOrThrow,
getDashboardsByProjectId,
getEngagementCore,
- getEntryExitPagesCore,
- getEventById,
- getEventDetails,
- getEventList,
- getEventListPage,
- getEventMetas,
- getEventPropertyValuesCore,
- getEvents,
- getEventsCount,
getFunnel,
getFunnelChart,
getFunnelCore,
getFunnelProfileIds,
getFunnelStepProfiles,
- getGroupActivity,
- getGroupById,
- getGroupCore,
- getGroupList,
- getGroupListCount,
- getGroupListPage,
- getGroupMemberGrowth,
- getGroupMemberProfiles,
- getGroupMemberProfilesPage,
- getGroupMetrics,
- getGroupMostEvents,
- getGroupPopularRoutes,
- getGroupPropertyKeys,
- getGroupStats,
- getGroupsByIds,
- getGroupTypes,
- getGscAiEngines,
- getGscConnection,
- getGscOverview,
- getGscPageDetails,
- getGscPages,
- getGscPreviousOverview,
- getGscQueries,
- getGscQueryDetails,
- getGscSearchEngines,
- getId,
- getImportDateBounds,
- getIntegrationById,
- getInviteById,
- getInviteOrThrow,
- getInvites,
getLastEventPerProject,
- getMember,
- getMembers,
- getNotificationRuleByIdOrThrow,
- getOrganizationBillingEventsCount,
- getOrganizationBillingEventsCountSerie,
- getOrganizationById,
- getOrganizationByProjectId,
- getOrganizationEventsCount,
- getOrganizationEventsCountSince,
- getOrganizationSubscriptionChartEndDate,
- getOrganizations,
- getPageConversionsCore,
- getPagePerformanceCore,
- getPowerUsers,
- getProfileActivity,
- getProfileById,
- getProfileList,
- getProfileListCount,
- getProfileListPage,
- getProfileMetrics,
- getProfileMetricsCore,
- getProfileMostEvents,
- getProfilePopularRoutes,
- getProfilePropertyKeys,
- getProfilePropertyNames,
- getProfileSessionsCore,
- getProfiles,
- getProfilesInCohort,
- getProfileValues,
- getProfileWithEvents,
getProjectActivationStatus,
getProjectById,
getProjectByIdCached,
@@ -1266,15 +1153,8 @@ export {
getProjectForOrganization,
getProjects,
getProjectWithClients,
- getRealtimeActiveSessions,
- getRealtimeCoordinates,
- getRealtimeGeo,
- getRealtimeMapBadgeDetails,
- getRealtimePaths,
- getRealtimeReferrals,
getReferenceById,
getReferenceByIdOrThrow,
- getReferrerSpikes,
getReportById,
getReportByIdOrThrow,
getReportDataCore,
@@ -1290,14 +1170,6 @@ export {
getSalts,
getSankey,
getSankeyChart,
- getSegmentDailySeriesCore,
- getSessionById,
- getSessionDistinctValues,
- getSessionList,
- getSessionReplayChunksFrom,
- getSessionsCount,
- getSettingsForOrganization,
- getSettingsForProject,
getShareByProjectId,
getShareDashboard,
getShareDashboardByDashboardId,
@@ -1311,113 +1183,41 @@ export {
getShareReportById,
getShareReportByReportId,
getShareReportSettings,
- getStats,
- getTopEventNames,
- getTopOrigins,
- getTopPages,
- getTopPagesCore,
- getTotpStatus,
- getTrafficBreakdownCore,
getUsage,
getUserAccount,
getUserById,
getUserFlowCore,
getWeeklyRetentionSeriesCore,
- gscGetCannibalizationCore,
- gscGetOverviewCore,
- gscGetPageDetailsCore,
- gscGetQueryDetailsCore,
- gscGetQueryOpportunitiesCore,
- gscGetTopPagesCore,
- gscGetTopQueriesCore,
- identifyProfile,
- insertImportBatch,
- insertPingRecord,
- insertProfilesBatch,
- insertRawEventsBatch,
- inviteUserToOrganization,
- listAllInsights,
listChartEvents,
listChartProperties,
listClientsForOrganization,
- listCohortMemberProfiles,
listConversations,
- listDailyInsightCandidates,
listDashboardsCore,
- listEventNamesCore,
- listEventPropertiesCore,
- listGroupTypesCore,
- listGscConnectionsForSync,
- listGscSites,
- listInsights,
- listIntegrationsForProject,
- listNotificationRules,
- listNotifications,
listProducts,
listProjectsCore,
listProjectsForOrganization,
listReferences,
- listRefreshableCohortIds,
listReportsCore,
listUserDeletionBlockers,
- moveImportsToProduction,
moveReport,
overviewService,
pagesService,
pauseSubscription,
portal,
- previewWeeklyDigest,
- queryEventsCore,
- querySessionsCore,
- regenerateTotpRecoveryCodes,
- removeOrganizationMember,
- requestPasswordReset,
- resetPasswordWithToken,
resetReportLayouts,
resetV1CompatServicesForTests,
resolveClientProjectId,
- resolveGscDateRange,
resumeSubscription,
- revokeInvite,
- runDeleteCron,
- runGscProjectBackfill,
- runGscProjectSync,
- runImportJob,
- runOnboardingCron,
- runPingCron,
- runProjectInsights,
- scanLegacyInsights,
- scheduleOrganizationDeletion,
scheduleProjectDeletion,
- selectGscSite,
- sendWeeklyDigests,
- setupTotp,
setV1CompatServices,
- signInToShare,
- signInWithEmail,
- signInWithTotp,
- signOutUser,
- signUpWithEmail,
- syncGscData,
- testExportIntegrationConnection,
- testIntegrationConnection,
updateClientForOrganization,
- updateCohortMembership,
updateDashboard,
- updateEventMeta,
- updateGroup,
- updateImportStatus,
- updateOrganization,
- updateOrganizationMemberAccess,
updateProjectForOrganization,
updateReference,
updateReport,
updateReportLayout,
updateUserProfile,
upsertConversationTitle,
- upsertGroup,
- upsertIntegration,
- upsertProfile,
V1_COMPAT_REQUEST_ID,
validateOverviewShareAccess,
validateReportAccess,
diff --git a/packages/core/src/modules/assistant/assistant.routes.ts b/packages/core/src/modules/assistant/assistant.routes.ts
index b459ccaa9..c50d614bf 100644
--- a/packages/core/src/modules/assistant/assistant.routes.ts
+++ b/packages/core/src/modules/assistant/assistant.routes.ts
@@ -81,7 +81,7 @@ export const assistantRoutes = defineRoutes((app) =>
const [access, organization, settings] = await Promise.all([
getProjectAccess({ projectId, userId }),
- getOrganizationByProjectIdCached(projectId),
+ getOrganizationByProjectIdCached(ctx, projectId),
getSettingsForProject(ctx, projectId).catch(() => ({
timezone: 'UTC',
})),
diff --git a/packages/core/src/modules/cohort/cohort.service.ts b/packages/core/src/modules/cohort/cohort.service.ts
index 065b50834..05a0512c4 100644
--- a/packages/core/src/modules/cohort/cohort.service.ts
+++ b/packages/core/src/modules/cohort/cohort.service.ts
@@ -873,11 +873,9 @@ export async function listCohortMemberProfiles(
}
): Promise<{ data: IServiceProfile[]; count: number }> {
const { buildFilterWhere } = await import('../chart/src/table-filter-where');
- const { profileSearchCondition } = await import('../profile/profile.service');
- // M10-005: `getProfiles` takes `ServiceDeps` now and this function has none
- // — packages/trpc's cohort router still calls it bare — so it reaches the
- // v1-compat spelling. Converting this module is its own task.
- const { getProfiles } = await import('../../v1-compat');
+ const { getProfiles, profileSearchCondition } = await import(
+ '../profile/profile.service'
+ );
const offset = Math.max(0, (cursor ?? 0) * take);
const searchClause = profileSearchCondition(search);
@@ -923,7 +921,7 @@ export async function listCohortMemberProfiles(
return { data: [], count };
}
- const profiles = await getProfiles(ids, projectId);
+ const profiles = await getProfiles(deps, ids, projectId);
const byId = new Map(profiles.map((p) => [p.id, p]));
const data = ids
.map((id) => byId.get(id))
diff --git a/packages/core/src/modules/conversation/conversation.rpc.ts b/packages/core/src/modules/conversation/conversation.rpc.ts
index 530f43096..2dc9997b5 100644
--- a/packages/core/src/modules/conversation/conversation.rpc.ts
+++ b/packages/core/src/modules/conversation/conversation.rpc.ts
@@ -123,6 +123,7 @@ export const conversationRouter = createTRPCRouter({
// the project (they'd still be able to tag the conversation with
// an unrelated org id).
const organization = await getOrganizationByProjectIdCached(
+ ctx,
input.projectId
);
if (!organization) {
diff --git a/packages/core/src/modules/gsc/gsc.service.ts b/packages/core/src/modules/gsc/gsc.service.ts
index 46442d4a5..50ac9ddf8 100644
--- a/packages/core/src/modules/gsc/gsc.service.ts
+++ b/packages/core/src/modules/gsc/gsc.service.ts
@@ -8,10 +8,10 @@
// M10-009: every exported function takes `ServiceDeps` and reaches Postgres
// as `deps.db` and ClickHouse as `deps.ch`; the `loadDb()`/`loadChClient()`
// lazy loaders are gone, so the requestId minted at the edge reaches the query
-// (ADR-018, docs/TECH_DEBT.md §4). `getGscCannibalization` is the exception:
-// `cacheable` keys on the call's ARGUMENTS (packages/redis/cachable.ts) so it
-// cannot take `deps` as a leading parameter, and reaches the boot scope
-// through the declared v1-compat seam instead.
+// (ADR-018, docs/TECH_DEBT.md §4). `getGscCannibalization` is `cacheablePerDeps`
+// (M15-004): `cacheable` keys on the call's ARGUMENTS
+// (packages/redis/cachable.ts), so the caller's deps travel beside the key
+// rather than inside it and the Redis key stays byte-identical.
//
// DELIBERATE BEHAVIOUR CHANGE, recorded: the reads and the four sync inserts
// used @openpanel/db's `originalCh` (the first configured node, no retry).
@@ -24,11 +24,11 @@
// tag: ADR-013 converts the analytics read path one query per P7 task, and
// this module's queries haven't been converted yet.
-import { cacheable } from '@openpanel/redis';
import { createLogger, type ILogger } from '../../clients/logger';
import type { Logger } from '../../logger';
import { TRPCNotFoundError } from '../../rpc/errors';
import type { ServiceDeps, Services } from '../../services';
+import { cacheablePerDeps } from '../../shared/cacheable-per-deps';
import { chQuery } from '../../shared/ch-query';
import { TABLE_NAMES } from '../../shared/ch-tables';
import { decrypt, encrypt } from '../../shared/encryption';
@@ -45,10 +45,6 @@ function getLogger(): ILogger {
return _logger;
}
-/** `getGscCannibalization` is `cacheable` — see the header. */
-function loadCompatServiceDeps() {
- return import('../../v1-compat').then((m) => m.compatServiceDeps());
-}
export interface GscSite {
siteUrl: string;
permissionLevel: string;
@@ -448,14 +444,14 @@ export interface GscCannibalizedQuery {
}>;
}
-export const getGscCannibalization = cacheable(
+export const getGscCannibalization = cacheablePerDeps(
'getGscCannibalization',
async (
+ deps: ServiceDeps,
projectId: string,
startDate: string,
endDate: string
): Promise<GscCannibalizedQuery[]> => {
- const deps = await loadCompatServiceDeps();
const db = deps.db;
const conn = await db.gscConnection.findUniqueOrThrow({
where: { projectId },
@@ -1252,7 +1248,12 @@ export async function gscGetCannibalizationCore(
endDate: string;
}
) {
- return getGscCannibalization(input.projectId, input.startDate, input.endDate);
+ return getGscCannibalization(
+ deps,
+ input.projectId,
+ input.startDate,
+ input.endDate
+ );
}
// ---------------------------------------------------------------------------
@@ -1522,7 +1523,12 @@ export function createGscService(deps: ServiceDeps, _services: () => Services) {
getQueries,
getSearchEngines,
getAiEngines,
- getCannibalization: getGscCannibalization,
+ getCannibalization: (
+ projectId: string,
+ startDate: string,
+ endDate: string
+ ): Promise<GscCannibalizedQuery[]> =>
+ getGscCannibalization(deps, projectId, startDate, endDate),
listConnectionsForSync: (): Promise<{ projectId: string }[]> =>
listGscConnectionsForSync(deps),
runProjectSync: (projectId: string): Promise<void> =>
diff --git a/packages/core/src/modules/ingest/ingest.routes.ts b/packages/core/src/modules/ingest/ingest.routes.ts
index 956b4a2f3..2959ea68b 100644
--- a/packages/core/src/modules/ingest/ingest.routes.ts
+++ b/packages/core/src/modules/ingest/ingest.routes.ts
@@ -130,7 +130,7 @@ function windDownGuard(deps: AppDeps) {
ctx: HttpCtx;
status: StatusFn;
}) => {
- const blocked = await isIngestionWoundDown({
+ const blocked = await isIngestionWoundDown(ctx, {
projectId: client.projectId,
selfHosted: deps.config.selfHosted,
logger: ctx.logger,
diff --git a/packages/core/src/modules/ingest/ingest.service.ts b/packages/core/src/modules/ingest/ingest.service.ts
index c2863e339..c7cc879db 100644
--- a/packages/core/src/modules/ingest/ingest.service.ts
+++ b/packages/core/src/modules/ingest/ingest.service.ts
@@ -562,11 +562,14 @@ export async function ingestTrack(
*/
const WIND_DOWN_BLOCKED_STEPS = new Set(['blocked', 'final_warning']);
-export async function isIngestionWoundDown(request: {
- projectId: string | null | undefined;
- selfHosted: boolean;
- logger: Logger;
-}): Promise<boolean> {
+export async function isIngestionWoundDown(
+ deps: ServiceDeps,
+ request: {
+ projectId: string | null | undefined;
+ selfHosted: boolean;
+ logger: Logger;
+ }
+): Promise<boolean> {
if (request.selfHosted || !request.projectId) {
return false;
}
@@ -576,7 +579,10 @@ export async function isIngestionWoundDown(request: {
try {
// Cached for 5 minutes and invalidated by the Polar webhook, so paying
// again lifts the block on the next checkout rather than on a TTL.
- const organization = await getOrganizationByProjectIdCached(projectId);
+ const organization = await getOrganizationByProjectIdCached(
+ deps,
+ projectId
+ );
if (
!(
diff --git a/packages/core/src/modules/ingest/src/incoming-event-handler.ts b/packages/core/src/modules/ingest/src/incoming-event-handler.ts
index 0d45addb0..b1e5a0323 100644
--- a/packages/core/src/modules/ingest/src/incoming-event-handler.ts
+++ b/packages/core/src/modules/ingest/src/incoming-event-handler.ts
@@ -104,9 +104,11 @@ export interface IncomingEventBindings {
/**
* BullMQ-producer orchestration (notification/src/notification-dispatch.ts).
* Injected rather than imported so the hot path's per-message handler keeps
- * the notification module out of its own import graph.
+ * the notification module out of its own import graph. Takes the message's
+ * own scope: an enqueue made here carries that message's requestId.
*/
checkNotificationRulesForEvent(
+ deps: Ctx,
payload: IServiceCreateEventPayload
): Promise<unknown>;
/**
@@ -130,7 +132,8 @@ export function createIncomingEventDeps(
logger: ctx.logger,
sessions: ctx.buffers.session,
createEvent: (payload) => createEvent(ctx, payload),
- checkNotificationRulesForEvent: bindings.checkNotificationRulesForEvent,
+ checkNotificationRulesForEvent: (payload) =>
+ bindings.checkNotificationRulesForEvent(ctx, payload),
projects: {
getCached: bindings.getCachedProject,
markFirstEvent: async (projectId) => {
diff --git a/packages/core/src/modules/ingest/wind-down.test.ts b/packages/core/src/modules/ingest/wind-down.test.ts
index 2a4fb838d..112e099e2 100644
--- a/packages/core/src/modules/ingest/wind-down.test.ts
+++ b/packages/core/src/modules/ingest/wind-down.test.ts
@@ -21,11 +21,16 @@ import {
mock,
} from 'bun:test';
import type { Logger } from '../../logger';
+import type { ServiceDeps } from '../../services';
const getOrganizationByProjectIdCached = mock(
- async (_projectId: string): Promise<unknown> => null
+ async (_deps: unknown, _projectId: string): Promise<unknown> => null
);
+/** The gate only threads `deps` through to the organization lookup, which is
+ * mocked, so an opaque marker is enough to assert it arrives. */
+const deps = { marker: 'service-deps' } as unknown as ServiceDeps;
+
// Spread a plain-object SNAPSHOT of the real module: a partial factory
// replaces the whole module process-wide, and every other importer of it then
// fails on a missing export. The snapshot (not the live import binding) is
@@ -87,13 +92,16 @@ describe('isIngestionWoundDown', () => {
const { logger } = makeLogger();
expect(
- await isIngestionWoundDown({
+ await isIngestionWoundDown(deps, {
projectId: 'proj-1',
selfHosted: false,
logger,
})
).toBe(true);
- expect(getOrganizationByProjectIdCached).toHaveBeenCalledWith('proj-1');
+ expect(getOrganizationByProjectIdCached).toHaveBeenCalledWith(
+ deps,
+ 'proj-1'
+ );
});
}
@@ -106,7 +114,7 @@ describe('isIngestionWoundDown', () => {
const { logger } = makeLogger();
expect(
- await isIngestionWoundDown({
+ await isIngestionWoundDown(deps, {
projectId: 'proj-1',
selfHosted: false,
logger,
@@ -128,7 +136,7 @@ describe('isIngestionWoundDown', () => {
const { logger } = makeLogger();
expect(
- await isIngestionWoundDown({
+ await isIngestionWoundDown(deps, {
projectId: 'proj-1',
selfHosted: false,
logger,
@@ -141,7 +149,7 @@ describe('isIngestionWoundDown', () => {
const { logger, calls } = makeLogger();
expect(
- await isIngestionWoundDown({
+ await isIngestionWoundDown(deps, {
projectId: 'proj-1',
selfHosted: false,
logger,
@@ -154,7 +162,7 @@ describe('isIngestionWoundDown', () => {
const { logger } = makeLogger();
expect(
- await isIngestionWoundDown({
+ await isIngestionWoundDown(deps, {
projectId: 'proj-1',
selfHosted: true,
logger,
@@ -167,7 +175,7 @@ describe('isIngestionWoundDown', () => {
const { logger } = makeLogger();
expect(
- await isIngestionWoundDown({
+ await isIngestionWoundDown(deps, {
projectId: null,
selfHosted: false,
logger,
diff --git a/packages/core/src/modules/insight/insight.rpc.ts b/packages/core/src/modules/insight/insight.rpc.ts
index 0c32d4c87..2ee85b7aa 100644
--- a/packages/core/src/modules/insight/insight.rpc.ts
+++ b/packages/core/src/modules/insight/insight.rpc.ts
@@ -116,7 +116,7 @@ export const insightRouter = createTRPCRouter({
const db = ctx.db;
const { getSegmentDailySeriesCore, getTrafficBreakdownCore } =
- await import('../../v1-compat');
+ await import('../overview/overview.service');
const insight = await db.projectInsight.findUniqueOrThrow({
where: { id: insightId },
@@ -154,13 +154,13 @@ export const insightRouter = createTRPCRouter({
const breakdowns = await Promise.all(
EXPLAIN_COLUMNS.map(async (column) => {
const [cur, base] = await Promise.all([
- getTrafficBreakdownCore({
+ getTrafficBreakdownCore(ctx, {
projectId: insight.projectId,
column,
startDate: iso(start),
endDate: iso(end),
}),
- getTrafficBreakdownCore({
+ getTrafficBreakdownCore(ctx, {
projectId: insight.projectId,
column,
startDate: iso(baseStart),
@@ -192,14 +192,14 @@ export const insightRouter = createTRPCRouter({
if (segment?.key && segment.value) {
const [curSeries, baseSeries] = await Promise.all([
- getSegmentDailySeriesCore({
+ getSegmentDailySeriesCore(ctx, {
projectId: insight.projectId,
column: segment.key,
value: segment.value,
startDate: iso(start),
endDate: iso(end),
}),
- getSegmentDailySeriesCore({
+ getSegmentDailySeriesCore(ctx, {
projectId: insight.projectId,
column: segment.key,
value: segment.value,
diff --git a/packages/core/src/modules/insight/insight.service.ts b/packages/core/src/modules/insight/insight.service.ts
index 553384641..8f33114a8 100644
--- a/packages/core/src/modules/insight/insight.service.ts
+++ b/packages/core/src/modules/insight/insight.service.ts
@@ -391,16 +391,18 @@ async function buildDigestData(
const iso = (ms: number) => new Date(ms).toISOString();
const db = deps.db;
- const { getAnalyticsOverviewCore } = await import('../../v1-compat');
+ const { getAnalyticsOverviewCore } = await import(
+ '../overview/overview.service'
+ );
const [cur, prev] = await Promise.all([
- getAnalyticsOverviewCore({
+ getAnalyticsOverviewCore(deps, {
projectId: project.id,
startDate: iso(curStart),
endDate: iso(now),
interval: 'day',
}),
- getAnalyticsOverviewCore({
+ getAnalyticsOverviewCore(deps, {
projectId: project.id,
startDate: iso(prevStart),
endDate: iso(curStart),
diff --git a/packages/core/src/modules/notification/notification.rpc.ts b/packages/core/src/modules/notification/notification.rpc.ts
index cb42d9e58..95641d445 100644
--- a/packages/core/src/modules/notification/notification.rpc.ts
+++ b/packages/core/src/modules/notification/notification.rpc.ts
@@ -56,7 +56,7 @@ export const notificationRouter = createTRPCRouter({
const userId = requireLogin(ctx.session.userId);
// Clear the cache for the project
- await getNotificationRulesByProjectId.clear(input.projectId);
+ await getNotificationRulesByProjectId.clear(ctx, input.projectId);
await ctx.services.auth.requireProjectAccess({
userId,
diff --git a/packages/core/src/modules/notification/notification.service.ts b/packages/core/src/modules/notification/notification.service.ts
index cd0e6c66a..0eaab7a5e 100644
--- a/packages/core/src/modules/notification/notification.service.ts
+++ b/packages/core/src/modules/notification/notification.service.ts
@@ -17,12 +17,12 @@
// would spawn a pino-pretty transport worker thread per test file).
import type { Integration, Prisma } from '@openpanel/db/src/prisma-client';
-import { cacheable } from '@openpanel/redis';
import { pathOr } from 'ramda';
import { sendEmail } from '../../clients/email';
import { getServerIntegration } from '../../clients/integrations/registry';
import { TRPCBadRequestError, TRPCForbiddenError } from '../../rpc/errors';
import type { ServiceDeps, Services } from '../../services';
+import { cacheablePerDeps } from '../../shared/cacheable-per-deps';
import { stripLeadingAndTrailingSlashes } from '../../shared/string';
import type {
IServiceCreateEventPayload,
@@ -69,17 +69,10 @@ export type INotificationPayload =
| { type: 'event'; event: IServiceCreateEventPayload }
| { type: 'funnel'; funnel: IServiceEvent[] };
-// M10-009: `getNotificationRulesByProjectId` is `cacheable`, whose key is
-// derived from the call's ARGUMENTS (packages/redis/cachable.ts), so it cannot
-// take `ServiceDeps` as a leading parameter — it reaches Postgres through the
-// declared v1-compat seam instead, same as shared/access-lookups.ts's
-// `getProjectAccess`. Every other function in this file takes `deps` and uses
-// `deps.db`. GENUINE CYCLE, kept lazy: services.ts -> notification.service.ts
-// (this file) -> v1-compat.ts -> services.ts.
-function loadCompatDb() {
- return import('../../v1-compat').then((m) => m.compatDb());
-}
-
+// M15-004: `getNotificationRulesByProjectId` is `cacheablePerDeps` — `cacheable`
+// keys on the call's ARGUMENTS (packages/redis/cachable.ts), so the caller's
+// deps travel beside the key rather than inside it and the Redis key stays
+// byte-identical. Every function in this file now reads `deps.db`.
function loadPrisma() {
return import('../../v1-compat').then((m) => m.compatPrisma());
}
@@ -90,11 +83,10 @@ export type INotificationRuleCached = Awaited<
ReturnType<typeof getNotificationRulesByProjectId>
>[number];
-export const getNotificationRulesByProjectId = cacheable(
+export const getNotificationRulesByProjectId = cacheablePerDeps(
'getNotificationRulesByProjectId',
- async (projectId: string) => {
- const db = await loadCompatDb();
- return db.notificationRule.findMany({
+ (deps: ServiceDeps, projectId: string) =>
+ deps.db.notificationRule.findMany({
where: { projectId },
select: {
id: true,
@@ -105,8 +97,7 @@ export const getNotificationRulesByProjectId = cacheable(
template: true,
integrations: { select: { id: true } },
},
- });
- },
+ }),
60 * 24,
{ cacheEmptyArray: true }
);
diff --git a/packages/core/src/modules/notification/src/notification-dispatch.ts b/packages/core/src/modules/notification/src/notification-dispatch.ts
index 0999c3c15..c0c6110eb 100644
Binary files a/packages/core/src/modules/notification/src/notification-dispatch.ts and b/packages/core/src/modules/notification/src/notification-dispatch.ts differ
diff --git a/packages/core/src/modules/organization/organization.service.ts b/packages/core/src/modules/organization/organization.service.ts
index 18e996046..d5a1119a6 100644
--- a/packages/core/src/modules/organization/organization.service.ts
+++ b/packages/core/src/modules/organization/organization.service.ts
@@ -13,16 +13,16 @@
// M10-009: every exported function takes `ServiceDeps` and reaches Postgres
// as `deps.db` and ClickHouse as `deps.ch` (through core's own `chQuery`), so
// the requestId minted at the edge reaches the query (ADR-018,
-// docs/TECH_DEBT.md §4). The three `cacheable` wrappers are the exception:
-// `cacheable` keys on the call's ARGUMENTS (packages/redis/cachable.ts), so
-// `deps` cannot be a leading parameter and they reach the boot scope through
-// the declared v1-compat seam instead.
+// docs/TECH_DEBT.md §4). The two `cacheable` wrappers are `cacheablePerDeps`
+// (M15-004): `cacheable` keys on the call's ARGUMENTS
+// (packages/redis/cachable.ts), so the caller's deps travel beside the key
+// rather than inside it and the Redis key stays byte-identical.
//
// M12-006 also made `shared/access-lookups.ts` a static import: that file
// value-imports only zod-free leaves (`@openpanel/redis`, a Prisma TYPE) and
-// reaches Postgres through the lazy v1-compat seam itself, so it has no static
-// edge back here and the dynamic form deferred nothing (ADR-007: no lazy
-// loaders).
+// reaches Postgres through the lazy v1-compat seam itself (the one seam
+// M15-004 could not close — its bare signature is pinned by a protected wire
+// contract), so it has no static edge back here.
//
// M12-006 converted all five ClickHouse statements here onto the ADR-013 `sql`
// tag: the four billing counters and `deleteFromClickhouse`'s project filter
@@ -40,7 +40,6 @@ import type {
ProjectAccess,
User,
} from '@openpanel/db/src/prisma-client';
-import { cacheable } from '@openpanel/redis';
import { sendEmail } from '../../clients/email';
import { TRPCBadRequestError } from '../../rpc/errors';
import type { ServiceDeps, Services } from '../../services';
@@ -48,6 +47,7 @@ import {
getOrganizationAccess,
getProjectAccess,
} from '../../shared/access-lookups';
+import { cacheablePerDeps } from '../../shared/cacheable-per-deps';
import { formatClickhouseDate } from '../../shared/ch-dates';
import { chQuery } from '../../shared/ch-query';
import { isClickhouseClustered, TABLE_NAMES } from '../../shared/ch-tables';
@@ -79,13 +79,6 @@ const DELETE_GRACE_PERIOD_MS = 24 * 60 * 60 * 1000;
// Invite link lifetime — matches V1's `addDays(new Date(), 3)`.
const INVITE_EXPIRY_MS = 3 * 24 * 60 * 60 * 1000;
-/** The three `cacheable` wrappers below cannot carry `ServiceDeps` — see the
- * header. GENUINE CYCLE, kept lazy: services.ts -> organization.service.ts
- * (this file) -> v1-compat.ts -> services.ts. */
-function loadCompatServiceDeps() {
- return import('../../v1-compat').then((m) => m.compatServiceDeps());
-}
-
export async function getOrganizations(
deps: ServiceDeps,
userId: string | null
@@ -143,10 +136,10 @@ export async function getOrganizationByProjectId(
}
const ORGANIZATION_BY_PROJECT_CACHE_TTL_SEC = 60 * 5;
-export const getOrganizationByProjectIdCached = cacheable(
+export const getOrganizationByProjectIdCached = cacheablePerDeps(
'getOrganizationByProjectId',
- async (projectId: string) =>
- getOrganizationByProjectId(await loadCompatServiceDeps(), projectId),
+ (deps: ServiceDeps, projectId: string) =>
+ getOrganizationByProjectId(deps, projectId),
ORGANIZATION_BY_PROJECT_CACHE_TTL_SEC
);
@@ -435,15 +428,12 @@ export async function getOrganizationBillingEventsCountSerie(
}
const BILLING_EVENTS_SERIE_CACHE_TTL_SEC = 60 * 10;
-export const getOrganizationBillingEventsCountSerieCached = cacheable(
+export const getOrganizationBillingEventsCountSerieCached = cacheablePerDeps(
'getOrganizationBillingEventsCountSerie',
- async (
+ (
+ deps: ServiceDeps,
...args: Tail<Parameters<typeof getOrganizationBillingEventsCountSerie>>
- ) =>
- getOrganizationBillingEventsCountSerie(
- await loadCompatServiceDeps(),
- ...args
- ),
+ ) => getOrganizationBillingEventsCountSerie(deps, ...args),
BILLING_EVENTS_SERIE_CACHE_TTL_SEC
);
@@ -452,7 +442,7 @@ export async function getOrganizationSubscriptionChartEndDate(
projectId: string,
endDate: string
): Promise<string | null> {
- const organization = await getOrganizationByProjectIdCached(projectId);
+ const organization = await getOrganizationByProjectIdCached(deps, projectId);
if (!organization) {
return null;
}
diff --git a/packages/core/src/modules/session/session.jobs.ts b/packages/core/src/modules/session/session.jobs.ts
index 1c966399b..06e7642b4 100644
--- a/packages/core/src/modules/session/session.jobs.ts
+++ b/packages/core/src/modules/session/session.jobs.ts
@@ -90,9 +90,11 @@ async function sessionEndDeps(
(await chQuery<IClickhouseEvent>(ctx, query)).map(transformEvent),
profileBackfill: ctx.buffers.profileBackfill,
notifications: {
- getRules: notifications.getNotificationRulesByProjectId,
+ getRules: (projectId) =>
+ notifications.getNotificationRulesByProjectId(ctx, projectId),
hasFunnelRules: notifications.getHasFunnelRules,
- checkFunnelRules: checkNotificationRulesForSessionEnd,
+ checkFunnelRules: (events) =>
+ checkNotificationRulesForSessionEnd(ctx, events),
},
};
}
@@ -107,7 +109,7 @@ export const sessionQueueJobs = {
await createSessionEnd(data, await sessionEndDeps(ctx, logger));
try {
- await updateEventsCount(data.event.projectId);
+ await updateEventsCount(ctx, data.event.projectId);
} catch (error) {
logger.error({ err: error }, 'Failed to update events count');
}
diff --git a/packages/core/src/modules/session/session.service.ts b/packages/core/src/modules/session/session.service.ts
index 6157284fa..5db1b03c6 100644
--- a/packages/core/src/modules/session/session.service.ts
+++ b/packages/core/src/modules/session/session.service.ts
@@ -10,15 +10,15 @@
//
// M10-009: the ClickHouse client is `deps.ch`, reached through core's own
// `chQuery` (shared/ch-query.ts), so the requestId minted at the edge reaches
-// every query here (ADR-018, docs/TECH_DEBT.md §4). The one exception is
-// `getSessionsCountCached`: `cacheable` keys on the call's ARGUMENTS
-// (packages/redis/cachable.ts), so `ServiceDeps` cannot be a leading
-// parameter — it reaches the boot scope's deps through the declared v1-compat
-// seam instead. The remaining `load*` functions are intra-package lazy
-// imports, kept lazy for a cycle, not for a client.
-
-import { cacheable } from '@openpanel/redis';
+// every query here (ADR-018, docs/TECH_DEBT.md §4). `getSessionsCountCached`
+// is `cacheablePerDeps` (M15-004): `cacheable` keys on the call's ARGUMENTS
+// (packages/redis/cachable.ts), so the caller's deps travel beside the key
+// rather than inside it, and the Redis key stays byte-identical. The remaining
+// `load*` functions are intra-package lazy imports, kept lazy for a cycle, not
+// for a client.
+
import type { ServiceDeps, Services } from '../../services';
+import { cacheablePerDeps } from '../../shared/cacheable-per-deps';
import { chQuery } from '../../shared/ch-query';
import { getSafeJson } from '../../shared/json';
import type { IServiceProfile } from '../profile/profile.service';
@@ -51,11 +51,6 @@ function loadFilterCompiler() {
return import('../chart/src/table-filter-where');
}
-/** `getSessionsCountCached` cannot carry `ServiceDeps` — see the header. */
-function loadCompatServiceDeps() {
- return import('../../v1-compat').then((m) => m.compatServiceDeps());
-}
-
function loadLookback() {
return import('../../shared/lookback');
}
@@ -309,14 +304,11 @@ export async function getSessionList(
});
}
- // M10-005: `getProfilesCached` takes `ServiceDeps` now and `getSessionList`
- // has none — packages/trpc's session router still calls it bare — so it
- // reaches the v1-compat spelling. Converting this module is its own task.
- const { getProfilesCached } = await import('../../v1-compat');
+ const { getProfilesCached } = await import('../profile/profile.service');
const profileIds = data
.filter((e) => e.device_id !== e.profile_id)
.map((e) => e.profile_id);
- const profiles = await getProfilesCached(profileIds, projectId);
+ const profiles = await getProfilesCached(deps, profileIds, projectId);
const map = new Map<string, IServiceProfile>(profiles.map((p) => [p.id, p]));
const items = data.map(transformSession).map((item) => ({
@@ -360,10 +352,12 @@ export async function getSessionsCount(
return result[0]?.count ?? 0;
}
-export const getSessionsCountCached = cacheable(
+export const getSessionsCountCached = cacheablePerDeps(
'getSessionsCount',
- async (options: Omit<GetSessionListOptions, 'take' | 'cursor'>) =>
- getSessionsCount(await loadCompatServiceDeps(), options),
+ (
+ deps: ServiceDeps,
+ options: Omit<GetSessionListOptions, 'take' | 'cursor'>
+ ): Promise<number> => getSessionsCount(deps, options),
SESSIONS_COUNT_CACHE_SECONDS
);
diff --git a/packages/core/src/modules/session/src/usage.ts b/packages/core/src/modules/session/src/usage.ts
index f5a838edc..37a010caf 100644
--- a/packages/core/src/modules/session/src/usage.ts
+++ b/packages/core/src/modules/session/src/usage.ts
@@ -4,25 +4,20 @@
// at 80% / 100% of the billing limit.
import type { Organization } from '@openpanel/db/src/prisma-client';
-import { cacheable } from '@openpanel/redis';
import { sendEmail } from '../../../clients/email';
-import { createLogger, type ILogger } from '../../../clients/logger';
-import type { Logger } from '../../../logger';
+import type { ServiceDeps } from '../../../services';
+import { cacheablePerDeps } from '../../../shared/cacheable-per-deps';
-// project.service.ts's `getProjectEventsCount` takes `ServiceDeps` now
-// (M10-004); this file has none (its own db access is the lazy `loadDb()`
-// below), so it reaches the bare, v1-compat-wrapped spelling instead.
-// GENUINE CYCLE, kept lazy: services.ts -> session.service.ts -> this file
-// -> v1-compat.ts -> services.ts.
-//
-// EVERY v1-compat symbol this file uses goes through here, never a static
-// import: jobs.registry.ts reaches this file (session.jobs.ts -> session-end
-// -> usage), and one static edge to v1-compat pulls services.ts and all 36
-// services into the registry's import graph — which builds a ClickHouse
-// client at import time and breaks the offline contract
+// The two project counters stay a DYNAMIC import: jobs.registry.ts reaches
+// this file (session.jobs.ts -> session-end -> usage), and a static edge to
+// project.service.ts pulls a ClickHouse client into the registry's import
+// graph, which breaks the offline contract
// verification/golden/queue-keys/check.sh depends on.
-function loadProjectService() {
- return import('../../../v1-compat');
+function loadCounters() {
+ return Promise.all([
+ import('../../project/project.service'),
+ import('../../organization/organization.service'),
+ ]);
}
const INT4_MAX = 2_147_483_647;
@@ -30,24 +25,6 @@ const USAGE_WARNING_THRESHOLD = 0.8;
const UPDATE_EVENTS_COUNT_CACHE_SECONDS = 60 * 60;
const DEFAULT_DASHBOARD_URL = 'https://dashboard.openpanel.dev';
-// M10-009: `updateEventsCount` is `cacheable`, whose key is derived from the
-// call's ARGUMENTS (packages/redis/cachable.ts), so it cannot take a
-// `ServiceDeps` leading parameter — Postgres comes through the same declared
-// v1-compat seam this file already reaches for `getProjectEventsCount`, which
-// hands back the boot scope's `AppDeps.db` rather than a second singleton.
-function loadDb() {
- return import('../../../v1-compat').then((m) => m.compatDb());
-}
-
-// `cacheable` keys on the function's arguments, so the per-run ctx.logger
-// cannot travel with the projectId; a module logger, created on first use
-// (same as import.service.ts), stands in for it.
-let _logger: ILogger | undefined;
-function getLogger(): Logger {
- _logger ??= createLogger({ name: 'core:session' });
- return _logger;
-}
-
function isSelfHosted(): boolean {
return process.env.SELF_HOSTED === 'true';
}
@@ -76,57 +53,61 @@ function nextExceededAt(
return organization.subscriptionPeriodEventsCountExceededAt;
}
-export const updateEventsCount = cacheable(async function updateEventsCount(
- projectId: string
-) {
- const logger = getLogger();
- const db = await loadDb();
- const organization = await db.organization.findFirst({
- where: { projects: { some: { id: projectId } } },
- include: { projects: true },
- });
-
- if (!organization) {
- return;
- }
-
- const { getOrganizationBillingEventsCount, getProjectEventsCount } =
- await loadProjectService();
- const organizationEventsCount =
- await getOrganizationBillingEventsCount(organization);
- const projectEventsCount = await getProjectEventsCount(projectId);
-
- if (projectEventsCount) {
- // Only a sort key and activity threshold, never billing — clamping is safe.
- await db.project.update({
- where: { id: projectId },
- data: { eventsCount: clampToInt4(projectEventsCount) },
+export const updateEventsCount = cacheablePerDeps(
+ 'updateEventsCount',
+ async (deps: ServiceDeps, projectId: string): Promise<true | undefined> => {
+ const logger = deps.logger;
+ const db = deps.db;
+ const organization = await db.organization.findFirst({
+ where: { projects: { some: { id: projectId } } },
+ include: { projects: true },
});
- }
- if (organizationEventsCount) {
- await db.organization.update({
- where: { id: organization.id },
- data: {
- subscriptionPeriodEventsCount: clampToInt4(organizationEventsCount),
- subscriptionPeriodEventsCountExceededAt: nextExceededAt(
- organization,
- organizationEventsCount
- ),
- },
- });
+ if (!organization) {
+ return;
+ }
- if (!isSelfHosted()) {
- try {
- await sendUsageAlerts(organization, organizationEventsCount, logger);
- } catch (error) {
- logger.error({ err: error }, 'Failed to send usage alert emails');
+ const [{ getProjectEventsCount }, { getOrganizationBillingEventsCount }] =
+ await loadCounters();
+ const organizationEventsCount = await getOrganizationBillingEventsCount(
+ deps,
+ organization
+ );
+ const projectEventsCount = await getProjectEventsCount(deps, projectId);
+
+ if (projectEventsCount) {
+ // Only a sort key and activity threshold, never billing — clamping is safe.
+ await db.project.update({
+ where: { id: projectId },
+ data: { eventsCount: clampToInt4(projectEventsCount) },
+ });
+ }
+
+ if (organizationEventsCount) {
+ await db.organization.update({
+ where: { id: organization.id },
+ data: {
+ subscriptionPeriodEventsCount: clampToInt4(organizationEventsCount),
+ subscriptionPeriodEventsCountExceededAt: nextExceededAt(
+ organization,
+ organizationEventsCount
+ ),
+ },
+ });
+
+ if (!isSelfHosted()) {
+ try {
+ await sendUsageAlerts(deps, organization, organizationEventsCount);
+ } catch (error) {
+ logger.error({ err: error }, 'Failed to send usage alert emails');
+ }
}
}
- }
- return true;
-}, UPDATE_EVENTS_COUNT_CACHE_SECONDS);
+ return true;
+ },
+ UPDATE_EVENTS_COUNT_CACHE_SECONDS
+);
/**
* One warning at 80% and one notice at 100% per billing cycle. The sent-at
@@ -134,10 +115,11 @@ export const updateEventsCount = cacheable(async function updateEventsCount(
* counter (or the limit is raised), so each cycle can alert again.
*/
async function sendUsageAlerts(
+ deps: ServiceDeps,
organization: Organization,
- count: number,
- logger: Logger
+ count: number
) {
+ const logger = deps.logger;
const limit = organization.subscriptionPeriodEventsLimit;
if (!limit || limit <= 0) {
return;
@@ -154,7 +136,7 @@ async function sendUsageAlerts(
return;
}
- const db = await loadDb();
+ const db = deps.db;
// Claim the alert atomically BEFORE sending: session jobs for different
// projects of the same org can run concurrently, and both would otherwise
diff --git a/packages/core/src/modules/subscription/subscription.service.ts b/packages/core/src/modules/subscription/subscription.service.ts
index fbd6b127f..eb22b7339 100644
--- a/packages/core/src/modules/subscription/subscription.service.ts
+++ b/packages/core/src/modules/subscription/subscription.service.ts
@@ -42,14 +42,10 @@ import { z } from 'zod';
import type { Logger } from '../../logger';
import { TRPCBadRequestError } from '../../rpc/errors';
import type { ServiceDeps, Services } from '../../services';
-// `getOrganizationById` takes `ServiceDeps` since M10-009 and these four
-// functions carry none (V1's still-live subscription router calls them with a
-// bare userId) — reached through the v1-compat seam, same as the rest of this
-// file's cross-module calls. GENUINE CYCLE, kept lazy on the other side.
-import { getOrganizationById } from '../../v1-compat';
import { getAccessChecks } from '../auth/auth.service';
import {
getOrganizationBillingEventsCountSerieCached,
+ getOrganizationById,
getOrganizationByProjectIdCached,
} from '../organization/organization.service';
import {
@@ -72,8 +68,11 @@ const POLAR_PRODUCTS_CACHE_KEY = 'polar:products';
const POLAR_PRODUCTS_CACHE_TTL_SECONDS = 60 * 60 * 24;
const DEFAULT_USAGE_WINDOW_DAYS = 30;
-export async function getCurrentSubscriptionProduct(organizationId: string) {
- const organization = await getOrganizationById(organizationId);
+export async function getCurrentSubscriptionProduct(
+ deps: ServiceDeps,
+ organizationId: string
+) {
+ const organization = await getOrganizationById(deps, organizationId);
if (!organization.subscriptionProductId) {
return null;
@@ -183,13 +182,13 @@ export async function getUsage(deps: ServiceDeps, organizationId: string) {
organization.subscriptionStartsAt &&
organization.subscriptionEndsAt
) {
- return getOrganizationBillingEventsCountSerieCached(organization, {
+ return getOrganizationBillingEventsCountSerieCached(deps, organization, {
startDate: organization.subscriptionStartsAt,
endDate: organization.subscriptionEndsAt,
});
}
- return getOrganizationBillingEventsCountSerieCached(organization, {
+ return getOrganizationBillingEventsCountSerieCached(deps, organization, {
startDate: subDays(new Date(), DEFAULT_USAGE_WINDOW_DAYS),
endDate: new Date(),
});
@@ -206,7 +205,7 @@ export async function cancelSubscription(
organizationId: input.organizationId,
});
- const organization = await getOrganizationById(input.organizationId);
+ const organization = await getOrganizationById(deps, input.organizationId);
if (!organization.subscriptionId) {
throw new TRPCBadRequestError('Organization has no subscription');
}
@@ -246,7 +245,7 @@ export async function pauseSubscription(
organizationId: input.organizationId,
});
- const organization = await getOrganizationById(input.organizationId);
+ const organization = await getOrganizationById(deps, input.organizationId);
if (!organization.subscriptionId) {
throw new TRPCBadRequestError('Organization has no subscription');
}
@@ -285,7 +284,7 @@ export async function resumeSubscription(
const { requireOrganizationAdmin } = await getAccessChecks();
await requireOrganizationAdmin({ userId, organizationId });
- const organization = await getOrganizationById(organizationId);
+ const organization = await getOrganizationById(deps, organizationId);
if (!organization.subscriptionId) {
throw new TRPCBadRequestError('Organization has no subscription');
}
@@ -324,7 +323,7 @@ export async function applySaveDiscount(
throw new TRPCBadRequestError('Save discount is not configured');
}
- const organization = await getOrganizationById(organizationId);
+ const organization = await getOrganizationById(deps, organizationId);
if (!organization.subscriptionId) {
throw new TRPCBadRequestError('Organization has no subscription');
}
@@ -354,11 +353,15 @@ export async function applySaveDiscount(
return { success: true };
}
-export async function portal(userId: string, organizationId: string) {
+export async function portal(
+ deps: ServiceDeps,
+ userId: string,
+ organizationId: string
+) {
const { requireOrganizationAdmin } = await getAccessChecks();
await requireOrganizationAdmin({ userId, organizationId });
- const organization = await getOrganizationById(organizationId);
+ const organization = await getOrganizationById(deps, organizationId);
if (!organization.subscriptionCustomerId) {
throw new TRPCBadRequestError('Organization has no subscription');
}
@@ -478,7 +481,7 @@ async function clearOrganizationCache(
where: { organizationId },
});
for (const project of projects) {
- await getOrganizationByProjectIdCached.clear(project.id);
+ await getOrganizationByProjectIdCached.clear(deps, project.id);
}
}
@@ -807,7 +810,10 @@ export function createSubscriptionService(
_services: () => Services
) {
return {
- getCurrentSubscriptionProduct,
+ getCurrentSubscriptionProduct: (
+ organizationId: string
+ ): ReturnType<typeof getCurrentSubscriptionProduct> =>
+ getCurrentSubscriptionProduct(deps, organizationId),
checkout: (
userId: string,
input: ICheckout,
@@ -837,7 +843,10 @@ export function createSubscriptionService(
organizationId: string
): ReturnType<typeof applySaveDiscount> =>
applySaveDiscount(deps, userId, organizationId),
- portal,
+ portal: (
+ userId: string,
+ organizationId: string
+ ): ReturnType<typeof portal> => portal(deps, userId, organizationId),
handlePolarWebhookEvent: (
rawBody: string | Buffer,
headers: Record<string, string>,
diff --git a/packages/core/src/shared/cacheable-per-deps.ts b/packages/core/src/shared/cacheable-per-deps.ts
index 1b67566ba..7f0aed625 100644
--- a/packages/core/src/shared/cacheable-per-deps.ts
+++ b/packages/core/src/shared/cacheable-per-deps.ts
@@ -22,7 +22,7 @@
// Redis GET where it used to cost none. Boot-scoped callers (the v1-compat
// seam, job handlers) keep a process-lived L1.
-import { cacheable } from '@openpanel/redis';
+import { type CacheableOptions, cacheable } from '@openpanel/redis';
import type { ServiceDeps } from '../services';
type Cacheable<A extends unknown[], R> = ((...args: A) => Promise<R>) & {
@@ -41,7 +41,8 @@ export type CacheablePerDeps<A extends unknown[], R> = ((
export function cacheablePerDeps<A extends unknown[], R>(
name: string,
fn: (deps: ServiceDeps, ...args: A) => Promise<R>,
- expireInSec: number
+ expireInSec: number,
+ options?: CacheableOptions
): CacheablePerDeps<A, R> {
const byDeps = new WeakMap<ServiceDeps, Cacheable<A, R>>();
@@ -53,7 +54,8 @@ export function cacheablePerDeps<A extends unknown[], R>(
const built = cacheable(
name,
(...args: A) => fn(deps, ...args),
- expireInSec
+ expireInSec,
+ options
) as unknown as Cacheable<A, R>;
byDeps.set(deps, built);
return built;
diff --git a/packages/core/src/v1-compat.ts b/packages/core/src/v1-compat.ts
index 8741096be..505cbc7dc 100644
--- a/packages/core/src/v1-compat.ts
+++ b/packages/core/src/v1-compat.ts
@@ -1,281 +1,37 @@
-// V1 COMPAT SEAM — stays after `packages/trpc` and `packages/queue` are
-// deleted (M11-004); it is not part of that deletion. `apps/api/src/main.ts`
-// has mounted this package's own `rpc.router.ts` `appRouter` since M11-001,
-// but the mcp and assistant tool runtimes still reach a module through a
-// BARE barrel export and have no `ServiceDeps` to hand it — MCP tool
-// handlers have a fixed `@modelcontextprotocol/sdk` signature
-// (modules/mcp/src/auth.ts lazy-imports this file; the gsc tools call
-// getGsc* through it) and the assistant tool runtime is the same shape.
+// V1 COMPAT SEAM — what is left of it.
//
-// The alternative was to leave every module its own
-// `import('@openpanel/db/...')` loader, which is exactly the drift
-// docs/TECH_DEBT.md §4 exists to remove. Instead the boot scope registers
-// the deps it has ALREADY built, once, here, and the barrel's bare wrappers
-// read them from this one place.
+// M15-004 removed class (b): the 204 deps-threading wrappers that reached
+// Postgres/ClickHouse through this file's boot-scoped `ServiceDeps` on behalf
+// of a caller that already held one. Every one of those callers now passes the
+// `deps` it was handed, so a converted read path carries the requestId minted
+// at the edge all the way to the query (ADR-018, ADR-022 amendment A3) instead
+// of losing it here.
+//
+// What remains is class (a) — the sibling-service wrappers, which need a
+// service graph rather than a connection and die with R3's `services()`
+// accessor (M15-005) — plus three seams that belong to neither:
+// `compatPrisma` (the `Prisma` namespace, a sentinel value, not a client),
+// `compatChHelpers` (ADR-013's still-unconverted query helpers) and
+// `compatDb`, kept for `shared/access-lookups.ts` alone: its three lookups are
+// `cacheable`, keyed on their ARGUMENTS, and their bare signature is pinned by
+// the protected wire contract `verification/contracts/auth/
+// group-b-project-access.mts` through `packages/db`'s re-export shim.
//
// Nothing that has a `Ctx` comes through here. HTTP routes, core's own
// procedures and job handlers all use `ctx.services.*`, built from the
-// request-scoped ctx, so the requestId minted at the edge still reaches the
-// query (ADR-018). What comes through this file gets the boot logger —
-// exactly what those callers got before this wave, no worse.
+// request-scoped ctx.
//
// A process that never builds `AppDeps` — this package's own unit suites,
-// which exercise a service directly — falls back to the singletons the
-// deleted module-level `loadDb()` / `loadChClient()` loaders reached, so
-// those callers behave exactly as they did before this wave. The fallback is
+// which exercise a service directly — falls back to the singletons the deleted
+// module-level `loadDb()` / `loadChClient()` loaders reached. The fallback is
// LAZY: importing `@openpanel/core` still constructs no database, which is
// what keeps `bun test` runnable offline.
-import {
- disableTotp as authDisableTotp,
- enableTotp as authEnableTotp,
- extendSessionCookie as authExtendSessionCookie,
- getTotpStatus as authGetTotpStatus,
- regenerateTotpRecoveryCodes as authRegenerateTotpRecoveryCodes,
- requestPasswordReset as authRequestPasswordReset,
- resetPasswordWithToken as authResetPasswordWithToken,
- setupTotp as authSetupTotp,
- signInWithEmail as authSignInWithEmail,
- signInWithTotp as authSignInWithTotp,
- signOutUser as authSignOutUser,
- signUpWithEmail as authSignUpWithEmail,
- type SignInShareInput,
- signInToShare as signInToShareWithDeps,
-} from './modules/auth/auth.service';
-import {
- computeCohort as cohort_computeCohort,
- countCohort as cohort_countCohort,
- deleteCohortMembership as cohort_deleteCohortMembership,
- getCohortCount as cohort_getCohortCount,
- getCohortEventsPerDay as cohort_getCohortEventsPerDay,
- getCohortMemberEvents as cohort_getCohortMemberEvents,
- getCohortMemberRoutes as cohort_getCohortMemberRoutes,
- getCohortMembers as cohort_getCohortMembers,
- getProfilesInCohort as cohort_getProfilesInCohort,
- listCohortMemberProfiles as cohort_listCohortMemberProfiles,
- listRefreshableCohortIds as cohort_listRefreshableCohortIds,
- updateCohortMembership as cohort_updateCohortMembership,
-} from './modules/cohort/cohort.service';
-import {
- createBotEvent as event_createBotEvent,
- createEvent as event_createEvent,
- getBotEventsPage as event_getBotEventsPage,
- getConversionEventNames as event_getConversionEventNames,
- getConversionListPage as event_getConversionListPage,
- getEventById as event_getEventById,
- getEventDetails as event_getEventDetails,
- getEventList as event_getEventList,
- getEventListPage as event_getEventListPage,
- getEventMetas as event_getEventMetas,
- getEventPropertyValuesCore as event_getEventPropertyValuesCore,
- getEvents as event_getEvents,
- getEventsCount as event_getEventsCount,
- getTopEventNames as event_getTopEventNames,
- getTopOrigins as event_getTopOrigins,
- getTopPages as event_getTopPages,
- listEventNamesCore as event_listEventNamesCore,
- listEventPropertiesCore as event_listEventPropertiesCore,
- queryEventsCore as event_queryEventsCore,
- updateEventMeta as event_updateEventMeta,
-} from './modules/event/event.service';
-import {
- createGroup as group_createGroup,
- deleteGroup as group_deleteGroup,
- findGroupsCore as group_findGroupsCore,
- getGroupActivity as group_getGroupActivity,
- getGroupById as group_getGroupById,
- getGroupCore as group_getGroupCore,
- getGroupList as group_getGroupList,
- getGroupListCount as group_getGroupListCount,
- getGroupListPage as group_getGroupListPage,
- getGroupMemberGrowth as group_getGroupMemberGrowth,
- getGroupMemberProfiles as group_getGroupMemberProfiles,
- getGroupMemberProfilesPage as group_getGroupMemberProfilesPage,
- getGroupMetrics as group_getGroupMetrics,
- getGroupMostEvents as group_getGroupMostEvents,
- getGroupPopularRoutes as group_getGroupPopularRoutes,
- getGroupPropertyKeys as group_getGroupPropertyKeys,
- getGroupStats as group_getGroupStats,
- getGroupsByIds as group_getGroupsByIds,
- getGroupTypes as group_getGroupTypes,
- listGroupTypesCore as group_listGroupTypesCore,
- updateGroup as group_updateGroup,
- upsertGroup as group_upsertGroup,
-} from './modules/group/group.service';
-import {
- completeGscOAuthCallback as gsc_completeGscOAuthCallback,
- disconnectGscConnection as gsc_disconnectGscConnection,
- getGscAiEngines as gsc_getGscAiEngines,
- getGscConnection as gsc_getGscConnection,
- getGscOverview as gsc_getGscOverview,
- getGscPageDetails as gsc_getGscPageDetails,
- getGscPages as gsc_getGscPages,
- getGscPreviousOverview as gsc_getGscPreviousOverview,
- getGscQueries as gsc_getGscQueries,
- getGscQueryDetails as gsc_getGscQueryDetails,
- getGscSearchEngines as gsc_getGscSearchEngines,
- gscGetCannibalizationCore as gsc_gscGetCannibalizationCore,
- gscGetOverviewCore as gsc_gscGetOverviewCore,
- gscGetPageDetailsCore as gsc_gscGetPageDetailsCore,
- gscGetQueryDetailsCore as gsc_gscGetQueryDetailsCore,
- gscGetQueryOpportunitiesCore as gsc_gscGetQueryOpportunitiesCore,
- gscGetTopPagesCore as gsc_gscGetTopPagesCore,
- gscGetTopQueriesCore as gsc_gscGetTopQueriesCore,
- listGscConnectionsForSync as gsc_listGscConnectionsForSync,
- listGscSites as gsc_listGscSites,
- resolveGscDateRange as gsc_resolveGscDateRange,
- runGscProjectBackfill as gsc_runGscProjectBackfill,
- runGscProjectSync as gsc_runGscProjectSync,
- selectGscSite as gsc_selectGscSite,
- syncGscData as gsc_syncGscData,
-} from './modules/gsc/gsc.service';
-import {
- backfillSessionsToProduction as import__backfillSessionsToProduction,
- cleanupSessionStartEndEvents as import__cleanupSessionStartEndEvents,
- cleanupStagingData as import__cleanupStagingData,
- createSessionsStartEndEvents as import__createSessionsStartEndEvents,
- generateGapBasedSessionIds as import__generateGapBasedSessionIds,
- getImportDateBounds as import__getImportDateBounds,
- insertImportBatch as import__insertImportBatch,
- insertProfilesBatch as import__insertProfilesBatch,
- insertRawEventsBatch as import__insertRawEventsBatch,
- moveImportsToProduction as import__moveImportsToProduction,
- runImportJob as import__runImportJob,
- updateImportStatus as import__updateImportStatus,
-} from './modules/import/import.service';
-import {
- cleanupStaleInsights as insight_cleanupStaleInsights,
- getReferrerSpikes as insight_getReferrerSpikes,
- listAllInsights as insight_listAllInsights,
- listDailyInsightCandidates as insight_listDailyInsightCandidates,
- listInsights as insight_listInsights,
- previewWeeklyDigest as insight_previewWeeklyDigest,
- runProjectInsights as insight_runProjectInsights,
- scanLegacyInsights as insight_scanLegacyInsights,
- sendWeeklyDigests as insight_sendWeeklyDigests,
-} from './modules/insight/insight.service';
-import {
- completeSlackOAuthCallback as integration_completeSlackOAuthCallback,
- createOrUpdateSlackIntegration as integration_createOrUpdateSlackIntegration,
- deleteIntegration as integration_deleteIntegration,
- getIntegrationById as integration_getIntegrationById,
- listIntegrationsForProject as integration_listIntegrationsForProject,
- testExportIntegrationConnection as integration_testExportIntegrationConnection,
- testIntegrationConnection as integration_testIntegrationConnection,
- upsertIntegration as integration_upsertIntegration,
-} from './modules/integration/integration.service';
-import {
- getStats as misc_getStats,
- insertPingRecord as misc_insertPingRecord,
- runPingCron as misc_runPingCron,
-} from './modules/misc/misc.service';
-import {
- createOrUpdateNotificationRule as notification_createOrUpdateNotificationRule,
- deleteNotificationRule as notification_deleteNotificationRule,
- deliverNotification as notification_deliverNotification,
- getNotificationRuleByIdOrThrow as notification_getNotificationRuleByIdOrThrow,
- listNotificationRules as notification_listNotificationRules,
- listNotifications as notification_listNotifications,
-} from './modules/notification/notification.service';
-import {
- canSkipOnboarding as onboarding_canSkipOnboarding,
- createOnboardingProject as onboarding_createOnboardingProject,
- runOnboardingCron as onboarding_runOnboardingCron,
-} from './modules/onboarding/onboarding.service';
-import {
- cancelOrganizationDeletion as organization_cancelOrganizationDeletion,
- connectUserToOrganization as organization_connectUserToOrganization,
- deleteFromClickhouse as organization_deleteFromClickhouse,
- deleteOrganization as organization_deleteOrganization,
- deleteProjects as organization_deleteProjects,
- getInviteById as organization_getInviteById,
- getInviteOrThrow as organization_getInviteOrThrow,
- getInvites as organization_getInvites,
- getMember as organization_getMember,
- getMembers as organization_getMembers,
- getOrganizationBillingEventsCount as organization_getOrganizationBillingEventsCount,
- getOrganizationBillingEventsCountSerie as organization_getOrganizationBillingEventsCountSerie,
- getOrganizationById as organization_getOrganizationById,
- getOrganizationByProjectId as organization_getOrganizationByProjectId,
- getOrganizationEventsCount as organization_getOrganizationEventsCount,
- getOrganizationEventsCountSince as organization_getOrganizationEventsCountSince,
- getOrganizationSubscriptionChartEndDate as organization_getOrganizationSubscriptionChartEndDate,
- getOrganizations as organization_getOrganizations,
- getSettingsForOrganization as organization_getSettingsForOrganization,
- getSettingsForProject as organization_getSettingsForProject,
- inviteUserToOrganization as organization_inviteUserToOrganization,
- removeOrganizationMember as organization_removeOrganizationMember,
- revokeInvite as organization_revokeInvite,
- runDeleteCron as organization_runDeleteCron,
- scheduleOrganizationDeletion as organization_scheduleOrganizationDeletion,
- updateOrganization as organization_updateOrganization,
- updateOrganizationMemberAccess as organization_updateOrganizationMemberAccess,
-} from './modules/organization/organization.service';
import {
getRawWhereClause,
isPageFilter,
- getAnalyticsOverviewCore as overview_getAnalyticsOverviewCore,
- getSegmentDailySeriesCore as overview_getSegmentDailySeriesCore,
- getTrafficBreakdownCore as overview_getTrafficBreakdownCore,
} from './modules/overview/overview.service';
-import {
- getEntryExitPagesCore as pages_getEntryExitPagesCore,
- getPageConversionsCore as pages_getPageConversionsCore,
- getPagePerformanceCore as pages_getPagePerformanceCore,
- getTopPagesCore as pages_getTopPagesCore,
-} from './modules/overview/pages.service';
-import {
- adjustProfileProperty as profile_adjustProfileProperty,
- findProfilesCore as profile_findProfilesCore,
- getPowerUsers as profile_getPowerUsers,
- getProfileActivity as profile_getProfileActivity,
- getProfileById as profile_getProfileById,
- getProfileList as profile_getProfileList,
- getProfileListCount as profile_getProfileListCount,
- getProfileListPage as profile_getProfileListPage,
- getProfileMetrics as profile_getProfileMetrics,
- getProfileMetricsCore as profile_getProfileMetricsCore,
- getProfileMostEvents as profile_getProfileMostEvents,
- getProfilePopularRoutes as profile_getProfilePopularRoutes,
- getProfilePropertyKeys as profile_getProfilePropertyKeys,
- getProfilePropertyNames as profile_getProfilePropertyNames,
- getProfileSessionsCore as profile_getProfileSessionsCore,
- getProfiles as profile_getProfiles,
- getProfilesCached as profile_getProfilesCached,
- getProfileValues as profile_getProfileValues,
- getProfileWithEvents as profile_getProfileWithEvents,
- identifyProfile as profile_identifyProfile,
- upsertProfile as profile_upsertProfile,
-} from './modules/profile/profile.service';
-import {
- getRealtimeActiveSessions as realtime_getRealtimeActiveSessions,
- getRealtimeCoordinates as realtime_getRealtimeCoordinates,
- getRealtimeGeo as realtime_getRealtimeGeo,
- getRealtimeMapBadgeDetails as realtime_getRealtimeMapBadgeDetails,
- getRealtimePaths as realtime_getRealtimePaths,
- getRealtimeReferrals as realtime_getRealtimeReferrals,
-} from './modules/realtime/realtime.service';
-import {
- getSessionById as session_getSessionById,
- getSessionDistinctValues as session_getSessionDistinctValues,
- getSessionList as session_getSessionList,
- getSessionReplayChunksFrom as session_getSessionReplayChunksFrom,
- getSessionsCount as session_getSessionsCount,
- querySessionsCore as session_querySessionsCore,
-} from './modules/session/session.service';
import { createServices, type ServiceDeps, type Services } from './services';
-import type { ISetCookie } from './shared/cookie';
-import { getId as slugId_getId } from './shared/slug-id';
-
-/** Drops a function type's first (`deps`) parameter — every bare V1-compat
- * wrapper below has the same shape: the underlying function's parameters
- * minus `deps`, since this seam supplies that one itself. */
-type Tail<T extends readonly unknown[]> = T extends readonly [
- unknown,
- ...infer Rest,
-]
- ? Rest
- : never;
let registered: Services | undefined;
let registeredDeps: ServiceDeps | undefined;
@@ -336,7 +92,7 @@ function fallbackServiceDeps(): Promise<ServiceDeps> {
return fallback;
}
-export function compatServiceDeps(): Promise<ServiceDeps> {
+function compatServiceDeps(): Promise<ServiceDeps> {
return registeredDeps
? Promise.resolve(registeredDeps)
: fallbackServiceDeps();
@@ -349,21 +105,16 @@ function services(): Promise<Services> {
}
/**
- * The hot-path escape hatches (M10-004): a handful of callers — the ingest
- * pipeline's client auth, MCP's stateless tool handlers, the chat agent's
- * Prisma persistence — have a fixed, third-party-owned function signature
- * with no `Ctx`/`ServiceDeps` slot to add one to. They reach
- * Postgres/ClickHouse through these instead of `@openpanel/db` directly, so
- * a requestId minted at `/track` at least reaches AS FAR as this seam
- * reaches (no further — see this file's header on why that's still "no
- * worse" than before this wave).
+ * The one deps-free Postgres handle left (M15-004). `shared/access-lookups.ts`
+ * keeps it because its three lookups are `cacheable` on their ARGUMENTS and
+ * their bare signature is a protected wire contract
+ * (`verification/contracts/auth/group-b-project-access.mts` imports them
+ * through `packages/db/src/services/access.service.ts`). Every other caller of
+ * this seam now passes the `deps` it holds.
*/
export async function compatDb(): Promise<ServiceDeps['db']> {
return (await compatServiceDeps()).db;
}
-export async function compatCh(): Promise<ServiceDeps['ch']> {
- return (await compatServiceDeps()).ch;
-}
/**
* `subscription.service.ts` (has `deps`, but `deps.db`'s type is the client
* instance, not the namespace) and `mcp`'s `dashboard-management.ts` (no
@@ -384,8 +135,8 @@ export async function compatPrisma(): Promise<
* conversion (one query per task, old-vs-new result sets diffed) —
* `misc.service.ts`'s still-unconverted queries reach the query-building
* helpers here instead of importing `@openpanel/db` themselves. The CLIENT
- * itself is still `deps.ch` / `compatCh()`; this is only the pure helpers
- * that live beside it. (M12-006 converted the other two callers,
+ * itself is still `deps.ch` (M15-004 deleted `compatCh`); this is only the
+ * pure helpers that live beside it. (M12-006 converted the other two callers,
* `project.service.ts` and mcp's `analytics/property-values.ts`.)
*
* M12-008 dropped the `clix` member: `legacy-scan.ts` and `widget.rpc.ts` were
@@ -704,84 +455,6 @@ export const getChartReferences: Services['reference']['getChartReferences'] = (
container.reference.getChartReferences(...args)
);
-// --- auth ------------------------------------------------------------------
-
-// `signInToShare` lives in the auth module, but it reads the share module's
-// three lookups, so it took `ServiceDeps` in M10-003 too. V1's auth router
-// calls it with two arguments.
-export function signInToShare(
- input: SignInShareInput,
- setCookie: ISetCookie
-): Promise<true> {
- return compatServiceDeps().then((deps) =>
- signInToShareWithDeps(deps, input, setCookie)
- );
-}
-
-// M10-004: every other bare auth function gained `ServiceDeps` too — same
-// reasoning as `signInToShare` above, each reached through this seam.
-export const signOutUser: (
- ...args: Tail<Parameters<typeof authSignOutUser>>
-) => ReturnType<typeof authSignOutUser> = (...args) =>
- compatServiceDeps().then((deps) => authSignOutUser(deps, ...args));
-
-export const signUpWithEmail: (
- ...args: Tail<Parameters<typeof authSignUpWithEmail>>
-) => ReturnType<typeof authSignUpWithEmail> = (...args) =>
- compatServiceDeps().then((deps) => authSignUpWithEmail(deps, ...args));
-
-export const signInWithEmail: (
- ...args: Tail<Parameters<typeof authSignInWithEmail>>
-) => ReturnType<typeof authSignInWithEmail> = (...args) =>
- compatServiceDeps().then((deps) => authSignInWithEmail(deps, ...args));
-
-export const signInWithTotp: (
- ...args: Tail<Parameters<typeof authSignInWithTotp>>
-) => ReturnType<typeof authSignInWithTotp> = (...args) =>
- compatServiceDeps().then((deps) => authSignInWithTotp(deps, ...args));
-
-export const getTotpStatus: (
- ...args: Tail<Parameters<typeof authGetTotpStatus>>
-) => ReturnType<typeof authGetTotpStatus> = (...args) =>
- compatServiceDeps().then((deps) => authGetTotpStatus(deps, ...args));
-
-export const setupTotp: (
- ...args: Tail<Parameters<typeof authSetupTotp>>
-) => ReturnType<typeof authSetupTotp> = (...args) =>
- compatServiceDeps().then((deps) => authSetupTotp(deps, ...args));
-
-export const enableTotp: (
- ...args: Tail<Parameters<typeof authEnableTotp>>
-) => ReturnType<typeof authEnableTotp> = (...args) =>
- compatServiceDeps().then((deps) => authEnableTotp(deps, ...args));
-
-export const disableTotp: (
- ...args: Tail<Parameters<typeof authDisableTotp>>
-) => ReturnType<typeof authDisableTotp> = (...args) =>
- compatServiceDeps().then((deps) => authDisableTotp(deps, ...args));
-
-export const regenerateTotpRecoveryCodes: (
- ...args: Tail<Parameters<typeof authRegenerateTotpRecoveryCodes>>
-) => ReturnType<typeof authRegenerateTotpRecoveryCodes> = (...args) =>
- compatServiceDeps().then((deps) =>
- authRegenerateTotpRecoveryCodes(deps, ...args)
- );
-
-export const resetPasswordWithToken: (
- ...args: Tail<Parameters<typeof authResetPasswordWithToken>>
-) => ReturnType<typeof authResetPasswordWithToken> = (...args) =>
- compatServiceDeps().then((deps) => authResetPasswordWithToken(deps, ...args));
-
-export const requestPasswordReset: (
- ...args: Tail<Parameters<typeof authRequestPasswordReset>>
-) => ReturnType<typeof authRequestPasswordReset> = (...args) =>
- compatServiceDeps().then((deps) => authRequestPasswordReset(deps, ...args));
-
-export const extendSessionCookie: (
- ...args: Tail<Parameters<typeof authExtendSessionCookie>>
-) => ReturnType<typeof authExtendSessionCookie> = (...args) =>
- compatServiceDeps().then((deps) => authExtendSessionCookie(deps, ...args));
-
// --- client ------------------------------------------------------------
export const getClientById: Services['client']['getClientById'] = (...args) =>
@@ -999,476 +672,6 @@ export const deleteConversation: Services['conversation']['deleteConversation']
container.conversation.deleteConversation(...args)
);
-// M10-005: the runtime path's bare spellings. `event`, `profile`, `group`,
-// `misc`, `overview`/`pages` and `realtime` all gained a `ServiceDeps` first
-// parameter; V1's `@openpanel/trpc` routers and `@openpanel/queue`'s
-// notification dispatch called them bare through here before both were
-// deleted (M11-003 moved notification dispatch into this module's own
-// src/notification-dispatch.ts; M11-004 deleted packages/trpc).
-
-// --- event -------------------------------------------------------------------
-
-export const createBotEvent: (
- ...args: Tail<Parameters<typeof event_createBotEvent>>
-) => ReturnType<typeof event_createBotEvent> = (...args) =>
- compatServiceDeps().then((deps) => event_createBotEvent(deps, ...args));
-
-export const createEvent: (
- ...args: Tail<Parameters<typeof event_createEvent>>
-) => ReturnType<typeof event_createEvent> = (...args) =>
- compatServiceDeps().then((deps) => event_createEvent(deps, ...args));
-
-export const getBotEventsPage: (
- ...args: Tail<Parameters<typeof event_getBotEventsPage>>
-) => ReturnType<typeof event_getBotEventsPage> = (...args) =>
- compatServiceDeps().then((deps) => event_getBotEventsPage(deps, ...args));
-
-export const getConversionEventNames: (
- ...args: Tail<Parameters<typeof event_getConversionEventNames>>
-) => ReturnType<typeof event_getConversionEventNames> = (...args) =>
- compatServiceDeps().then((deps) =>
- event_getConversionEventNames(deps, ...args)
- );
-
-export const getConversionListPage: (
- ...args: Tail<Parameters<typeof event_getConversionListPage>>
-) => ReturnType<typeof event_getConversionListPage> = (...args) =>
- compatServiceDeps().then((deps) =>
- event_getConversionListPage(deps, ...args)
- );
-
-export const getEventById: (
- ...args: Tail<Parameters<typeof event_getEventById>>
-) => ReturnType<typeof event_getEventById> = (...args) =>
- compatServiceDeps().then((deps) => event_getEventById(deps, ...args));
-
-export const getEventDetails: (
- ...args: Tail<Parameters<typeof event_getEventDetails>>
-) => ReturnType<typeof event_getEventDetails> = (...args) =>
- compatServiceDeps().then((deps) => event_getEventDetails(deps, ...args));
-
-export const getEventList: (
- ...args: Tail<Parameters<typeof event_getEventList>>
-) => ReturnType<typeof event_getEventList> = (...args) =>
- compatServiceDeps().then((deps) => event_getEventList(deps, ...args));
-
-export const getEventListPage: (
- ...args: Tail<Parameters<typeof event_getEventListPage>>
-) => ReturnType<typeof event_getEventListPage> = (...args) =>
- compatServiceDeps().then((deps) => event_getEventListPage(deps, ...args));
-
-export const getEventMetas: (
- ...args: Tail<Parameters<typeof event_getEventMetas>>
-) => ReturnType<typeof event_getEventMetas> = (...args) =>
- compatServiceDeps().then((deps) => event_getEventMetas(deps, ...args));
-
-export const getEventPropertyValuesCore: (
- ...args: Tail<Parameters<typeof event_getEventPropertyValuesCore>>
-) => ReturnType<typeof event_getEventPropertyValuesCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- event_getEventPropertyValuesCore(deps, ...args)
- );
-
-export const getEvents: (
- ...args: Tail<Parameters<typeof event_getEvents>>
-) => ReturnType<typeof event_getEvents> = (...args) =>
- compatServiceDeps().then((deps) => event_getEvents(deps, ...args));
-
-export const getEventsCount: (
- ...args: Tail<Parameters<typeof event_getEventsCount>>
-) => ReturnType<typeof event_getEventsCount> = (...args) =>
- compatServiceDeps().then((deps) => event_getEventsCount(deps, ...args));
-
-export const getTopEventNames: (
- ...args: Tail<Parameters<typeof event_getTopEventNames>>
-) => ReturnType<typeof event_getTopEventNames> = (...args) =>
- compatServiceDeps().then((deps) => event_getTopEventNames(deps, ...args));
-
-export const getTopOrigins: (
- ...args: Tail<Parameters<typeof event_getTopOrigins>>
-) => ReturnType<typeof event_getTopOrigins> = (...args) =>
- compatServiceDeps().then((deps) => event_getTopOrigins(deps, ...args));
-
-export const getTopPages: (
- ...args: Tail<Parameters<typeof event_getTopPages>>
-) => ReturnType<typeof event_getTopPages> = (...args) =>
- compatServiceDeps().then((deps) => event_getTopPages(deps, ...args));
-
-export const listEventNamesCore: (
- ...args: Tail<Parameters<typeof event_listEventNamesCore>>
-) => ReturnType<typeof event_listEventNamesCore> = (...args) =>
- compatServiceDeps().then((deps) => event_listEventNamesCore(deps, ...args));
-
-export const listEventPropertiesCore: (
- ...args: Tail<Parameters<typeof event_listEventPropertiesCore>>
-) => ReturnType<typeof event_listEventPropertiesCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- event_listEventPropertiesCore(deps, ...args)
- );
-
-export const queryEventsCore: (
- ...args: Tail<Parameters<typeof event_queryEventsCore>>
-) => ReturnType<typeof event_queryEventsCore> = (...args) =>
- compatServiceDeps().then((deps) => event_queryEventsCore(deps, ...args));
-
-export const updateEventMeta: (
- ...args: Tail<Parameters<typeof event_updateEventMeta>>
-) => ReturnType<typeof event_updateEventMeta> = (...args) =>
- compatServiceDeps().then((deps) => event_updateEventMeta(deps, ...args));
-
-// --- profile -----------------------------------------------------------------
-
-export const adjustProfileProperty: (
- ...args: Tail<Parameters<typeof profile_adjustProfileProperty>>
-) => ReturnType<typeof profile_adjustProfileProperty> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_adjustProfileProperty(deps, ...args)
- );
-
-export const findProfilesCore: (
- ...args: Tail<Parameters<typeof profile_findProfilesCore>>
-) => ReturnType<typeof profile_findProfilesCore> = (...args) =>
- compatServiceDeps().then((deps) => profile_findProfilesCore(deps, ...args));
-
-export const getPowerUsers: (
- ...args: Tail<Parameters<typeof profile_getPowerUsers>>
-) => ReturnType<typeof profile_getPowerUsers> = (...args) =>
- compatServiceDeps().then((deps) => profile_getPowerUsers(deps, ...args));
-
-export const getProfileActivity: (
- ...args: Tail<Parameters<typeof profile_getProfileActivity>>
-) => ReturnType<typeof profile_getProfileActivity> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfileActivity(deps, ...args));
-
-export const getProfileById: (
- ...args: Tail<Parameters<typeof profile_getProfileById>>
-) => ReturnType<typeof profile_getProfileById> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfileById(deps, ...args));
-
-export const getProfileList: (
- ...args: Tail<Parameters<typeof profile_getProfileList>>
-) => ReturnType<typeof profile_getProfileList> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfileList(deps, ...args));
-
-export const getProfileListCount: (
- ...args: Tail<Parameters<typeof profile_getProfileListCount>>
-) => ReturnType<typeof profile_getProfileListCount> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfileListCount(deps, ...args)
- );
-
-export const getProfileListPage: (
- ...args: Tail<Parameters<typeof profile_getProfileListPage>>
-) => ReturnType<typeof profile_getProfileListPage> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfileListPage(deps, ...args));
-
-export const getProfileMetrics: (
- ...args: Tail<Parameters<typeof profile_getProfileMetrics>>
-) => ReturnType<typeof profile_getProfileMetrics> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfileMetrics(deps, ...args));
-
-export const getProfileMetricsCore: (
- ...args: Tail<Parameters<typeof profile_getProfileMetricsCore>>
-) => ReturnType<typeof profile_getProfileMetricsCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfileMetricsCore(deps, ...args)
- );
-
-export const getProfileMostEvents: (
- ...args: Tail<Parameters<typeof profile_getProfileMostEvents>>
-) => ReturnType<typeof profile_getProfileMostEvents> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfileMostEvents(deps, ...args)
- );
-
-export const getProfilePopularRoutes: (
- ...args: Tail<Parameters<typeof profile_getProfilePopularRoutes>>
-) => ReturnType<typeof profile_getProfilePopularRoutes> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfilePopularRoutes(deps, ...args)
- );
-
-export const getProfilePropertyKeys: (
- ...args: Tail<Parameters<typeof profile_getProfilePropertyKeys>>
-) => ReturnType<typeof profile_getProfilePropertyKeys> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfilePropertyKeys(deps, ...args)
- );
-
-export const getProfilePropertyNames: (
- ...args: Tail<Parameters<typeof profile_getProfilePropertyNames>>
-) => ReturnType<typeof profile_getProfilePropertyNames> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfilePropertyNames(deps, ...args)
- );
-
-export const getProfileSessionsCore: (
- ...args: Tail<Parameters<typeof profile_getProfileSessionsCore>>
-) => ReturnType<typeof profile_getProfileSessionsCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfileSessionsCore(deps, ...args)
- );
-
-export const getProfileValues: (
- ...args: Tail<Parameters<typeof profile_getProfileValues>>
-) => ReturnType<typeof profile_getProfileValues> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfileValues(deps, ...args));
-
-export const getProfileWithEvents: (
- ...args: Tail<Parameters<typeof profile_getProfileWithEvents>>
-) => ReturnType<typeof profile_getProfileWithEvents> = (...args) =>
- compatServiceDeps().then((deps) =>
- profile_getProfileWithEvents(deps, ...args)
- );
-
-export const getProfiles: (
- ...args: Tail<Parameters<typeof profile_getProfiles>>
-) => ReturnType<typeof profile_getProfiles> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfiles(deps, ...args));
-
-/** `session.service.ts`'s `getSessionList` is still deps-free (its own task),
- * and this is the one cached read it makes. */
-export const getProfilesCached: (
- ...args: Tail<Parameters<typeof profile_getProfilesCached>>
-) => ReturnType<typeof profile_getProfilesCached> = (...args) =>
- compatServiceDeps().then((deps) => profile_getProfilesCached(deps, ...args));
-
-export const identifyProfile: (
- ...args: Tail<Parameters<typeof profile_identifyProfile>>
-) => ReturnType<typeof profile_identifyProfile> = (...args) =>
- compatServiceDeps().then((deps) => profile_identifyProfile(deps, ...args));
-
-export const upsertProfile: (
- ...args: Tail<Parameters<typeof profile_upsertProfile>>
-) => ReturnType<typeof profile_upsertProfile> = (...args) =>
- compatServiceDeps().then((deps) => profile_upsertProfile(deps, ...args));
-
-// --- group -------------------------------------------------------------------
-
-export const createGroup: (
- ...args: Tail<Parameters<typeof group_createGroup>>
-) => ReturnType<typeof group_createGroup> = (...args) =>
- compatServiceDeps().then((deps) => group_createGroup(deps, ...args));
-
-export const deleteGroup: (
- ...args: Tail<Parameters<typeof group_deleteGroup>>
-) => ReturnType<typeof group_deleteGroup> = (...args) =>
- compatServiceDeps().then((deps) => group_deleteGroup(deps, ...args));
-
-export const findGroupsCore: (
- ...args: Tail<Parameters<typeof group_findGroupsCore>>
-) => ReturnType<typeof group_findGroupsCore> = (...args) =>
- compatServiceDeps().then((deps) => group_findGroupsCore(deps, ...args));
-
-export const getGroupActivity: (
- ...args: Tail<Parameters<typeof group_getGroupActivity>>
-) => ReturnType<typeof group_getGroupActivity> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupActivity(deps, ...args));
-
-export const getGroupById: (
- ...args: Tail<Parameters<typeof group_getGroupById>>
-) => ReturnType<typeof group_getGroupById> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupById(deps, ...args));
-
-export const getGroupCore: (
- ...args: Tail<Parameters<typeof group_getGroupCore>>
-) => ReturnType<typeof group_getGroupCore> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupCore(deps, ...args));
-
-export const getGroupList: (
- ...args: Tail<Parameters<typeof group_getGroupList>>
-) => ReturnType<typeof group_getGroupList> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupList(deps, ...args));
-
-export const getGroupListCount: (
- ...args: Tail<Parameters<typeof group_getGroupListCount>>
-) => ReturnType<typeof group_getGroupListCount> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupListCount(deps, ...args));
-
-export const getGroupListPage: (
- ...args: Tail<Parameters<typeof group_getGroupListPage>>
-) => ReturnType<typeof group_getGroupListPage> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupListPage(deps, ...args));
-
-export const getGroupMemberGrowth: (
- ...args: Tail<Parameters<typeof group_getGroupMemberGrowth>>
-) => ReturnType<typeof group_getGroupMemberGrowth> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupMemberGrowth(deps, ...args));
-
-export const getGroupMemberProfiles: (
- ...args: Tail<Parameters<typeof group_getGroupMemberProfiles>>
-) => ReturnType<typeof group_getGroupMemberProfiles> = (...args) =>
- compatServiceDeps().then((deps) =>
- group_getGroupMemberProfiles(deps, ...args)
- );
-
-export const getGroupMemberProfilesPage: (
- ...args: Tail<Parameters<typeof group_getGroupMemberProfilesPage>>
-) => ReturnType<typeof group_getGroupMemberProfilesPage> = (...args) =>
- compatServiceDeps().then((deps) =>
- group_getGroupMemberProfilesPage(deps, ...args)
- );
-
-export const getGroupMetrics: (
- ...args: Tail<Parameters<typeof group_getGroupMetrics>>
-) => ReturnType<typeof group_getGroupMetrics> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupMetrics(deps, ...args));
-
-export const getGroupMostEvents: (
- ...args: Tail<Parameters<typeof group_getGroupMostEvents>>
-) => ReturnType<typeof group_getGroupMostEvents> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupMostEvents(deps, ...args));
-
-export const getGroupPopularRoutes: (
- ...args: Tail<Parameters<typeof group_getGroupPopularRoutes>>
-) => ReturnType<typeof group_getGroupPopularRoutes> = (...args) =>
- compatServiceDeps().then((deps) =>
- group_getGroupPopularRoutes(deps, ...args)
- );
-
-export const getGroupPropertyKeys: (
- ...args: Tail<Parameters<typeof group_getGroupPropertyKeys>>
-) => ReturnType<typeof group_getGroupPropertyKeys> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupPropertyKeys(deps, ...args));
-
-export const getGroupStats: (
- ...args: Tail<Parameters<typeof group_getGroupStats>>
-) => ReturnType<typeof group_getGroupStats> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupStats(deps, ...args));
-
-export const getGroupTypes: (
- ...args: Tail<Parameters<typeof group_getGroupTypes>>
-) => ReturnType<typeof group_getGroupTypes> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupTypes(deps, ...args));
-
-export const getGroupsByIds: (
- ...args: Tail<Parameters<typeof group_getGroupsByIds>>
-) => ReturnType<typeof group_getGroupsByIds> = (...args) =>
- compatServiceDeps().then((deps) => group_getGroupsByIds(deps, ...args));
-
-export const listGroupTypesCore: (
- ...args: Tail<Parameters<typeof group_listGroupTypesCore>>
-) => ReturnType<typeof group_listGroupTypesCore> = (...args) =>
- compatServiceDeps().then((deps) => group_listGroupTypesCore(deps, ...args));
-
-export const updateGroup: (
- ...args: Tail<Parameters<typeof group_updateGroup>>
-) => ReturnType<typeof group_updateGroup> = (...args) =>
- compatServiceDeps().then((deps) => group_updateGroup(deps, ...args));
-
-export const upsertGroup: (
- ...args: Tail<Parameters<typeof group_upsertGroup>>
-) => ReturnType<typeof group_upsertGroup> = (...args) =>
- compatServiceDeps().then((deps) => group_upsertGroup(deps, ...args));
-
-// --- overview ----------------------------------------------------------------
-
-export const getAnalyticsOverviewCore: (
- ...args: Tail<Parameters<typeof overview_getAnalyticsOverviewCore>>
-) => ReturnType<typeof overview_getAnalyticsOverviewCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- overview_getAnalyticsOverviewCore(deps, ...args)
- );
-
-export const getSegmentDailySeriesCore: (
- ...args: Tail<Parameters<typeof overview_getSegmentDailySeriesCore>>
-) => ReturnType<typeof overview_getSegmentDailySeriesCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- overview_getSegmentDailySeriesCore(deps, ...args)
- );
-
-export const getTrafficBreakdownCore: (
- ...args: Tail<Parameters<typeof overview_getTrafficBreakdownCore>>
-) => ReturnType<typeof overview_getTrafficBreakdownCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- overview_getTrafficBreakdownCore(deps, ...args)
- );
-
-// --- pages -------------------------------------------------------------------
-
-export const getEntryExitPagesCore: (
- ...args: Tail<Parameters<typeof pages_getEntryExitPagesCore>>
-) => ReturnType<typeof pages_getEntryExitPagesCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- pages_getEntryExitPagesCore(deps, ...args)
- );
-
-export const getPageConversionsCore: (
- ...args: Tail<Parameters<typeof pages_getPageConversionsCore>>
-) => ReturnType<typeof pages_getPageConversionsCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- pages_getPageConversionsCore(deps, ...args)
- );
-
-export const getPagePerformanceCore: (
- ...args: Tail<Parameters<typeof pages_getPagePerformanceCore>>
-) => ReturnType<typeof pages_getPagePerformanceCore> = (...args) =>
- compatServiceDeps().then((deps) =>
- pages_getPagePerformanceCore(deps, ...args)
- );
-
-export const getTopPagesCore: (
- ...args: Tail<Parameters<typeof pages_getTopPagesCore>>
-) => ReturnType<typeof pages_getTopPagesCore> = (...args) =>
- compatServiceDeps().then((deps) => pages_getTopPagesCore(deps, ...args));
-
-// --- realtime ----------------------------------------------------------------
-
-export const getRealtimeActiveSessions: (
- ...args: Tail<Parameters<typeof realtime_getRealtimeActiveSessions>>
-) => ReturnType<typeof realtime_getRealtimeActiveSessions> = (...args) =>
- compatServiceDeps().then((deps) =>
- realtime_getRealtimeActiveSessions(deps, ...args)
- );
-
-export const getRealtimeCoordinates: (
- ...args: Tail<Parameters<typeof realtime_getRealtimeCoordinates>>
-) => ReturnType<typeof realtime_getRealtimeCoordinates> = (...args) =>
- compatServiceDeps().then((deps) =>
- realtime_getRealtimeCoordinates(deps, ...args)
- );
-
-export const getRealtimeGeo: (
- ...args: Tail<Parameters<typeof realtime_getRealtimeGeo>>
-) => ReturnType<typeof realtime_getRealtimeGeo> = (...args) =>
- compatServiceDeps().then((deps) => realtime_getRealtimeGeo(deps, ...args));
-
-export const getRealtimeMapBadgeDetails: (
- ...args: Tail<Parameters<typeof realtime_getRealtimeMapBadgeDetails>>
-) => ReturnType<typeof realtime_getRealtimeMapBadgeDetails> = (...args) =>
- compatServiceDeps().then((deps) =>
- realtime_getRealtimeMapBadgeDetails(deps, ...args)
- );
-
-export const getRealtimePaths: (
- ...args: Tail<Parameters<typeof realtime_getRealtimePaths>>
-) => ReturnType<typeof realtime_getRealtimePaths> = (...args) =>
- compatServiceDeps().then((deps) => realtime_getRealtimePaths(deps, ...args));
-
-export const getRealtimeReferrals: (
- ...args: Tail<Parameters<typeof realtime_getRealtimeReferrals>>
-) => ReturnType<typeof realtime_getRealtimeReferrals> = (...args) =>
- compatServiceDeps().then((deps) =>
- realtime_getRealtimeReferrals(deps, ...args)
- );
-
-// --- misc --------------------------------------------------------------------
-
-export const getStats: (
- ...args: Tail<Parameters<typeof misc_getStats>>
-) => ReturnType<typeof misc_getStats> = (...args) =>
- compatServiceDeps().then((deps) => misc_getStats(deps, ...args));
-
-export const insertPingRecord: (
- ...args: Tail<Parameters<typeof misc_insertPingRecord>>
-) => ReturnType<typeof misc_insertPingRecord> = (...args) =>
- compatServiceDeps().then((deps) => misc_insertPingRecord(deps, ...args));
-
-export const runPingCron: (
- ...args: Tail<Parameters<typeof misc_runPingCron>>
-) => ReturnType<typeof misc_runPingCron> = (...args) =>
- compatServiceDeps().then((deps) => misc_runPingCron(deps, ...args));
-
// V1's (now-deleted) `@openpanel/trpc` overview and event routers called
// these as OBJECTS (`overviewService.getMetrics(...)`,
// `pagesService.getTopPages(...)`), and one of them still did
@@ -1533,572 +736,3 @@ export const pagesService = {
container.pages.getPageTimeseries(...args)
)) as Services['pages']['getPageTimeseries'],
};
-
-// --- onboarding ------------------------------------------------------------------
-
-export const canSkipOnboarding: (
- ...args: Tail<Parameters<typeof onboarding_canSkipOnboarding>>
-) => ReturnType<typeof onboarding_canSkipOnboarding> = (...args) =>
- compatServiceDeps().then((deps) => onboarding_canSkipOnboarding(deps, ...args));
-
-export const createOnboardingProject: (
- ...args: Tail<Parameters<typeof onboarding_createOnboardingProject>>
-) => ReturnType<typeof onboarding_createOnboardingProject> = (...args) =>
- compatServiceDeps().then((deps) => onboarding_createOnboardingProject(deps, ...args));
-
-export const runOnboardingCron: (
- ...args: Tail<Parameters<typeof onboarding_runOnboardingCron>>
-) => ReturnType<typeof onboarding_runOnboardingCron> = (...args) =>
- compatServiceDeps().then((deps) => onboarding_runOnboardingCron(deps, ...args));
-
-// --- integration -----------------------------------------------------------------
-
-export const completeSlackOAuthCallback: (
- ...args: Tail<Parameters<typeof integration_completeSlackOAuthCallback>>
-) => ReturnType<typeof integration_completeSlackOAuthCallback> = (...args) =>
- compatServiceDeps().then((deps) => integration_completeSlackOAuthCallback(deps, ...args));
-
-export const createOrUpdateSlackIntegration: (
- ...args: Tail<Parameters<typeof integration_createOrUpdateSlackIntegration>>
-) => ReturnType<typeof integration_createOrUpdateSlackIntegration> = (...args) =>
- compatServiceDeps().then((deps) => integration_createOrUpdateSlackIntegration(deps, ...args));
-
-export const deleteIntegration: (
- ...args: Tail<Parameters<typeof integration_deleteIntegration>>
-) => ReturnType<typeof integration_deleteIntegration> = (...args) =>
- compatServiceDeps().then((deps) => integration_deleteIntegration(deps, ...args));
-
-export const getIntegrationById: (
- ...args: Tail<Parameters<typeof integration_getIntegrationById>>
-) => ReturnType<typeof integration_getIntegrationById> = (...args) =>
- compatServiceDeps().then((deps) => integration_getIntegrationById(deps, ...args));
-
-export const listIntegrationsForProject: (
- ...args: Tail<Parameters<typeof integration_listIntegrationsForProject>>
-) => ReturnType<typeof integration_listIntegrationsForProject> = (...args) =>
- compatServiceDeps().then((deps) => integration_listIntegrationsForProject(deps, ...args));
-
-export const testExportIntegrationConnection: (
- ...args: Tail<Parameters<typeof integration_testExportIntegrationConnection>>
-) => ReturnType<typeof integration_testExportIntegrationConnection> = (...args) =>
- compatServiceDeps().then((deps) => integration_testExportIntegrationConnection(deps, ...args));
-
-export const testIntegrationConnection: (
- ...args: Tail<Parameters<typeof integration_testIntegrationConnection>>
-) => ReturnType<typeof integration_testIntegrationConnection> = (...args) =>
- compatServiceDeps().then((deps) => integration_testIntegrationConnection(deps, ...args));
-
-export const upsertIntegration: (
- ...args: Tail<Parameters<typeof integration_upsertIntegration>>
-) => ReturnType<typeof integration_upsertIntegration> = (...args) =>
- compatServiceDeps().then((deps) => integration_upsertIntegration(deps, ...args));
-
-// --- notification ----------------------------------------------------------------
-
-export const createOrUpdateNotificationRule: (
- ...args: Tail<Parameters<typeof notification_createOrUpdateNotificationRule>>
-) => ReturnType<typeof notification_createOrUpdateNotificationRule> = (...args) =>
- compatServiceDeps().then((deps) => notification_createOrUpdateNotificationRule(deps, ...args));
-
-export const deleteNotificationRule: (
- ...args: Tail<Parameters<typeof notification_deleteNotificationRule>>
-) => ReturnType<typeof notification_deleteNotificationRule> = (...args) =>
- compatServiceDeps().then((deps) => notification_deleteNotificationRule(deps, ...args));
-
-export const deliverNotification: (
- ...args: Tail<Parameters<typeof notification_deliverNotification>>
-) => ReturnType<typeof notification_deliverNotification> = (...args) =>
- compatServiceDeps().then((deps) => notification_deliverNotification(deps, ...args));
-
-export const getNotificationRuleByIdOrThrow: (
- ...args: Tail<Parameters<typeof notification_getNotificationRuleByIdOrThrow>>
-) => ReturnType<typeof notification_getNotificationRuleByIdOrThrow> = (...args) =>
- compatServiceDeps().then((deps) => notification_getNotificationRuleByIdOrThrow(deps, ...args));
-
-export const listNotificationRules: (
- ...args: Tail<Parameters<typeof notification_listNotificationRules>>
-) => ReturnType<typeof notification_listNotificationRules> = (...args) =>
- compatServiceDeps().then((deps) => notification_listNotificationRules(deps, ...args));
-
-export const listNotifications: (
- ...args: Tail<Parameters<typeof notification_listNotifications>>
-) => ReturnType<typeof notification_listNotifications> = (...args) =>
- compatServiceDeps().then((deps) => notification_listNotifications(deps, ...args));
-
-// --- slug-id ---------------------------------------------------------------------
-
-export const getId: (
- ...args: Tail<Parameters<typeof slugId_getId>>
-) => ReturnType<typeof slugId_getId> = (...args) =>
- compatServiceDeps().then((deps) => slugId_getId(deps, ...args));
-
-// --- insight ---------------------------------------------------------------------
-
-export const cleanupStaleInsights: (
- ...args: Tail<Parameters<typeof insight_cleanupStaleInsights>>
-) => ReturnType<typeof insight_cleanupStaleInsights> = (...args) =>
- compatServiceDeps().then((deps) => insight_cleanupStaleInsights(deps, ...args));
-
-export const listAllInsights: (
- ...args: Tail<Parameters<typeof insight_listAllInsights>>
-) => ReturnType<typeof insight_listAllInsights> = (...args) =>
- compatServiceDeps().then((deps) => insight_listAllInsights(deps, ...args));
-
-export const listDailyInsightCandidates: (
- ...args: Tail<Parameters<typeof insight_listDailyInsightCandidates>>
-) => ReturnType<typeof insight_listDailyInsightCandidates> = (...args) =>
- compatServiceDeps().then((deps) => insight_listDailyInsightCandidates(deps, ...args));
-
-export const listInsights: (
- ...args: Tail<Parameters<typeof insight_listInsights>>
-) => ReturnType<typeof insight_listInsights> = (...args) =>
- compatServiceDeps().then((deps) => insight_listInsights(deps, ...args));
-
-export const previewWeeklyDigest: (
- ...args: Tail<Parameters<typeof insight_previewWeeklyDigest>>
-) => ReturnType<typeof insight_previewWeeklyDigest> = (...args) =>
- compatServiceDeps().then((deps) => insight_previewWeeklyDigest(deps, ...args));
-
-export const runProjectInsights: (
- ...args: Tail<Parameters<typeof insight_runProjectInsights>>
-) => ReturnType<typeof insight_runProjectInsights> = (...args) =>
- compatServiceDeps().then((deps) => insight_runProjectInsights(deps, ...args));
-
-export const scanLegacyInsights: (
- ...args: Tail<Parameters<typeof insight_scanLegacyInsights>>
-) => ReturnType<typeof insight_scanLegacyInsights> = (...args) =>
- compatServiceDeps().then((deps) => insight_scanLegacyInsights(deps, ...args));
-
-export const sendWeeklyDigests: (
- ...args: Tail<Parameters<typeof insight_sendWeeklyDigests>>
-) => ReturnType<typeof insight_sendWeeklyDigests> = (...args) =>
- compatServiceDeps().then((deps) => insight_sendWeeklyDigests(deps, ...args));
-
-// --- insight (referrer spikes) ---------------------------------------------------
-
-export const getReferrerSpikes: (
- ...args: Tail<Parameters<typeof insight_getReferrerSpikes>>
-) => ReturnType<typeof insight_getReferrerSpikes> = (...args) =>
- compatServiceDeps().then((deps) => insight_getReferrerSpikes(deps, ...args));
-
-// --- session ---------------------------------------------------------------------
-
-export const getSessionById: (
- ...args: Tail<Parameters<typeof session_getSessionById>>
-) => ReturnType<typeof session_getSessionById> = (...args) =>
- compatServiceDeps().then((deps) => session_getSessionById(deps, ...args));
-
-export const getSessionDistinctValues: (
- ...args: Tail<Parameters<typeof session_getSessionDistinctValues>>
-) => ReturnType<typeof session_getSessionDistinctValues> = (...args) =>
- compatServiceDeps().then((deps) => session_getSessionDistinctValues(deps, ...args));
-
-export const getSessionList: (
- ...args: Tail<Parameters<typeof session_getSessionList>>
-) => ReturnType<typeof session_getSessionList> = (...args) =>
- compatServiceDeps().then((deps) => session_getSessionList(deps, ...args));
-
-export const getSessionReplayChunksFrom: (
- ...args: Tail<Parameters<typeof session_getSessionReplayChunksFrom>>
-) => ReturnType<typeof session_getSessionReplayChunksFrom> = (...args) =>
- compatServiceDeps().then((deps) => session_getSessionReplayChunksFrom(deps, ...args));
-
-export const getSessionsCount: (
- ...args: Tail<Parameters<typeof session_getSessionsCount>>
-) => ReturnType<typeof session_getSessionsCount> = (...args) =>
- compatServiceDeps().then((deps) => session_getSessionsCount(deps, ...args));
-
-export const querySessionsCore: (
- ...args: Tail<Parameters<typeof session_querySessionsCore>>
-) => ReturnType<typeof session_querySessionsCore> = (...args) =>
- compatServiceDeps().then((deps) => session_querySessionsCore(deps, ...args));
-
-// --- import ----------------------------------------------------------------------
-
-export const backfillSessionsToProduction: (
- ...args: Tail<Parameters<typeof import__backfillSessionsToProduction>>
-) => ReturnType<typeof import__backfillSessionsToProduction> = (...args) =>
- compatServiceDeps().then((deps) => import__backfillSessionsToProduction(deps, ...args));
-
-export const cleanupSessionStartEndEvents: (
- ...args: Tail<Parameters<typeof import__cleanupSessionStartEndEvents>>
-) => ReturnType<typeof import__cleanupSessionStartEndEvents> = (...args) =>
- compatServiceDeps().then((deps) => import__cleanupSessionStartEndEvents(deps, ...args));
-
-export const cleanupStagingData: (
- ...args: Tail<Parameters<typeof import__cleanupStagingData>>
-) => ReturnType<typeof import__cleanupStagingData> = (...args) =>
- compatServiceDeps().then((deps) => import__cleanupStagingData(deps, ...args));
-
-export const createSessionsStartEndEvents: (
- ...args: Tail<Parameters<typeof import__createSessionsStartEndEvents>>
-) => ReturnType<typeof import__createSessionsStartEndEvents> = (...args) =>
- compatServiceDeps().then((deps) => import__createSessionsStartEndEvents(deps, ...args));
-
-export const generateGapBasedSessionIds: (
- ...args: Tail<Parameters<typeof import__generateGapBasedSessionIds>>
-) => ReturnType<typeof import__generateGapBasedSessionIds> = (...args) =>
- compatServiceDeps().then((deps) => import__generateGapBasedSessionIds(deps, ...args));
-
-export const getImportDateBounds: (
- ...args: Tail<Parameters<typeof import__getImportDateBounds>>
-) => ReturnType<typeof import__getImportDateBounds> = (...args) =>
- compatServiceDeps().then((deps) => import__getImportDateBounds(deps, ...args));
-
-export const insertImportBatch: (
- ...args: Tail<Parameters<typeof import__insertImportBatch>>
-) => ReturnType<typeof import__insertImportBatch> = (...args) =>
- compatServiceDeps().then((deps) => import__insertImportBatch(deps, ...args));
-
-export const insertProfilesBatch: (
- ...args: Tail<Parameters<typeof import__insertProfilesBatch>>
-) => ReturnType<typeof import__insertProfilesBatch> = (...args) =>
- compatServiceDeps().then((deps) => import__insertProfilesBatch(deps, ...args));
-
-export const insertRawEventsBatch: (
- ...args: Tail<Parameters<typeof import__insertRawEventsBatch>>
-) => ReturnType<typeof import__insertRawEventsBatch> = (...args) =>
- compatServiceDeps().then((deps) => import__insertRawEventsBatch(deps, ...args));
-
-export const moveImportsToProduction: (
- ...args: Tail<Parameters<typeof import__moveImportsToProduction>>
-) => ReturnType<typeof import__moveImportsToProduction> = (...args) =>
- compatServiceDeps().then((deps) => import__moveImportsToProduction(deps, ...args));
-
-export const runImportJob: (
- ...args: Tail<Parameters<typeof import__runImportJob>>
-) => ReturnType<typeof import__runImportJob> = (...args) =>
- compatServiceDeps().then((deps) => import__runImportJob(deps, ...args));
-
-export const updateImportStatus: (
- ...args: Tail<Parameters<typeof import__updateImportStatus>>
-) => ReturnType<typeof import__updateImportStatus> = (...args) =>
- compatServiceDeps().then((deps) => import__updateImportStatus(deps, ...args));
-
-// --- cohort ----------------------------------------------------------------------
-
-export const computeCohort: (
- ...args: Tail<Parameters<typeof cohort_computeCohort>>
-) => ReturnType<typeof cohort_computeCohort> = (...args) =>
- compatServiceDeps().then((deps) => cohort_computeCohort(deps, ...args));
-
-export const countCohort: (
- ...args: Tail<Parameters<typeof cohort_countCohort>>
-) => ReturnType<typeof cohort_countCohort> = (...args) =>
- compatServiceDeps().then((deps) => cohort_countCohort(deps, ...args));
-
-export const deleteCohortMembership: (
- ...args: Tail<Parameters<typeof cohort_deleteCohortMembership>>
-) => ReturnType<typeof cohort_deleteCohortMembership> = (...args) =>
- compatServiceDeps().then((deps) => cohort_deleteCohortMembership(deps, ...args));
-
-export const getCohortCount: (
- ...args: Tail<Parameters<typeof cohort_getCohortCount>>
-) => ReturnType<typeof cohort_getCohortCount> = (...args) =>
- compatServiceDeps().then((deps) => cohort_getCohortCount(deps, ...args));
-
-export const getCohortEventsPerDay: (
- ...args: Tail<Parameters<typeof cohort_getCohortEventsPerDay>>
-) => ReturnType<typeof cohort_getCohortEventsPerDay> = (...args) =>
- compatServiceDeps().then((deps) => cohort_getCohortEventsPerDay(deps, ...args));
-
-export const getCohortMemberEvents: (
- ...args: Tail<Parameters<typeof cohort_getCohortMemberEvents>>
-) => ReturnType<typeof cohort_getCohortMemberEvents> = (...args) =>
- compatServiceDeps().then((deps) => cohort_getCohortMemberEvents(deps, ...args));
-
-export const getCohortMemberRoutes: (
- ...args: Tail<Parameters<typeof cohort_getCohortMemberRoutes>>
-) => ReturnType<typeof cohort_getCohortMemberRoutes> = (...args) =>
- compatServiceDeps().then((deps) => cohort_getCohortMemberRoutes(deps, ...args));
-
-export const getCohortMembers: (
- ...args: Tail<Parameters<typeof cohort_getCohortMembers>>
-) => ReturnType<typeof cohort_getCohortMembers> = (...args) =>
- compatServiceDeps().then((deps) => cohort_getCohortMembers(deps, ...args));
-
-export const getProfilesInCohort: (
- ...args: Tail<Parameters<typeof cohort_getProfilesInCohort>>
-) => ReturnType<typeof cohort_getProfilesInCohort> = (...args) =>
- compatServiceDeps().then((deps) => cohort_getProfilesInCohort(deps, ...args));
-
-export const listCohortMemberProfiles: (
- ...args: Tail<Parameters<typeof cohort_listCohortMemberProfiles>>
-) => ReturnType<typeof cohort_listCohortMemberProfiles> = (...args) =>
- compatServiceDeps().then((deps) => cohort_listCohortMemberProfiles(deps, ...args));
-
-export const listRefreshableCohortIds: (
- ...args: Tail<Parameters<typeof cohort_listRefreshableCohortIds>>
-) => ReturnType<typeof cohort_listRefreshableCohortIds> = (...args) =>
- compatServiceDeps().then((deps) => cohort_listRefreshableCohortIds(deps, ...args));
-
-export const updateCohortMembership: (
- ...args: Tail<Parameters<typeof cohort_updateCohortMembership>>
-) => ReturnType<typeof cohort_updateCohortMembership> = (...args) =>
- compatServiceDeps().then((deps) => cohort_updateCohortMembership(deps, ...args));
-
-// --- gsc -------------------------------------------------------------------------
-
-export const completeGscOAuthCallback: (
- ...args: Tail<Parameters<typeof gsc_completeGscOAuthCallback>>
-) => ReturnType<typeof gsc_completeGscOAuthCallback> = (...args) =>
- compatServiceDeps().then((deps) => gsc_completeGscOAuthCallback(deps, ...args));
-
-export const disconnectGscConnection: (
- ...args: Tail<Parameters<typeof gsc_disconnectGscConnection>>
-) => ReturnType<typeof gsc_disconnectGscConnection> = (...args) =>
- compatServiceDeps().then((deps) => gsc_disconnectGscConnection(deps, ...args));
-
-export const getGscAiEngines: (
- ...args: Tail<Parameters<typeof gsc_getGscAiEngines>>
-) => ReturnType<typeof gsc_getGscAiEngines> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscAiEngines(deps, ...args));
-
-export const getGscConnection: (
- ...args: Tail<Parameters<typeof gsc_getGscConnection>>
-) => ReturnType<typeof gsc_getGscConnection> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscConnection(deps, ...args));
-
-export const getGscOverview: (
- ...args: Tail<Parameters<typeof gsc_getGscOverview>>
-) => ReturnType<typeof gsc_getGscOverview> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscOverview(deps, ...args));
-
-export const getGscPageDetails: (
- ...args: Tail<Parameters<typeof gsc_getGscPageDetails>>
-) => ReturnType<typeof gsc_getGscPageDetails> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscPageDetails(deps, ...args));
-
-export const getGscPages: (
- ...args: Tail<Parameters<typeof gsc_getGscPages>>
-) => ReturnType<typeof gsc_getGscPages> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscPages(deps, ...args));
-
-export const getGscPreviousOverview: (
- ...args: Tail<Parameters<typeof gsc_getGscPreviousOverview>>
-) => ReturnType<typeof gsc_getGscPreviousOverview> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscPreviousOverview(deps, ...args));
-
-export const getGscQueries: (
- ...args: Tail<Parameters<typeof gsc_getGscQueries>>
-) => ReturnType<typeof gsc_getGscQueries> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscQueries(deps, ...args));
-
-export const getGscQueryDetails: (
- ...args: Tail<Parameters<typeof gsc_getGscQueryDetails>>
-) => ReturnType<typeof gsc_getGscQueryDetails> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscQueryDetails(deps, ...args));
-
-export const getGscSearchEngines: (
- ...args: Tail<Parameters<typeof gsc_getGscSearchEngines>>
-) => ReturnType<typeof gsc_getGscSearchEngines> = (...args) =>
- compatServiceDeps().then((deps) => gsc_getGscSearchEngines(deps, ...args));
-
-export const gscGetCannibalizationCore: (
- ...args: Tail<Parameters<typeof gsc_gscGetCannibalizationCore>>
-) => ReturnType<typeof gsc_gscGetCannibalizationCore> = (...args) =>
- compatServiceDeps().then((deps) => gsc_gscGetCannibalizationCore(deps, ...args));
-
-export const gscGetOverviewCore: (
- ...args: Tail<Parameters<typeof gsc_gscGetOverviewCore>>
-) => ReturnType<typeof gsc_gscGetOverviewCore> = (...args) =>
- compatServiceDeps().then((deps) => gsc_gscGetOverviewCore(deps, ...args));
-
-export const gscGetPageDetailsCore: (
- ...args: Tail<Parameters<typeof gsc_gscGetPageDetailsCore>>
-) => ReturnType<typeof gsc_gscGetPageDetailsCore> = (...args) =>
- compatServiceDeps().then((deps) => gsc_gscGetPageDetailsCore(deps, ...args));
-
-export const gscGetQueryDetailsCore: (
- ...args: Tail<Parameters<typeof gsc_gscGetQueryDetailsCore>>
-) => ReturnType<typeof gsc_gscGetQueryDetailsCore> = (...args) =>
- compatServiceDeps().then((deps) => gsc_gscGetQueryDetailsCore(deps, ...args));
-
-export const gscGetQueryOpportunitiesCore: (
- ...args: Tail<Parameters<typeof gsc_gscGetQueryOpportunitiesCore>>
-) => ReturnType<typeof gsc_gscGetQueryOpportunitiesCore> = (...args) =>
- compatServiceDeps().then((deps) => gsc_gscGetQueryOpportunitiesCore(deps, ...args));
-
-export const gscGetTopPagesCore: (
- ...args: Tail<Parameters<typeof gsc_gscGetTopPagesCore>>
-) => ReturnType<typeof gsc_gscGetTopPagesCore> = (...args) =>
- compatServiceDeps().then((deps) => gsc_gscGetTopPagesCore(deps, ...args));
-
-export const gscGetTopQueriesCore: (
- ...args: Tail<Parameters<typeof gsc_gscGetTopQueriesCore>>
-) => ReturnType<typeof gsc_gscGetTopQueriesCore> = (...args) =>
- compatServiceDeps().then((deps) => gsc_gscGetTopQueriesCore(deps, ...args));
-
-export const listGscConnectionsForSync: (
- ...args: Tail<Parameters<typeof gsc_listGscConnectionsForSync>>
-) => ReturnType<typeof gsc_listGscConnectionsForSync> = (...args) =>
- compatServiceDeps().then((deps) => gsc_listGscConnectionsForSync(deps, ...args));
-
-export const listGscSites: (
- ...args: Tail<Parameters<typeof gsc_listGscSites>>
-) => ReturnType<typeof gsc_listGscSites> = (...args) =>
- compatServiceDeps().then((deps) => gsc_listGscSites(deps, ...args));
-
-export const resolveGscDateRange: (
- ...args: Tail<Parameters<typeof gsc_resolveGscDateRange>>
-) => ReturnType<typeof gsc_resolveGscDateRange> = (...args) =>
- compatServiceDeps().then((deps) => gsc_resolveGscDateRange(deps, ...args));
-
-export const runGscProjectBackfill: (
- ...args: Tail<Parameters<typeof gsc_runGscProjectBackfill>>
-) => ReturnType<typeof gsc_runGscProjectBackfill> = (...args) =>
- compatServiceDeps().then((deps) => gsc_runGscProjectBackfill(deps, ...args));
-
-export const runGscProjectSync: (
- ...args: Tail<Parameters<typeof gsc_runGscProjectSync>>
-) => ReturnType<typeof gsc_runGscProjectSync> = (...args) =>
- compatServiceDeps().then((deps) => gsc_runGscProjectSync(deps, ...args));
-
-export const selectGscSite: (
- ...args: Tail<Parameters<typeof gsc_selectGscSite>>
-) => ReturnType<typeof gsc_selectGscSite> = (...args) =>
- compatServiceDeps().then((deps) => gsc_selectGscSite(deps, ...args));
-
-export const syncGscData: (
- ...args: Tail<Parameters<typeof gsc_syncGscData>>
-) => ReturnType<typeof gsc_syncGscData> = (...args) =>
- compatServiceDeps().then((deps) => gsc_syncGscData(deps, ...args));
-
-// --- organization ----------------------------------------------------------------
-
-export const cancelOrganizationDeletion: (
- ...args: Tail<Parameters<typeof organization_cancelOrganizationDeletion>>
-) => ReturnType<typeof organization_cancelOrganizationDeletion> = (...args) =>
- compatServiceDeps().then((deps) => organization_cancelOrganizationDeletion(deps, ...args));
-
-export const connectUserToOrganization: (
- ...args: Tail<Parameters<typeof organization_connectUserToOrganization>>
-) => ReturnType<typeof organization_connectUserToOrganization> = (...args) =>
- compatServiceDeps().then((deps) => organization_connectUserToOrganization(deps, ...args));
-
-export const deleteFromClickhouse: (
- ...args: Tail<Parameters<typeof organization_deleteFromClickhouse>>
-) => ReturnType<typeof organization_deleteFromClickhouse> = (...args) =>
- compatServiceDeps().then((deps) => organization_deleteFromClickhouse(deps, ...args));
-
-export const deleteOrganization: (
- ...args: Tail<Parameters<typeof organization_deleteOrganization>>
-) => ReturnType<typeof organization_deleteOrganization> = (...args) =>
- compatServiceDeps().then((deps) => organization_deleteOrganization(deps, ...args));
-
-export const deleteProjects: (
- ...args: Tail<Parameters<typeof organization_deleteProjects>>
-) => ReturnType<typeof organization_deleteProjects> = (...args) =>
- compatServiceDeps().then((deps) => organization_deleteProjects(deps, ...args));
-
-export const getInviteById: (
- ...args: Tail<Parameters<typeof organization_getInviteById>>
-) => ReturnType<typeof organization_getInviteById> = (...args) =>
- compatServiceDeps().then((deps) => organization_getInviteById(deps, ...args));
-
-export const getInviteOrThrow: (
- ...args: Tail<Parameters<typeof organization_getInviteOrThrow>>
-) => ReturnType<typeof organization_getInviteOrThrow> = (...args) =>
- compatServiceDeps().then((deps) => organization_getInviteOrThrow(deps, ...args));
-
-export const getInvites: (
- ...args: Tail<Parameters<typeof organization_getInvites>>
-) => ReturnType<typeof organization_getInvites> = (...args) =>
- compatServiceDeps().then((deps) => organization_getInvites(deps, ...args));
-
-export const getMember: (
- ...args: Tail<Parameters<typeof organization_getMember>>
-) => ReturnType<typeof organization_getMember> = (...args) =>
- compatServiceDeps().then((deps) => organization_getMember(deps, ...args));
-
-export const getMembers: (
- ...args: Tail<Parameters<typeof organization_getMembers>>
-) => ReturnType<typeof organization_getMembers> = (...args) =>
- compatServiceDeps().then((deps) => organization_getMembers(deps, ...args));
-
-export const getOrganizationBillingEventsCount: (
- ...args: Tail<Parameters<typeof organization_getOrganizationBillingEventsCount>>
-) => ReturnType<typeof organization_getOrganizationBillingEventsCount> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizationBillingEventsCount(deps, ...args));
-
-export const getOrganizationById: (
- ...args: Tail<Parameters<typeof organization_getOrganizationById>>
-) => ReturnType<typeof organization_getOrganizationById> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizationById(deps, ...args));
-
-export const getOrganizationByProjectId: (
- ...args: Tail<Parameters<typeof organization_getOrganizationByProjectId>>
-) => ReturnType<typeof organization_getOrganizationByProjectId> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizationByProjectId(deps, ...args));
-
-export const getOrganizationEventsCount: (
- ...args: Tail<Parameters<typeof organization_getOrganizationEventsCount>>
-) => ReturnType<typeof organization_getOrganizationEventsCount> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizationEventsCount(deps, ...args));
-
-export const getOrganizationEventsCountSince: (
- ...args: Tail<Parameters<typeof organization_getOrganizationEventsCountSince>>
-) => ReturnType<typeof organization_getOrganizationEventsCountSince> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizationEventsCountSince(deps, ...args));
-
-export const getOrganizationSubscriptionChartEndDate: (
- ...args: Tail<Parameters<typeof organization_getOrganizationSubscriptionChartEndDate>>
-) => ReturnType<typeof organization_getOrganizationSubscriptionChartEndDate> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizationSubscriptionChartEndDate(deps, ...args));
-
-export const getOrganizations: (
- ...args: Tail<Parameters<typeof organization_getOrganizations>>
-) => ReturnType<typeof organization_getOrganizations> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizations(deps, ...args));
-
-export const getSettingsForOrganization: (
- ...args: Tail<Parameters<typeof organization_getSettingsForOrganization>>
-) => ReturnType<typeof organization_getSettingsForOrganization> = (...args) =>
- compatServiceDeps().then((deps) => organization_getSettingsForOrganization(deps, ...args));
-
-export const getSettingsForProject: (
- ...args: Tail<Parameters<typeof organization_getSettingsForProject>>
-) => ReturnType<typeof organization_getSettingsForProject> = (...args) =>
- compatServiceDeps().then((deps) => organization_getSettingsForProject(deps, ...args));
-
-export const inviteUserToOrganization: (
- ...args: Tail<Parameters<typeof organization_inviteUserToOrganization>>
-) => ReturnType<typeof organization_inviteUserToOrganization> = (...args) =>
- compatServiceDeps().then((deps) => organization_inviteUserToOrganization(deps, ...args));
-
-export const removeOrganizationMember: (
- ...args: Tail<Parameters<typeof organization_removeOrganizationMember>>
-) => ReturnType<typeof organization_removeOrganizationMember> = (...args) =>
- compatServiceDeps().then((deps) => organization_removeOrganizationMember(deps, ...args));
-
-export const revokeInvite: (
- ...args: Tail<Parameters<typeof organization_revokeInvite>>
-) => ReturnType<typeof organization_revokeInvite> = (...args) =>
- compatServiceDeps().then((deps) => organization_revokeInvite(deps, ...args));
-
-export const runDeleteCron: (
- ...args: Tail<Parameters<typeof organization_runDeleteCron>>
-) => ReturnType<typeof organization_runDeleteCron> = (...args) =>
- compatServiceDeps().then((deps) => organization_runDeleteCron(deps, ...args));
-
-export const scheduleOrganizationDeletion: (
- ...args: Tail<Parameters<typeof organization_scheduleOrganizationDeletion>>
-) => ReturnType<typeof organization_scheduleOrganizationDeletion> = (...args) =>
- compatServiceDeps().then((deps) => organization_scheduleOrganizationDeletion(deps, ...args));
-
-export const updateOrganization: (
- ...args: Tail<Parameters<typeof organization_updateOrganization>>
-) => ReturnType<typeof organization_updateOrganization> = (...args) =>
- compatServiceDeps().then((deps) => organization_updateOrganization(deps, ...args));
-
-export const updateOrganizationMemberAccess: (
- ...args: Tail<Parameters<typeof organization_updateOrganizationMemberAccess>>
-) => ReturnType<typeof organization_updateOrganizationMemberAccess> = (...args) =>
- compatServiceDeps().then((deps) => organization_updateOrganizationMemberAccess(deps, ...args));
-
-// --- organization (billing serie) ------------------------------------------------
-
-export const getOrganizationBillingEventsCountSerie: (
- ...args: Tail<Parameters<typeof organization_getOrganizationBillingEventsCountSerie>>
-) => ReturnType<typeof organization_getOrganizationBillingEventsCountSerie> = (...args) =>
- compatServiceDeps().then((deps) => organization_getOrganizationBillingEventsCountSerie(deps, ...args));
diff --git a/packages/core/test/buffer-fixtures.ts b/packages/core/test/buffer-fixtures.ts
index 8cdec5510..d3816affa 100644
--- a/packages/core/test/buffer-fixtures.ts
+++ b/packages/core/test/buffer-fixtures.ts
@@ -21,12 +21,22 @@ const silentLogger: Logger = {
*
* M10-009: `BufferDeps.ch` is the boot scope's ClickHouse client, so a suite
* that exercises a flush hands in its own fake here rather than mocking
- * `@openpanel/db`'s module. `stubBufferDeps` leaves it unset — a buffer that
- * reaches ClickHouse without one is a bug this stub should surface, not hide.
+ * `@openpanel/db`'s module. `stubBufferDeps` hands in a client that throws on
+ * first touch — a buffer that reaches ClickHouse without one is a bug this
+ * stub should surface, not hide.
*/
+const throwingClickHouse = new Proxy({} as BufferDeps['ch'], {
+ get() {
+ throw new Error(
+ 'stubBufferDeps has no ClickHouse client — use bufferDepsWithCh(fake)'
+ );
+ },
+});
+
export const stubBufferDeps: BufferDeps = {
createLogger: () => silentLogger,
isCronPaused: () => Promise.resolve(false),
+ ch: throwingClickHouse,
};
/** `stubBufferDeps` plus a fake ClickHouse client for the flush path. */
diff --git a/packages/core/test/request-id-end-to-end.test.ts b/packages/core/test/request-id-end-to-end.test.ts
index 6fb01742e..12aa55e9e 100644
--- a/packages/core/test/request-id-end-to-end.test.ts
+++ b/packages/core/test/request-id-end-to-end.test.ts
@@ -653,6 +653,45 @@ test("the envelope's requestId reaches the handler's logger, its buffer write an
]);
});
+// M15-004: the notification dispatch used to reach Postgres and the
+// `notification` producer through v1-compat's BOOT scope, so every job it
+// enqueued was stamped `v1-compat` no matter which message triggered it. It
+// takes the caller's scope now, and this is the hop that proves it: the
+// binding enqueues exactly what `triggerNotification` enqueues, off the deps
+// it was handed, and the envelope must carry the message's own id.
+test("a converted read path's own enqueue carries the message's requestId", async () => {
+ const handleEvent = createIncomingEventHandler(ingestHarness.deps, {
+ ...ingestBindings,
+ checkNotificationRulesForEvent: (deps) =>
+ deps.queues.notification.sendNotification.add({
+ notification: {
+ projectId: INGEST_PROJECT_ID,
+ title: 'rule matched',
+ message: 'screen_view',
+ },
+ }),
+ });
+
+ await handleEvent(ingestEnvelope(INGEST_REQUEST_ID), {
+ partition: 0,
+ offset: '1',
+ });
+
+ // One per event the message produced (session_start + screen_view); both
+ // enqueued off the same message scope.
+ const dispatched = ingestHarness.recorded
+ .filter(({ queue }) => queue === 'notification')
+ .map(({ job, meta }) => ({ job, requestId: meta.requestId }));
+
+ expect(dispatched).toHaveLength(2);
+ expect(dispatched).toEqual(
+ dispatched.map(() => ({
+ job: 'sendNotification',
+ requestId: INGEST_REQUEST_ID,
+ }))
+ );
+});
+
test('a second message is scoped to its own id, and an envelope without one still gets scoped', async () => {
const handleEvent = createIncomingEventHandler(
ingestHarness.deps,