: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(cdp): let a marketing email step skip the frequency cap (#124979)
Harley Alexanderf66fd077a802
diff --git a/nodejs/src/cdp/schema/hogflow.ts b/nodejs/src/cdp/schema/hogflow.tsindex f1481b1034b1..c55cb6f4a18c 100644--- a/nodejs/src/cdp/schema/hogflow.ts+++ b/nodejs/src/cdp/schema/hogflow.ts@@ -249,6 +249,10 @@ export const HogFlowActionSchema = z.discriminatedUnion('type', [sensitive: z.boolean().optional(),// When true, links get utm_source, utm_medium and utm_campaign tags they don't already carry.utm_tags_enabled: z.boolean().optional(),+ // When true, a marketing send ignores the team's frequency cap and takes no slot under it. Opt-outs+ // and unsubscribe headers still apply. For product email that is marketing in form but must not+ // crowd out, or be crowded out by, other marketing email.+ skip_frequency_cap: z.boolean().optional(),// Liquid templates that replace the default tag values. An empty value keeps the default.utm_params: z.object({diff --git a/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts b/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.tsindex b0edc411d6d0..cbf2c8b716d3 100644--- a/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts+++ b/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts@@ -665,7 +665,8 @@ describe('RecipientPreferencesService', () => {let persons: { getCyclotronPerson: jest.Mock }const emailAction = (- categoryType?: 'marketing' | 'transactional'+ categoryType?: 'marketing' | 'transactional',+ skipFrequencyCap?: boolean): Extract<HogFlowAction, { type: 'function_email' }> => ({id: 'email',name: 'Send email',@@ -675,6 +676,7 @@ describe('RecipientPreferencesService', () => {config: {template_id: 'template-email',message_category_type: categoryType,+ skip_frequency_cap: skipFrequencyCap,inputs: { email: { value: { to: { email: '[email protected]' } } } },},created_at: Date.now(),@@ -768,6 +770,7 @@ describe('RecipientPreferencesService', () => {it.each([['transactional sends', emailAction('transactional'), { max_messages: 0, window_days: 7 }],+ ['marketing sends that skip the cap', emailAction('marketing', true), { max_messages: 1, window_days: 7 }],['teams with no cap', emailAction(), { max_messages: null, window_days: null }],])('never caps %s', async (_, action, cap) => {frequencyCap = capdiff --git a/nodejs/src/cdp/services/messaging/recipient-preferences.service.ts b/nodejs/src/cdp/services/messaging/recipient-preferences.service.tsindex 6ccf81b71427..71c21a054a7f 100644--- a/nodejs/src/cdp/services/messaging/recipient-preferences.service.ts+++ b/nodejs/src/cdp/services/messaging/recipient-preferences.service.ts@@ -48,7 +48,12 @@ export class RecipientPreferencesService {action: HogFlowAction): Promise<boolean> {const messageAction = this.asMessageAction(action)- if (!this.frequencyCap || !messageAction || messageAction.config.message_category_type === 'transactional') {+ if (+ !this.frequencyCap ||+ !messageAction ||+ messageAction.config.message_category_type === 'transactional' ||+ (messageAction.type === 'function_email' && messageAction.config.skip_frequency_cap === true)+ ) {return false}try {