Files
zooqueen 252e1cb076 Generated clients call the API where it is mounted
`insights/mount.py` is explicit: `/v1/` is the mount and `/api/` is the older
spelling, kept on the wire for released CLI builds and personal-API-key
holders and rewritten once at the edge by `ApiRewriteMiddleware`. Our own
frontend was still on the older spelling: the orval clients were generated
two days before the mount moved and the move did not regenerate them, so 70
files and 2323 paths said `/api/`.

That is not only a spelling. `prepareUrl` in `lib/api.ts` rewrites `/v1/*` to
the selected region's host in OAuth mode and nothing else, because that is
what the cloud CORS allowlist covers — so every generated call quietly stayed
same-origin, and `getExportsContentRetrieveUrl` builds an `<img src>` that
never reaches `lib/api.ts` at all.

The clients are regenerated from a spec that needs postgres, the datastore and
Django, so this is the path strings only, which is the whole of what the mount
move changes in them: orval copies paths verbatim from the spec, and the spec
takes them from the URLconf. Doc comments carried the same stale prefix and
move with them; their Python docstrings already say `/v1/`. The two frozen
OAuth client-metadata paths are identifiers rather than API surface and appear
in none of these files.

The Slack task prompt told the agent to POST to
`$INSIGHTS_API_URL/api/projects/...`, which is a live request path, not prose.
2026-08-24 23:13:08 -07:00

133 lines
5.0 KiB
TypeScript
Generated

import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
/**
* Auto-generated from the Django backend OpenAPI schema.
* To modify these types, update the Django serializers or views, then run:
* insightscli build:openapi
* Questions or issues? #team-devex on Slack
*
* Insights API - generated
* OpenAPI spec version: 1.0.0
*/
import type {
IdentityMatchingLinksListParams,
IdentityMatchingLinksResponseApi,
IdentityMatchingRunsResponseApi,
ProductPushCampaignActiveRetrieveParams,
ProductPushCampaignApi,
SdkHealthReportApi,
SdkHealthReportRetrieveParams,
} from './api.schemas'
export const getProductPushCampaignActiveRetrieveUrl = (
organizationId: string,
params?: ProductPushCampaignActiveRetrieveParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/v1/organizations/${organizationId}/product_push_campaign/active/?${stringifiedParams}`
: `/v1/organizations/${organizationId}/product_push_campaign/active/`
}
/**
* The organization's currently active product push campaign. 204 when no campaign is active, or when the given project already uses the campaign's product.
*/
export const productPushCampaignActiveRetrieve = async (
organizationId: string,
params?: ProductPushCampaignActiveRetrieveParams,
options?: RequestInit
): Promise<ProductPushCampaignApi | void> => {
return apiMutator<ProductPushCampaignApi | void>(getProductPushCampaignActiveRetrieveUrl(organizationId, params), {
...options,
method: 'GET',
})
}
export const getIdentityMatchingLinksListUrl = (projectId: string, params?: IdentityMatchingLinksListParams) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/v1/projects/${projectId}/identity_matching_links/?${stringifiedParams}`
: `/v1/projects/${projectId}/identity_matching_links/`
}
/**
* Scored links between anonymous distinct IDs and identified persons, with the evidence behind each link. Produced by the identity matching Dagster job; empty until that job has run for this project.
* @summary List identity matching links
*/
export const identityMatchingLinksList = async (
projectId: string,
params?: IdentityMatchingLinksListParams,
options?: RequestInit
): Promise<IdentityMatchingLinksResponseApi> => {
return apiMutator<IdentityMatchingLinksResponseApi>(getIdentityMatchingLinksListUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getIdentityMatchingLinksRunsRetrieveUrl = (projectId: string) => {
return `/v1/projects/${projectId}/identity_matching_links/runs/`
}
/**
* Recent identity matching runs for this project with link counts, tier breakdowns, and paid attribution stats per scoring model, most recent first.
* @summary List identity matching runs
*/
export const identityMatchingLinksRunsRetrieve = async (
projectId: string,
options?: RequestInit
): Promise<IdentityMatchingRunsResponseApi> => {
return apiMutator<IdentityMatchingRunsResponseApi>(getIdentityMatchingLinksRunsRetrieveUrl(projectId), {
...options,
method: 'GET',
})
}
export const getSdkHealthReportRetrieveUrl = (projectId: string, params?: SdkHealthReportRetrieveParams) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/v1/projects/${projectId}/sdk_health/report/?${stringifiedParams}`
: `/v1/projects/${projectId}/sdk_health/report/`
}
/**
* Returns a pre-digested health assessment of the Insights SDKs the project is using. Covers which SDKs are current vs outdated (smart-semver rules with grace periods and traffic-percentage thresholds), per-version breakdown, and a human-readable reason for each assessment. Use this to diagnose SDK version issues, surface upgrade recommendations, or check overall SDK health.
* @summary Get SDK health report for a project
*/
export const sdkHealthReportRetrieve = async (
projectId: string,
params?: SdkHealthReportRetrieveParams,
options?: RequestInit
): Promise<SdkHealthReportApi> => {
return apiMutator<SdkHealthReportApi>(getSdkHealthReportRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}