Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

5.5 KB
Raw Blame
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts"
// @generated from file usage_ingestion/v1/service.proto (package usage_ingestion.v1, syntax proto3)
import type { Message } from '@bufbuild/protobuf'
import type { GenFile, GenMessage, GenService } from '@bufbuild/protobuf/codegenv2'
import { fileDesc, messageDesc, serviceDesc } from '@bufbuild/protobuf/codegenv2'

/**
 * Describes the file usage_ingestion/v1/service.proto.
 */
export const file_usage_ingestion_v1_service: GenFile =
    /*@__PURE__*/
    fileDesc(
        'CiB1c2FnZV9pbmdlc3Rpb24vdjEvc2VydmljZS5wcm90bxISdXNhZ2VfaW5nZXN0aW9uLnYxIpYBChJCaWxsaW5nVXNhZ2VSZWNvcmQSDwoHdGVhbV9pZBgBIAEoAxIUCgx0aW1lc3RhbXBfbXMYAiABKAMSEwoLcHJvZHVjZXJfaWQYAyABKAkSEQoJdXNhZ2Vfa2V5GAQgASgJEhEKCXJlY29yZF9pZBgFIAEoCRIQCghxdWFudGl0eRgGIAEoAxIMCgR1bml0GAcgASgJIlQKGUluZ2VzdEJpbGxpbmdVc2FnZVJlcXVlc3QSNwoHcmVjb3JkcxgBIAMoCzImLnVzYWdlX2luZ2VzdGlvbi52MS5CaWxsaW5nVXNhZ2VSZWNvcmQiOQoaSW5nZXN0QmlsbGluZ1VzYWdlUmVzcG9uc2USGwoTYWNjZXB0ZWRfcmVjb3JkX2lkcxgBIAMoCTKFAQoOVXNhZ2VJbmdlc3Rpb24ScwoSSW5nZXN0QmlsbGluZ1VzYWdlEi0udXNhZ2VfaW5nZXN0aW9uLnYxLkluZ2VzdEJpbGxpbmdVc2FnZVJlcXVlc3QaLi51c2FnZV9pbmdlc3Rpb24udjEuSW5nZXN0QmlsbGluZ1VzYWdlUmVzcG9uc2ViBnByb3RvMw'
    )

/**
 * Fields 1-5 are the record's identity, in the order the storage sorting key uses them:
 * (team_id, toDate(timestamp), producer_id, usage_key, record_id). A retry reuses all five
 * and collapses to one row. Correcting a quantity means re-sending the same identity, and
 * the last send wins.
 *
 * @generated from message usage_ingestion.v1.BillingUsageRecord
 */
export type BillingUsageRecord = Message<'usage_ingestion.v1.BillingUsageRecord'> & {
    /**
     * The service owns organization attribution: it resolves the organization from team_id,
     * so producers cannot supply one.
     *
     * @generated from field: int64 team_id = 1;
     */
    teamId: bigint

    /**
     * Stamp this from the producer's own clock when it emits, never from a customer payload.
     * It is part of the identity, so a value a customer controls would let them decide
     * whether their own records deduplicate.
     *
     * @generated from field: int64 timestamp_ms = 2;
     */
    timestampMs: bigint

    /**
     * @generated from field: string producer_id = 3;
     */
    producerId: string

    /**
     * @generated from field: string usage_key = 4;
     */
    usageKey: string

    /**
     * @generated from field: string record_id = 5;
     */
    recordId: string

    /**
     * @generated from field: int64 quantity = 6;
     */
    quantity: bigint

    /**
     * @generated from field: string unit = 7;
     */
    unit: string
}

/**
 * Describes the message usage_ingestion.v1.BillingUsageRecord.
 * Use `create(BillingUsageRecordSchema)` to create a new message.
 */
export const BillingUsageRecordSchema: GenMessage<BillingUsageRecord> =
    /*@__PURE__*/
    messageDesc(file_usage_ingestion_v1_service, 0)

/**
 * @generated from message usage_ingestion.v1.IngestBillingUsageRequest
 */
export type IngestBillingUsageRequest = Message<'usage_ingestion.v1.IngestBillingUsageRequest'> & {
    /**
     * @generated from field: repeated usage_ingestion.v1.BillingUsageRecord records = 1;
     */
    records: BillingUsageRecord[]
}

/**
 * Describes the message usage_ingestion.v1.IngestBillingUsageRequest.
 * Use `create(IngestBillingUsageRequestSchema)` to create a new message.
 */
export const IngestBillingUsageRequestSchema: GenMessage<IngestBillingUsageRequest> =
    /*@__PURE__*/
    messageDesc(file_usage_ingestion_v1_service, 1)

/**
 * @generated from message usage_ingestion.v1.IngestBillingUsageResponse
 */
export type IngestBillingUsageResponse = Message<'usage_ingestion.v1.IngestBillingUsageResponse'> & {
    /**
     * A subset of the records sent: the service skips a record it can never accept, such as one
     * whose team has no organization, so that one team cannot discard the whole batch. Compare
     * this against what you sent to learn what was dropped, because a dropped record is reported
     * here rather than as an error. The RPC waits for Kafka delivery confirmation, so callers must
     * use it off their request-critical path. A retry after an unavailable response is safe
     * because record_id is the deduplication identity, including when Kafka delivered only part
     * of the batch.
     *
     * @generated from field: repeated string accepted_record_ids = 1;
     */
    acceptedRecordIds: string[]
}

/**
 * Describes the message usage_ingestion.v1.IngestBillingUsageResponse.
 * Use `create(IngestBillingUsageResponseSchema)` to create a new message.
 */
export const IngestBillingUsageResponseSchema: GenMessage<IngestBillingUsageResponse> =
    /*@__PURE__*/
    messageDesc(file_usage_ingestion_v1_service, 2)

/**
 * UsageIngestion accepts usage records for durable analytics. Producers must reuse
 * record_id when retrying a record. The service preserves the producer's timestamp and
 * assigns insertion time when it publishes.
 *
 * IngestBillingUsage carries tenant-billable usage: exact, idempotent, retained
 * indefinitely. Cost and resource metering is a separate RPC and table.
 *
 * @generated from service usage_ingestion.v1.UsageIngestion
 */
export const UsageIngestion: GenService<{
    /**
     * @generated from rpc usage_ingestion.v1.UsageIngestion.IngestBillingUsage
     */
    ingestBillingUsage: {
        methodKind: 'unary'
        input: typeof IngestBillingUsageRequestSchema
        output: typeof IngestBillingUsageResponseSchema
    }
}> = /*@__PURE__*/ serviceDesc(file_usage_ingestion_v1_service, 0)