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

745 lines
28 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 {
MessageAssetApi,
PaginatedAsyncDeletionStatusListApi,
PaginatedPersonRecordListApi,
PatchedPersonRecordApi,
PersonBulkDeleteRequestApi,
PersonBulkDeleteResponseApi,
PersonDeletePropertyRequestApi,
PersonPropertiesAtTimeResponseApi,
PersonRecordApi,
PersonSplitRequestApi,
PersonSplitResponseApi,
PersonUpdatePropertyRequestApi,
PersonsActivityRetrieveParams,
PersonsAllActivityRetrieveParams,
PersonsBatchByDistinctIdsCreateParams,
PersonsBatchByUuidsCreateParams,
PersonsBulkDeleteCreateParams,
PersonsCohortsRetrieveParams,
PersonsDeletePropertyCreateParams,
PersonsDeletionStatusListParams,
PersonsEmailsListParams,
PersonsListParams,
PersonsPartialUpdateParams,
PersonsPropertiesAtTimeRetrieveParams,
PersonsPropertiesTimelineRetrieveParams,
PersonsPushNotificationsListParams,
PersonsResetPersonDistinctIdCreateParams,
PersonsRetrieveParams,
PersonsSplitCreateParams,
PersonsUpdateParams,
PersonsUpdatePropertyCreateParams,
PersonsValuesRetrieveParams,
} from './api.schemas'
// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B
type WritableKeys<T> = {
[P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P>
}[keyof T]
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never
type Writable<T> = Pick<T, WritableKeys<T>>
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
? {
[P in keyof Writable<T>]: T[P] extends object ? NonReadonly<NonNullable<T[P]>> : T[P]
}
: DistributeReadOnlyOverUnions<T>
export const getPersonsListUrl = (projectId: string, params?: PersonsListParams) => {
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}/persons/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsList = async (
projectId: string,
params?: PersonsListParams,
options?: RequestInit
): Promise<PaginatedPersonRecordListApi> => {
return apiMutator<PaginatedPersonRecordListApi>(getPersonsListUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getPersonsRetrieveUrl = (projectId: string, id: string, params?: PersonsRetrieveParams) => {
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}/persons/${id}/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsRetrieve = async (
projectId: string,
id: string,
params?: PersonsRetrieveParams,
options?: RequestInit
): Promise<PersonRecordApi> => {
return apiMutator<PersonRecordApi>(getPersonsRetrieveUrl(projectId, id, params), {
...options,
method: 'GET',
})
}
export const getPersonsUpdateUrl = (projectId: string, id: string, params?: PersonsUpdateParams) => {
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}/persons/${id}/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/`
}
/**
* Only for setting properties on the person. "properties" from the request data will be updated via a "$set" event.
* This means that only the properties listed will be updated, but other properties won't be removed nor updated.
* If you would like to remove a property use the `delete_property` endpoint.
*/
export const personsUpdate = async (
projectId: string,
id: string,
personRecordApi?: NonReadonly<PersonRecordApi>,
params?: PersonsUpdateParams,
options?: RequestInit
): Promise<PersonRecordApi> => {
return apiMutator<PersonRecordApi>(getPersonsUpdateUrl(projectId, id, params), {
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personRecordApi),
})
}
export const getPersonsPartialUpdateUrl = (projectId: string, id: string, params?: PersonsPartialUpdateParams) => {
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}/persons/${id}/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsPartialUpdate = async (
projectId: string,
id: string,
patchedPersonRecordApi?: NonReadonly<PatchedPersonRecordApi>,
params?: PersonsPartialUpdateParams,
options?: RequestInit
): Promise<PersonRecordApi> => {
return apiMutator<PersonRecordApi>(getPersonsPartialUpdateUrl(projectId, id, params), {
...options,
method: 'PATCH',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(patchedPersonRecordApi),
})
}
export const getPersonsActivityRetrieveUrl = (
projectId: string,
id: number,
params?: PersonsActivityRetrieveParams
) => {
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}/persons/${id}/activity/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/activity/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsActivityRetrieve = async (
projectId: string,
id: number,
params?: PersonsActivityRetrieveParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsActivityRetrieveUrl(projectId, id, params), {
...options,
method: 'GET',
})
}
export const getPersonsDeletePropertyCreateUrl = (
projectId: string,
id: string,
params?: PersonsDeletePropertyCreateParams
) => {
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}/persons/${id}/delete_property/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/delete_property/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsDeletePropertyCreate = async (
projectId: string,
id: string,
personDeletePropertyRequestApi: PersonDeletePropertyRequestApi,
params?: PersonsDeletePropertyCreateParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsDeletePropertyCreateUrl(projectId, id, params), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personDeletePropertyRequestApi),
})
}
export const getPersonsEmailsListUrl = (projectId: string, id: number, params?: PersonsEmailsListParams) => {
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}/persons/${id}/emails/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/emails/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsEmailsList = async (
projectId: string,
id: number,
params?: PersonsEmailsListParams,
options?: RequestInit
): Promise<MessageAssetApi[]> => {
return apiMutator<MessageAssetApi[]>(getPersonsEmailsListUrl(projectId, id, params), {
...options,
method: 'GET',
})
}
export const getPersonsPropertiesTimelineRetrieveUrl = (
projectId: string,
id: number,
params?: PersonsPropertiesTimelineRetrieveParams
) => {
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}/persons/${id}/properties_timeline/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/properties_timeline/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsPropertiesTimelineRetrieve = async (
projectId: string,
id: number,
params?: PersonsPropertiesTimelineRetrieveParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsPropertiesTimelineRetrieveUrl(projectId, id, params), {
...options,
method: 'GET',
})
}
export const getPersonsPushNotificationsListUrl = (
projectId: string,
id: number,
params?: PersonsPushNotificationsListParams
) => {
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}/persons/${id}/push_notifications/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/push_notifications/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsPushNotificationsList = async (
projectId: string,
id: number,
params?: PersonsPushNotificationsListParams,
options?: RequestInit
): Promise<MessageAssetApi[]> => {
return apiMutator<MessageAssetApi[]>(getPersonsPushNotificationsListUrl(projectId, id, params), {
...options,
method: 'GET',
})
}
export const getPersonsSplitCreateUrl = (projectId: string, id: string, params?: PersonsSplitCreateParams) => {
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}/persons/${id}/split/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/split/`
}
/**
* Split distinct_ids off a merged person. Two mutually exclusive modes:
*
* - **`distinct_ids_to_split`** (recommended for surgical edits): moves only the listed distinct_ids off this person onto new single-id persons. The original person keeps every other distinct_id and its properties.
* - **`main_distinct_id`**: keeps only the specified distinct_id on this person; moves every *other* distinct_id off onto its own new person. If omitted, the first distinct_id is kept.
*
* The original person always retains its properties. To clear individual properties afterward, use the `delete_property` endpoint.
*
* The split runs asynchronously: a 201 response means the task was enqueued. Newly-created split-off persons get a deterministic UUID derived from `(team_id, distinct_id)`, so they can be located client-side without polling. If you need to delete a split-off person after this call, prefer looking it up by that deterministic UUID rather than by distinct_id, since the latter still resolves to the original merged person until the async task completes.
*/
export const personsSplitCreate = async (
projectId: string,
id: string,
personSplitRequestApi?: PersonSplitRequestApi,
params?: PersonsSplitCreateParams,
options?: RequestInit
): Promise<PersonSplitResponseApi> => {
return apiMutator<PersonSplitResponseApi>(getPersonsSplitCreateUrl(projectId, id, params), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personSplitRequestApi),
})
}
export const getPersonsUpdatePropertyCreateUrl = (
projectId: string,
id: string,
params?: PersonsUpdatePropertyCreateParams
) => {
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}/persons/${id}/update_property/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/${id}/update_property/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsUpdatePropertyCreate = async (
projectId: string,
id: string,
personUpdatePropertyRequestApi: PersonUpdatePropertyRequestApi,
params?: PersonsUpdatePropertyCreateParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsUpdatePropertyCreateUrl(projectId, id, params), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personUpdatePropertyRequestApi),
})
}
export const getPersonsAllActivityRetrieveUrl = (projectId: string, params?: PersonsAllActivityRetrieveParams) => {
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}/persons/activity/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/activity/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsAllActivityRetrieve = async (
projectId: string,
params?: PersonsAllActivityRetrieveParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsAllActivityRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getPersonsBatchByDistinctIdsCreateUrl = (
projectId: string,
params?: PersonsBatchByDistinctIdsCreateParams
) => {
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}/persons/batch_by_distinct_ids/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/batch_by_distinct_ids/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsBatchByDistinctIdsCreate = async (
projectId: string,
personRecordApi?: NonReadonly<PersonRecordApi>,
params?: PersonsBatchByDistinctIdsCreateParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsBatchByDistinctIdsCreateUrl(projectId, params), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personRecordApi),
})
}
export const getPersonsBatchByUuidsCreateUrl = (projectId: string, params?: PersonsBatchByUuidsCreateParams) => {
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}/persons/batch_by_uuids/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/batch_by_uuids/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsBatchByUuidsCreate = async (
projectId: string,
personRecordApi?: NonReadonly<PersonRecordApi>,
params?: PersonsBatchByUuidsCreateParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsBatchByUuidsCreateUrl(projectId, params), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personRecordApi),
})
}
export const getPersonsBulkDeleteCreateUrl = (projectId: string, params?: PersonsBulkDeleteCreateParams) => {
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}/persons/bulk_delete/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/bulk_delete/`
}
/**
* This endpoint allows you to bulk delete persons, either by the Insights person IDs or by distinct IDs. You can pass in a maximum of 1000 IDs per call. Only events captured before the request will be deleted.
*/
export const personsBulkDeleteCreate = async (
projectId: string,
personBulkDeleteRequestApi?: PersonBulkDeleteRequestApi,
params?: PersonsBulkDeleteCreateParams,
options?: RequestInit
): Promise<PersonBulkDeleteResponseApi> => {
return apiMutator<PersonBulkDeleteResponseApi>(getPersonsBulkDeleteCreateUrl(projectId, params), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personBulkDeleteRequestApi),
})
}
export const getPersonsCohortsRetrieveUrl = (projectId: string, params: PersonsCohortsRetrieveParams) => {
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}/persons/cohorts/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/cohorts/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsCohortsRetrieve = async (
projectId: string,
params: PersonsCohortsRetrieveParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsCohortsRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getPersonsDeletionStatusListUrl = (projectId: string, params?: PersonsDeletionStatusListParams) => {
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}/persons/deletion_status/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/deletion_status/`
}
/**
* List the status of queued event deletions for persons. When you delete a person with `delete_events=true`, an async deletion is queued. Use this endpoint to check whether those deletions are still pending or have been completed.
*/
export const personsDeletionStatusList = async (
projectId: string,
params?: PersonsDeletionStatusListParams,
options?: RequestInit
): Promise<PaginatedAsyncDeletionStatusListApi> => {
return apiMutator<PaginatedAsyncDeletionStatusListApi>(getPersonsDeletionStatusListUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getPersonsPropertiesAtTimeRetrieveUrl = (
projectId: string,
params: PersonsPropertiesAtTimeRetrieveParams
) => {
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}/persons/properties_at_time/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/properties_at_time/`
}
/**
* Get person properties as they existed at a specific point in time.
*
* This endpoint reconstructs person properties by querying Datastore events
* for $set and $set_once operations up to the specified timestamp.
*
* Query parameters:
* - distinct_id: The distinct_id of the person
* - timestamp: ISO datetime string for the point in time (e.g., "2023-06-15T14:30:00Z")
* - include_set_once: Whether to handle $set_once operations (default: false)
*/
export const personsPropertiesAtTimeRetrieve = async (
projectId: string,
params: PersonsPropertiesAtTimeRetrieveParams,
options?: RequestInit
): Promise<PersonPropertiesAtTimeResponseApi> => {
return apiMutator<PersonPropertiesAtTimeResponseApi>(getPersonsPropertiesAtTimeRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getPersonsResetPersonDistinctIdCreateUrl = (
projectId: string,
params?: PersonsResetPersonDistinctIdCreateParams
) => {
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}/persons/reset_person_distinct_id/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/reset_person_distinct_id/`
}
/**
* Reset a distinct_id for a deleted person. This allows the distinct_id to be used again.
*/
export const personsResetPersonDistinctIdCreate = async (
projectId: string,
personRecordApi?: NonReadonly<PersonRecordApi>,
params?: PersonsResetPersonDistinctIdCreateParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsResetPersonDistinctIdCreateUrl(projectId, params), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(personRecordApi),
})
}
export const getPersonsValuesRetrieveUrl = (projectId: string, params: PersonsValuesRetrieveParams) => {
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}/persons/values/?${stringifiedParams}`
: `/v1/projects/${projectId}/persons/values/`
}
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://hanzo.ai/docs/api/capture), the `$set` and `$unset` [properties](https://hanzo.ai/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsValuesRetrieve = async (
projectId: string,
params: PersonsValuesRetrieveParams,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getPersonsValuesRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}