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.

feat(tasks): split task sources by client (#109482)

Dylan Martinada2f9158a9b
diff --git a/packages/agent/packages/agent-contracts/src/domain-types.ts b/packages/agent/packages/agent-contracts/src/domain-types.ts
index 19871379eeb2..5d5f68e105b2 100644
--- a/packages/agent/packages/agent-contracts/src/domain-types.ts
+++ b/packages/agent/packages/agent-contracts/src/domain-types.ts
@@ -76,6 +76,11 @@ export interface OrganizationMemberBasic {
user: UserBasic;
}
+export type TaskClientProvenance =
+ | "posthog_desktop"
+ | "posthog_mobile"
+ | "posthog_web";
+
export interface Task {
id: string;
task_number: number | null;
@@ -95,6 +100,7 @@ export interface Task {
last_activity_at?: string;
created_by?: UserBasic | null;
origin_product: string;
+ client_provenance?: TaskClientProvenance | null;
repository?: string | null; // Format: "organization/repository" (e.g., "posthog/posthog-js")
repositories?: string[];
github_integration?: number | null;
diff --git a/packages/agent/packages/agent-contracts/src/index.ts b/packages/agent/packages/agent-contracts/src/index.ts
index a97303c79d22..0004d7eff39d 100644
--- a/packages/agent/packages/agent-contracts/src/index.ts
+++ b/packages/agent/packages/agent-contracts/src/index.ts
@@ -104,6 +104,7 @@ export {
type PendingFollowupMessage,
type StoreSkillStub,
type Task,
+ type TaskClientProvenance,
type TaskRun,
type TaskRunArtifact,
type TaskRunArtifactMetadata,
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 1f9f893cc400..f9fb229b232d 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -296,7 +296,7 @@ LOGOUT_URL = "/logout"
LOGIN_REDIRECT_URL = "/"
APPEND_SLASH = False
CORS_URLS_REGEX = r"^(/site_app/|/array/|/static/|/oauth/token/?|/toolbar_oauth/check|/api/(?!early_access_features|surveys|web_experiments).*$)"
-CORS_ALLOW_HEADERS = default_headers + CORS_ALLOWED_TRACING_HEADERS
+CORS_ALLOW_HEADERS = default_headers + CORS_ALLOWED_TRACING_HEADERS + ("x-posthog-client-provenance",)
X_FRAME_OPTIONS = "SAMEORIGIN"
SOCIAL_AUTH_JSONFIELD_ENABLED = True
diff --git a/products/desktop/apps/mobile/src/lib/posthogApiClient.test.ts b/products/desktop/apps/mobile/src/lib/posthogApiClient.test.ts
index 9585278ff2f5..80adb096236b 100644
--- a/products/desktop/apps/mobile/src/lib/posthogApiClient.test.ts
+++ b/products/desktop/apps/mobile/src/lib/posthogApiClient.test.ts
@@ -98,6 +98,7 @@ describe("createPostHogApiClient", () => {
options: {
appVersion: "1.2.3",
githubConnectFrom: "posthog_mobile",
+ taskClientProvenance: "posthog_mobile",
userAgent: "posthog/mobile.hog.dev; version: 1.2.3",
},
});
diff --git a/products/desktop/apps/mobile/src/lib/posthogApiClient.ts b/products/desktop/apps/mobile/src/lib/posthogApiClient.ts
index 7879cb5bf663..20a8bcaf070d 100644
--- a/products/desktop/apps/mobile/src/lib/posthogApiClient.ts
+++ b/products/desktop/apps/mobile/src/lib/posthogApiClient.ts
@@ -75,6 +75,7 @@ export function createPostHogApiClient(): PostHogAPIClient {
appVersion,
fetch: mobileFetch,
githubConnectFrom: MOBILE_GITHUB_CONNECT_FROM,
+ taskClientProvenance: "posthog_mobile",
userAgent: `posthog/mobile.hog.dev; version: ${appVersion}`,
},
);
diff --git a/products/desktop/apps/web/package.json b/products/desktop/apps/web/package.json
index 78efa4aedf81..082716ab47e7 100644
--- a/products/desktop/apps/web/package.json
+++ b/products/desktop/apps/web/package.json
@@ -16,6 +16,7 @@
"@inversifyjs/strongly-typed": "2.2.0",
"@pierre/diffs": "^1.2.10",
"@posthog/agent": "link:../../../../packages/agent/packages/agent",
+ "@posthog/api-client": "workspace:*",
"@posthog/core": "workspace:*",
"@posthog/di": "workspace:*",
"@posthog/harness": "link:../../../../packages/agent/packages/harness",
diff --git a/products/desktop/apps/web/src/main.tsx b/products/desktop/apps/web/src/main.tsx
index e73e04b60120..8464ebb4c4fb 100644
--- a/products/desktop/apps/web/src/main.tsx
+++ b/products/desktop/apps/web/src/main.tsx
@@ -3,6 +3,7 @@ import "reflect-metadata";
// before any of the imports below create them.
import "./web-storage";
import "@posthog/ui/styles/globals.css";
+import { setPosthogApiClientTaskClientProvenance } from "@posthog/api-client/posthog-client";
import { AUTH_SERVICE } from "@posthog/core/auth/auth.module";
import { boot } from "@posthog/di/contribution";
import { ServiceProvider } from "@posthog/di/react";
@@ -18,6 +19,8 @@ import {
} from "./web-oauth-flow";
import { requestPersistentStorage } from "./web-persistent-storage";
+setPosthogApiClientTaskClientProvenance("posthog_web");
+
if (window.location.pathname === OAUTH_CALLBACK_PATH) {
// OAuth popup landing: relay code+state to the opener tab and close.
// Nothing else may run here — restoring a session in the popup could
diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.ts
index a72649f0a164..1e741dd17d25 100644
--- a/products/desktop/packages/api-client/src/generated.ts
+++ b/products/desktop/packages/api-client/src/generated.ts
@@ -4258,6 +4258,7 @@ export namespace Schemas {
fix?: (string | null) | undefined;
message: string;
start?: (number | null) | undefined;
+ url?: (string | null) | undefined;
};
export type PredicateFixAction =
| "edit_query"
@@ -6195,6 +6196,7 @@ export namespace Schemas {
export type DashboardCustomization = Partial<{
tile_spacing: TileSpacingEnum;
layout_compaction: LayoutCompactionEnum;
+ group_titles: Record<string, string>;
}>;
/**
* Serializer mixin that handles tags for objects.
@@ -6283,6 +6285,10 @@ export namespace Schemas {
* Serializer mixin that handles tags for objects.
*/
layout_compaction?: (LayoutCompactionEnum & unknown) | undefined;
+ /**
+ * Serializer mixin that handles tags for objects.
+ */
+ group_titles?: (Record<string, string> | null) | undefined;
tiles: Array<Record<string, unknown>> | null;
/**
* Serializer mixin that handles tags for objects.
@@ -6381,6 +6387,11 @@ export namespace Schemas {
sm: _DashboardPatchTileLayoutBoxOpenApi;
xs?: _DashboardPatchTileLayoutBoxOpenApi | undefined;
};
+ /**
+ * * `winner` - Winner
+ * * `cheeky-hog` - Cheeky hog
+ */
+ export type DashboardTileBadgeEnum = "winner" | "cheeky-hog";
/**
* * `activity_events_list` - activity_events_list
* * `canvas_app` - canvas_app
@@ -6559,6 +6570,8 @@ export namespace Schemas {
id: number;
layouts: _DashboardPatchTileLayoutsOpenApi;
show_description: boolean;
+ group_key: string | null;
+ badge: DashboardTileBadgeEnum | NullEnum;
widget: DashboardPatchWidgetOpenApi;
}>;
export type DashboardTileBasic = {
@@ -6653,6 +6666,10 @@ export namespace Schemas {
* Serializer mixin that handles tags for objects.
*/
layout_compaction?: (LayoutCompactionEnum & unknown) | undefined;
+ /**
+ * Serializer mixin that handles tags for objects.
+ */
+ group_titles?: (Record<string, string> | null) | undefined;
tiles: Array<Record<string, unknown>> | null;
/**
* Serializer mixin that handles tags for objects.
@@ -9892,6 +9909,7 @@ export namespace Schemas {
* * `no_metric` - No Metric
* * `srm` - Sample Ratio Mismatch
* * `zero_exposures` - Zero Exposures
+ * * `forced_variant_release_condition` - Forced Variant Release Condition
*/
export type ExperimentHealthFindingCodeEnum =
| "flag_off_while_running"
@@ -9901,7 +9919,8 @@ export namespace Schemas {
| "bias_risk_multiple_excluded"
| "no_metric"
| "srm"
- | "zero_exposures";
+ | "zero_exposures"
+ | "forced_variant_release_condition";
/**
* * `critical` - Critical severity
* * `warning` - Warning severity
@@ -9918,6 +9937,7 @@ export namespace Schemas {
* * `add_primary_metric` - Add Primary Metric
* * `add_secondary_metric` - Add Secondary Metric
* * `edit_exposure_criteria` - Edit Exposure Criteria
+ * * `edit_release_conditions` - Edit Release Conditions
*/
export type ExperimentHealthFindingActionKindEnum =
| "open_feature_flag"
@@ -9925,7 +9945,8 @@ export namespace Schemas {
| "use_first_seen_variant"
| "add_primary_metric"
| "add_secondary_metric"
- | "edit_exposure_criteria";
+ | "edit_exposure_criteria"
+ | "edit_release_conditions";
export type ExperimentHealthFinding = {
/**
* Stable identifier of the problem. Each code has one meaning across every surface that reports it.
@@ -9938,6 +9959,7 @@ export namespace Schemas {
* * `no_metric` - No Metric
* * `srm` - Sample Ratio Mismatch
* * `zero_exposures` - Zero Exposures
+ * * `forced_variant_release_condition` - Forced Variant Release Condition
*/
code: ExperimentHealthFindingCodeEnum;
/**
@@ -12232,6 +12254,8 @@ export namespace Schemas {
* * `Neo4j` - Neo4j
* * `TestDino` - TestDino
* * `ChessCom` - ChessCom
+ * * `Userback` - Userback
+ * * `Rewardful` - Rewardful
*/
export type ExternalDataSourceTypeEnum =
| "Ashby"
@@ -13606,7 +13630,9 @@ export namespace Schemas {
| "Arcade"
| "Neo4j"
| "TestDino"
- | "ChessCom";
+ | "ChessCom"
+ | "Userback"
+ | "Rewardful";
/**
* * `web` - web
* * `api` - api
@@ -14990,6 +15016,8 @@ export namespace Schemas {
* * `Neo4j` - Neo4j
* * `TestDino` - TestDino
* * `ChessCom` - ChessCom
+ * * `Userback` - Userback
+ * * `Rewardful` - Rewardful
*/
source_type: ExternalDataSourceTypeEnum;
/**
@@ -15191,7 +15219,7 @@ export namespace Schemas {
*/
evaluation_contexts?: Array<unknown> | undefined;
/**
- * Legacy dashboard of saved usage insights for this flag, or null if it has none. New flags show usage charts inline instead. The dashboard creation endpoint is deprecated and will be removed after September 25, 2026.
+ * Legacy dashboard of saved usage insights for this flag, or null if it has none. Usage charts are on the flag's Usage tab. The API does not create these dashboards.
*/
usage_dashboard: number | null;
/**
@@ -18507,6 +18535,15 @@ export namespace Schemas {
channel: string;
created_at?: (string | null) | undefined;
};
+ /**
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web
+ */
+ export type TaskClientProvenanceEnum =
+ | "posthog_desktop"
+ | "posthog_mobile"
+ | "posthog_web";
/**
* Detail response for a task.
*
@@ -18596,6 +18633,14 @@ export namespace Schemas {
* ``latest_run`` nests the run-detail shape. ``created_by`` mirrors core ``UserBasicSerializer``.
*/
origin_key?: (string | null) | undefined;
+ /**
+ * Detail response for a task.
+ *
+ * Reads from a frozen ``TaskDetailDTO`` produced by the facade. ``github_integration`` /
+ * ``github_user_integration`` are integration ids, ``signal_report`` is the report id, and
+ * ``latest_run`` nests the run-detail shape. ``created_by`` mirrors core ``UserBasicSerializer``.
+ */
+ client_provenance?: (TaskClientProvenanceEnum | NullEnum) | undefined;
};
/**
* Basic list response for a task, returned when the list is asked for ``basic=true``.
@@ -18709,6 +18754,17 @@ export namespace Schemas {
* server-side.
*/
origin_key?: (string | null) | undefined;
+ /**
+ * Basic list response for a task, returned when the list is asked for ``basic=true``.
+ *
+ * A surface that renders only a summary of each task asks for the basic payload and gets this
+ * smaller shape. It drops the full ``description`` body, which dominates the list payload, and
+ * replaces it with ``description_preview`` (the first characters) so a feed can still show a
+ * prompt snippet. The default list response keeps the full ``description``, and ``retrieve``
+ * always returns it. A client uses the ``search`` query parameter to match description text
+ * server-side.
+ */
+ client_provenance?: (TaskClientProvenanceEnum | NullEnum) | undefined;
/**
* First 1000 characters of the description, so a summary surface can show a prompt snippet without the full body. Open the task for the complete text.
*/
@@ -19263,6 +19319,7 @@ export namespace Schemas {
quick_filter_ids: Array<string> | null;
grid_spacing: TileSpacingEnum;
layout_compaction: LayoutCompactionEnum;
+ group_titles: Record<string, string> | null;
tiles: Array<DashboardPatchTileOpenApi>;
use_template: string;
use_dashboard: number | null;
@@ -19760,6 +19817,7 @@ export namespace Schemas {
email_tracking_consent_mode: EmailTrackingConsentModeEnum;
workflow_task_rate_limit_per_day: number | null;
workflow_task_team_rate_limit_per_day: number | null;
+ default_email_integration_id: number | null;
}>;
export type TeamFeatureFlagPolicyConfig = Partial<{
require_tags: boolean;
@@ -21002,6 +21060,14 @@ export namespace Schemas {
* ``latest_run`` nests the run-detail shape. ``created_by`` mirrors core ``UserBasicSerializer``.
*/
origin_key?: (string | null) | undefined;
+ /**
+ * Detail response for a task.
+ *
+ * Reads from a frozen ``TaskDetailDTO`` produced by the facade. ``github_integration`` /
+ * ``github_user_integration`` are integration ids, ``signal_report`` is the report id, and
+ * ``latest_run`` nests the run-detail shape. ``created_by`` mirrors core ``UserBasicSerializer``.
+ */
+ client_provenance?: (TaskClientProvenanceEnum | NullEnum) | undefined;
/**
* Detail response for a task.
*
@@ -21190,6 +21256,13 @@ export namespace Schemas {
* from, instead of inferring them from ``latest_run`` (or, worse, the top-level task ``id``).
*/
origin_key?: (string | null) | undefined;
+ /**
+ * The task ``run`` action's response: the refreshed task detail plus the run this call made.
+ *
+ * ``run`` is the run the call created or activated — the payload a caller reads run-scoped ids
+ * from, instead of inferring them from ``latest_run`` (or, worse, the top-level task ``id``).
+ */
+ client_provenance?: (TaskClientProvenanceEnum | NullEnum) | undefined;
/**
* The task ``run`` action's response: the refreshed task detail plus the run this call made.
*
@@ -21637,6 +21710,9 @@ export namespace Endpoints {
};
responses: { 200: Schemas.Ticket };
};
+ /**
+ * Soft-delete a ticket. A daily sweeper hard-deletes it after the grace window.
+ */
export type delete_Conversations_tickets_destroy = {
method: "DELETE";
path: "/api/projects/{project_id}/conversations/tickets/{id}/";
@@ -22583,7 +22659,10 @@ export namespace Endpoints {
basic: boolean;
channel: string;
ci_status: "passing" | "failing" | "pending" | "none";
- client_provenance: "posthog_desktop";
+ client_provenance:
+ | "posthog_desktop"
+ | "posthog_mobile"
+ | "posthog_web";
commented_by: number;
created_by: number;
exclude_origin_product:
@@ -22645,7 +22724,13 @@ export namespace Endpoints {
requestFormat: "json";
parameters: {
path: { project_id: string };
- header: Partial<{ "X-PostHog-Warm-Retry": string }>;
+ header: Partial<{
+ "X-PostHog-Client-Provenance":
+ | "posthog_desktop"
+ | "posthog_mobile"
+ | "posthog_web";
+ "X-PostHog-Warm-Retry": string;
+ }>;
body: Schemas.TaskCreate;
};
responses: {
diff --git a/products/desktop/packages/api-client/src/posthog-client.test.ts b/products/desktop/packages/api-client/src/posthog-client.test.ts
index 272f9a0f323e..95051c9928d8 100644
--- a/products/desktop/packages/api-client/src/posthog-client.test.ts
+++ b/products/desktop/packages/api-client/src/posthog-client.test.ts
@@ -39,6 +39,9 @@ describe("PostHogAPIClient", () => {
const [url, request] = fetch.mock.calls[0];
expect((url as URL).pathname).toBe("/api/projects/42/tasks/");
expect(request.method).toBe("POST");
+ expect(
+ (request.headers as Headers).get("X-PostHog-Client-Provenance"),
+ ).toBe("posthog_desktop");
expect(JSON.parse(request.body)).toEqual({
description: "Read the report evidence",
title: "Review report",
@@ -52,6 +55,45 @@ describe("PostHogAPIClient", () => {
},
);
+ it.each([
+ { provenance: "posthog_mobile", action: "creates" },
+ { provenance: "posthog_web", action: "creates" },
+ { provenance: "posthog_mobile", action: "warms" },
+ { provenance: "posthog_web", action: "warms" },
+ ] as const)(
+ "sends $provenance provenance when it $action a task",
+ async ({ provenance, action }) => {
+ const fetch = vi.fn().mockResolvedValue(
+ new Response(
+ JSON.stringify({
+ id: "task-1",
+ task_id: "task-1",
+ run_id: "run-1",
+ }),
+ { status: 201 },
+ ),
+ );
+ const client = new PostHogAPIClient(
+ "https://app.posthog.test",
+ async () => "token",
+ async () => "token",
+ 42,
+ { fetch, taskClientProvenance: provenance },
+ );
+
+ if (action === "creates") {
+ await client.createTask({ description: "Create a task" });
+ } else {
+ await client.warmTask({ repository: null, github_integration: null });
+ }
+
+ const request = fetch.mock.calls[0]?.[1];
+ expect(
+ (request?.headers as Headers).get("X-PostHog-Client-Provenance"),
+ ).toBe(provenance);
+ },
+ );
+
it("shows the setup dependency error returned by the server", async () => {
const detail =
"The workflow action is unavailable. Sync templates and retry setup.";
diff --git a/products/desktop/packages/api-client/src/posthog-client.ts b/products/desktop/packages/api-client/src/posthog-client.ts
index 0c50e36876f4..025135a18be5 100644
--- a/products/desktop/packages/api-client/src/posthog-client.ts
+++ b/products/desktop/packages/api-client/src/posthog-client.ts
@@ -10,6 +10,7 @@ import type {
SourceProduct,
SourceType,
StoredLogEntry,
+ TaskClientProvenance,
TaskRunArtifactMetadata,
} from "@posthog/shared";
import {
@@ -183,16 +184,24 @@ export function setPosthogApiClientLogger(logger: ApiClientLogger): void {
// Host build version, set by the host at boot (default "unknown"); avoids a
// build-time global so the package typechecks standalone and across importers.
let clientAppVersion = "unknown";
+let taskClientProvenance: TaskClientProvenance = "posthog_desktop";
export function setPosthogApiClientAppVersion(version: string): void {
clientAppVersion = version;
}
+export function setPosthogApiClientTaskClientProvenance(
+ provenance: TaskClientProvenance,
+): void {
+ taskClientProvenance = provenance;
+}
+
export interface PostHogAPIClientOptions {
fetch?: FetchImplementation;
appVersion?: string;
userAgent?: string | null;
githubConnectFrom?: string;
+ taskClientProvenance?: TaskClientProvenance;
}
export function getPosthogApiClientAppVersion(): string {
@@ -2091,6 +2100,7 @@ export class PostHogAPIClient {
private _teamId: number | null = null;
private githubConnectFrom: string;
private readonly apiHost: string;
+ private readonly taskClientProvenance: TaskClientProvenance;
constructor(
apiHost: string,
@@ -2102,6 +2112,8 @@ export class PostHogAPIClient {
const baseUrl = apiHost.endsWith("/") ? apiHost.slice(0, -1) : apiHost;
this.apiHost = baseUrl;
this.githubConnectFrom = options.githubConnectFrom ?? "posthog_code";
+ this.taskClientProvenance =
+ options.taskClientProvenance ?? taskClientProvenance;
this.api = createApiClient(
buildApiFetcher({
getAccessToken,
@@ -3540,7 +3552,9 @@ export class PostHogAPIClient {
const data = await this.withCloudUsageLimitCheck(() =>
this.api.post(`/api/projects/{project_id}/tasks/`, {
- header: {},
+ header: {
+ "X-PostHog-Client-Provenance": this.taskClientProvenance,
+ },
path: { project_id: teamId.toString() },
body: {
...taskOptions,
@@ -4569,6 +4583,11 @@ export class PostHogAPIClient {
method: "post",
url,
path: urlPath,
+ parameters: {
+ header: {
+ "X-PostHog-Client-Provenance": this.taskClientProvenance,
+ },
+ },
overrides: {
body: JSON.stringify({
repository: options.repository,
diff --git a/products/desktop/packages/api-client/src/task-normalization.ts b/products/desktop/packages/api-client/src/task-normalization.ts
index 10a3a82f1c60..c14ed2a9ab1e 100644
--- a/products/desktop/packages/api-client/src/task-normalization.ts
+++ b/products/desktop/packages/api-client/src/task-normalization.ts
@@ -255,6 +255,9 @@ export function normalizeTaskResponse(
last_activity_at: dto.last_activity_at ?? dto.updated_at ?? "",
...(dto.created_by === undefined ? {} : { created_by: dto.created_by }),
origin_product: dto.origin_product ?? "",
+ ...(dto.client_provenance === undefined
+ ? {}
+ : { client_provenance: dto.client_provenance }),
...(dto.repository === undefined ? {} : { repository: dto.repository }),
repositories: dto.repositories ?? (dto.repository ? [dto.repository] : []),
...(dto.github_integration === undefined
diff --git a/products/desktop/packages/core/src/canvas/channelItems.test.ts b/products/desktop/packages/core/src/canvas/channelItems.test.ts
index da88aa6a2ddf..9be6b0cbf2d2 100644
--- a/products/desktop/packages/core/src/canvas/channelItems.test.ts
+++ b/products/desktop/packages/core/src/canvas/channelItems.test.ts
@@ -11,7 +11,10 @@ import {
filterChannelItems,
groupChannelItems,
hasActiveChannelItemFilters,
+ MOBILE_SOURCE,
+ migrateLegacySources,
sortChannelItems,
+ WEB_SOURCE,
} from "./channelItems";
import type { DashboardRecord } from "./dashboardSchemas";
@@ -221,15 +224,27 @@ describe("buildChannelItems", () => {
expect(item.repository).toBeNull();
});
- it("reads the source for filed and Desktop sessions", () => {
- const items = build({
- feedTasks: [
- task({ id: "filed", origin_product: "slack" }),
- task({ id: "own", origin_product: "user_created" }),
- ],
- });
- expect(items.map((i) => i.source)).toEqual(["slack", DESKTOP_SOURCE]);
- });
+ it.each([
+ ["a filed session", "slack", undefined, "slack"],
+ ["a Desktop session", "user_created", "posthog_desktop", DESKTOP_SOURCE],
+ ["a legacy manual session", "user_created", undefined, DESKTOP_SOURCE],
+ ["a Mobile session", "user_created", "posthog_mobile", MOBILE_SOURCE],
+ ["a Web session", "user_created", "posthog_web", WEB_SOURCE],
+ ["a PostHog AI session", "posthog_ai", undefined, WEB_SOURCE],
+ ] as const)(
+ "maps %s to its source",
+ (_label, originProduct, clientProvenance, expected) => {
+ const [item] = build({
+ feedTasks: [
+ task({
+ origin_product: originProduct,
+ client_provenance: clientProvenance,
+ }),
+ ],
+ });
+ expect(item.source).toBe(expected);
+ },
+ );
it("marks the sessions asking for input and the ones you haven't read", () => {
const items = build({
@@ -458,6 +473,14 @@ describe("hasActiveChannelItemFilters", () => {
});
});
+describe("migrateLegacySources", () => {
+ it("preserves the old manual source across first-party clients", () => {
+ expect(
+ migrateLegacySources(["user_created", "posthog_ai", "slack"]),
+ ).toEqual([DESKTOP_SOURCE, MOBILE_SOURCE, WEB_SOURCE, "slack"]);
+ });
+});
+
describe("channelItemSources", () => {
it("offers each source once", () => {
const items = [
@@ -469,8 +492,8 @@ describe("channelItemSources", () => {
];
expect(channelItemSources(items)).toEqual([
"error_tracking",
- "slack",
DESKTOP_SOURCE,
+ "slack",
]);
});
});
diff --git a/products/desktop/packages/core/src/canvas/channelItems.ts b/products/desktop/packages/core/src/canvas/channelItems.ts
index 36a01c5c8baf..672854d71cc5 100644
--- a/products/desktop/packages/core/src/canvas/channelItems.ts
+++ b/products/desktop/packages/core/src/canvas/channelItems.ts
@@ -135,6 +135,18 @@ function environmentOf(
}
function sourceOf(task: Task): string | null {
+ if (task.origin_product === "posthog_ai") {
+ return WEB_SOURCE;
+ }
+ if (task.origin_product === "user_created") {
+ if (
+ task.client_provenance === MOBILE_SOURCE ||
+ task.client_provenance === WEB_SOURCE
+ ) {
+ return task.client_provenance;
+ }
+ return DESKTOP_SOURCE;
+ }
return task.origin_product || null;
}
@@ -230,7 +242,14 @@ export type ChannelItemSort = "recent" | "created" | "alpha";
export type KindFilter = "any" | "task" | "canvas";
export const ANY_SOURCE: SourceFilter = [];
-export const DESKTOP_SOURCE = "user_created";
+export const DESKTOP_SOURCE = "posthog_desktop";
+export const MOBILE_SOURCE = "posthog_mobile";
+export const WEB_SOURCE = "posthog_web";
+export const FIRST_PARTY_CLIENT_SOURCES = [
+ DESKTOP_SOURCE,
+ MOBILE_SOURCE,
+ WEB_SOURCE,
+] as const;
export interface ChannelItemFilters {
kind: KindFilter;
@@ -305,6 +324,18 @@ export function migrateSourceFilter({
return { ...rest, sources: source === "any" ? ANY_SOURCE : [source] };
}
+export function migrateLegacySources(sources: SourceFilter): string[] {
+ return Array.from(
+ new Set(
+ sources.flatMap((source) => {
+ if (source === "user_created") return FIRST_PARTY_CLIENT_SOURCES;
+ if (source === "posthog_ai") return [WEB_SOURCE];
+ return [source];
+ }),
+ ),
+ );
+}
+
/**
* The sources present in a list, so the menu only offers the ones that can
* actually match. Keyed by `origin_product`; sorted so the menu is stable
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx
index 05c3347345e3..2b488c654f74 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx
@@ -7,6 +7,8 @@ import {
DEFAULT_CHANNEL_ITEM_SORT,
DESKTOP_SOURCE,
hasActiveChannelItemFilters,
+ MOBILE_SOURCE,
+ WEB_SOURCE,
} from "@posthog/core/canvas/channelItems";
import { EditListItemAppearanceDialog } from "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog";
import type { Meta, StoryObj } from "@storybook/react-vite";
@@ -76,7 +78,14 @@ const meta: Meta<typeof Harness> = {
initialFilters: DEFAULT_CHANNEL_ITEM_FILTERS,
defaultFilters: DEFAULT_CHANNEL_ITEM_FILTERS,
initialSort: DEFAULT_CHANNEL_ITEM_SORT,
- sources: ["posthog_ai", "slack", "error_tracking", "support_queue"],
+ sources: [
+ DESKTOP_SOURCE,
+ MOBILE_SOURCE,
+ WEB_SOURCE,
+ "slack",
+ "error_tracking",
+ "support_queue",
+ ],
showCreatedBy: true,
showRunFilters: true,
},
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx
index be7aa7ceb9e1..6ae27df41d58 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx
@@ -10,9 +10,11 @@ import {
DESKTOP_SOURCE,
type EnvironmentFilter,
type KindFilter,
+ MOBILE_SOURCE,
type PinnedFilter,
type SourceFilter,
sameSources,
+ WEB_SOURCE,
} from "@posthog/core/canvas/channelItems";
import {
Button,
@@ -94,9 +96,10 @@ const SORT_OPTIONS: readonly Option<ChannelItemSort>[] = [
const SOURCE_LABELS: Record<string, string> = {
[DESKTOP_SOURCE]: "Desktop",
+ [MOBILE_SOURCE]: "Mobile",
+ [WEB_SOURCE]: "Web",
hogdesk: "HogDesk",
mcp_analytics: "MCP analytics",
- posthog_ai: "PostHog AI",
posthog_code: "PostHog Desktop",
review_hog: "ReviewHog",
};
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx
index 4a87301e0a95..f4daa4ca433a 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx
@@ -6,11 +6,11 @@ import {
type ChannelItemModel,
channelItemSortEvent,
channelItemSources,
- DESKTOP_SOURCE,
filterChannelItems,
groupChannelItems,
hasActiveChannelItemFilters,
PINNED_SECTION_KEY,
+ sameSources,
sortChannelItems,
} from "@posthog/core/canvas/channelItems";
import {
@@ -160,12 +160,16 @@ export function ChannelItemsPane({
const sources = useMemo(() => channelItemSources(items), [items]);
const filters = useMemo<ChannelItemFilters>(() => {
+ const selectedDefaultSources = sameSources(
+ rawFilters.sources,
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS.sources,
+ );
const scoped: ChannelItemFilters = {
...rawFilters,
...(hasMultipleAuthors ? {} : { createdBy: "anyone" as const }),
- sources: rawFilters.sources.filter(
- (source) => source === DESKTOP_SOURCE || sources.includes(source),
- ),
+ sources: selectedDefaultSources
+ ? rawFilters.sources
+ : rawFilters.sources.filter((source) => sources.includes(source)),
};
return hasRuns
? scoped
diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx
index f997a0a3ba55..5193281fcec5 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx
@@ -1,5 +1,6 @@
import {
buildChannelItems,
+ channelItemSources,
DEFAULT_CHANNEL_ITEM_FILTERS,
} from "@posthog/core/canvas/channelItems";
import { isPersonalChannel } from "@posthog/core/canvas/channelName";
@@ -176,13 +177,10 @@ export function WebsiteChannelHome({
shownFilters !== activityFilters ||
shownSort !== activitySort ||
shownGrouping !== activityGrouping;
- const activitySources = useMemo(() => {
- const seen = new Set<string>();
- for (const task of tasks) {
- if (task.origin_product) seen.add(task.origin_product);
- }
- return [...seen].sort();
- }, [tasks]);
+ const activitySources = useMemo(
+ () => channelItemSources(spaceItems),
+ [spaceItems],
+ );
const composerRef = useRef<ChannelHomeComposerHandle>(null);
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.test.ts b/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.test.ts
new file mode 100644
index 000000000000..60c094bdb145
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.test.ts
@@ -0,0 +1,42 @@
+import {
+ DEFAULT_CHANNEL_ITEM_FILTERS,
+ FIRST_PARTY_CLIENT_SOURCES,
+ WEB_SOURCE,
+} from "@posthog/core/canvas/channelItems";
+import { describe, expect, it } from "vitest";
+import { useSpaceActivityViewStore } from "./spaceActivityViewStore";
+
+describe("spaceActivityViewStore", () => {
+ const { sources: _, ...filtersWithoutSources } = DEFAULT_CHANNEL_ITEM_FILTERS;
+
+ it.each([
+ {
+ label: "saved sources",
+ filters: {
+ ...filtersWithoutSources,
+ sources: ["user_created", "posthog_ai", "slack"],
+ },
+ expected: [...FIRST_PARTY_CLIENT_SOURCES, "slack"],
+ },
+ {
+ label: "a legacy single source",
+ filters: { ...filtersWithoutSources, source: "posthog_ai" },
+ expected: [WEB_SOURCE],
+ },
+ ])(
+ "rehydration maps old $label to client sources",
+ async ({ filters, expected }) => {
+ localStorage.setItem(
+ "ph-space-activity-view",
+ JSON.stringify({ state: { filters }, version: 0 }),
+ );
+
+ await useSpaceActivityViewStore.persist.rehydrate();
+
+ const state = useSpaceActivityViewStore.getState();
+ expect(state.filters.sources).toEqual(expected);
+ expect(state.filters).not.toHaveProperty("source");
+ localStorage.removeItem("ph-space-activity-view");
+ },
+ );
+});
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.ts
index 0f084e9f397e..91d039648cf5 100644
--- a/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.ts
+++ b/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.ts
@@ -4,6 +4,7 @@ import {
type ChannelItemSort,
DEFAULT_CHANNEL_ITEM_FILTERS,
DEFAULT_CHANNEL_ITEM_SORT,
+ migrateLegacySources,
migrateSourceFilter,
} from "@posthog/core/canvas/channelItems";
import type { SpaceActivityType } from "@posthog/ui/features/canvas/components/channelFeedDisplay";
@@ -47,6 +48,9 @@ export const useSpaceActivityViewStore = create<SpaceActivityViewState>()(
const savedTypes = saved?.types?.filter((type) =>
ALL_SPACE_ACTIVITY_TYPES.includes(type),
);
+ const savedFilters = saved?.filters
+ ? migrateSourceFilter(saved.filters)
+ : {};
return {
...current,
...saved,
@@ -54,7 +58,10 @@ export const useSpaceActivityViewStore = create<SpaceActivityViewState>()(
savedTypes && savedTypes.length > 0 ? savedTypes : current.types,
filters: {
...current.filters,
- ...(saved?.filters ? migrateSourceFilter(saved.filters) : {}),
+ ...savedFilters,
+ ...(savedFilters.sources
+ ? { sources: migrateLegacySources(savedFilters.sources) }
+ : {}),
kind: "any",
},
};
diff --git a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts
index f7b32848b7cd..d7bb366cfa19 100644
--- a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts
+++ b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts
@@ -1,11 +1,24 @@
import {
DEFAULT_CHANNEL_ITEM_FILTERS,
DESKTOP_SOURCE,
+ MOBILE_SOURCE,
+ WEB_SOURCE,
} from "@posthog/core/canvas/channelItems";
import { describe, expect, it } from "vitest";
-import { useSidebarStore } from "./sidebarStore";
+import {
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
+ useSidebarStore,
+} from "./sidebarStore";
describe("sidebarStore", () => {
+ it("defaults Work to first-party sources", () => {
+ expect(DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS.sources).toEqual([
+ DESKTOP_SOURCE,
+ MOBILE_SOURCE,
+ WEB_SOURCE,
+ ]);
+ });
+
it("rehydration sanitizes list item metadata fields", async () => {
localStorage.setItem(
"sidebar-storage",
@@ -31,7 +44,7 @@ describe("sidebarStore", () => {
label: "the old default",
version: 0,
source: "any",
- expected: [DESKTOP_SOURCE],
+ expected: [DESKTOP_SOURCE, MOBILE_SOURCE, WEB_SOURCE],
},
{
label: "an old explicit source",
@@ -70,4 +83,29 @@ describe("sidebarStore", () => {
expect(channelItemFilters).not.toHaveProperty("source");
localStorage.removeItem("sidebar-storage");
});
+
+ it("rehydration maps old sources to client sources", async () => {
+ localStorage.setItem(
+ "sidebar-storage",
+ JSON.stringify({
+ state: {
+ channelItemFilters: {
+ ...DEFAULT_CHANNEL_ITEM_FILTERS,
+ sources: ["user_created", "posthog_ai", "slack"],
+ },
+ },
+ version: 2,
+ }),
+ );
+
+ await useSidebarStore.persist.rehydrate();
+
+ expect(useSidebarStore.getState().channelItemFilters.sources).toEqual([
+ DESKTOP_SOURCE,
+ MOBILE_SOURCE,
+ WEB_SOURCE,
+ "slack",
+ ]);
+ localStorage.removeItem("sidebar-storage");
+ });
});
diff --git a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts
index 142938218323..cae5a3cd8f8a 100644
--- a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts
+++ b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts
@@ -5,7 +5,8 @@ import {
DEFAULT_CHANNEL_ITEM_FILTERS,
DEFAULT_CHANNEL_ITEM_GROUPING,
DEFAULT_CHANNEL_ITEM_SORT,
- DESKTOP_SOURCE,
+ FIRST_PARTY_CLIENT_SOURCES,
+ migrateLegacySources,
migrateSourceFilter,
} from "@posthog/core/canvas/channelItems";
import { ALL_WORKSPACE_MODES } from "@posthog/core/sidebar/buildSidebarData";
@@ -71,10 +72,16 @@ interface SidebarStoreActions {
}
type SidebarStore = SidebarStoreState & SidebarStoreActions;
+type PersistedSidebarStoreState = Omit<
+ SidebarStoreState,
+ "isResizing" | "collapsedSections"
+> & {
+ collapsedSections: string[];
+};
export const DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS: ChannelItemFilters = {
...DEFAULT_CHANNEL_ITEM_FILTERS,
- sources: [DESKTOP_SOURCE],
+ sources: FIRST_PARTY_CLIENT_SOURCES,
};
export const useSidebarStore = create<SidebarStore>()(
@@ -167,23 +174,31 @@ export const useSidebarStore = create<SidebarStore>()(
}),
{
name: "sidebar-storage",
- version: 2,
+ version: 3,
migrate: (persisted, version) => {
- const state = persisted as {
+ const state = persisted as Omit<
+ Partial<PersistedSidebarStoreState>,
+ "channelItemFilters"
+ > & {
channelItemFilters?: Partial<ChannelItemFilters> & {
source?: unknown;
};
};
const saved = state.channelItemFilters;
- if (version >= 2 || !saved) return state;
- const filters = migrateSourceFilter(saved);
+ if (version >= 3 || !saved) {
+ return state as unknown as PersistedSidebarStoreState;
+ }
+ const filters = version < 2 ? migrateSourceFilter(saved) : saved;
+ const sources = filters.sources
+ ? migrateLegacySources(filters.sources)
+ : filters.sources;
return {
...state,
channelItemFilters:
- version === 0 && !filters.sources?.length
- ? { ...filters, sources: [DESKTOP_SOURCE] }
- : filters,
- };
+ version === 0 && !sources?.length
+ ? { ...filters, sources: FIRST_PARTY_CLIENT_SOURCES }
+ : { ...filters, sources },
+ } as unknown as PersistedSidebarStoreState;
},
partialize: (state) => ({
open: state.open,
diff --git a/products/desktop/pnpm-lock.yaml b/products/desktop/pnpm-lock.yaml
index fa91d10df73d..8de07beb57c3 100644
--- a/products/desktop/pnpm-lock.yaml
+++ b/products/desktop/pnpm-lock.yaml
@@ -801,6 +801,9 @@ importers:
'@posthog/agent':
specifier: link:../../../../packages/agent/packages/agent
version: link:../../../../packages/agent/packages/agent
+ '@posthog/api-client':
+ specifier: workspace:*
+ version: link:../../packages/api-client
'@posthog/core':
specifier: workspace:*
version: link:../../packages/core
diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.py
index 7115f69782c5..53ef93acd378 100644
--- a/products/tasks/backend/facade/api.py
+++ b/products/tasks/backend/facade/api.py
@@ -923,6 +923,7 @@ def _task_detail_to_dto(
channel=task.channel_id,
slack_thread_references=_task_slack_thread_references(task),
origin_key=None if task.is_scout_experiment else task.origin_key,
+ client_provenance=task.client_provenance,
)
diff --git a/products/tasks/backend/facade/client_provenance.py b/products/tasks/backend/facade/client_provenance.py
index cace06a6f3e7..370a4844db2f 100644
--- a/products/tasks/backend/facade/client_provenance.py
+++ b/products/tasks/backend/facade/client_provenance.py
@@ -1,13 +1,23 @@
from rest_framework.request import Request
from posthog.oauth_provenance import (
+ get_oauth_client_id,
is_interactive_desktop_grant,
is_sandbox_oauth_request as is_sandbox_oauth_request,
is_sandbox_origin_request as is_sandbox_origin_request,
)
+from posthog.temporal.oauth import POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_EU, POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_US
from products.tasks.backend.models import TaskClientProvenance
+TASK_CLIENT_PROVENANCE_HEADER = "X-PostHog-Client-Provenance"
+_MOBILE_OAUTH_CLIENT_IDS = frozenset(
+ {
+ POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_US,
+ POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_EU,
+ }
+)
+
def is_api_key_request(authenticator: object) -> bool:
"""Whether ``authenticator`` — a request's ``successful_authenticator`` — is a
@@ -37,6 +47,10 @@ def is_api_key_request(authenticator: object) -> bool:
def get_task_client_provenance(request: Request) -> TaskClientProvenance | None:
- if is_interactive_desktop_grant(request):
- return TaskClientProvenance.POSTHOG_DESKTOP
- return None
+ if not is_interactive_desktop_grant(request):
+ return None
+ if get_oauth_client_id(request) in _MOBILE_OAUTH_CLIENT_IDS:
+ return TaskClientProvenance.POSTHOG_MOBILE
+ if request.headers.get(TASK_CLIENT_PROVENANCE_HEADER) == TaskClientProvenance.POSTHOG_WEB:
+ return TaskClientProvenance.POSTHOG_WEB
+ return TaskClientProvenance.POSTHOG_DESKTOP
diff --git a/products/tasks/backend/facade/contracts.py b/products/tasks/backend/facade/contracts.py
index 11f88f0bfa60..21ac665516a4 100644
--- a/products/tasks/backend/facade/contracts.py
+++ b/products/tasks/backend/facade/contracts.py
@@ -255,6 +255,7 @@ class TaskDetailDTO:
channel: UUID | None = None
slack_thread_references: list[SlackThreadReferenceDTO] = Field(default_factory=list)
origin_key: str | None = None
+ client_provenance: str | None = None
@dataclass(frozen=True)
diff --git a/products/tasks/backend/logic/services/compute_quota.py b/products/tasks/backend/logic/services/compute_quota.py
index 91922efc230f..c3e2c9ecc508 100644
--- a/products/tasks/backend/logic/services/compute_quota.py
+++ b/products/tasks/backend/logic/services/compute_quota.py
@@ -14,6 +14,8 @@ ORGANIZATION_DEACTIVATED_DENIAL_CODE = ComputeQuotaDenialReason.ORGANIZATION_DEA
logger = logging.getLogger(__name__)
+POSTHOG_CODE_CLIENT_PROVENANCES = frozenset(TaskClientProvenance)
+
def organization_deactivated(team_id: int) -> bool:
return Team.objects.filter(id=team_id, organization__is_active=False).exists()
@@ -40,7 +42,7 @@ def is_billable_compute(
source_loop_id: object | None,
source_loop_internal: bool | None,
) -> bool:
- if client_provenance != TaskClientProvenance.POSTHOG_DESKTOP:
+ if client_provenance not in POSTHOG_CODE_CLIENT_PROVENANCES:
return False
if origin_product in (Task.OriginProduct.USER_CREATED, Task.OriginProduct.SPACE_SETUP):
return True
diff --git a/products/tasks/backend/logic/services/sandbox_usage.py b/products/tasks/backend/logic/services/sandbox_usage.py
index 0a46675f0700..52a3e7b41132 100644
--- a/products/tasks/backend/logic/services/sandbox_usage.py
+++ b/products/tasks/backend/logic/services/sandbox_usage.py
@@ -315,7 +315,7 @@ def get_billable_sandbox_compute_usage_by_team(
SandboxSession.objects.unscoped()
.select_related("task_run__task__loop")
.filter(
- client_provenance=TaskClientProvenance.POSTHOG_DESKTOP,
+ client_provenance__in=TaskClientProvenance.values,
user_attributed_at__isnull=False,
user_attributed_at__lt=end,
)
diff --git a/products/tasks/backend/logic/services/task_usage.py b/products/tasks/backend/logic/services/task_usage.py
index e49bb94fb844..ce67aa91f9c9 100644
--- a/products/tasks/backend/logic/services/task_usage.py
+++ b/products/tasks/backend/logic/services/task_usage.py
@@ -276,7 +276,7 @@ def _get_task_compute_cost(*, team_id: int, task_id: UUID) -> Decimal:
SandboxSession.objects.for_team(team_id)
.filter(
task_run__task_id=task_id,
- client_provenance=TaskClientProvenance.POSTHOG_DESKTOP,
+ client_provenance__in=TaskClientProvenance.values,
user_attributed_at__isnull=False,
)
.filter(
diff --git a/products/tasks/backend/logic/services/tests/test_compute_quota.py b/products/tasks/backend/logic/services/tests/test_compute_quota.py
index 822649070330..c85d780ba650 100644
--- a/products/tasks/backend/logic/services/tests/test_compute_quota.py
+++ b/products/tasks/backend/logic/services/tests/test_compute_quota.py
@@ -97,10 +97,9 @@ class TestComputeQuota:
assert not is_task_billable_compute(self.task(origin_product=origin, client_provenance=provenance))
@pytest.mark.parametrize("origin", [Task.OriginProduct.USER_CREATED, Task.OriginProduct.SPACE_SETUP])
- def test_desktop_started_origins_are_billable(self, origin):
- assert is_task_billable_compute(
- self.task(origin_product=origin, client_provenance=TaskClientProvenance.POSTHOG_DESKTOP)
- )
+ @pytest.mark.parametrize("provenance", list(TaskClientProvenance))
+ def test_first_party_client_origins_are_billable(self, origin, provenance):
+ assert is_task_billable_compute(self.task(origin_product=origin, client_provenance=provenance))
def test_unknown_origin_is_ineligible(self):
assert not is_billable_compute(
diff --git a/products/tasks/backend/logic/services/tests/test_sandbox_usage.py b/products/tasks/backend/logic/services/tests/test_sandbox_usage.py
index af4a2a9394a8..8841c3600478 100644
--- a/products/tasks/backend/logic/services/tests/test_sandbox_usage.py
+++ b/products/tasks/backend/logic/services/tests/test_sandbox_usage.py
@@ -392,17 +392,18 @@ class TestSandboxUsageAggregation(SandboxUsageBase):
memory_gib_second_usd=memory_gib_second_usd,
)
- def test_billable_compute_requires_trusted_desktop_user_created_snapshot(self):
- self._session(client_provenance=TaskClientProvenance.POSTHOG_DESKTOP)
+ def test_billable_compute_requires_trusted_first_party_client_user_created_snapshot(self):
+ for provenance in TaskClientProvenance:
+ self._session(client_provenance=provenance)
for origin in (Task.OriginProduct.SLACK, Task.OriginProduct.SIGNAL_REPORT, Task.OriginProduct.LOOP, None):
self._session(client_provenance=TaskClientProvenance.POSTHOG_DESKTOP, origin_product=origin)
self._session(client_provenance=None)
usage = get_billable_sandbox_compute_usage_by_team(self.BEGIN, self.END, rate_cards=(self._rate(),))
- assert usage.cpu_millicore_seconds == [(self.team.id, 14_400_000)]
- assert usage.memory_mib_seconds == [(self.team.id, 58_982_400)]
- assert usage.credits == [(self.team.id, 2016)]
+ assert usage.cpu_millicore_seconds == [(self.team.id, 43_200_000)]
+ assert usage.memory_mib_seconds == [(self.team.id, 176_947_200)]
+ assert usage.credits == [(self.team.id, 6048)]
def test_billable_compute_includes_user_loops_and_excludes_internal_loops(self):
self._loop_session(internal=False)
diff --git a/products/tasks/backend/logic/services/tests/test_task_usage.py b/products/tasks/backend/logic/services/tests/test_task_usage.py
index 08f55a9cbbbb..7a3c84b297ab 100644
--- a/products/tasks/backend/logic/services/tests/test_task_usage.py
+++ b/products/tasks/backend/logic/services/tests/test_task_usage.py
@@ -288,7 +288,7 @@ class TestTaskUsage(ClickhouseTestMixin, APIBaseTest):
assert costs == {priced_run: Decimal("1.25")}
- def test_compute_cost_only_includes_billable_desktop_sessions(self) -> None:
+ def test_compute_cost_only_includes_billable_first_party_client_sessions(self) -> None:
rate_start = datetime(2026, 8, 1, tzinfo=UTC)
rate_card = ComputeRateCard(
version="test",
@@ -297,7 +297,7 @@ class TestTaskUsage(ClickhouseTestMixin, APIBaseTest):
cpu_core_second_usd=Decimal("0.01"),
memory_gib_second_usd=Decimal("0.01"),
)
- for provenance in (TaskClientProvenance.POSTHOG_DESKTOP, None):
+ for provenance in (*TaskClientProvenance, None):
run = TaskRun.objects.create(task=self.task, team=self.team)
SandboxSession.objects.unscoped().create(
team=self.team,
@@ -326,7 +326,7 @@ class TestTaskUsage(ClickhouseTestMixin, APIBaseTest):
task_created_at=self.task.created_at,
)
- assert usage.compute_cost_usd == Decimal("0.20")
+ assert usage.compute_cost_usd == Decimal("0.60")
def test_usage_is_reported_before_the_first_rate_card_takes_effect(self) -> None:
rate_start = datetime(2026, 8, 1, tzinfo=UTC)
diff --git a/products/tasks/backend/migrations/0136_alter_loop_client_provenance_and_more.py b/products/tasks/backend/migrations/0136_alter_loop_client_provenance_and_more.py
new file mode 100644
index 000000000000..c06b18ce044c
--- /dev/null
+++ b/products/tasks/backend/migrations/0136_alter_loop_client_provenance_and_more.py
@@ -0,0 +1,47 @@
+# Generated by Django 5.2.17 on 2026-09-30 20:20
+
+from django.db import migrations, models
+
+import products.tasks.backend.models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("tasks", "0135_usertasksconfig_task_defaults"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="loop",
+ name="client_provenance",
+ field=models.CharField(
+ blank=True,
+ choices=products.tasks.backend.models.task_client_provenance_choices,
+ editable=False,
+ max_length=32,
+ null=True,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="sandboxsession",
+ name="client_provenance",
+ field=models.CharField(
+ blank=True,
+ choices=products.tasks.backend.models.task_client_provenance_choices,
+ editable=False,
+ max_length=32,
+ null=True,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="task",
+ name="client_provenance",
+ field=models.CharField(
+ blank=True,
+ choices=products.tasks.backend.models.task_client_provenance_choices,
+ editable=False,
+ max_length=32,
+ null=True,
+ ),
+ ),
+ ]
diff --git a/products/tasks/backend/migrations/max_migration.txt b/products/tasks/backend/migrations/max_migration.txt
index 9a6c617dcc6f..c94ff0b2b1ee 100644
--- a/products/tasks/backend/migrations/max_migration.txt
+++ b/products/tasks/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0135_usertasksconfig_task_defaults
+0136_alter_loop_client_provenance_and_more
diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.py
index 026e129a64c8..8d4a491130b1 100644
--- a/products/tasks/backend/models.py
+++ b/products/tasks/backend/models.py
@@ -333,6 +333,13 @@ PR_READY_EMAIL_PR_URL_STATE_KEY = "pr_ready_email_pr_url"
class TaskClientProvenance(models.TextChoices):
POSTHOG_DESKTOP = "posthog_desktop", "PostHog Desktop"
+ POSTHOG_MOBILE = "posthog_mobile", "PostHog Mobile"
+ POSTHOG_WEB = "posthog_web", "PostHog Web"
+
+
+def task_client_provenance_choices() -> list[tuple[str, str | Promise]]:
+ # Callable so growing the enum doesn't generate a no-op migration.
+ return list(TaskClientProvenance.choices)
def task_origin_product_choices() -> list[tuple[str, str | Promise]]:
@@ -421,7 +428,7 @@ class Task(Taggable, DeletedMetaFields, models.Model):
origin_product = models.CharField(max_length=20, choices=task_origin_product_choices)
client_provenance = models.CharField(
max_length=32,
- choices=TaskClientProvenance,
+ choices=task_client_provenance_choices,
null=True,
blank=True,
editable=False,
@@ -2208,7 +2215,7 @@ class Loop(ModelActivityMixin, TeamScopedRootMixin):
)
client_provenance = models.CharField(
max_length=32,
- choices=TaskClientProvenance,
+ choices=task_client_provenance_choices,
null=True,
blank=True,
editable=False,
@@ -3760,7 +3767,7 @@ class SandboxSession(TeamScopedRootMixin, UUIDModel):
)
client_provenance = models.CharField(
max_length=32,
- choices=TaskClientProvenance,
+ choices=task_client_provenance_choices,
null=True,
blank=True,
editable=False,
diff --git a/products/tasks/backend/presentation/serializers.py b/products/tasks/backend/presentation/serializers.py
index 3587c22f0044..3eb8843bd935 100644
--- a/products/tasks/backend/presentation/serializers.py
+++ b/products/tasks/backend/presentation/serializers.py
@@ -631,6 +631,12 @@ class TaskSerializer(DataclassSerializer):
"`desktop_onboarding_session:<user_id>`. Null for tasks people create themselves."
),
)
+ client_provenance = serializers.ChoiceField(
+ choices=tasks_facade.TaskClientProvenance.choices,
+ allow_null=True,
+ required=False,
+ help_text="First-party PostHog client that created this task.",
+ )
class Meta:
dataclass = TaskDetailDTO
@@ -661,6 +667,7 @@ class TaskSerializer(DataclassSerializer):
"channel",
"slack_thread_references",
"origin_key",
+ "client_provenance",
]
diff --git a/products/tasks/backend/presentation/views/api.py b/products/tasks/backend/presentation/views/api.py
index 940f412be18b..1c7afeb7fdac 100644
--- a/products/tasks/backend/presentation/views/api.py
+++ b/products/tasks/backend/presentation/views/api.py
@@ -80,6 +80,7 @@ from products.tasks.backend.facade.access import (
)
from products.tasks.backend.facade.billing import TaskTokenUsageUnavailable, get_task_usage
from products.tasks.backend.facade.client_provenance import (
+ TASK_CLIENT_PROVENANCE_HEADER,
get_task_client_provenance,
is_sandbox_oauth_request,
is_sandbox_origin_request,
@@ -738,7 +739,14 @@ class TaskViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
str,
OpenApiParameter.HEADER,
description="Retry token from a warm_run_activation_unavailable response; prevents creating a replacement run.",
- )
+ ),
+ OpenApiParameter(
+ TASK_CLIENT_PROVENANCE_HEADER,
+ str,
+ OpenApiParameter.HEADER,
+ enum=tasks_facade.TaskClientProvenance.values,
+ description="First-party client creating the task. Accepted only with an interactive PostHog OAuth grant.",
+ ),
],
responses={
201: TaskCreateResponseSerializer,
diff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.py
index 04844b505dc4..9178f834661e 100644
--- a/products/tasks/backend/tests/test_api.py
+++ b/products/tasks/backend/tests/test_api.py
@@ -41,7 +41,12 @@ from posthog.models.utils import generate_random_token_personal
from posthog.ph_client import filter_scout_experiment_capture
from posthog.scopes import MCP_BUILT_IN_AGENT_SCOPE
from posthog.storage import object_storage
-from posthog.temporal.oauth import ARRAY_APP_CLIENT_ID_DEV, ARRAY_APP_CLIENT_ID_US, POSTHOG_AI_APP_CLIENT_ID_DEV
+from posthog.temporal.oauth import (
+ ARRAY_APP_CLIENT_ID_DEV,
+ ARRAY_APP_CLIENT_ID_US,
+ POSTHOG_AI_APP_CLIENT_ID_DEV,
+ POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_US,
+)
from posthog.utils import absolute_uri
from products.posthog_ai.backend.models.assistant import Conversation
@@ -1534,18 +1539,41 @@ class TestTaskAPI(BaseTaskAPITest):
assert body["detail"] == "Task usage is temporarily unavailable."
assert body["code"] == "task_usage_upstream_unavailable"
- def test_desktop_oauth_task_creation_records_trusted_provenance(self):
- client = self._oauth_client(ARRAY_APP_CLIENT_ID_DEV)
+ @parameterized.expand(
+ [
+ ("desktop", ARRAY_APP_CLIENT_ID_DEV, None, TaskClientProvenance.POSTHOG_DESKTOP),
+ ("mobile", POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_US, None, TaskClientProvenance.POSTHOG_MOBILE),
+ (
+ "web",
+ ARRAY_APP_CLIENT_ID_DEV,
+ TaskClientProvenance.POSTHOG_WEB,
+ TaskClientProvenance.POSTHOG_WEB,
+ ),
+ ]
+ )
+ def test_oauth_task_creation_records_trusted_client_provenance(
+ self,
+ _name: str,
+ client_id: str,
+ header: TaskClientProvenance | None,
+ expected: TaskClientProvenance,
+ ) -> None:
+ client = self._oauth_client(client_id)
+ request_headers: dict[str, Any] = {}
+ if header:
+ request_headers["HTTP_X_POSTHOG_CLIENT_PROVENANCE"] = header
response = client.post(
"/api/projects/@current/tasks/",
- {"title": "Desktop task", "description": "Created in Desktop"},
+ {"title": "Client task", "description": "Created in a first-party client"},
format="json",
+ **request_headers,
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
task = Task.objects.get(id=response.json()["id"])
- self.assertEqual(task.client_provenance, TaskClientProvenance.POSTHOG_DESKTOP)
+ self.assertEqual(task.client_provenance, expected)
+ self.assertEqual(response.json()["client_provenance"], expected)
@parameterized.expand(
[
diff --git a/products/tasks/backend/tests/test_client_provenance.py b/products/tasks/backend/tests/test_client_provenance.py
index 3e9f00484fa7..8db41b6260d8 100644
--- a/products/tasks/backend/tests/test_client_provenance.py
+++ b/products/tasks/backend/tests/test_client_provenance.py
@@ -1,6 +1,8 @@
from types import SimpleNamespace
from typing import cast
+from django.conf import settings
+
from parameterized import parameterized
from rest_framework.request import Request
@@ -18,7 +20,11 @@ from posthog.temporal.oauth import (
POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_US,
)
-from products.tasks.backend.facade.client_provenance import get_task_client_provenance, is_api_key_request
+from products.tasks.backend.facade.client_provenance import (
+ TASK_CLIENT_PROVENANCE_HEADER,
+ get_task_client_provenance,
+ is_api_key_request,
+)
from products.tasks.backend.models import TaskClientProvenance
@@ -31,7 +37,8 @@ class TestTaskClientProvenance:
ARRAY_APP_CLIENT_ID_DEV,
True,
"task:write",
- True,
+ {},
+ TaskClientProvenance.POSTHOG_DESKTOP,
),
(
"mobile_us",
@@ -39,7 +46,8 @@ class TestTaskClientProvenance:
POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_US,
True,
"task:write",
- True,
+ {},
+ TaskClientProvenance.POSTHOG_MOBILE,
),
(
"mobile_eu",
@@ -47,7 +55,17 @@ class TestTaskClientProvenance:
POSTHOG_DESKTOP_MOBILE_APP_CLIENT_ID_EU,
True,
"task:write",
+ {"X-PostHog-Client-Provenance": TaskClientProvenance.POSTHOG_WEB},
+ TaskClientProvenance.POSTHOG_MOBILE,
+ ),
+ (
+ "web",
+ OAuthAccessTokenAuthentication,
+ ARRAY_APP_CLIENT_ID_DEV,
True,
+ "task:write",
+ {"X-PostHog-Client-Provenance": TaskClientProvenance.POSTHOG_WEB},
+ TaskClientProvenance.POSTHOG_WEB,
),
(
"other_oauth",
@@ -55,7 +73,8 @@ class TestTaskClientProvenance:
"other-client",
True,
"task:write",
- False,
+ {"X-PostHog-Client-Provenance": TaskClientProvenance.POSTHOG_WEB},
+ None,
),
(
"internal_desktop_app_token",
@@ -63,7 +82,8 @@ class TestTaskClientProvenance:
ARRAY_APP_CLIENT_ID_DEV,
True,
"task:write internal_run:read",
- False,
+ {"X-PostHog-Client-Provenance": TaskClientProvenance.POSTHOG_WEB},
+ None,
),
(
"server_token_without_internal_scope",
@@ -71,7 +91,8 @@ class TestTaskClientProvenance:
ARRAY_APP_CLIENT_ID_DEV,
False,
"task:write",
- False,
+ {},
+ None,
),
(
"personal_api_key",
@@ -79,18 +100,20 @@ class TestTaskClientProvenance:
ARRAY_APP_CLIENT_ID_DEV,
True,
"task:write",
- False,
+ {},
+ None,
),
]
)
- def test_derives_only_trusted_desktop_oauth(
+ def test_derives_only_trusted_client_provenance(
self,
_name: str,
authenticator_type: type,
client_id: str,
has_authorization_flow_lineage: bool,
scope: str,
- expected_desktop: bool,
+ headers: dict[str, str],
+ expected: TaskClientProvenance | None,
) -> None:
authenticator = authenticator_type()
authenticator.access_token = SimpleNamespace(
@@ -98,11 +121,11 @@ class TestTaskClientProvenance:
source_refresh_token_id="refresh-token-id" if has_authorization_flow_lineage else None,
scope=scope,
)
- request = cast(Request, SimpleNamespace(successful_authenticator=authenticator))
+ request = cast(Request, SimpleNamespace(successful_authenticator=authenticator, headers=headers))
provenance = get_task_client_provenance(request)
- assert (provenance == TaskClientProvenance.POSTHOG_DESKTOP) is expected_desktop
+ assert provenance == expected
def test_missing_authentication_provenance_fails_closed(self) -> None:
assert get_task_client_provenance(cast(Request, SimpleNamespace())) is None
@@ -113,6 +136,11 @@ class TestTaskClientProvenance:
assert is_sandbox_origin_request(request)
assert not is_sandbox_oauth_request(request)
+ def test_provenance_header_is_allowed_in_cors_preflights(self) -> None:
+ allowed_headers = {header.lower() for header in settings.CORS_ALLOW_HEADERS}
+
+ assert TASK_CLIENT_PROVENANCE_HEADER.lower() in allowed_headers
+
class TestIsApiKeyRequest:
@parameterized.expand(
diff --git a/products/tasks/backend/tests/test_filter_matrix.py b/products/tasks/backend/tests/test_filter_matrix.py
index 2e2350443efc..8d888911bb19 100644
--- a/products/tasks/backend/tests/test_filter_matrix.py
+++ b/products/tasks/backend/tests/test_filter_matrix.py
@@ -211,8 +211,12 @@ class TestTaskListFilterMatrix(TestCase):
desktop_task = self.tasks["peter_plain"]
desktop_task.client_provenance = "posthog_desktop"
desktop_task.save(update_fields=["client_provenance"])
+ mobile_task = self.tasks["mine_peter_commented"]
+ mobile_task.client_provenance = "posthog_mobile"
+ mobile_task.save(update_fields=["client_provenance"])
assert self._list(client_provenance="posthog_desktop") == self._ids("peter_plain")
+ assert self._list(client_provenance="posthog_mobile") == self._ids("mine_peter_commented")
assert self._list(client_provenance="posthog_desktop", created_by=self.me.id) == set()
assert self._list(client_provenance="posthog_desktop", search="billing") == self._ids("peter_plain")
assert self._list(client_provenance="posthog_desktop", search="missing") == set()
diff --git a/products/tasks/frontend/generated/api.schemas.ts b/products/tasks/frontend/generated/api.schemas.ts
index fd29eacefd11..1e90b9a84747 100644
--- a/products/tasks/frontend/generated/api.schemas.ts
+++ b/products/tasks/frontend/generated/api.schemas.ts
@@ -1874,6 +1874,19 @@ export interface SlackThreadReferenceDTOApi {
created_at?: string | null
}
+/**
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web
+ */
+export type TaskClientProvenanceEnumApi = (typeof TaskClientProvenanceEnumApi)[keyof typeof TaskClientProvenanceEnumApi]
+
+export const TaskClientProvenanceEnumApi = {
+ PosthogDesktop: 'posthog_desktop',
+ PosthogMobile: 'posthog_mobile',
+ PosthogWeb: 'posthog_web',
+} as const
+
/**
* @nullable
*/
@@ -1934,6 +1947,12 @@ export interface TaskDetailDTOApi {
* @nullable
*/
origin_key?: string | null
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnumApi | null
}
/**
@@ -1998,6 +2017,12 @@ export interface TaskBasicApi {
* @nullable
*/
origin_key?: string | null
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnumApi | null
/** First 1000 characters of the description, so a summary surface can show a prompt snippet without the full body. Open the task for the complete text. */
readonly description_preview: string
}
@@ -2317,6 +2342,12 @@ export interface TaskCreateResponseDTOApi {
* @nullable
*/
origin_key?: string | null
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnumApi | null
/** Error returned when the task was created but its first run could not start. */
run_error?: string
}
@@ -3298,6 +3329,12 @@ export interface TaskRunResponseApi {
* @nullable
*/
origin_key?: string | null
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnumApi | null
/** Error returned when the run could not start. */
run_error?: string
/** The run this call created or activated. Read run-scoped ids from here — `run.id` is the id the run's stream and command endpoints take, while the top-level `id` is the task's. Set on every 200; when `run_error` is also set, the run exists but its workflow did not start. */
@@ -5898,6 +5935,8 @@ export type TasksListParams = {
* Filter by the client that created the task
*
* * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web
* @minLength 1
*/
client_provenance?: TasksListClientProvenance
@@ -6049,6 +6088,8 @@ export type TasksListClientProvenance = (typeof TasksListClientProvenance)[keyof
export const TasksListClientProvenance = {
PosthogDesktop: 'posthog_desktop',
+ PosthogMobile: 'posthog_mobile',
+ PosthogWeb: 'posthog_web',
} as const
export type TasksListExcludeOriginProduct =
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index dd6fb1af6060..d80cad7eb7c2 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -74967,6 +74967,20 @@ export namespace Schemas {
created_at?: string | null;
}
+ /**
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web
+ */
+ export type TaskClientProvenanceEnum = typeof TaskClientProvenanceEnum[keyof typeof TaskClientProvenanceEnum];
+
+
+ export const TaskClientProvenanceEnum = {
+ PosthogDesktop: 'posthog_desktop',
+ PosthogMobile: 'posthog_mobile',
+ PosthogWeb: 'posthog_web',
+ } as const;
+
/**
* @nullable
*/
@@ -75027,6 +75041,12 @@ export namespace Schemas {
* @nullable
*/
origin_key?: string | null;
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnum | null;
}
/**
@@ -75091,6 +75111,12 @@ export namespace Schemas {
* @nullable
*/
origin_key?: string | null;
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnum | null;
/** First 1000 characters of the description, so a summary surface can show a prompt snippet without the full body. Open the task for the complete text. */
readonly description_preview: string;
}
@@ -108808,6 +108834,12 @@ export namespace Schemas {
* @nullable
*/
origin_key?: string | null;
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnum | null;
/** Error returned when the task was created but its first run could not start. */
run_error?: string;
}
@@ -110000,6 +110032,12 @@ export namespace Schemas {
* @nullable
*/
origin_key?: string | null;
+ /** First-party PostHog client that created this task.
+ *
+ * * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web */
+ client_provenance?: TaskClientProvenanceEnum | null;
/** Error returned when the run could not start. */
run_error?: string;
/** The run this call created or activated. Read run-scoped ids from here — `run.id` is the id the run's stream and command endpoints take, while the top-level `id` is the task's. Set on every 200; when `run_error` is also set, the run exists but its workflow did not start. */
@@ -129414,6 +129452,8 @@ export namespace Schemas {
* Filter by the client that created the task
*
* * `posthog_desktop` - PostHog Desktop
+ * * `posthog_mobile` - PostHog Mobile
+ * * `posthog_web` - PostHog Web
* @minLength 1
*/
client_provenance?: TasksListClientProvenance;
@@ -129568,6 +129608,8 @@ export namespace Schemas {
export const TasksListClientProvenance = {
PosthogDesktop: 'posthog_desktop',
+ PosthogMobile: 'posthog_mobile',
+ PosthogWeb: 'posthog_web',
} as const;
export type TasksListExcludeOriginProduct = typeof TasksListExcludeOriginProduct[keyof typeof TasksListExcludeOriginProduct];
diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.ts
index 218a8da8d08f..cdc4d32efea8 100644
--- a/services/mcp/src/generated/tasks/api.ts
+++ b/services/mcp/src/generated/tasks/api.ts
@@ -948,9 +948,11 @@ export const TasksListQueryParams = () => zod.object({
"Filter tasks by the CI check rollup on their most recent run's pull request, as last observed from GitHub. 'none' means the PR has no checks.\n\n\* `passing` - passing\n\* `failing` - failing\n\* `pending` - pending\n\* `none` - none"
),
client_provenance: zod
- .enum(['posthog_desktop'])
+ .enum(['posthog_desktop', 'posthog_mobile', 'posthog_web'])
.optional()
- .describe('Filter by the client that created the task\n\n\* `posthog_desktop` - PostHog Desktop'),
+ .describe(
+ 'Filter by the client that created the task\n\n\* `posthog_desktop` - PostHog Desktop\n\* `posthog_mobile` - PostHog Mobile\n\* `posthog_web` - PostHog Web'
+ ),
commented_by: zod
.number()
.optional()
@@ -1053,6 +1055,10 @@ export const TasksCreateParams = () => zod.object({
})
export const TasksCreateHeader = () => zod.object({
+ 'X-PostHog-Client-Provenance': zod
+ .enum(['posthog_desktop', 'posthog_mobile', 'posthog_web'])
+ .optional()
+ .describe('First-party client creating the task. Accepted only with an interactive PostHog OAuth grant.'),
'X-PostHog-Warm-Retry': zod
.string()
.optional()
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json
index b4444d804188..68601af595ba 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json
@@ -26,8 +26,8 @@
"type": "string"
},
"client_provenance": {
- "description": "Filter by the client that created the task\n\n* `posthog_desktop` - PostHog Desktop",
- "enum": ["posthog_desktop"],
+ "description": "Filter by the client that created the task\n\n* `posthog_desktop` - PostHog Desktop\n* `posthog_mobile` - PostHog Mobile\n* `posthog_web` - PostHog Web",
+ "enum": ["posthog_desktop", "posthog_mobile", "posthog_web"],
"type": "string"
},
"commented_by": {