Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions apps/api/src/routes/internal/query-engine.http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ import {
ProductEventsFunnelResponse,
ProductEventsFunnelBreakdownResponse,
ProductEventNamesResponse,
ProductEventsForTraceResponse,
ProductEventTraceSamplesResponse,
CommitSha,
FingerprintHash,
ServiceName,
Expand Down Expand Up @@ -2066,6 +2068,45 @@ export const HttpQueryEngineLive = HttpApiBuilder.group(MapleInternalApi, "query
})
}),
)
// Both directions of the trace ↔ product-event link.
.handle("productEventsForTrace", ({ payload }) =>
Effect.gen(function* () {
const tenant = yield* CurrentTenant.Context
const rows = yield* runQuery(Queries.productEventsForTrace, tenant, payload)
return new ProductEventsForTraceResponse({
data: rows.map((row) => ({
timestamp: String(row.timestamp),
eventName: String(row.eventName),
spanId: String(row.spanId),
serviceName: String(row.serviceName),
userId: String(row.userId),
groupId: String(row.groupId),
visitorId: String(row.visitorId),
sessionId: String(row.sessionId),
// Already decoded as Record<string, string> by the derived row
// schema — a non-string value fails that decode long before it
// reaches here, so there is nothing left to coerce.
attributes: row.attributes,
})),
})
}),
)
.handle("productEventTraceSamples", ({ payload }) =>
Effect.gen(function* () {
const tenant = yield* CurrentTenant.Context
const rows = yield* runQuery(Queries.productEventTraceSamples, tenant, payload)
return new ProductEventTraceSamplesResponse({
data: rows.map((row) => ({
traceId: String(row.traceId),
spanId: String(row.spanId),
timestamp: String(row.timestamp),
serviceName: String(row.serviceName),
userId: String(row.userId),
visitorId: String(row.visitorId),
})),
})
}),
)
.handle("executeRawSql", ({ payload }) =>
Effect.gen(function* () {
const tenant = yield* CurrentTenant.Context
Expand Down
13 changes: 13 additions & 0 deletions apps/cli/src/server/local-schema-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,17 @@ export const LOCAL_SCHEMA_HISTORY: ReadonlyArray<LocalSchemaHistoryEntry> = Obje
manifestDigest: "faf78f67abd5901351ce6632cee59f22fadb3c1f7eb9b195dc2f9702d4c9c9bd",
projectRevision: "ed74788ef292834069e0ea6ee3b22d68fc604fb66cb54d2d551db67ce8d20b3a",
}),
Object.freeze({
// TODO(v15): what changed, whether any part is rewritten or any row
// moves, and what this edge does NOT backfill.
//
// projectRevision is carried forward deliberately — it is a hardcoded
// constant that no longer tracks the generator's header, and the identity
// this gate compares is the fingerprint/digest pair.
version: 15,
fingerprint: "9c8d377e9709d823",
digest: "9c8d377e9709d82319807cd7fe7510a25f5385e91a2b08f2e4f93dbbb37ac510",
manifestDigest: "16620c2585833543b890fc606882fd679649cc13ffac7600c5611dfec5fb4ebd",
projectRevision: "ed74788ef292834069e0ea6ee3b22d68fc604fb66cb54d2d551db67ce8d20b3a",
}),
] as const)
2 changes: 1 addition & 1 deletion apps/cli/src/server/local-schema-version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Increment this value for every structural change to the generated local
// schema. The compatibility manifest and migration registry must be updated in
// the same change before a new value can ship.
export const LOCAL_SCHEMA_VERSION = 14 as const
export const LOCAL_SCHEMA_VERSION = 15 as const
2 changes: 2 additions & 0 deletions apps/cli/src/server/local-store-migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { v10ToV11ProductEventsModule } from "./local-store-migrations/v10-to-v11
import { v11ToV12ServiceMapEdgeQuantilesModule } from "./local-store-migrations/v11-to-v12-service-map-edge-quantiles"
import { v12ToV13ServiceOperationsDiscriminatorsModule } from "./local-store-migrations/v12-to-v13-service-operations-discriminators"
import { v13ToV14AiTraceIndexModule } from "./local-store-migrations/v13-to-v14-ai-trace-index"
import { v14ToV15ProductEventsFromTracesModule } from "./local-store-migrations/v14-to-v15-product-events-from-traces"
import type {
AnyLocalStoreMigrationModule,
LocalStoreMigration,
Expand Down Expand Up @@ -121,6 +122,7 @@ export const localStoreMigrations: ReadonlyArray<AnyLocalStoreMigrationModule> =
v11ToV12ServiceMapEdgeQuantilesModule,
v12ToV13ServiceOperationsDiscriminatorsModule,
v13ToV14AiTraceIndexModule,
v14ToV15ProductEventsFromTracesModule,
]

export const validateMigrationRegistry = (
Expand Down
Loading