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(cdp): add beehiiv realtime destination (#101541)

Daniel Marchukbc63ecb4d751
diff --git a/nodejs/src/cdp/templates/_destinations/beehiiv/beehiiv.template.test.ts b/nodejs/src/cdp/templates/_destinations/beehiiv/beehiiv.template.test.ts
new file mode 100644
index 000000000000..993a66c4298e
--- /dev/null
+++ b/nodejs/src/cdp/templates/_destinations/beehiiv/beehiiv.template.test.ts
@@ -0,0 +1,303 @@
+import { parseJSON } from '~/common/utils/json-parse'
+
+import { TemplateTester } from '../../test/test-helpers'
+import { template } from './beehiiv.template'
+
+const PUBLICATION_ID = 'pub_00000000-0000-0000-0000-000000000000'
+const EMAIL = '[email protected]'
+const COLLECTION_URL = `https://api.beehiiv.com/v2/publications/${PUBLICATION_ID}/subscriptions`
+const SUBSCRIPTION_URL = `${COLLECTION_URL}/by_email/max%2Bnewsletter%40posthog.com`
+
+const EXPECTED_HEADERS = {
+ Authorization: 'Bearer API_KEY',
+ 'Content-Type': 'application/json',
+}
+
+const defaultInputs = {
+ apiKey: 'API_KEY',
+ publicationId: PUBLICATION_ID,
+ email: EMAIL,
+ customFields: {
+ 'First Name': 'Max',
+ 'Last Name': 'AI',
+ Empty: '',
+ },
+ sendWelcomeEmail: false,
+ reactivateExisting: false,
+ utmSource: 'posthog',
+ utmMedium: 'product',
+ utmCampaign: 'newsletter-launch',
+ utmTerm: 'product-analytics',
+ utmContent: 'upgrade-cta',
+ referringSite: 'https://posthog.com/blog',
+}
+
+const parseBody = (invocation: any): Record<string, any> => {
+ return parseJSON(invocation.queueParameters.body)
+}
+
+describe('beehiiv template', () => {
+ const tester = new TemplateTester(template)
+
+ beforeEach(async () => {
+ await tester.beforeEach()
+ })
+
+ it('creates a subscriber when no subscription matches the email', async () => {
+ const lookupRequest = await tester.invoke(defaultInputs, {})
+
+ expect(lookupRequest.error).toBeUndefined()
+ expect(lookupRequest.finished).toBe(false)
+ expect(lookupRequest.invocation.queueParameters).toEqual({
+ type: 'fetch',
+ url: SUBSCRIPTION_URL,
+ method: 'GET',
+ headers: EXPECTED_HEADERS,
+ })
+
+ const createRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 404,
+ body: { errors: [{ message: 'Subscription not found' }] },
+ })
+
+ expect(createRequest.finished).toBe(false)
+ expect(createRequest.invocation.queueParameters).toMatchObject({
+ type: 'fetch',
+ url: COLLECTION_URL,
+ method: 'POST',
+ headers: EXPECTED_HEADERS,
+ })
+ expect(parseBody(createRequest.invocation)).toEqual({
+ email: EMAIL,
+ reactivate_existing: false,
+ send_welcome_email: false,
+ utm_source: 'posthog',
+ utm_medium: 'product',
+ utm_campaign: 'newsletter-launch',
+ utm_term: 'product-analytics',
+ utm_content: 'upgrade-cta',
+ referring_site: 'https://posthog.com/blog',
+ custom_fields: [
+ { name: 'First Name', value: 'Max' },
+ { name: 'Last Name', value: 'AI' },
+ ],
+ })
+
+ const done = await tester.invokeFetchResponse(createRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL } },
+ })
+
+ expect(done.error).toBeUndefined()
+ expect(done.finished).toBe(true)
+ expect(
+ done.logs.some((log) => log.message.includes(`Successfully created beehiiv subscription ${EMAIL}`))
+ ).toBe(true)
+ })
+
+ it('updates custom fields for an existing subscriber', async () => {
+ const lookupRequest = await tester.invoke(defaultInputs, {})
+ const updateRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL, status: 'active' } },
+ })
+
+ expect(updateRequest.finished).toBe(false)
+ expect(updateRequest.invocation.queueParameters).toMatchObject({
+ type: 'fetch',
+ url: SUBSCRIPTION_URL,
+ method: 'PUT',
+ headers: EXPECTED_HEADERS,
+ })
+ expect(parseBody(updateRequest.invocation)).toEqual({
+ custom_fields: [
+ { name: 'First Name', value: 'Max' },
+ { name: 'Last Name', value: 'AI' },
+ ],
+ })
+
+ const done = await tester.invokeFetchResponse(updateRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL } },
+ })
+
+ expect(done.error).toBeUndefined()
+ expect(done.finished).toBe(true)
+ })
+
+ it('leaves an unsubscribed subscriber unsubscribed when reactivation is off', async () => {
+ const lookupRequest = await tester.invoke({ ...defaultInputs, reactivateExisting: false }, {})
+ const updateRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL, status: 'inactive' } },
+ })
+
+ expect(updateRequest.invocation.queueParameters).toMatchObject({
+ url: SUBSCRIPTION_URL,
+ method: 'PUT',
+ })
+ expect(parseBody(updateRequest.invocation)).not.toHaveProperty('unsubscribe')
+ })
+
+ it('reactivates an unsubscribed subscriber through the create endpoint when enabled', async () => {
+ const inputs = { ...defaultInputs, reactivateExisting: true }
+ const lookupRequest = await tester.invoke(inputs, {})
+ const reactivateRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL, status: 'inactive' } },
+ })
+
+ expect(reactivateRequest.invocation.queueParameters).toMatchObject({
+ type: 'fetch',
+ url: COLLECTION_URL,
+ method: 'POST',
+ })
+ expect(parseBody(reactivateRequest.invocation)).toMatchObject({
+ email: EMAIL,
+ reactivate_existing: true,
+ })
+
+ const updateRequest = await tester.invokeFetchResponse(reactivateRequest.invocation, {
+ status: 201,
+ body: { data: { id: 'sub_123', email: EMAIL, status: 'active' } },
+ })
+
+ expect(updateRequest.invocation.queueParameters).toMatchObject({
+ url: SUBSCRIPTION_URL,
+ method: 'PUT',
+ })
+ expect(parseBody(updateRequest.invocation)).toEqual({
+ custom_fields: [
+ { name: 'First Name', value: 'Max' },
+ { name: 'Last Name', value: 'AI' },
+ ],
+ })
+ })
+
+ it.each(['active', 'validating', 'invalid'])(
+ 'goes straight to the update for a %s subscriber when reactivation is enabled',
+ async (status) => {
+ const lookupRequest = await tester.invoke({ ...defaultInputs, reactivateExisting: true }, {})
+ const updateRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL, status } },
+ })
+
+ expect(updateRequest.invocation.queueParameters).toMatchObject({
+ url: SUBSCRIPTION_URL,
+ method: 'PUT',
+ })
+ }
+ )
+
+ it('asks the create endpoint to reactivate a missing subscriber when enabled', async () => {
+ const missingLookupRequest = await tester.invoke({ ...defaultInputs, reactivateExisting: true }, {})
+ const createRequest = await tester.invokeFetchResponse(missingLookupRequest.invocation, {
+ status: 404,
+ body: {},
+ })
+ expect(parseBody(createRequest.invocation)).toMatchObject({ reactivate_existing: true })
+ })
+
+ it('skips an existing subscriber when there are no fields to update', async () => {
+ const lookupRequest = await tester.invoke({ ...defaultInputs, customFields: {} }, {})
+ const response = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL, status: 'active' } },
+ })
+
+ expect(response.error).toBeUndefined()
+ expect(response.finished).toBe(true)
+ expect(response.invocation.queueParameters).toBeFalsy()
+ expect(
+ response.logs.some((log) =>
+ log.message.includes('Subscription already exists and there are no fields to update. Skipping...')
+ )
+ ).toBe(true)
+ })
+
+ it('runs when the custom field mapping is missing from the inputs', async () => {
+ const { customFields: _omitted, ...inputsWithoutMapping } = defaultInputs
+ const lookupRequest = await tester.invoke({ ...inputsWithoutMapping, customFields: null }, {})
+
+ expect(lookupRequest.error).toBeUndefined()
+ expect(lookupRequest.invocation.queueParameters).toMatchObject({
+ url: SUBSCRIPTION_URL,
+ method: 'GET',
+ })
+
+ const createRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 404,
+ body: {},
+ })
+
+ expect(createRequest.error).toBeUndefined()
+ expect(parseBody(createRequest.invocation)).not.toHaveProperty('custom_fields')
+ })
+
+ it('skips when email is empty', async () => {
+ const response = await tester.invoke({ ...defaultInputs, email: '' }, {})
+
+ expect(response.error).toBeUndefined()
+ expect(response.finished).toBe(true)
+ expect(response.invocation.queueParameters).toBeFalsy()
+ expect(response.logs.some((log) => log.message.includes('No email set. Skipping...'))).toBe(true)
+ })
+
+ it('throws when the subscriber lookup fails', async () => {
+ const lookupRequest = await tester.invoke(defaultInputs, {})
+ const errorResponse = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 401,
+ body: { errors: [{ message: 'Unauthorized' }] },
+ })
+
+ expect(errorResponse.finished).toBe(true)
+ expect(errorResponse.error).toMatch('Error looking up beehiiv subscription (status 401)')
+ })
+
+ it('throws when subscriber creation fails', async () => {
+ const lookupRequest = await tester.invoke(defaultInputs, {})
+ const createRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 404,
+ body: {},
+ })
+ const errorResponse = await tester.invokeFetchResponse(createRequest.invocation, {
+ status: 400,
+ body: { errors: [{ message: 'Invalid email' }] },
+ })
+
+ expect(errorResponse.finished).toBe(true)
+ expect(errorResponse.error).toMatch('Error creating beehiiv subscription (status 400)')
+ })
+
+ it('throws when reactivation fails, before any field update', async () => {
+ const lookupRequest = await tester.invoke({ ...defaultInputs, reactivateExisting: true }, {})
+ const reactivateRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL, status: 'inactive' } },
+ })
+ const errorResponse = await tester.invokeFetchResponse(reactivateRequest.invocation, {
+ status: 400,
+ body: { errors: [{ message: 'Invalid email' }] },
+ })
+
+ expect(errorResponse.finished).toBe(true)
+ expect(errorResponse.error).toMatch('Error reactivating beehiiv subscription (status 400)')
+ expect(errorResponse.invocation.queueParameters).toBeFalsy()
+ })
+
+ it('throws when subscriber update fails', async () => {
+ const lookupRequest = await tester.invoke(defaultInputs, {})
+ const updateRequest = await tester.invokeFetchResponse(lookupRequest.invocation, {
+ status: 200,
+ body: { data: { id: 'sub_123', email: EMAIL } },
+ })
+ const errorResponse = await tester.invokeFetchResponse(updateRequest.invocation, {
+ status: 429,
+ body: { errors: [{ message: 'Rate limit exceeded' }] },
+ })
+
+ expect(errorResponse.finished).toBe(true)
+ expect(errorResponse.error).toMatch('Error updating beehiiv subscription (status 429)')
+ })
+})
diff --git a/nodejs/src/cdp/templates/_destinations/beehiiv/beehiiv.template.ts b/nodejs/src/cdp/templates/_destinations/beehiiv/beehiiv.template.ts
new file mode 100644
index 000000000000..d983493fece4
--- /dev/null
+++ b/nodejs/src/cdp/templates/_destinations/beehiiv/beehiiv.template.ts
@@ -0,0 +1,237 @@
+import { HogFunctionTemplate } from '~/cdp/types'
+
+export const template: HogFunctionTemplate = {
+ status: 'alpha',
+ free: false,
+ type: 'destination',
+ id: 'template-beehiiv',
+ name: 'beehiiv',
+ description: 'Sync PostHog persons to beehiiv as subscribers',
+ icon_url: '/static/services/beehiiv.png',
+ category: ['User Engagement Platforms'],
+ code_language: 'hog',
+ code: `
+if (empty(inputs.email)) {
+ print('No email set. Skipping...')
+ return
+}
+
+let headers := {
+ 'Authorization': f'Bearer {inputs.apiKey}',
+ 'Content-Type': 'application/json'
+}
+
+let customFields := []
+for (let name, value in inputs.customFields ?? {}) {
+ if (not empty(name) and not empty(value)) {
+ customFields := arrayPushBack(customFields, {
+ 'name': name,
+ 'value': value
+ })
+ }
+}
+
+let encodedEmail := encodeURLComponent(inputs.email)
+let subscriptionUrl := f'https://api.beehiiv.com/v2/publications/{inputs.publicationId}/subscriptions/by_email/{encodedEmail}'
+let getRes := fetch(subscriptionUrl, {
+ 'method': 'GET',
+ 'headers': headers
+})
+
+if (getRes.status == 404) {
+ let createBody := {
+ 'email': inputs.email,
+ 'reactivate_existing': inputs.reactivateExisting,
+ 'send_welcome_email': inputs.sendWelcomeEmail
+ }
+
+ if (not empty(inputs.utmSource)) createBody.utm_source := inputs.utmSource
+ if (not empty(inputs.utmMedium)) createBody.utm_medium := inputs.utmMedium
+ if (not empty(inputs.utmCampaign)) createBody.utm_campaign := inputs.utmCampaign
+ if (not empty(inputs.utmTerm)) createBody.utm_term := inputs.utmTerm
+ if (not empty(inputs.utmContent)) createBody.utm_content := inputs.utmContent
+ if (not empty(inputs.referringSite)) createBody.referring_site := inputs.referringSite
+ if (not empty(customFields)) createBody.custom_fields := customFields
+
+ let createRes := fetch(f'https://api.beehiiv.com/v2/publications/{inputs.publicationId}/subscriptions', {
+ 'method': 'POST',
+ 'headers': headers,
+ 'body': createBody
+ })
+
+ if (createRes.status >= 400) {
+ throw Error(f'Error creating beehiiv subscription (status {createRes.status}): {createRes.body}')
+ }
+
+ print(f'Successfully created beehiiv subscription {inputs.email}')
+ return
+}
+
+if (getRes.status >= 400) {
+ throw Error(f'Error looking up beehiiv subscription (status {getRes.status}): {getRes.body}')
+}
+
+// beehiiv ignores 'unsubscribe' on the update endpoint. Only a create call with
+// reactivate_existing brings an unsubscribed subscriber back. Other non-active
+// statuses (validating, invalid) must not go through here.
+if (inputs.reactivateExisting and getRes.body.data.status == 'inactive') {
+ let reactivateRes := fetch(f'https://api.beehiiv.com/v2/publications/{inputs.publicationId}/subscriptions', {
+ 'method': 'POST',
+ 'headers': headers,
+ 'body': {
+ 'email': inputs.email,
+ 'reactivate_existing': true,
+ 'send_welcome_email': inputs.sendWelcomeEmail
+ }
+ })
+
+ if (reactivateRes.status >= 400) {
+ throw Error(f'Error reactivating beehiiv subscription (status {reactivateRes.status}): {reactivateRes.body}')
+ }
+
+ print(f'Successfully reactivated beehiiv subscription {inputs.email}')
+}
+
+let updateBody := {}
+if (not empty(customFields)) updateBody.custom_fields := customFields
+
+if (empty(updateBody)) {
+ print('Subscription already exists and there are no fields to update. Skipping...')
+ return
+}
+
+let updateRes := fetch(subscriptionUrl, {
+ 'method': 'PUT',
+ 'headers': headers,
+ 'body': updateBody
+})
+
+if (updateRes.status >= 400) {
+ throw Error(f'Error updating beehiiv subscription (status {updateRes.status}): {updateRes.body}')
+}
+
+print(f'Successfully updated beehiiv subscription {inputs.email}')
+`,
+ inputs_schema: [
+ {
+ key: 'apiKey',
+ type: 'string',
+ label: 'API key',
+ description:
+ 'Create an API key in beehiiv under Settings > Workspace Settings > API. The key must have access to the selected publication.',
+ secret: true,
+ required: true,
+ },
+ {
+ key: 'publicationId',
+ type: 'string',
+ label: 'Publication ID',
+ description: 'The beehiiv publication ID, beginning with `pub_`.',
+ secret: false,
+ required: true,
+ },
+ {
+ key: 'email',
+ type: 'string',
+ label: 'Email',
+ description: 'Email address used to find, create, or update the beehiiv subscription.',
+ default: '{person.properties.email ?? event.properties.email}',
+ secret: false,
+ required: true,
+ },
+ {
+ key: 'customFields',
+ type: 'dictionary',
+ label: 'Custom field mapping',
+ description:
+ 'Map existing beehiiv custom field names to PostHog values. Unknown beehiiv custom fields are ignored by the beehiiv API.',
+ default: {
+ 'First Name': '{person.properties.first_name}',
+ 'Last Name': '{person.properties.last_name}',
+ },
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'sendWelcomeEmail',
+ type: 'boolean',
+ label: 'Send welcome email',
+ description: 'Send the publication welcome email when a new subscription is created.',
+ default: false,
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'reactivateExisting',
+ type: 'boolean',
+ label: 'Reactivate existing subscription',
+ description:
+ 'Reactivate a previously unsubscribed subscriber. Enable this only when the person has knowingly requested to resubscribe.',
+ default: false,
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'utmSource',
+ type: 'string',
+ label: 'UTM source',
+ description: 'Acquisition source applied when a subscription is first created.',
+ default: 'posthog',
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'utmMedium',
+ type: 'string',
+ label: 'UTM medium',
+ description: 'Acquisition medium applied when a subscription is first created.',
+ default: '{event.properties.utm_medium}',
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'utmCampaign',
+ type: 'string',
+ label: 'UTM campaign',
+ description: 'Acquisition campaign applied when a subscription is first created.',
+ default: '{event.properties.utm_campaign}',
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'utmTerm',
+ type: 'string',
+ label: 'UTM term',
+ description: 'Acquisition term applied when a subscription is first created.',
+ default: '{event.properties.utm_term}',
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'utmContent',
+ type: 'string',
+ label: 'UTM content',
+ description: 'Acquisition content applied when a subscription is first created.',
+ default: '{event.properties.utm_content}',
+ secret: false,
+ required: false,
+ },
+ {
+ key: 'referringSite',
+ type: 'string',
+ label: 'Referring site',
+ description: 'Referring URL applied when a subscription is first created.',
+ default: '{event.properties.$referrer}',
+ secret: false,
+ required: false,
+ },
+ ],
+ filters: {
+ events: [
+ { id: '$identify', name: '$identify', type: 'events', order: 0 },
+ { id: '$set', name: '$set', type: 'events', order: 1 },
+ ],
+ actions: [],
+ filter_test_accounts: true,
+ },
+}
diff --git a/nodejs/src/cdp/templates/index.ts b/nodejs/src/cdp/templates/index.ts
index 167c8c8bd161..e785f0cb41ef 100644
--- a/nodejs/src/cdp/templates/index.ts
+++ b/nodejs/src/cdp/templates/index.ts
@@ -3,6 +3,7 @@ import { SEGMENT_DESTINATIONS } from '../segment/segment-templates'
import { HogFunctionTemplate, NativeTemplate } from '../types'
import { template as accoilTemplate } from './_destinations/accoil/accoil.template'
import { template as appcuesTemplate } from './_destinations/appcues/appcues.template'
+import { template as beehiivTemplate } from './_destinations/beehiiv/beehiiv.template'
import { template as clickupTemplate } from './_destinations/clickup/clickup.template'
import { template as closeTemplate } from './_destinations/close/close.template'
import { allComingSoonTemplates } from './_destinations/coming-soon/coming-soon-destinations.template'
@@ -94,6 +95,7 @@ export const HOG_FUNCTION_TEMPLATES_DESTINATIONS: HogFunctionTemplate[] = [
googleTagManagerTemplate,
emailTemplate,
pushTemplate,
+ beehiivTemplate,
clickupTemplate,
posthogCaptureTemplate,
posthogGroupIdentifyTemplate,
diff --git a/nodejs/tests/fixtures/hog-bytecode/2c19db04e9dd4b9ca07ddc34e00daeae5ccee50ae0abdbd92e28c79f45be3536.json b/nodejs/tests/fixtures/hog-bytecode/2c19db04e9dd4b9ca07ddc34e00daeae5ccee50ae0abdbd92e28c79f45be3536.json
new file mode 100644
index 000000000000..0e33e573092b
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/2c19db04e9dd4b9ca07ddc34e00daeae5ccee50ae0abdbd92e28c79f45be3536.json
@@ -0,0 +1 @@
+["_H",1,32,"newsletter-launch",38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/90f62f8e54e2e0b771e75a9774cafce6e4cc22d8c24064f84966cdedcbc2298c.json b/nodejs/tests/fixtures/hog-bytecode/90f62f8e54e2e0b771e75a9774cafce6e4cc22d8c24064f84966cdedcbc2298c.json
new file mode 100644
index 000000000000..6dcc4a366e85
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/90f62f8e54e2e0b771e75a9774cafce6e4cc22d8c24064f84966cdedcbc2298c.json
@@ -0,0 +1 @@
+["_H",1,32,"product-analytics",38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/a55c958f1e370bb1f9e2b681bfffe10a166eab52a1814e14743fd9233cf5b7a7.json b/nodejs/tests/fixtures/hog-bytecode/a55c958f1e370bb1f9e2b681bfffe10a166eab52a1814e14743fd9233cf5b7a7.json
new file mode 100644
index 000000000000..b04d5a95a059
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/a55c958f1e370bb1f9e2b681bfffe10a166eab52a1814e14743fd9233cf5b7a7.json
@@ -0,0 +1 @@
+["_H",1,32,"https://posthog.com/blog",38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/bc516e6a310b5ab58f4a210698da1d9d836e4fedb70c02796cc9b9a610d134c8.json b/nodejs/tests/fixtures/hog-bytecode/bc516e6a310b5ab58f4a210698da1d9d836e4fedb70c02796cc9b9a610d134c8.json
new file mode 100644
index 000000000000..5d57cb9be16e
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/bc516e6a310b5ab58f4a210698da1d9d836e4fedb70c02796cc9b9a610d134c8.json
@@ -0,0 +1 @@
+["_H",1,32,"pub_00000000-0000-0000-0000-000000000000",38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/c150d40ac10779445fe439fc042fccc5bb31e01cf703ff15a94f75da47080dfe.json b/nodejs/tests/fixtures/hog-bytecode/c150d40ac10779445fe439fc042fccc5bb31e01cf703ff15a94f75da47080dfe.json
new file mode 100644
index 000000000000..61ef0f6941e3
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/c150d40ac10779445fe439fc042fccc5bb31e01cf703ff15a94f75da47080dfe.json
@@ -0,0 +1 @@
+["_H",1,32,"email",32,"inputs",1,2,2,"empty",1,40,8,32,"No email set. Skipping...",2,"print",1,35,31,38,32,"Authorization",32,"Bearer ",32,"apiKey",32,"inputs",1,2,2,"concat",2,32,"Content-Type",32,"application/json",42,2,43,0,32,"customFields",32,"inputs",1,2,47,3,35,42,0,36,2,2,"keys",1,36,2,2,"values",1,33,1,36,4,2,"length",1,31,31,36,6,36,5,16,40,56,36,3,36,5,45,37,7,36,4,36,5,45,37,8,36,7,2,"empty",1,5,36,8,2,"empty",1,5,3,2,40,17,36,1,32,"name",36,7,32,"value",36,8,42,2,2,"arrayPushBack",2,37,1,36,5,33,1,6,37,5,39,-63,35,35,35,35,35,35,35,32,"email",32,"inputs",1,2,2,"encodeURLComponent",1,32,"https://api.beehiiv.com/v2/publications/",32,"publicationId",32,"inputs",1,2,32,"/subscriptions/by_email/",36,2,2,"concat",4,36,3,32,"method",32,"GET",32,"headers",36,0,42,2,2,"fetch",2,33,404,36,4,32,"status",45,11,40,259,32,"email",32,"email",32,"inputs",1,2,32,"reactivate_existing",32,"reactivateExisting",32,"inputs",1,2,32,"send_welcome_email",32,"sendWelcomeEmail",32,"inputs",1,2,42,3,32,"utmSource",32,"inputs",1,2,2,"empty",1,5,40,11,36,5,32,"utm_source",32,"utmSource",32,"inputs",1,2,46,32,"utmMedium",32,"inputs",1,2,2,"empty",1,5,40,11,36,5,32,"utm_medium",32,"utmMedium",32,"inputs",1,2,46,32,"utmCampaign",32,"inputs",1,2,2,"empty",1,5,40,11,36,5,32,"utm_campaign",32,"utmCampaign",32,"inputs",1,2,46,32,"utmTerm",32,"inputs",1,2,2,"empty",1,5,40,11,36,5,32,"utm_term",32,"utmTerm",32,"inputs",1,2,46,32,"utmContent",32,"inputs",1,2,2,"empty",1,5,40,11,36,5,32,"utm_content",32,"utmContent",32,"inputs",1,2,46,32,"referringSite",32,"inputs",1,2,2,"empty",1,5,40,11,36,5,32,"referring_site",32,"referringSite",32,"inputs",1,2,46,36,1,2,"empty",1,5,40,7,36,5,32,"custom_fields",36,1,46,32,"https://api.beehiiv.com/v2/publications/",32,"publicationId",32,"inputs",1,2,32,"/subscriptions",2,"concat",3,32,"method",32,"POST",32,"headers",36,0,32,"body",36,5,42,3,2,"fetch",2,33,400,36,6,32,"status",45,14,40,21,32,"Error creating beehiiv subscription (status ",36,6,32,"status",45,32,"): ",36,6,32,"body",45,2,"concat",4,2,"Error",1,49,32,"Successfully created beehiiv subscription ",32,"email",32,"inputs",1,2,2,"concat",2,2,"print",1,35,31,38,35,35,33,400,36,4,32,"status",45,14,40,21,32,"Error looking up beehiiv subscription (status ",36,4,32,"status",45,32,"): ",36,4,32,"body",45,2,"concat",4,2,"Error",1,49,32,"reactivateExisting",32,"inputs",1,2,32,"inactive",36,4,32,"body",45,32,"data",45,32,"status",45,11,3,2,40,96,32,"https://api.beehiiv.com/v2/publications/",32,"publicationId",32,"inputs",1,2,32,"/subscriptions",2,"concat",3,32,"method",32,"POST",32,"headers",36,0,32,"body",32,"email",32,"email",32,"inputs",1,2,32,"reactivate_existing",29,32,"send_welcome_email",32,"sendWelcomeEmail",32,"inputs",1,2,42,3,42,3,2,"fetch",2,33,400,36,5,32,"status",45,14,40,21,32,"Error reactivating beehiiv subscription (status ",36,5,32,"status",45,32,"): ",36,5,32,"body",45,2,"concat",4,2,"Error",1,49,32,"Successfully reactivated beehiiv subscription ",32,"email",32,"inputs",1,2,2,"concat",2,2,"print",1,35,35,42,0,36,1,2,"empty",1,5,40,7,36,5,32,"custom_fields",36,1,46,36,5,2,"empty",1,40,8,32,"Subscription already exists and there are no fields to update. Skipping...",2,"print",1,35,31,38,36,3,32,"method",32,"PUT",32,"headers",36,0,32,"body",36,5,42,3,2,"fetch",2,33,400,36,6,32,"status",45,14,40,21,32,"Error updating beehiiv subscription (status ",36,6,32,"status",45,32,"): ",36,6,32,"body",45,2,"concat",4,2,"Error",1,49,32,"Successfully updated beehiiv subscription ",32,"email",32,"inputs",1,2,2,"concat",2,2,"print",1,35,35,35,35,35,35,35,35]
diff --git a/nodejs/tests/fixtures/hog-bytecode/ed4366949ca3bee669b487ab88e7c2c4f55f57cddc13700ff980d8017e7c5476.json b/nodejs/tests/fixtures/hog-bytecode/ed4366949ca3bee669b487ab88e7c2c4f55f57cddc13700ff980d8017e7c5476.json
new file mode 100644
index 000000000000..303c628f125f
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/ed4366949ca3bee669b487ab88e7c2c4f55f57cddc13700ff980d8017e7c5476.json
@@ -0,0 +1 @@
+["_H",1,32,"upgrade-cta",38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/f7c3fc6274de02b3f1fbe56a5b1815ad2aca38dfd4add054a73b0bc992eca2c6.json b/nodejs/tests/fixtures/hog-bytecode/f7c3fc6274de02b3f1fbe56a5b1815ad2aca38dfd4add054a73b0bc992eca2c6.json
new file mode 100644
index 000000000000..14aec7051737
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/f7c3fc6274de02b3f1fbe56a5b1815ad2aca38dfd4add054a73b0bc992eca2c6.json
@@ -0,0 +1 @@
+["_H",1,32,"[email protected]",38]