Add usage-limit banner analytics plumbing

This commit is contained in:
James Chu
2026-04-27 11:45:37 -04:00
parent 42fe140d1a
commit 094106eda9
14 changed files with 82 additions and 45 deletions
+11 -4
View File
@@ -4094,13 +4094,13 @@
"action": {
"$ref": "#/definitions/TrackUsageLimitBannerAction"
},
"creditType": {
"$ref": "#/definitions/AddCreditsNudgeCreditType"
"bannerType": {
"$ref": "#/definitions/UsageLimitBannerType"
}
},
"required": [
"action",
"creditType"
"bannerType"
],
"type": "object"
},
@@ -4287,6 +4287,13 @@
],
"type": "object"
},
"UsageLimitBannerType": {
"enum": [
"workspace_member_credits_depleted",
"workspace_member_usage_limit_reached"
],
"type": "string"
},
"UserInput": {
"oneOf": [
{
@@ -6170,4 +6177,4 @@
}
],
"title": "ClientRequest"
}
}
@@ -16930,13 +16930,13 @@
"action": {
"$ref": "#/definitions/v2/TrackUsageLimitBannerAction"
},
"creditType": {
"$ref": "#/definitions/v2/AddCreditsNudgeCreditType"
"bannerType": {
"$ref": "#/definitions/v2/UsageLimitBannerType"
}
},
"required": [
"action",
"creditType"
"bannerType"
],
"title": "TrackUsageLimitBannerParams",
"type": "object"
@@ -17370,6 +17370,13 @@
"title": "TurnSteerResponse",
"type": "object"
},
"UsageLimitBannerType": {
"enum": [
"workspace_member_credits_depleted",
"workspace_member_usage_limit_reached"
],
"type": "string"
},
"UserInput": {
"oneOf": [
{
@@ -17805,4 +17812,4 @@
},
"title": "CodexAppServerProtocol",
"type": "object"
}
}
@@ -14816,13 +14816,13 @@
"action": {
"$ref": "#/definitions/TrackUsageLimitBannerAction"
},
"creditType": {
"$ref": "#/definitions/AddCreditsNudgeCreditType"
"bannerType": {
"$ref": "#/definitions/UsageLimitBannerType"
}
},
"required": [
"action",
"creditType"
"bannerType"
],
"title": "TrackUsageLimitBannerParams",
"type": "object"
@@ -15256,6 +15256,13 @@
"title": "TurnSteerResponse",
"type": "object"
},
"UsageLimitBannerType": {
"enum": [
"workspace_member_credits_depleted",
"workspace_member_usage_limit_reached"
],
"type": "string"
},
"UserInput": {
"oneOf": [
{
@@ -15690,4 +15697,4 @@
},
"title": "CodexAppServerProtocolV2",
"type": "object"
}
}
@@ -922,4 +922,4 @@
],
"title": "RawResponseItemCompletedNotification",
"type": "object"
}
}
@@ -1452,4 +1452,4 @@
],
"title": "ThreadResumeParams",
"type": "object"
}
}
@@ -1,32 +1,32 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AddCreditsNudgeCreditType": {
"enum": [
"credits",
"usage_limit"
],
"type": "string"
},
"TrackUsageLimitBannerAction": {
"enum": [
"shown",
"cta_clicked"
],
"type": "string"
},
"UsageLimitBannerType": {
"enum": [
"workspace_member_credits_depleted",
"workspace_member_usage_limit_reached"
],
"type": "string"
}
},
"properties": {
"action": {
"$ref": "#/definitions/TrackUsageLimitBannerAction"
},
"creditType": {
"$ref": "#/definitions/AddCreditsNudgeCreditType"
"bannerType": {
"$ref": "#/definitions/UsageLimitBannerType"
}
},
"required": [
"action",
"creditType"
"bannerType"
],
"title": "TrackUsageLimitBannerParams",
"type": "object"
@@ -1,7 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AddCreditsNudgeCreditType } from "./AddCreditsNudgeCreditType";
import type { TrackUsageLimitBannerAction } from "./TrackUsageLimitBannerAction";
import type { UsageLimitBannerType } from "./UsageLimitBannerType";
export type TrackUsageLimitBannerParams = { action: TrackUsageLimitBannerAction, creditType: AddCreditsNudgeCreditType, };
export type TrackUsageLimitBannerParams = { action: TrackUsageLimitBannerAction, bannerType: UsageLimitBannerType, };
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type UsageLimitBannerType = "workspace_member_credits_depleted" | "workspace_member_usage_limit_reached";
@@ -405,6 +405,7 @@ export type { TurnStartedNotification } from "./TurnStartedNotification";
export type { TurnStatus } from "./TurnStatus";
export type { TurnSteerParams } from "./TurnSteerParams";
export type { TurnSteerResponse } from "./TurnSteerResponse";
export type { UsageLimitBannerType } from "./UsageLimitBannerType";
export type { UserInput } from "./UserInput";
export type { WarningNotification } from "./WarningNotification";
export type { WebSearchAction } from "./WebSearchAction";
@@ -1473,7 +1473,7 @@ mod tests {
request_id: RequestId::Integer(2),
params: v2::TrackUsageLimitBannerParams {
action: v2::TrackUsageLimitBannerAction::CtaClicked,
credit_type: v2::AddCreditsNudgeCreditType::UsageLimit,
banner_type: v2::UsageLimitBannerType::WorkspaceMemberUsageLimitReached,
},
};
assert_eq!(request.id(), &RequestId::Integer(2));
@@ -1484,7 +1484,7 @@ mod tests {
"id": 2,
"params": {
"action": "cta_clicked",
"creditType": "usage_limit",
"bannerType": "workspace_member_usage_limit_reached",
},
}),
serde_json::to_value(&request)?,
@@ -2255,7 +2255,7 @@ pub struct SendAddCreditsNudgeEmailParams {
#[ts(export_to = "v2/")]
pub struct TrackUsageLimitBannerParams {
pub action: TrackUsageLimitBannerAction,
pub credit_type: AddCreditsNudgeCreditType,
pub banner_type: UsageLimitBannerType,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
@@ -2266,6 +2266,14 @@ pub enum TrackUsageLimitBannerAction {
CtaClicked,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
#[ts(export_to = "v2/", rename_all = "snake_case")]
pub enum UsageLimitBannerType {
WorkspaceMemberCreditsDepleted,
WorkspaceMemberUsageLimitReached,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
#[ts(export_to = "v2/", rename_all = "snake_case")]