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(workflows): capture sent push notifications as message assets (#74555)

Daniel Marchuk39fcbd0e5a34
diff --git a/nodejs/src/cdp/cdp-services.ts b/nodejs/src/cdp/cdp-services.ts
index f86a546a66f9..2ad29f518a65 100644
--- a/nodejs/src/cdp/cdp-services.ts
+++ b/nodejs/src/cdp/cdp-services.ts
@@ -436,7 +436,8 @@ export function createCdpCoreServices(
backoffBaseMs: config.CDP_FETCH_BACKOFF_BASE_MS,
backoffMaxMs: config.CDP_FETCH_BACKOFF_MAX_MS,
},
- redis
+ redis,
+ messageAssetsService
)
const hogExecutor = new HogExecutorService(
diff --git a/nodejs/src/cdp/services/messaging/message-assets.service.test.ts b/nodejs/src/cdp/services/messaging/message-assets.service.test.ts
index 3980cfbd40e6..b93c2cf15ddb 100644
--- a/nodejs/src/cdp/services/messaging/message-assets.service.test.ts
+++ b/nodejs/src/cdp/services/messaging/message-assets.service.test.ts
@@ -1,4 +1,7 @@
-import { CyclotronInvocationQueueParametersEmailType } from '~/cdp/schema/cyclotron'
+import {
+ CyclotronInvocationQueueParametersEmailType,
+ CyclotronInvocationQueueParametersSendPushNotificationType,
+} from '~/cdp/schema/cyclotron'
import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { parseJSON } from '~/common/utils/json-parse'
@@ -22,6 +25,20 @@ const emailParams = (
...overrides,
}) as CyclotronInvocationQueueParametersEmailType
+const pushParams = (
+ payloadOverrides: Record<string, unknown> = {}
+): CyclotronInvocationQueueParametersSendPushNotificationType =>
+ ({
+ type: 'sendPushNotification',
+ integrationIds: [1],
+ distinctId: 'user-1',
+ payload: {
+ title: 'Your order shipped',
+ body: 'Track it in the app',
+ ...payloadOverrides,
+ },
+ }) as unknown as CyclotronInvocationQueueParametersSendPushNotificationType
+
const invocationWithAction = (id: string, teamId = 7): CyclotronJobInvocationHogFunction => {
const invocation = createExampleInvocation({ id, team_id: teamId })
invocation.state.actionId = 'email-step'
@@ -114,6 +131,78 @@ describe('MessageAssetsService', () => {
})
})
+ describe('buildRowForPush', () => {
+ it('names the person as the recipient, matching how email fills that column', () => {
+ // The Assets tab shows `recipient` as its RECIPIENT column, and for email that is the
+ // address — so a push has to name who it reached, not which providers carried it.
+ const row = service.buildRowForPush(invocationWithAction('flow-1', 7), pushParams(), ['Firebase', 'APNs'])
+
+ expect(row).not.toBeNull()
+ expect(row!.kind).toBe('push')
+ expect(row!.team_id).toBe(7)
+ expect(row!.subject).toBe('Your order shipped')
+ expect(row!.recipient).toBe(row!.distinct_id)
+ expect(row!.recipient).not.toBe('Firebase, APNs')
+ expect(row!.status).toBe('sent')
+ expect(row!.html).toContain('Your order shipped')
+ expect(row!.html).toContain('Track it in the app')
+ // The delivering channels are not part of what the recipient saw, so they stay out of the
+ // snapshot for the same reason the custom `data` payload does.
+ expect(row!.html).not.toContain('Firebase')
+ })
+
+ it('captures nothing when the push reached no device', () => {
+ // An asset is a snapshot of what a recipient received, so a send that reached nobody has
+ // nothing to show — it would render as an ordinary row with a blank recipient. The attempt
+ // stays visible through the `push_skipped` metric and the run log explaining why.
+ const row = service.buildRowForPush(invocationWithAction('flow-1'), pushParams(), [])
+
+ expect(row).toBeNull()
+ })
+
+ it('renders the iOS subtitle, which the recipient sees as a second line', () => {
+ // Delivered via the APNS alert, so a snapshot without it doesn't match the notification
+ // that actually arrived on the device.
+ const row = service.buildRowForPush(
+ invocationWithAction('flow-1'),
+ pushParams({ apns: { subtitle: 'Your account is ready' } }),
+ ['APNs']
+ )
+
+ expect(row!.html).toContain('Your account is ready')
+ })
+
+ it('keeps the custom data payload out of the stored preview', () => {
+ // `data` is app routing context rather than something the recipient saw, and can carry
+ // arbitrary customer values we should not re-render in the UI.
+ const row = service.buildRowForPush(
+ invocationWithAction('flow-1'),
+ pushParams({ data: { internal_ref: 'super-secret-value' } }),
+ ['Firebase']
+ )
+
+ expect(row!.html).not.toContain('super-secret-value')
+ })
+
+ it('escapes notification content so a crafted title cannot inject markup into the viewer', () => {
+ const row = service.buildRowForPush(
+ invocationWithAction('flow-1'),
+ pushParams({ title: '<img src=x onerror=alert(1)>' }),
+ ['Firebase']
+ )
+
+ expect(row!.html).not.toContain('<img src=x')
+ expect(row!.html).toContain('&lt;img src=x')
+ })
+
+ it('returns null for a push sent outside a workflow step, which the Assets API cannot retrieve', () => {
+ const invocation = invocationWithAction('flow-1')
+ invocation.state.actionId = undefined
+
+ expect(service.buildRowForPush(invocation, pushParams(), ['Firebase'])).toBeNull()
+ })
+ })
+
describe('queueInvocationResults + flush', () => {
it('does not produce anything until flush is called', () => {
const row = service.buildRowForEmail(invocationWithAction('flow-1'), emailParams())!
diff --git a/nodejs/src/cdp/services/messaging/message-assets.service.ts b/nodejs/src/cdp/services/messaging/message-assets.service.ts
index 32202411c9e6..28a177864fa7 100644
--- a/nodejs/src/cdp/services/messaging/message-assets.service.ts
+++ b/nodejs/src/cdp/services/messaging/message-assets.service.ts
@@ -1,6 +1,10 @@
import { Counter, Gauge } from 'prom-client'
-import { CyclotronInvocationQueueParametersEmailType } from '~/cdp/schema/cyclotron'
+import {
+ CyclotronInvocationQueueParametersEmailType,
+ CyclotronInvocationQueueParametersSendPushNotificationType,
+ PushNotificationPayloadType,
+} from '~/cdp/schema/cyclotron'
import { MESSAGE_ASSETS_OUTPUT, MessageAssetsOutput } from '~/common/outputs'
import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { safeClickhouseString } from '~/common/utils/db/utils'
@@ -67,6 +71,38 @@ const wrapPlainTextAsHtml = (text: string): string => {
// the safe budget — the row still lands, the chip works, and the batch is unaffected.
const MAX_HTML_BYTES = 4 * 1024 * 1024
+const escapeHtml = (text: string): string => text.replace(/[&<>"']/g, (c) => HTML_ESCAPE[c])
+
+// A push has no stored body to replay the way an email does, so render the delivered content into the
+// same `html` column. That keeps one asset pipeline and one viewer for both channels: the person view
+// renders this snapshot instead of needing a push-specific renderer.
+// Only the parts the recipient actually saw are rendered. The custom `data` payload is deliberately
+// left out: it is app routing context, not user-visible, and can carry arbitrary customer data we
+// should not be re-displaying in the UI.
+//
+// Two interpolations below carry a `nosemgrep` for `raw-html-format`. That rule fires on customer data
+// reaching a hand-built HTML string at all and can't see a local escaper, but every value here goes
+// through `escapeHtml` (which covers `& < > " '`, enough for both text nodes and the one quoted
+// attribute), and the viewer renders this in an iframe with `sandbox=""`, so scripts can't run even if
+// the escaping were wrong. Keep both properties if you edit this: escape at every interpolation, and
+// don't render anything the recipient didn't see.
+const renderPushPreviewHtml = (payload: PushNotificationPayloadType): string => {
+ const image = payload.image
+ ? `<img src="${escapeHtml(payload.image)}" alt="" style="width:100%;max-height:180px;object-fit:cover;border-radius:8px;margin-top:8px">`
+ : ''
+ // The recipient sees this as a second bold line under the title on iOS, so a snapshot that drops
+ // it doesn't match the notification that was delivered.
+ const subtitle = payload.apns?.subtitle
+ ? `<div style="font-size:15px;font-weight:600;color:#111;margin-bottom:2px">${escapeHtml(payload.apns.subtitle)}</div>`
+ : ''
+ const body = payload.body
+ ? // nosemgrep: javascript.express.security.injection.raw-html-format.raw-html-format
+ `<div style="font-size:14px;line-height:1.4;color:#2d2d2d">${escapeHtml(payload.body)}</div>`
+ : ''
+ // nosemgrep: javascript.express.security.injection.raw-html-format.raw-html-format
+ return `<!doctype html><meta charset="utf-8"><div style="font-family:ui-sans-serif,system-ui,-apple-system,sans-serif;padding:1rem;max-width:420px;margin:1rem auto"><div style="background:#f4f4f5;border-radius:14px;padding:12px 14px"><div style="font-size:15px;font-weight:600;color:#111;margin-bottom:2px">${escapeHtml(payload.title)}</div>${subtitle}${body}${image}</div></div>`
+}
+
const oversizedPlaceholderHtml = (bytes: number): string => {
const mb = (bytes / 1024 / 1024).toFixed(1)
return `<!doctype html><meta charset="utf-8"><div style="padding:1rem;font-family:ui-sans-serif,system-ui,sans-serif;color:#555;max-width:640px;margin:2rem auto"><h3 style="margin:0 0 0.5rem">Email too large to capture</h3><p style="margin:0">The rendered email was ${mb}&nbsp;MB, which exceeds the ${MAX_HTML_BYTES / 1024 / 1024}&nbsp;MB capture limit. The send itself succeeded — this placeholder is stored so the &ldquo;View email&rdquo; link works, but the original body is not viewable here.</p></div>`
@@ -127,6 +163,51 @@ export class MessageAssetsService {
}
}
+ // One row per push step, not per channel. A step fans out to several provider integrations, but the
+ // recipient experiences a single notification, so the person view should show one entry rather than
+ // a near-identical row per channel. `platforms` is what actually took delivery, and the caller only
+ // builds a row once at least one channel has, so this is only ever a delivered notification.
+ buildRowForPush(
+ invocation: CyclotronJobInvocationHogFunction,
+ params: CyclotronInvocationQueueParametersSendPushNotificationType,
+ platforms: string[]
+ ): MessageAssetRow | null {
+ if (!invocation.state.actionId) {
+ return null
+ }
+ const payload = params.payload
+ // Same rule as the email row: drop only when there is no content to show. A title-less push
+ // still delivered something the recipient saw, so a body alone is worth capturing.
+ if (!payload?.title && !payload?.body) {
+ return null
+ }
+ // Nothing took delivery, so there is no notification a recipient saw to snapshot.
+ if (platforms.length === 0) {
+ return null
+ }
+ const recipient = params.distinctId
+ return {
+ team_id: invocation.teamId,
+ function_kind: 'hog_flow',
+ function_id: invocation.functionId,
+ parent_run_id: invocation.parentRunId ?? '',
+ invocation_id: invocation.id,
+ action_id: invocation.state.actionId ?? '',
+ kind: 'push',
+ distinct_id: recipient,
+ person_id: invocation.state.globals.person?.id ?? '',
+ // The person, not the providers that carried it, so the Assets tab's RECIPIENT column means
+ // the same thing for push as it does for email. Per-channel outcomes stay in the run log.
+ recipient,
+ subject: payload.title,
+ status: 'sent',
+ sent_at: isoMicroseconds(new Date()),
+ version: microsecondsSinceEpoch(),
+ is_deleted: 0,
+ html: renderPushPreviewHtml(payload),
+ }
+ }
+
queueInvocationResults(results: CyclotronJobInvocationResult[]): void {
for (const result of results) {
if (!result.emailAssets || result.emailAssets.length === 0) {
@@ -158,7 +239,13 @@ export class MessageAssetsService {
})
)
)
- counterMessageAssetsCaptured.inc({ kind: 'email' }, rows.length)
+ const capturedByKind = new Map<MessageAssetRow['kind'], number>()
+ for (const row of rows) {
+ capturedByKind.set(row.kind, (capturedByKind.get(row.kind) ?? 0) + 1)
+ }
+ for (const [kind, count] of capturedByKind) {
+ counterMessageAssetsCaptured.inc({ kind }, count)
+ }
} catch (error) {
counterMessageAssetsFailed.inc(rows.length)
logger.error('⚠️', `failed to flush message assets — dropping batch: ${error}`, {
diff --git a/nodejs/src/cdp/services/messaging/push-notification.service.test.ts b/nodejs/src/cdp/services/messaging/push-notification.service.test.ts
index 0fc85a36a877..1406c7a90eec 100644
--- a/nodejs/src/cdp/services/messaging/push-notification.service.test.ts
+++ b/nodejs/src/cdp/services/messaging/push-notification.service.test.ts
@@ -7,6 +7,7 @@ import { EncryptedFields } from '~/cdp/utils/encryption-utils'
import { parseJSON } from '~/common/utils/json-parse'
import { IntegrationManagerService } from '../managers/integration-manager.service'
+import { MessageAssetsService } from './message-assets.service'
import { PushNotificationFetchUtils, PushNotificationService } from './push-notification.service'
const encryptedFields = new EncryptedFields('01234567890123456789012345678901')
@@ -184,6 +185,123 @@ describe('PushNotificationService', () => {
expect(result.metrics).not.toContainEqual(expect.objectContaining({ metric_name: 'push_sent' }))
})
+ describe('message asset capture', () => {
+ let serviceWithAssets: PushNotificationService
+
+ const respondWith = (status: number): void => {
+ mockTrackedFetch.mockResolvedValue({
+ fetchError: null,
+ fetchResponse: {
+ status,
+ headers: {},
+ text: () => Promise.resolve('{}'),
+ dump: () => Promise.resolve(),
+ },
+ fetchDuration: 10,
+ })
+ }
+
+ beforeEach(() => {
+ serviceWithAssets = new PushNotificationService(
+ integrationManager,
+ encryptedFields,
+ fetchUtils,
+ mockRedis,
+ new MessageAssetsService({ produce: jest.fn() } as any)
+ )
+ })
+
+ // Guards the wiring between the send and the Assets tab, which the `buildRowForPush` unit
+ // tests can't see: drop the assets service from the constructor call in cdp-services.ts, or
+ // narrow the capture condition, and a delivered push stops producing a row while every
+ // other test here stays green.
+ it.each([
+ {
+ outcome: 'was delivered',
+ status: 200,
+ tokens: { '$device_push_subscription_test-project': 'device-token-123' },
+ captured: 'sent',
+ },
+ { outcome: 'reached no device', status: 200, tokens: {}, captured: 'nothing' },
+ {
+ outcome: 'failed terminally',
+ status: 400,
+ tokens: { '$device_push_subscription_test-project': 'device-token-123' },
+ captured: 'nothing',
+ },
+ ])('captures a push that $outcome as $captured', async ({ status, tokens, captured }) => {
+ respondWith(status)
+ const invocation = createSendPushNotificationInvocation(
+ Object.fromEntries(
+ Object.entries(tokens).map(([key, token]) => [key, encryptedFields.encrypt(token)])
+ )
+ )
+ invocation.state.actionId = 'action_push_1'
+
+ const result = await serviceWithAssets.executeSendPushNotification(invocation)
+
+ if (captured === 'nothing') {
+ // An asset is a snapshot of what a recipient received; a send that reached nobody
+ // has none, and email behaves the same way (it captures only on success).
+ expect(result.emailAssets).toEqual([])
+ return
+ }
+ expect(result.emailAssets).toHaveLength(1)
+ expect(result.emailAssets[0]).toMatchObject({
+ kind: 'push',
+ status: captured,
+ action_id: 'action_push_1',
+ subject: 'Test notification',
+ })
+ })
+
+ it('keeps a delivered notification successful when the capture itself throws', async () => {
+ // The send has already gone out at this point, so letting a capture failure surface
+ // would fail the invocation and the retry would deliver the notification again.
+ respondWith(200)
+ const invocation = createSendPushNotificationInvocation({
+ '$device_push_subscription_test-project': encryptedFields.encrypt('device-token-123'),
+ })
+ invocation.state.actionId = 'action_push_1'
+ const exploding = new PushNotificationService(
+ integrationManager,
+ encryptedFields,
+ fetchUtils,
+ mockRedis,
+ {
+ buildRowForPush: () => {
+ throw new Error('boom')
+ },
+ } as any
+ )
+
+ const result = await exploding.executeSendPushNotification(invocation)
+
+ expect(result.error).toBeUndefined()
+ expect(result.metrics).toContainEqual(expect.objectContaining({ metric_name: 'push_sent' }))
+ expect(result.emailAssets).toEqual([])
+ expect(result.logs.map((log) => log.message)).toContainEqual(
+ expect.stringContaining('could not be captured')
+ )
+ })
+
+ it('captures one asset per notification, not one per delivered channel', async () => {
+ respondWith(200)
+ integrationManager.get = jest
+ .fn()
+ .mockResolvedValue({ ...firebaseIntegration, kind: 'firebase' as const })
+ const invocation = createSendPushNotificationInvocation({
+ '$device_push_subscription_test-project': encryptedFields.encrypt('device-token-123'),
+ })
+ invocation.state.actionId = 'action_push_1'
+ ;(invocation.queueParameters as any).integrationIds = [1, 2]
+
+ const result = await serviceWithAssets.executeSendPushNotification(invocation)
+
+ expect(result.emailAssets).toHaveLength(1)
+ })
+ })
+
it('does not match tokens for a different app identifier', async () => {
const invocation = createSendPushNotificationInvocation({
'$device_push_subscription_other-project': encryptedFields.encrypt('other-token'),
diff --git a/nodejs/src/cdp/services/messaging/push-notification.service.ts b/nodejs/src/cdp/services/messaging/push-notification.service.ts
index 2158610d4b48..5fc2b4258cd4 100644
--- a/nodejs/src/cdp/services/messaging/push-notification.service.ts
+++ b/nodejs/src/cdp/services/messaging/push-notification.service.ts
@@ -9,6 +9,7 @@ import {
import { RedisV2 } from '~/common/redis/redis-v2'
import { instrumented } from '~/common/tracing/tracing-utils'
import { parseJSON } from '~/common/utils/json-parse'
+import { logger } from '~/common/utils/logger'
import { FetchOptions, FetchResponse } from '~/common/utils/request'
import type { CyclotronJobInvocationHogFunction, CyclotronJobInvocationResult, IntegrationType } from '../../types'
@@ -17,6 +18,7 @@ import { EncryptedFields } from '../../utils/encryption-utils'
import { createInvocationResult } from '../../utils/invocation-utils'
import { getDevicePushSubscriptionToken } from '../../utils/push-subscription-utils'
import { IntegrationManagerService } from '../managers/integration-manager.service'
+import { MessageAssetsService } from './message-assets.service'
import {
NormalizedPushError,
PushPlatform,
@@ -128,7 +130,8 @@ export class PushNotificationService {
private integrationManager: IntegrationManagerService,
private encryptedFields: EncryptedFields,
private fetchUtils: PushNotificationFetchUtils,
- private redis: RedisV2 | null
+ private redis: RedisV2 | null,
+ private messageAssetsService?: MessageAssetsService
) {}
@instrumented('push-notification.executeSendPushNotification')
@@ -184,6 +187,9 @@ export class PushNotificationService {
let otherErrorCount = 0
const errors: PushSendError[] = []
let firstError: string | undefined
+ // Which providers took delivery. Only its emptiness is read, to decide whether there is a
+ // delivered notification worth capturing.
+ const deliveredPlatforms = new Set<string>()
for (const integrationId of integrationIds) {
try {
const integration = await this.integrationManager.get(integrationId)
@@ -202,6 +208,7 @@ export class PushNotificationService {
if (sent) {
successCount++
+ deliveredPlatforms.add(integration.kind === 'firebase' ? 'Firebase' : 'APNs')
} else {
// A channel with no registered device token for this recipient is skipped, not failed.
skippedCount++
@@ -265,6 +272,27 @@ export class PushNotificationService {
pushMetric('push_sent', successCount)
pushMetric('push_skipped', skippedCount)
pushMetric('push_failed', errorCount)
+
+ // Captured at the terminal outcome for the same reason the business metrics are: a rescheduled
+ // attempt returns earlier, so a retried notification produces one asset rather than one per try.
+ // Only a delivered notification is captured, matching email: an asset is a snapshot of what a
+ // recipient received, and a skip has no recipient. Skips stay visible as `push_skipped` plus the
+ // per-channel run log explaining why.
+ if (this.messageAssetsService && successCount > 0) {
+ // Best-effort: the notification is already delivered by this point, so a capture failure
+ // must not fail the invocation. Throwing here would send the whole batch back for a retry
+ // and deliver every notification in it a second time. Losing an Assets row is the cheaper
+ // outcome, and it is the same trade the flush path already makes on a Kafka failure.
+ try {
+ const assetRow = this.messageAssetsService.buildRowForPush(invocation, params, [...deliveredPlatforms])
+ if (assetRow) {
+ result.emailAssets.push(assetRow)
+ }
+ } catch (err) {
+ addLog('warn', 'The notification was delivered but could not be captured for the Assets tab.')
+ logger.warn('⚠️', `failed to capture a sent push notification: ${err}`, { error: String(err) })
+ }
+ }
for (const error of errors) {
pushNotificationFailedCounter.labels({ platform: error.platform, reason: error.reason }).inc()
}
diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.ts
index 4146e054fd2b..0da69755902f 100644
--- a/nodejs/src/cdp/types.ts
+++ b/nodejs/src/cdp/types.ts
@@ -574,11 +574,17 @@ export type MessageAssetRow = {
parent_run_id: string
invocation_id: string
action_id: string
- kind: 'email'
+ kind: 'email' | 'push'
distinct_id: string
person_id: string
+ // Where the message went: the address for email. Push has no address, so this carries the
+ // recipient's distinct_id instead. The delivering channels are deliberately not stored here,
+ // because the captured preview is a snapshot of what the recipient saw and they never saw those.
recipient: string
+ // The message's headline: an email subject line, or a push notification title.
subject: string
+ // Only delivered messages are captured, so this is 'sent' today. It stays a union because open
+ // tracking will write a higher-version row with its own status and collapse onto this one.
status: 'sent'
sent_at: string // ISO microsecond DateTime64
version: string // microsecond-precision UInt64, serialized as string to dodge JS's 53-bit cap
diff --git a/products/persons/frontend/generated/api.schemas.ts b/products/persons/frontend/generated/api.schemas.ts
index cb7e001f1f15..1c997e43a773 100644
--- a/products/persons/frontend/generated/api.schemas.ts
+++ b/products/persons/frontend/generated/api.schemas.ts
@@ -257,19 +257,19 @@ export interface MessageAssetApi {
function_name: string
/** The batch run this email belongs to, for batch-triggered workflows. Empty for event-triggered runs. */
parent_run_id: string
- /** Asset kind. Currently always 'email'. */
+ /** Message channel this asset was sent on: 'email' or 'push'. The per-person endpoint currently returns only 'email'. */
kind: string
/** The recipient's distinct_id. */
distinct_id: string
/** The recipient's person UUID, if resolved. */
person_id: string
- /** The recipient email address. */
+ /** Who the message went to: the email address for 'email', or the recipient's distinct ID for 'push'. */
recipient: string
- /** The email subject line. */
+ /** The email subject line, or the push notification title. */
subject: string
- /** Delivery status at capture time. Currently always 'sent'. */
+ /** Delivery status at capture time. Currently always 'sent' - only delivered messages are captured. */
status: string
- /** When the email was sent. */
+ /** When the message was sent. */
sent_at: string
}
diff --git a/products/workflows/backend/api/message_assets.py b/products/workflows/backend/api/message_assets.py
index 0f89cf00fbbc..dffe72dd722c 100644
--- a/products/workflows/backend/api/message_assets.py
+++ b/products/workflows/backend/api/message_assets.py
@@ -74,13 +74,20 @@ class MessageAssetSerializer(serializers.Serializer):
parent_run_id = serializers.CharField(
help_text="The batch run this email belongs to, for batch-triggered workflows. Empty for event-triggered runs."
)
- kind = serializers.CharField(help_text="Asset kind. Currently always 'email'.")
+ kind = serializers.CharField(
+ help_text="Message channel this asset was sent on: 'email' or 'push'. The per-person endpoint "
+ "currently returns only 'email'."
+ )
distinct_id = serializers.CharField(help_text="The recipient's distinct_id.")
person_id = serializers.CharField(help_text="The recipient's person UUID, if resolved.")
- recipient = serializers.CharField(help_text="The recipient email address.")
- subject = serializers.CharField(help_text="The email subject line.")
- status = serializers.CharField(help_text="Delivery status at capture time. Currently always 'sent'.")
- sent_at = serializers.DateTimeField(help_text="When the email was sent.")
+ recipient = serializers.CharField(
+ help_text="Who the message went to: the email address for 'email', or the recipient's distinct ID for 'push'."
+ )
+ subject = serializers.CharField(help_text="The email subject line, or the push notification title.")
+ status = serializers.CharField(
+ help_text="Delivery status at capture time. Currently always 'sent' - only delivered messages are captured."
+ )
+ sent_at = serializers.DateTimeField(help_text="When the message was sent.")
class MessageAssetsRequestSerializer(serializers.Serializer):
@@ -267,6 +274,10 @@ def fetch_message_assets_for_person(
# Standalone hog_function email destinations aren't surfaced anywhere yet,
# so this endpoint only returns workflow-step rows.
"function_kind = 'hog_flow'",
+ # Push assets are captured but not yet surfaced: this backs the person Emails tab, and a push
+ # rendered as an email row would misrepresent it. Drop this filter when that tab becomes a
+ # combined Messages view.
+ "kind = 'email'",
]
kwargs: dict[str, Any] = {
"team_id": team_id,
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index d5cd5076fdeb..b9a86dc7f783 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -636,19 +636,19 @@ export interface MessageAssetApi {
function_name: string
/** The batch run this email belongs to, for batch-triggered workflows. Empty for event-triggered runs. */
parent_run_id: string
- /** Asset kind. Currently always 'email'. */
+ /** Message channel this asset was sent on: 'email' or 'push'. The per-person endpoint currently returns only 'email'. */
kind: string
/** The recipient's distinct_id. */
distinct_id: string
/** The recipient's person UUID, if resolved. */
person_id: string
- /** The recipient email address. */
+ /** Who the message went to: the email address for 'email', or the recipient's distinct ID for 'push'. */
recipient: string
- /** The email subject line. */
+ /** The email subject line, or the push notification title. */
subject: string
- /** Delivery status at capture time. Currently always 'sent'. */
+ /** Delivery status at capture time. Currently always 'sent' - only delivered messages are captured. */
status: string
- /** When the email was sent. */
+ /** When the message was sent. */
sent_at: string
}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 3e8bd063f2c4..5681cd0cb4f5 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -40427,19 +40427,19 @@ export namespace Schemas {
function_name: string;
/** The batch run this email belongs to, for batch-triggered workflows. Empty for event-triggered runs. */
parent_run_id: string;
- /** Asset kind. Currently always 'email'. */
+ /** Message channel this asset was sent on: 'email' or 'push'. The per-person endpoint currently returns only 'email'. */
kind: string;
/** The recipient's distinct_id. */
distinct_id: string;
/** The recipient's person UUID, if resolved. */
person_id: string;
- /** The recipient email address. */
+ /** Who the message went to: the email address for 'email', or the recipient's distinct ID for 'push'. */
recipient: string;
- /** The email subject line. */
+ /** The email subject line, or the push notification title. */
subject: string;
- /** Delivery status at capture time. Currently always 'sent'. */
+ /** Delivery status at capture time. Currently always 'sent' - only delivered messages are captured. */
status: string;
- /** When the email was sent. */
+ /** When the message was sent. */
sent_at: string;
}