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): expose source.id on hog function globals (#116114)

Meikel Ratz95835d72dd8d
diff --git a/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts b/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts
index 22d92a9c2e05..f8bbc4746a4e 100644
--- a/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts
+++ b/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts
@@ -181,6 +181,7 @@ export class CdpSourceWebhooksConsumer extends CdpConsumerBase<PluginsServerConf
return {
source: {
+ id: hogFunction.id,
name: hogFunction.name ?? `Hog function: ${hogFunction.id}`,
url: `${projectUrl}/functions/${hogFunction.id}`,
},
diff --git a/nodejs/src/cdp/services/batch-export-hog-function.service.ts b/nodejs/src/cdp/services/batch-export-hog-function.service.ts
index 376c64479589..1ffdc9d45224 100644
--- a/nodejs/src/cdp/services/batch-export-hog-function.service.ts
+++ b/nodejs/src/cdp/services/batch-export-hog-function.service.ts
@@ -121,6 +121,7 @@ export class BatchExportHogFunctionService {
return {
...globals,
source: {
+ id: hogFunction.id,
name: hogFunction.name ?? `Hog function: ${hogFunction.id}`,
url: `${projectUrl}/functions/${hogFunction.id}`,
},
diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.ts
index 4bf874df99db..2d6fc1f4254d 100644
--- a/nodejs/src/cdp/types.ts
+++ b/nodejs/src/cdp/types.ts
@@ -94,6 +94,7 @@ export type HogFunctionInvocationGlobals = {
url: string
}
source?: {
+ id?: string
name: string
url: string
}
diff --git a/nodejs/src/cdp/utils/invocation-utils.test.ts b/nodejs/src/cdp/utils/invocation-utils.test.ts
index 6cf097428a72..fdc303dae45b 100644
--- a/nodejs/src/cdp/utils/invocation-utils.test.ts
+++ b/nodejs/src/cdp/utils/invocation-utils.test.ts
@@ -37,6 +37,7 @@ describe('Invocation utils', () => {
expect(invocations).toHaveLength(1)
expect(invocations[0].state.globals.source).toEqual({
+ id: fn.id,
name: 'Hog Function',
url: `http://localhost:8000/projects/1/functions/${fn.id}/configuration/`,
})
diff --git a/nodejs/src/cdp/utils/invocation-utils.ts b/nodejs/src/cdp/utils/invocation-utils.ts
index 8f6bb9e422aa..1d980536e589 100644
--- a/nodejs/src/cdp/utils/invocation-utils.ts
+++ b/nodejs/src/cdp/utils/invocation-utils.ts
@@ -109,6 +109,7 @@ export async function buildHogFunctionInvocations(
const globalsWithSource = {
...triggerGlobals,
source: {
+ id: hogFunction.id,
name: hogFunction.name ?? `Hog function: ${hogFunction.id}`,
url: `${triggerGlobals.project.url}/functions/${hogFunction.id}/configuration/`,
},