Skip to content

Commit

Permalink
fix: Filter out templates if not enabled (#23938)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored and thmsobrmlr committed Jul 25, 2024
1 parent 86d55bc commit a6571ff
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
26 changes: 22 additions & 4 deletions frontend/src/scenes/pipeline/destinations/newDestinationsLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { actions, afterMount, connect, kea, listeners, path, reducers, selectors
import { loaders } from 'kea-loaders'
import { actionToUrl, combineUrl, router, urlToAction } from 'kea-router'
import api from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { objectsEqual } from 'lib/utils'
import posthog from 'posthog-js'
import { urls } from 'scenes/urls'
Expand Down Expand Up @@ -42,7 +44,7 @@ export interface Fuse extends FuseClass<NewDestinationItemType> {}

export const newDestinationsLogic = kea<newDestinationsLogicType>([
connect({
values: [userLogic, ['user']],
values: [userLogic, ['user'], featureFlagLogic, ['featureFlags']],
}),
path(() => ['scenes', 'pipeline', 'destinations', 'newDestinationsLogic']),
actions({
Expand Down Expand Up @@ -104,10 +106,26 @@ export const newDestinationsLogic = kea<newDestinationsLogicType>([
},
],
destinations: [
(s) => [s.plugins, s.hogFunctionTemplates, s.batchExportServiceNames, router.selectors.hashParams],
(plugins, hogFunctionTemplates, batchExportServiceNames, hashParams): NewDestinationItemType[] => {
(s) => [
s.plugins,
s.hogFunctionTemplates,
s.batchExportServiceNames,
s.featureFlags,
router.selectors.hashParams,
],
(
plugins,
hogFunctionTemplates,
batchExportServiceNames,
featureFlags,
hashParams
): NewDestinationItemType[] => {
const hogTemplates = featureFlags[FEATURE_FLAGS.HOG_FUNCTIONS]
? Object.values(hogFunctionTemplates)
: []

return [
...Object.values(hogFunctionTemplates).map((hogFunction) => ({
...hogTemplates.map((hogFunction) => ({
icon: <HogFunctionIcon size="small" src={hogFunction.icon_url} />,
name: hogFunction.name,
description: hogFunction.description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
exampleInvocationGlobals: [
(s) => [s.configuration, s.currentTeam, s.groupTypes],
(configuration, currentTeam, groupTypes): HogFunctionInvocationGlobals => {
const currentUrl = window.location.href.split('#')[0]
const globals: HogFunctionInvocationGlobals = {
event: {
uuid: uuid(),
Expand All @@ -312,7 +313,7 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
timestamp: dayjs().toISOString(),
url: `${window.location.origin}/project/${currentTeam?.id}/events/`,
properties: {
$current_url: window.location.href,
$current_url: currentUrl,
$browser: 'Chrome',
},
},
Expand All @@ -332,7 +333,7 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
},
source: {
name: configuration?.name ?? 'Unnamed',
url: window.location.href,
url: currentUrl,
},
}

Expand Down
2 changes: 1 addition & 1 deletion posthog/cdp/templates/customerio/template_customerio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Based off of https://customer.io/docs/api/track/#operation/entity

template: HogFunctionTemplate = HogFunctionTemplate(
status="alpha",
status="beta",
id="template-customerio",
name="Update persons in Customer.io",
description="Updates persons in Customer.io",
Expand Down
2 changes: 1 addition & 1 deletion posthog/cdp/templates/hubspot/template_hubspot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


template: HogFunctionTemplate = HogFunctionTemplate(
status="alpha",
status="beta",
id="template-hubspot",
name="Create Hubspot contact",
description="Creates a new contact in Hubspot whenever an event is triggered.",
Expand Down
2 changes: 1 addition & 1 deletion posthog/cdp/templates/intercom/template_intercom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


template: HogFunctionTemplate = HogFunctionTemplate(
status="alpha",
status="beta",
id="template-Intercom",
name="Send data to Intercom",
description="Send events and contact information to Intercom",
Expand Down
2 changes: 1 addition & 1 deletion posthog/cdp/templates/sendgrid/template_sendgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Based off of https://www.twilio.com/docs/sendgrid/api-reference/contacts/add-or-update-a-contact

template: HogFunctionTemplate = HogFunctionTemplate(
status="alpha",
status="beta",
id="template-sendgrid",
name="Update marketing contacts in Sendgrid",
description="Update marketing contacts in Sendgrid",
Expand Down

0 comments on commit a6571ff

Please sign in to comment.