Skip to content

Commit

Permalink
Merge branch 'master' into dw-editor-variables
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE authored Dec 4, 2024
2 parents 0ffb394 + f79cb71 commit c1369b4
Show file tree
Hide file tree
Showing 19 changed files with 343 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ export const definitionPopoverLogic = kea<definitionPopoverLogicType>([
}

if (!('distinct_id_field' in item)) {
const idField = Object.values(warehouseItem.fields).find((n) => n.name === 'id')
if (idField) {
warehouseItem['distinct_id_field'] = idField.name
const distinctIdField =
Object.values(warehouseItem.fields).find((n) => n.name === 'distinct_id') ??
Object.values(warehouseItem.fields).find((n) => n.name === 'id')
if (distinctIdField) {
warehouseItem['distinct_id_field'] = distinctIdField.name
}
}

Expand Down
25 changes: 14 additions & 11 deletions frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ const getDashboardItemId = (section: TileId, tab: string | undefined, isModal?:
// pretend to be a new-AdHoc to get the correct behaviour elsewhere
return `new-AdHoc.web-analytics.${section}.${tab || 'default'}.${isModal ? 'modal' : 'default'}`
}

const teamId = window.POSTHOG_APP_CONTEXT?.current_team?.id
const persistConfig = { persist: true, prefix: `${teamId}__` }
export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
path(['scenes', 'webAnalytics', 'webAnalyticsSceneLogic']),
connect(() => ({
Expand Down Expand Up @@ -280,7 +283,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
reducers({
webAnalyticsFilters: [
initialWebAnalyticsFilter,
{ persist: true },
persistConfig,
{
setWebAnalyticsFilters: (_, { webAnalyticsFilters }) => webAnalyticsFilters,
togglePropertyFilter: (oldPropertyFilters, { key, value, type }): WebAnalyticsPropertyFilters => {
Expand Down Expand Up @@ -352,47 +355,47 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
],
_graphsTab: [
null as string | null,
{ persist: true },
persistConfig,
{
setGraphsTab: (_, { tab }) => tab,
togglePropertyFilter: (oldTab, { tabChange }) => tabChange?.graphsTab || oldTab,
},
],
_sourceTab: [
null as string | null,
{ persist: true },
persistConfig,
{
setSourceTab: (_, { tab }) => tab,
togglePropertyFilter: (oldTab, { tabChange }) => tabChange?.sourceTab || oldTab,
},
],
_deviceTab: [
null as string | null,
{ persist: true },
persistConfig,
{
setDeviceTab: (_, { tab }) => tab,
togglePropertyFilter: (oldTab, { tabChange }) => tabChange?.deviceTab || oldTab,
},
],
_pathTab: [
null as string | null,
{ persist: true },
persistConfig,
{
setPathTab: (_, { tab }) => tab,
togglePropertyFilter: (oldTab, { tabChange }) => tabChange?.pathTab || oldTab,
},
],
_geographyTab: [
null as string | null,
{ persist: true },
persistConfig,
{
setGeographyTab: (_, { tab }) => tab,
togglePropertyFilter: (oldTab, { tabChange }) => tabChange?.geographyTab || oldTab,
},
],
isPathCleaningEnabled: [
null as boolean | null,
{ persist: true },
persistConfig,
{
setIsPathCleaningEnabled: (_, { isPathCleaningEnabled }) => isPathCleaningEnabled,
},
Expand All @@ -413,7 +416,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
dateTo: initialDateTo,
interval: initialInterval,
},
{ persist: true },
persistConfig,
{
setDates: (_, { dateTo, dateFrom }) => ({
dateTo,
Expand Down Expand Up @@ -443,21 +446,21 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
],
shouldFilterTestAccounts: [
false as boolean,
{ persist: true },
persistConfig,
{
setShouldFilterTestAccounts: (_, { shouldFilterTestAccounts }) => shouldFilterTestAccounts,
},
],
shouldStripQueryParams: [
false as boolean,
{ persist: true },
persistConfig,
{
setShouldStripQueryParams: (_, { shouldStripQueryParams }) => shouldStripQueryParams,
},
],
conversionGoal: [
null as WebAnalyticsConversionGoal | null,
{ persist: true },
persistConfig,
{
setConversionGoal: (_, { conversionGoal }) => conversionGoal,
},
Expand Down
28 changes: 17 additions & 11 deletions posthog/api/proxy_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ def generate_target_cname(organization_id, domain) -> str:
return f"{digest}.{settings.PROXY_BASE_CNAME}"


def _capture_proxy_event(request, record: ProxyRecord, event_type: str) -> None:
organization = Organization.objects.get(id=record.organization_id)
posthoganalytics.capture(
request.user.distinct_id,
f"managed reverse proxy {event_type}",
properties={
"proxy_record_id": record.id,
"domain": record.domain,
"target_cname": record.target_cname,
},
groups=groups(organization),
)


class ProxyRecordSerializer(serializers.ModelSerializer):
class Meta:
model = ProxyRecord
Expand Down Expand Up @@ -79,17 +93,7 @@ def create(self, request, *args, **kwargs):
)

serializer = self.get_serializer(record)
organization = Organization.objects.get(id=record.organization_id)
posthoganalytics.capture(
request.user.distinct_id,
"managed reverse proxy created",
properties={
"proxy_record_id": record.id,
"domain": record.domain,
"target_cname": record.target_cname,
},
groups=groups(organization),
)
_capture_proxy_event(request, record, "created")
return Response(serializer.data)

def destroy(self, request, *args, pk=None, **kwargs):
Expand Down Expand Up @@ -120,6 +124,8 @@ def destroy(self, request, *args, pk=None, **kwargs):
record.status = ProxyRecord.Status.DELETING
record.save()

_capture_proxy_event(request, record, "deleted")

return Response(
{"success": True},
status=status.HTTP_200_OK,
Expand Down
12 changes: 6 additions & 6 deletions posthog/api/test/__snapshots__/test_action.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '99'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '99'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down Expand Up @@ -471,12 +471,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '99'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '99'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down Expand Up @@ -667,12 +667,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '99'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '99'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down
12 changes: 6 additions & 6 deletions posthog/api/test/__snapshots__/test_annotation.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '107'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '107'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down Expand Up @@ -454,12 +454,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '107'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '107'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down Expand Up @@ -669,12 +669,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '107'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '107'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down
4 changes: 2 additions & 2 deletions posthog/api/test/__snapshots__/test_decide.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,12 @@
INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '253'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '253'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down
4 changes: 2 additions & 2 deletions posthog/api/test/__snapshots__/test_element.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '272'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '272'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down
8 changes: 4 additions & 4 deletions posthog/api/test/__snapshots__/test_feature_flag.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -2001,12 +2001,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '313'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '313'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand All @@ -2021,12 +2021,12 @@
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'feature_flag'
AND "ee_accesscontrol"."resource_id" = '130'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'feature_flag'
AND "ee_accesscontrol"."resource_id" = '130'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999))
'''
Expand Down
8 changes: 4 additions & 4 deletions posthog/api/test/__snapshots__/test_insight.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1380,12 +1380,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '447'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '447'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down Expand Up @@ -1493,12 +1493,12 @@
LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")
WHERE (("ee_accesscontrol"."organization_member_id" IS NULL
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '447'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("posthog_organizationmembership"."user_id" = 99999
AND "ee_accesscontrol"."resource" = 'project'
AND "ee_accesscontrol"."resource_id" = '447'
AND "ee_accesscontrol"."resource_id" = '99999'
AND "ee_accesscontrol"."role_id" IS NULL
AND "ee_accesscontrol"."team_id" = 99999)
OR ("ee_accesscontrol"."organization_member_id" IS NULL
Expand Down
Loading

0 comments on commit c1369b4

Please sign in to comment.