Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: embeddable hog function configuration #28671

Merged
merged 20 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 136 additions & 119 deletions frontend/src/scenes/pipeline/hogfunctions/HogFunctionConfiguration.tsx

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions frontend/src/scenes/pipeline/hogfunctions/HogFunctionInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,18 @@ export function HogFunctionInputs({
}}
>
<SortableContext disabled={!showSource} items={inputSchemaIds} strategy={verticalListSortingStrategy}>
{configuration.inputs_schema?.map((schema) => {
return (
<HogFunctionInputWithSchema
key={schema.key}
schema={schema}
configuration={configuration}
setConfigurationValue={setConfigurationValue}
/>
)
})}
{configuration.inputs_schema
?.filter((i) => !i.hidden)
.map((schema) => {
return (
<HogFunctionInputWithSchema
key={schema.key}
schema={schema}
configuration={configuration}
setConfigurationValue={setConfigurationValue}
/>
)
})}
</SortableContext>
</DndContext>
</>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4666,6 +4666,7 @@ export type HogFunctionInputSchemaType = {
required?: boolean
default?: any
secret?: boolean
hidden?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing - we have this in the plugin-server as well. It's not a biggy but would be cool to add it to the types there as well so we dont forget about it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I left it out specifically because it was more of a frontend concern but happy to add it

templating?: boolean
description?: string
integration?: string
Expand Down
1 change: 1 addition & 0 deletions plugin-server/src/cdp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export type HogFunctionInputSchemaType = {
required?: boolean
default?: any
secret?: boolean
hidden?: boolean
description?: string
integration?: string
integration_key?: string
Expand Down
4 changes: 3 additions & 1 deletion posthog/cdp/templates/hog_function_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
PluginConfig = None


SubTemplateId = Literal["early-access-feature-enrollment", "survey-response", "activity-log"]
SubTemplateId = Literal[
"early-access-feature-enrollment", "survey-response", "activity-log", "error-tracking-issue-created"
]


HogFunctionTemplateType = Literal[
Expand Down
31 changes: 31 additions & 0 deletions posthog/cdp/templates/slack/template_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"label": "Slack workspace",
"requiredScopes": "channels:read groups:read chat:write chat:write.customize",
"secret": False,
"hidden": False,
"required": True,
},
{
Expand All @@ -48,6 +49,7 @@
"label": "Channel to post to",
"description": "Select the channel to post to (e.g. #general). The PostHog app must be installed in the workspace.",
"secret": False,
"hidden": False,
"required": True,
},
{
Expand All @@ -57,6 +59,7 @@
"default": ":hedgehog:",
"required": False,
"secret": False,
"hidden": False,
},
{
"key": "username",
Expand All @@ -65,6 +68,7 @@
"default": "PostHog",
"required": False,
"secret": False,
"hidden": False,
},
{
"key": "blocks",
Expand Down Expand Up @@ -97,6 +101,7 @@
],
"secret": False,
"required": False,
"hidden": False,
},
{
"key": "text",
Expand All @@ -106,6 +111,7 @@
"default": "*{person.name}* triggered event: '{event.event}'",
"secret": False,
"required": False,
"hidden": False,
},
],
sub_templates=[
Expand Down Expand Up @@ -201,5 +207,30 @@
},
},
),
HogFunctionSubTemplate(
id="error-tracking-issue-created",
name="Post to Slack on issue created",
description="",
filters={"events": [{"id": "$error_tracking_issue_created", "type": "events"}]},
type="internal_destination",
input_schema_overrides={
"blocks": {
"default": [
{
"text": {
"text": "*{person.properties.email}* {event.properties.activity} {event.properties.scope} {event.properties.item_id} ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The message format reuses activity log properties but error tracking events may have different property names. Verify that event.properties.activity, scope, and item_id exist for $error_tracking_issue_created events.

"type": "mrkdwn",
},
"type": "section",
}
],
"hidden": True,
},
"text": {
"default": "*{person.properties.email}* {event.properties.activity} {event.properties.scope} {event.properties.item_id}",
"hidden": True,
},
},
),
],
)
5 changes: 5 additions & 0 deletions posthog/cdp/templates/webhook/template_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"label": "Webhook URL",
"secret": False,
"required": True,
"hidden": False,
},
{
"key": "method",
Expand Down Expand Up @@ -64,6 +65,7 @@
],
"default": "POST",
"required": False,
"hidden": False,
},
{
"key": "body",
Expand All @@ -72,6 +74,7 @@
"default": {"event": "{event}", "person": "{person}"},
"secret": False,
"required": False,
"hidden": False,
},
{
"key": "headers",
Expand All @@ -80,6 +83,7 @@
"secret": False,
"required": False,
"default": {"Content-Type": "application/json"},
"hidden": False,
},
{
"key": "debug",
Expand All @@ -89,6 +93,7 @@
"secret": False,
"required": False,
"default": False,
"hidden": False,
},
],
sub_templates=[
Expand Down
3 changes: 3 additions & 0 deletions posthog/cdp/templates/zapier/template_zapier.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"description": "The path of the Zapier webhook. You can create your own or use our native Zapier integration https://zapier.com/apps/posthog/integrations",
"secret": False,
"required": True,
"hidden": False,
},
{
"key": "body",
Expand All @@ -53,6 +54,7 @@
},
"secret": False,
"required": False,
"hidden": False,
},
{
"key": "debug",
Expand All @@ -62,6 +64,7 @@
"secret": False,
"required": False,
"default": False,
"hidden": False,
},
],
)
28 changes: 25 additions & 3 deletions posthog/cdp/test/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,22 @@ def test_validate_inputs_schema(self):
inputs_schema = create_example_inputs_schema()
assert validate_inputs_schema(inputs_schema) == snapshot(
[
{"type": "string", "key": "url", "label": "Webhook URL", "required": True, "secret": False},
{"type": "json", "key": "payload", "label": "JSON Payload", "required": True, "secret": False},
{
"type": "string",
"key": "url",
"label": "Webhook URL",
"required": True,
"secret": False,
"hidden": False,
},
{
"type": "json",
"key": "payload",
"label": "JSON Payload",
"required": True,
"secret": False,
"hidden": False,
},
{
"type": "choice",
"key": "method",
Expand All @@ -67,8 +81,16 @@ def test_validate_inputs_schema(self):
],
"required": True,
"secret": False,
"hidden": False,
},
{
"type": "dictionary",
"key": "headers",
"label": "Headers",
"required": False,
"secret": False,
"hidden": False,
},
{"type": "dictionary", "key": "headers", "label": "Headers", "required": False, "secret": False},
]
)

Expand Down
1 change: 1 addition & 0 deletions posthog/cdp/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class InputsSchemaItemSerializer(serializers.Serializer):
required = serializers.BooleanField(default=False) # type: ignore
default = serializers.JSONField(required=False)
secret = serializers.BooleanField(default=False)
hidden = serializers.BooleanField(default=False)
description = serializers.CharField(required=False)
integration = serializers.CharField(required=False)
integration_key = serializers.CharField(required=False)
Expand Down
Loading