diff --git a/frontend/src/scenes/pipeline/hogfunctions/HogFunctionConfiguration.tsx b/frontend/src/scenes/pipeline/hogfunctions/HogFunctionConfiguration.tsx index a41e56c5fe033..2d7d32ba85010 100644 --- a/frontend/src/scenes/pipeline/hogfunctions/HogFunctionConfiguration.tsx +++ b/frontend/src/scenes/pipeline/hogfunctions/HogFunctionConfiguration.tsx @@ -43,6 +43,9 @@ export interface HogFunctionConfigurationProps { id?: string | null displayOptions?: { + embedded?: boolean + hidePageHeader?: boolean + hideOverview?: boolean showFilters?: boolean showExpectedVolume?: boolean showStatus?: boolean @@ -167,6 +170,9 @@ export function HogFunctionConfiguration({ return } + const embedded = displayOptions.embedded ?? false + const includeHeaderButtons = !(displayOptions.hidePageHeader ?? false) + const showOverview = !(displayOptions.hideOverview ?? false) const showFilters = displayOptions.showFilters ?? ['destination', 'internal_destination', 'site_destination', 'broadcast'].includes(type) @@ -189,17 +195,21 @@ export function HogFunctionConfiguration({ displayOptions.showTesting ?? ['destination', 'internal_destination', 'transformation', 'broadcast', 'email'].includes(type) + const showLeftPanel = showOverview || showExpectedVolume || showPersonsCount || showFilters + return (
- - {headerButtons} - {saveButtons} - - } - /> + {includeHeaderButtons && ( + + {headerButtons} + {saveButtons} + + } + /> + )} {hogFunction?.filters?.bytecode_error ? (
@@ -216,134 +226,141 @@ export function HogFunctionConfiguration({ className="space-y-3" >
-
-
-
- - {({ value, onChange }) => ( - onChange(val)} - /> - )} - - -
- {configuration.name} - {template && } -
- - {showStatus && } - {showEnabled && ( - + {showLeftPanel && ( +
+
+
+ {({ value, onChange }) => ( - onChange(!value)} - checked={value} - disabled={loading} - bordered + onChange(val)} /> )} - )} -
- - - - - - - {isLegacyPlugin ? null : hogFunction?.template && - !hogFunction.template.id.startsWith('template-blank-') ? ( - -

- This function was built from the template{' '} - {hogFunction.template.name}. If the template is updated, this - function is not affected unless you choose to update it. -

+
+ {configuration.name} + {template && } +
-
-
- Close -
+ {showStatus && } + {showEnabled && ( + + {({ value, onChange }) => ( + onChange(!value)} + checked={value} + disabled={loading} + bordered + /> + )} + + )} +
+ + + + + + - duplicateFromTemplate()} - > - New function from template - + {isLegacyPlugin ? null : hogFunction?.template && + !hogFunction.template.id.startsWith('template-blank-') ? ( + +

+ This function was built from the template{' '} + {hogFunction.template.name}. If the template is updated, + this function is not affected unless you choose to update it. +

- {templateHasChanged ? ( - resetToTemplate()}> - Update +
+
+ Close +
+ + duplicateFromTemplate()} + > + New function from template - ) : null} + + {templateHasChanged ? ( + resetToTemplate()} + > + Update + + ) : null} +
+ } + > +
+ + Built from template: + {hogFunction?.template.name} + + {templateHasChanged ? ( + Update available! + ) : null} +
- } - > -
- - Built from template: - {hogFunction?.template.name} - - {templateHasChanged ? ( - Update available! - ) : null} - -
- - ) : null} -
+ + ) : null} +
- {showFilters && } + {showFilters && } - {showPersonsCount && ( -
-
- Matching persons -
- {personsCount && !personsCountLoading ? ( - <> - Found{' '} - - - {personsCount ?? 0} {personsCount !== 1 ? 'people' : 'person'} - - {' '} - to send to. - - ) : personsCountLoading ? ( -
- + {showPersonsCount && ( +
+
+ Matching persons
- ) : ( -

The expected volume could not be calculated

- )} -
- )} + {personsCount && !personsCountLoading ? ( + <> + Found{' '} + + + {personsCount ?? 0} {personsCount !== 1 ? 'people' : 'person'} + + {' '} + to send to. + + ) : personsCountLoading ? ( +
+ +
+ ) : ( +

The expected volume could not be calculated

+ )} +
+ )} - {showExpectedVolume ? : null} -
+ {showExpectedVolume ? : null} +
+ )}
-
+
{usesGroups && !hasGroupsAddon ? ( diff --git a/frontend/src/scenes/pipeline/hogfunctions/HogFunctionInputs.tsx b/frontend/src/scenes/pipeline/hogfunctions/HogFunctionInputs.tsx index fd4e899451fdb..ad574d4f87563 100644 --- a/frontend/src/scenes/pipeline/hogfunctions/HogFunctionInputs.tsx +++ b/frontend/src/scenes/pipeline/hogfunctions/HogFunctionInputs.tsx @@ -533,16 +533,18 @@ export function HogFunctionInputs({ }} > - {configuration.inputs_schema?.map((schema) => { - return ( - - ) - })} + {configuration.inputs_schema + ?.filter((i) => !i.hidden) + .map((schema) => { + return ( + + ) + })} diff --git a/frontend/src/types.ts b/frontend/src/types.ts index e7db463255411..8667b033e48e8 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -4666,6 +4666,7 @@ export type HogFunctionInputSchemaType = { required?: boolean default?: any secret?: boolean + hidden?: boolean templating?: boolean description?: string integration?: string diff --git a/plugin-server/src/cdp/types.ts b/plugin-server/src/cdp/types.ts index c0b4f4399169f..4a72f16269c57 100644 --- a/plugin-server/src/cdp/types.ts +++ b/plugin-server/src/cdp/types.ts @@ -265,6 +265,7 @@ export type HogFunctionInputSchemaType = { required?: boolean default?: any secret?: boolean + hidden?: boolean description?: string integration?: string integration_key?: string diff --git a/posthog/cdp/templates/hog_function_template.py b/posthog/cdp/templates/hog_function_template.py index d70f1d7925d75..0ccc4f771b574 100644 --- a/posthog/cdp/templates/hog_function_template.py +++ b/posthog/cdp/templates/hog_function_template.py @@ -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[ diff --git a/posthog/cdp/templates/slack/template_slack.py b/posthog/cdp/templates/slack/template_slack.py index 3f4fe65e52e20..de395af28fdfe 100644 --- a/posthog/cdp/templates/slack/template_slack.py +++ b/posthog/cdp/templates/slack/template_slack.py @@ -38,6 +38,7 @@ "label": "Slack workspace", "requiredScopes": "channels:read groups:read chat:write chat:write.customize", "secret": False, + "hidden": False, "required": True, }, { @@ -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, }, { @@ -57,6 +59,7 @@ "default": ":hedgehog:", "required": False, "secret": False, + "hidden": False, }, { "key": "username", @@ -65,6 +68,7 @@ "default": "PostHog", "required": False, "secret": False, + "hidden": False, }, { "key": "blocks", @@ -97,6 +101,7 @@ ], "secret": False, "required": False, + "hidden": False, }, { "key": "text", @@ -106,6 +111,7 @@ "default": "*{person.name}* triggered event: '{event.event}'", "secret": False, "required": False, + "hidden": False, }, ], sub_templates=[ @@ -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} ", + "type": "mrkdwn", + }, + "type": "section", + } + ], + "hidden": True, + }, + "text": { + "default": "*{person.properties.email}* {event.properties.activity} {event.properties.scope} {event.properties.item_id}", + "hidden": True, + }, + }, + ), ], ) diff --git a/posthog/cdp/templates/webhook/template_webhook.py b/posthog/cdp/templates/webhook/template_webhook.py index 2dac56049c08d..e6163b9514092 100644 --- a/posthog/cdp/templates/webhook/template_webhook.py +++ b/posthog/cdp/templates/webhook/template_webhook.py @@ -34,6 +34,7 @@ "label": "Webhook URL", "secret": False, "required": True, + "hidden": False, }, { "key": "method", @@ -64,6 +65,7 @@ ], "default": "POST", "required": False, + "hidden": False, }, { "key": "body", @@ -72,6 +74,7 @@ "default": {"event": "{event}", "person": "{person}"}, "secret": False, "required": False, + "hidden": False, }, { "key": "headers", @@ -80,6 +83,7 @@ "secret": False, "required": False, "default": {"Content-Type": "application/json"}, + "hidden": False, }, { "key": "debug", @@ -89,6 +93,7 @@ "secret": False, "required": False, "default": False, + "hidden": False, }, ], sub_templates=[ diff --git a/posthog/cdp/templates/zapier/template_zapier.py b/posthog/cdp/templates/zapier/template_zapier.py index f44ed6f43dc5c..3f0c45da22b17 100644 --- a/posthog/cdp/templates/zapier/template_zapier.py +++ b/posthog/cdp/templates/zapier/template_zapier.py @@ -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", @@ -53,6 +54,7 @@ }, "secret": False, "required": False, + "hidden": False, }, { "key": "debug", @@ -62,6 +64,7 @@ "secret": False, "required": False, "default": False, + "hidden": False, }, ], ) diff --git a/posthog/cdp/test/test_validation.py b/posthog/cdp/test/test_validation.py index c889081e0b1f8..c64dead526ba2 100644 --- a/posthog/cdp/test/test_validation.py +++ b/posthog/cdp/test/test_validation.py @@ -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", @@ -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}, ] ) diff --git a/posthog/cdp/validation.py b/posthog/cdp/validation.py index 96e048e934338..7f06cd689f75b 100644 --- a/posthog/cdp/validation.py +++ b/posthog/cdp/validation.py @@ -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)