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(customer-analytics): let teams edit shared views (#96766)

Arthur Moreira de Deus30a2116f4065
diff --git a/posthog/api/column_configuration.py b/posthog/api/column_configuration.py
index 847e00f26633..926009fff57d 100644
--- a/posthog/api/column_configuration.py
+++ b/posthog/api/column_configuration.py
@@ -1,4 +1,4 @@
-from typing import Any
+from typing import Any, NoReturn
from django.core.exceptions import PermissionDenied as DjangoPermissionDenied
from django.db import IntegrityError
@@ -6,7 +6,7 @@ from django.db.models import Q, QuerySet
from django.http import Http404
import structlog
-from drf_spectacular.utils import extend_schema
+from drf_spectacular.utils import extend_schema, extend_schema_view
from rest_framework import serializers, viewsets
from rest_framework.exceptions import APIException, NotFound, PermissionDenied
from rest_framework.permissions import SAFE_METHODS
@@ -22,6 +22,15 @@ from posthog.models import ColumnConfiguration
logger = structlog.get_logger(__name__)
+TEAM_EDITABLE_VIEW_CONTEXT_KEYS = {"customer_analytics_accounts_columns"}
+
+
+class ColumnConfigurationListQuerySerializer(serializers.Serializer):
+ context_key = serializers.CharField(
+ required=False,
+ help_text="Return saved views for this context only.",
+ )
+
class ColumnConfigurationSerializer(serializers.ModelSerializer):
filters = serializers.JSONField(
@@ -79,6 +88,7 @@ class ColumnConfigurationSerializer(serializers.ModelSerializer):
return values
+@extend_schema_view(list=extend_schema(parameters=[ColumnConfigurationListQuerySerializer]))
@extend_schema(extensions={"x-product": ProductKey.PRODUCT_ANALYTICS})
class ColumnConfigurationViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
scope_object = "INTERNAL"
@@ -130,7 +140,14 @@ class ColumnConfigurationViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
# view, or a wrong id) is a 404 — not an unhandled 500.
raise NotFound("View not found")
- if self.request.method not in SAFE_METHODS and object.created_by != self.request.user:
+ if (
+ self.request.method not in SAFE_METHODS
+ and (
+ object.visibility == ColumnConfiguration.Visibility.PRIVATE
+ or object.context_key not in TEAM_EDITABLE_VIEW_CONTEXT_KEYS
+ )
+ and object.created_by != self.request.user
+ ):
raise PermissionDenied("You do not have permission to change this view")
return object
@@ -178,18 +195,31 @@ class ColumnConfigurationViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
try:
instance = serializer.save(team=self.team, created_by=self.request.user)
self._log_activity(instance=instance, previous=None)
- except IntegrityError as e:
- error_str = str(e)
- if "unique_user_view_name" in error_str:
- raise Conflict(detail="A private view with this name already exists")
- elif "unique_team_view_name" in error_str:
- raise Conflict(detail="A shared view with this name already exists")
- raise
+ except IntegrityError as error:
+ self._raise_name_conflict(error)
def perform_update(self, serializer):
previous = self.get_object()
- instance = serializer.save()
- self._log_activity(instance=instance, previous=previous)
+ target_visibility = serializer.validated_data.get("visibility", previous.visibility)
+ save_kwargs = (
+ {"created_by": self.request.user}
+ if previous.visibility == ColumnConfiguration.Visibility.SHARED
+ and target_visibility == ColumnConfiguration.Visibility.PRIVATE
+ else {}
+ )
+ try:
+ instance = serializer.save(**save_kwargs)
+ self._log_activity(instance=instance, previous=previous)
+ except IntegrityError as error:
+ self._raise_name_conflict(error)
+
+ def _raise_name_conflict(self, error: IntegrityError) -> NoReturn:
+ error_str = str(error)
+ if "unique_user_view_name" in error_str:
+ raise Conflict(detail="A private view with this name already exists")
+ if "unique_team_view_name" in error_str:
+ raise Conflict(detail="A shared view with this name already exists")
+ raise error
def _log_activity(self, instance, previous):
log_activity_from_viewset(
diff --git a/posthog/api/test/test_column_configuration.py b/posthog/api/test/test_column_configuration.py
index f20440455815..95c9d26b4f46 100644
--- a/posthog/api/test/test_column_configuration.py
+++ b/posthog/api/test/test_column_configuration.py
@@ -127,37 +127,75 @@ class TestColumnConfigurationAPI(APIBaseTest):
assert len(data["results"]) == 1
assert data["results"][0]["id"] == str(config.id)
- def test_user_can_only_edit_their_views(self):
- another_config = ColumnConfiguration.objects.create(
+ def test_team_member_can_edit_a_shared_view(self):
+ shared_view = ColumnConfiguration.objects.create(
team=self.team,
visibility=ColumnConfiguration.Visibility.SHARED,
- context_key="context-key",
+ context_key="customer_analytics_accounts_columns",
columns=["*", "person", "timestamp"],
created_by=self.another_user,
)
response = self.client.patch(
- f"/api/environments/{self.team.id}/column_configurations/{str(another_config.id)}", {"name": "New name"}
+ f"/api/environments/{self.team.id}/column_configurations/{shared_view.id}/", {"name": "New name"}
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ shared_view.refresh_from_db()
+ assert shared_view.name == "New name"
+
+ @parameterized.expand([("patch", {"name": "New name"}), ("delete", None)])
+ def test_team_member_cannot_change_another_shared_view_outside_accounts(
+ self, method: str, data: dict[str, str] | None
+ ) -> None:
+ shared_view = ColumnConfiguration.objects.create(
+ team=self.team,
+ visibility=ColumnConfiguration.Visibility.SHARED,
+ context_key="events_table",
+ columns=["*", "person", "timestamp"],
+ created_by=self.another_user,
+ )
+
+ response = getattr(self.client, method)(
+ f"/api/environments/{self.team.id}/column_configurations/{shared_view.id}/", data=data
)
assert response.status_code == status.HTTP_403_FORBIDDEN
- assert response.json()["detail"] == "You do not have permission to change this view"
+ assert ColumnConfiguration.objects.filter(id=shared_view.id).exists()
- def test_user_can_only_delete_their_views(self):
- another_config = ColumnConfiguration.objects.create(
+ def test_team_member_can_delete_a_shared_view(self):
+ shared_view = ColumnConfiguration.objects.create(
team=self.team,
visibility=ColumnConfiguration.Visibility.SHARED,
- context_key="context-key",
+ context_key="customer_analytics_accounts_columns",
columns=["*", "person", "timestamp"],
created_by=self.another_user,
)
- response = self.client.delete(
- f"/api/environments/{self.team.id}/column_configurations/{str(another_config.id)}"
+ response = self.client.delete(f"/api/environments/{self.team.id}/column_configurations/{shared_view.id}/")
+
+ assert response.status_code == status.HTTP_204_NO_CONTENT
+ assert not ColumnConfiguration.objects.filter(id=shared_view.id).exists()
+
+ def test_shared_view_becomes_the_editors_private_view(self):
+ shared_view = ColumnConfiguration.objects.create(
+ team=self.team,
+ visibility=ColumnConfiguration.Visibility.SHARED,
+ context_key="customer_analytics_accounts_columns",
+ columns=["*", "person", "timestamp"],
+ created_by=self.another_user,
)
- assert response.status_code == status.HTTP_403_FORBIDDEN
- assert response.json()["detail"] == "You do not have permission to change this view"
+ response = self.client.patch(
+ f"/api/environments/{self.team.id}/column_configurations/{shared_view.id}/",
+ {"visibility": ColumnConfiguration.Visibility.PRIVATE},
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json()["visibility"] == ColumnConfiguration.Visibility.PRIVATE
+ assert response.json()["created_by"] == self.user.id
+ shared_view.refresh_from_db()
+ assert shared_view.created_by == self.user
def test_list_without_context_key_excludes_others_private_views(self):
ColumnConfiguration.objects.create(
@@ -194,6 +232,63 @@ class TestColumnConfigurationAPI(APIBaseTest):
assert response.status_code == status.HTTP_404_NOT_FOUND
+ @parameterized.expand([("patch", {"name": "New name"}), ("delete", None)])
+ def test_cannot_change_another_users_private_view(self, method: str, data: dict[str, str] | None):
+ private_view = ColumnConfiguration.objects.create(
+ team=self.team,
+ visibility=ColumnConfiguration.Visibility.PRIVATE,
+ context_key="context-key",
+ columns=["*"],
+ created_by=self.another_user,
+ )
+
+ response = getattr(self.client, method)(
+ f"/api/environments/{self.team.id}/column_configurations/{private_view.id}/", data=data
+ )
+
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+ assert ColumnConfiguration.objects.filter(id=private_view.id).exists()
+
+ @parameterized.expand(
+ [
+ (
+ "private",
+ ColumnConfiguration.Visibility.PRIVATE,
+ "A private view with this name already exists",
+ ),
+ (
+ "shared",
+ ColumnConfiguration.Visibility.SHARED,
+ "A shared view with this name already exists",
+ ),
+ ]
+ )
+ def test_update_name_conflict(self, _name: str, target_visibility: str, expected_detail: str):
+ existing_view = ColumnConfiguration.objects.create(
+ team=self.team,
+ visibility=target_visibility,
+ context_key="customer_analytics_accounts_columns",
+ name="Existing name",
+ columns=["*"],
+ created_by=self.user if target_visibility == ColumnConfiguration.Visibility.PRIVATE else self.another_user,
+ )
+ view_to_update = ColumnConfiguration.objects.create(
+ team=self.team,
+ visibility=ColumnConfiguration.Visibility.SHARED,
+ context_key="customer_analytics_accounts_columns",
+ name="Original name",
+ columns=["*"],
+ created_by=self.another_user,
+ )
+
+ response = self.client.patch(
+ f"/api/environments/{self.team.id}/column_configurations/{view_to_update.id}/",
+ {"name": existing_view.name, "visibility": target_visibility},
+ )
+
+ assert response.status_code == status.HTTP_409_CONFLICT
+ assert response.json()["detail"] == expected_detail
+
def test_update_via_patch(self):
create_response = self.client.post(
f"/api/environments/{self.team.id}/column_configurations/",
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index f028a79c071e..07feab423ce2 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -258,7 +258,7 @@ Views are persisted as `ColumnConfiguration` rows under `context_key = 'customer
- `filters` ← search text, tags, assignment status (`assignmentStatus`, always stored so a new `all` view is distinct from a legacy field-less view that restores as assigned-only), assigned-to filter, tile filter, custom-property filters (JSON; custom-property filters key by definition **id**, so they survive renames)
- `properties` ← `{ tiles }` — overview tile configuration (a `properties` field added to the `ColumnConfiguration` model)
-**Visibility** is `private` or `shared`; only the creator can edit or delete a view (enforced by the backend viewset).
+**Visibility** is `private` or `shared`. The owner can see and change a private view. Any team member who can see a shared view can edit or delete it. When a team member makes a shared view private, the view becomes that member's private view.
**Auto-restore:** the last-used view `id` is persisted in a team-scoped localStorage key (`currentViewId`).
A shared link's `#view=` URL hash always wins over the saved `currentViewId`.
@@ -270,7 +270,8 @@ The operation is idempotent and skips non-creators.
**Column configurator:** `AccountsColumnConfigurator.tsx` no longer persists columns itself — "Done" closes only.
Column changes are saved as part of a view via `AccountsViewSelector.tsx` (the view dropdown in `AccountsTabFilters`), which offers "Save current view" (creates) and "Update '<name>'" (patches the selected view).
-The configurator's footer also surfaces that path (`SaveViewButton`): "Update "<name>"" when the current view is editable (disabled until dirty), otherwise "Save as new view" — both delegate to `accountsViewsLogic` (`updateView` / `setIsCreating`), the latter opening the create-view modal that `AccountsViewSelector` renders.
+The selector uses one modal to create and edit views. Edit mode fills the form with the saved name and visibility. The Manage menu offers Edit and Delete for every visible view.
+The configurator's footer also surfaces that path (`SaveViewButton`): "Update "<name>"" when the current view is editable (disabled until dirty), otherwise "Save as new view". Both actions delegate to `accountsViewsLogic` (`updateView` / `setIsCreating`).
The available-columns picker defaults to an "All columns" category that searches across every non-freeform group at once (each result row shows its source group); picking a category in the dropdown narrows the search to it, and "SQL expression" stays a dedicated freeform entry.
## Max / agent integration
@@ -340,8 +341,8 @@ We track user actions on the Accounts list with `posthog.capture()`. Conventions
| ~~`customer analytics accounts columns saved`~~ | _Deprecated — no longer emitted. Column changes are now saved as part of a view (see view events below)._ | _n/a_ |
| `customer analytics accounts overview tiles edited` | `accountsOverviewTilesLogic` editor close (diffed vs open snapshot, only when changed) | `tiles_added`, `tiles_removed`, `tiles_updated`, `reordered`, `tile_count_before`, `tile_count_after` |
| `customer analytics accounts overview tiles localstorage read` | `accountsOverviewTilesLogic` `afterMount` (only when a legacy custom value exists) | `tile_count` — **tombstone**: a legacy localStorage tiles value was read; once this stops firing, no browser still carries one and the read path can be removed |
-| `customer analytics accounts view saved` | `accountsViewsLogic` `submitNewViewForm` listener (success) | `visibility` (`private` \| `shared`) |
-| `customer analytics accounts view updated` | `accountsViewsLogic` `updateViewSuccess` listener | _(none)_ |
+| `customer analytics accounts view saved` | `accountsViewsLogic` `submitViewForm` listener after a create succeeds | `visibility` (`private` \| `shared`) |
+| `customer analytics accounts view updated` | `accountsViewsLogic` `updateViewSuccess` listener after content or metadata changes | _(none)_ |
| `customer analytics accounts view selected` | `accountsViewsLogic` `applyView` listener | `visibility` |
| `customer analytics accounts view deleted` | `accountsViewsLogic` `deleteViewSuccess` listener | _(none)_ |
| `customer analytics account role assigned` | `accountsLogic` `updateAccountRole` | `role` (`csm` \| `account_executive` \| `account_owner` for the seeded definitions, else the definition name), `is_assigned`, `assigned_user_id`, `source` (`list_row` from `accountsLogic.updateAccountRole` \| `relationships_tab` from `accountRelationshipsLogic` assign/end) |
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
index b01b19e7bae8..cf65c7f272c1 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
@@ -26,7 +26,7 @@ describe('AccountsTabFilters', () => {
get: {
'/api/organizations/:organization_id/members/': () => [200, { results: [] }],
'/api/projects/:team_id/tags': () => [200, []],
- '/api/environments/:team_id/column_configurations': () => [
+ '/api/projects/:team_id/column_configurations': () => [
200,
{ count: savedViews.length, results: savedViews },
],
@@ -63,7 +63,7 @@ describe('AccountsTabFilters', () => {
return screen.getByText('My accounts').closest('.LemonCheckbox')!.querySelector('input')!
}
- it('offers shared saved views when none is selected', async () => {
+ it('offers edit and delete for a shared saved view', async () => {
savedViews = [
{
id: 'shared-view',
@@ -83,7 +83,20 @@ describe('AccountsTabFilters', () => {
fireEvent.click(await screen.findByText('Select view'))
- expect(await screen.findByText('Shared accounts')).toBeInTheDocument()
+ const sharedViewLabel = await screen.findByText('Shared accounts')
+ const viewMenuItem = sharedViewLabel.closest('li')
+ expect(viewMenuItem).not.toBeNull()
+
+ const viewButtons = viewMenuItem!.querySelectorAll('button')
+ expect(viewButtons).toHaveLength(2)
+ fireEvent.click(viewButtons[1])
+
+ expect(await screen.findByText('Edit')).toBeInTheDocument()
+ expect(screen.getByText('Delete')).toBeInTheDocument()
+
+ fireEvent.click(screen.getByText('Edit'))
+ expect(await screen.findByText('Edit view')).toBeInTheDocument()
+ expect(screen.getByDisplayValue('Shared accounts')).toBeInTheDocument()
})
it('renders the "My accounts" checkbox', () => {
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsViewSelector.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsViewSelector.tsx
index c8795ed41d19..2d00cafeb287 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsViewSelector.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsViewSelector.tsx
@@ -15,32 +15,31 @@ import {
import { LemonField } from 'lib/lemon-ui/LemonField'
-import { ColumnConfigurationApi } from 'products/product_analytics/frontend/generated/api.schemas'
+import type { ColumnConfigurationApi } from 'products/product_analytics/frontend/generated/api.schemas'
import { accountsViewsLogic } from './accountsViewsLogic'
export function AccountsViewSelector(): JSX.Element {
- const { views, currentView, isDirty, viewsLoading, canEditCurrentView, user } = useValues(accountsViewsLogic)
- const { selectView, updateView, setViewToDelete, setViewToRename, setIsCreating } = useActions(accountsViewsLogic)
+ const { views, currentView, isDirty, viewsLoading } = useValues(accountsViewsLogic)
+ const { selectView, updateView, setViewToDelete, setViewToEdit, setIsCreating } = useActions(accountsViewsLogic)
const menuItems: LemonMenuItems = [
{
- items: views.map((view) => {
- const canEdit = view.created_by === user?.id
- return {
- label: view.name,
- icon: <ViewVisibilityIcon view={view} />,
- active: currentView?.id === view.id,
- onClick: () => selectView(view.id),
- ...(canEdit && {
+ items: views.map(
+ (view) =>
+ ({
+ label: view.name,
+ icon: <ViewVisibilityIcon view={view} />,
+ active: currentView?.id === view.id,
+ onClick: () => selectView(view.id),
sideAction: {
icon: <IconPencil />,
tooltip: 'Manage view',
dropdown: {
overlay: (
<>
- <LemonButton size="small" fullWidth onClick={() => setViewToRename(view.id)}>
- Rename
+ <LemonButton size="small" fullWidth onClick={() => setViewToEdit(view.id)}>
+ Edit
</LemonButton>
<LemonButton
size="small"
@@ -54,9 +53,8 @@ export function AccountsViewSelector(): JSX.Element {
),
},
},
- }),
- } as LemonMenuItem
- }),
+ }) as LemonMenuItem
+ ),
},
{
items: [{ label: 'Save as new view...', icon: <IconPlus />, onClick: () => setIsCreating(true) }],
@@ -95,7 +93,6 @@ export function AccountsViewSelector(): JSX.Element {
size="small"
type="secondary"
tooltip="Update this view with the current configuration"
- disabledReason={!canEditCurrentView ? 'You can only edit views you created' : undefined}
loading={viewsLoading}
onClick={() => updateView({ id: currentView.id, updates: {} })}
data-attr="accounts-update-view"
@@ -104,28 +101,34 @@ export function AccountsViewSelector(): JSX.Element {
</LemonButton>
)}
- <CreateViewModal />
- <RenameViewModal />
+ <ViewModal />
<DeleteViewModal />
</div>
)
}
-function CreateViewModal(): JSX.Element {
- const { isCreating, isNewViewFormSubmitting } = useValues(accountsViewsLogic)
- const { submitNewViewForm, resetNewViewForm, setIsCreating } = useActions(accountsViewsLogic)
+function ViewModal(): JSX.Element {
+ const { isCreating, viewToEdit, isViewFormSubmitting, viewsLoading } = useValues(accountsViewsLogic)
+ const { submitViewForm, resetViewForm, setIsCreating, setViewToEdit } = useActions(accountsViewsLogic)
+ const isEditing = !!viewToEdit
+ const isSaving = isViewFormSubmitting || viewsLoading
const close = (): void => {
setIsCreating(false)
- resetNewViewForm()
+ setViewToEdit(null)
+ resetViewForm()
}
return (
<LemonModal
- isOpen={isCreating}
+ isOpen={isCreating || isEditing}
onClose={close}
- title="Save as new view"
- description="Save the current filters, columns, ordering, and overview tiles as a reusable view"
+ title={isEditing ? 'Edit view' : 'Save as new view'}
+ description={
+ isEditing
+ ? undefined
+ : 'Save the current filters, columns, ordering, and overview tiles as a reusable view'
+ }
footer={
<>
<LemonButton type="secondary" onClick={close}>
@@ -133,19 +136,23 @@ function CreateViewModal(): JSX.Element {
</LemonButton>
<LemonButton
type="primary"
- onClick={submitNewViewForm}
- loading={isNewViewFormSubmitting}
- disabledReason={isNewViewFormSubmitting ? 'Saving…' : undefined}
+ onClick={submitViewForm}
+ loading={isSaving}
+ disabledReason={isSaving ? 'Saving…' : undefined}
>
- Save view
+ {isEditing ? 'Save changes' : 'Save view'}
</LemonButton>
</>
}
>
- <Form logic={accountsViewsLogic} formKey="newViewForm">
+ <Form logic={accountsViewsLogic} formKey="viewForm">
<div className="space-y-4">
<LemonField name="name" label="View name">
- <LemonInput placeholder="e.g. Enterprise accounts" autoFocus onPressEnter={submitNewViewForm} />
+ <LemonInput
+ placeholder="e.g. Enterprise accounts"
+ autoFocus
+ onPressEnter={isSaving ? undefined : submitViewForm}
+ />
</LemonField>
<LemonField name="visibility" label="Visibility">
<LemonSegmentedButton
@@ -162,48 +169,8 @@ function CreateViewModal(): JSX.Element {
)
}
-function RenameViewModal(): JSX.Element {
- const { views, viewToRename, viewsLoading } = useValues(accountsViewsLogic)
- const { setViewToRename, submitRenameViewForm, resetRenameViewForm } = useActions(accountsViewsLogic)
- const view = views.find((v) => v.id === viewToRename)
-
- const close = (): void => {
- setViewToRename(null)
- resetRenameViewForm()
- }
-
- return (
- <LemonModal
- isOpen={!!viewToRename}
- onClose={close}
- title="Rename view"
- footer={
- <>
- <LemonButton type="secondary" onClick={close}>
- Cancel
- </LemonButton>
- <LemonButton
- type="primary"
- onClick={submitRenameViewForm}
- loading={viewsLoading}
- disabledReason={viewsLoading ? 'Saving…' : undefined}
- >
- Rename
- </LemonButton>
- </>
- }
- >
- <Form logic={accountsViewsLogic} formKey="renameViewForm">
- <LemonField name="name" label="View name">
- <LemonInput placeholder={view?.name} autoFocus onPressEnter={submitRenameViewForm} />
- </LemonField>
- </Form>
- </LemonModal>
- )
-}
-
function DeleteViewModal(): JSX.Element {
- const { views, viewToDelete } = useValues(accountsViewsLogic)
+ const { views, viewToDelete, viewsLoading } = useValues(accountsViewsLogic)
const { deleteView, setViewToDelete } = useActions(accountsViewsLogic)
const view = views.find((v) => v.id === viewToDelete)
@@ -224,9 +191,10 @@ function DeleteViewModal(): JSX.Element {
onClick={() => {
if (viewToDelete) {
deleteView({ id: viewToDelete })
- setViewToDelete(null)
}
}}
+ loading={viewsLoading}
+ disabledReason={viewsLoading ? 'Deleting…' : undefined}
>
Delete
</LemonButton>
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
index 304c20246c47..4b09a5f39eba 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
@@ -63,7 +63,7 @@ describe('accountsViewsLogic', () => {
})
it('lists views on mount', async () => {
- useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 1, results: [buildView()] } } })
+ useMocks({ get: { '/api/projects/:team_id/column_configurations/': { count: 1, results: [buildView()] } } })
mountAll()
await expectLogic(logic)
.toDispatchActions(['loadViewsSuccess'])
@@ -73,7 +73,7 @@ describe('accountsViewsLogic', () => {
})
it('holds the first accounts fetch until the persisted view is applied', async () => {
- useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 1, results: [buildView()] } } })
+ useMocks({ get: { '/api/projects/:team_id/column_configurations/': { count: 1, results: [buildView()] } } })
localStorage.setItem(
`customerAnalytics.accounts.accountsViewsLogic.${MOCK_DEFAULT_TEAM.id}.currentViewId`,
JSON.stringify('view-1')
@@ -92,7 +92,7 @@ describe('accountsViewsLogic', () => {
})
it('opens the gate when loading views fails, so the list still fetches', async () => {
- useMocks({ get: { '/api/environments/:team_id/column_configurations/': () => [500, {}] } })
+ useMocks({ get: { '/api/projects/:team_id/column_configurations/': () => [500, {}] } })
localStorage.setItem(
`customerAnalytics.accounts.accountsViewsLogic.${MOCK_DEFAULT_TEAM.id}.currentViewId`,
JSON.stringify('view-1')
@@ -109,7 +109,7 @@ describe('accountsViewsLogic', () => {
})
it('applyView hydrates columns, filters, sort, and tiles', async () => {
- useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
+ useMocks({ get: { '/api/projects/:team_id/column_configurations/': { count: 0, results: [] } } })
mountAll()
const view = buildView({
filters: {
@@ -152,7 +152,7 @@ describe('accountsViewsLogic', () => {
})
it('translates an applied saved view into the Postgres query', async () => {
- useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
+ useMocks({ get: { '/api/projects/:team_id/column_configurations/': { count: 0, results: [] } } })
mountAll()
await expectLogic(logic, () =>
logic.actions.applyView(
@@ -175,7 +175,7 @@ describe('accountsViewsLogic', () => {
})
it('applies a legacy saved view (no assignment field) as assigned-only', async () => {
- useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
+ useMocks({ get: { '/api/projects/:team_id/column_configurations/': { count: 0, results: [] } } })
mountAll()
// A view saved before the status field existed must not silently broaden to all.
await expectLogic(logic, () =>
@@ -188,7 +188,7 @@ describe('accountsViewsLogic', () => {
})
it('keeps column widths when the selected view changes', async () => {
- useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
+ useMocks({ get: { '/api/projects/:team_id/column_configurations/': { count: 0, results: [] } } })
mountAll()
logic.actions.setColumnWidth('name', 320)
@@ -200,7 +200,7 @@ describe('accountsViewsLogic', () => {
it('isDirty flips when live state diverges from the applied view and clears on re-apply', async () => {
useMocks({
get: {
- '/api/environments/:team_id/column_configurations/': { count: 1, results: [buildView()] },
+ '/api/projects/:team_id/column_configurations/': { count: 1, results: [buildView()] },
},
})
mountAll()
@@ -218,8 +218,8 @@ describe('accountsViewsLogic', () => {
it('deleteView clears currentViewId when the active view is removed', async () => {
useMocks({
- get: { '/api/environments/:team_id/column_configurations/': { count: 1, results: [buildView()] } },
- delete: { '/api/environments/:team_id/column_configurations/:id/': [204] },
+ get: { '/api/projects/:team_id/column_configurations/': { count: 1, results: [buildView()] } },
+ delete: { '/api/projects/:team_id/column_configurations/:id/': [204] },
})
mountAll()
await expectLogic(logic).toDispatchActions(['loadViewsSuccess'])
@@ -229,29 +229,64 @@ describe('accountsViewsLogic', () => {
.toMatchValues({ currentViewId: null })
})
- it('rename seeds the form with the current name and patches the trimmed name on submit', async () => {
- let patchedBody: any = null
+ it('creates a view from the current state', async () => {
+ let createdBody: Record<string, unknown> | null = null
useMocks({
- get: { '/api/environments/:team_id/column_configurations/': { count: 1, results: [buildView()] } },
+ get: { '/api/projects/:team_id/column_configurations/': { count: 0, results: [] } },
+ post: {
+ '/api/projects/:team_id/column_configurations/': async ({ request }) => {
+ createdBody = (await request.json()) as Record<string, unknown>
+ return [201, buildView({ name: 'New view', visibility: 'private' })]
+ },
+ },
+ })
+ mountAll()
+ await expectLogic(logic).toDispatchActions(['loadViewsSuccess'])
+
+ logic.actions.setViewFormValues({ name: ' New view ', visibility: 'private' })
+ await expectLogic(logic, () => logic.actions.submitViewForm()).toDispatchActions([
+ 'applyView',
+ 'submitViewFormSuccess',
+ ])
+
+ expect(createdBody).toEqual(
+ expect.objectContaining({
+ context_key: 'customer_analytics_accounts_columns',
+ name: 'New view',
+ visibility: 'private',
+ })
+ )
+ })
+
+ it('edit seeds the form and patches the trimmed name and visibility', async () => {
+ let patchedBody: Record<string, unknown> | null = null
+ const sharedView = buildView({ created_by: 999 })
+ useMocks({
+ get: { '/api/projects/:team_id/column_configurations/': { count: 1, results: [sharedView] } },
patch: {
- '/api/environments/:team_id/column_configurations/:id/': async ({ request }) => {
- patchedBody = await request.json()
- return [200, buildView({ name: patchedBody.name })]
+ '/api/projects/:team_id/column_configurations/:id/': async ({ request }) => {
+ patchedBody = (await request.json()) as Record<string, unknown>
+ return [200, buildView({ created_by: CURRENT_USER_ID, name: 'Renamed', visibility: 'private' })]
},
},
})
mountAll()
await expectLogic(logic).toDispatchActions(['loadViewsSuccess'])
+ logic.actions.applyView(sharedView)
+ expect(logic.values.canEditCurrentView).toBe(true)
- await expectLogic(logic, () => logic.actions.setViewToRename('view-1'))
- .toDispatchActions(['setRenameViewFormValue'])
- .toMatchValues({ viewToRename: 'view-1', renameViewForm: { name: 'Enterprise' } })
+ await expectLogic(logic, () => logic.actions.setViewToEdit('view-1'))
+ .toDispatchActions(['setViewFormValues'])
+ .toMatchValues({
+ viewToEdit: 'view-1',
+ viewForm: { name: 'Enterprise', visibility: 'shared' },
+ })
- logic.actions.setRenameViewFormValue('name', ' Renamed ')
- await expectLogic(logic, () => logic.actions.submitRenameViewForm())
+ logic.actions.setViewFormValues({ name: ' Renamed ', visibility: 'private' })
+ await expectLogic(logic, () => logic.actions.submitViewForm())
.toDispatchActions(['updateView', 'updateViewSuccess'])
- .toMatchValues({ viewToRename: null })
- expect(patchedBody.name).toBe('Renamed')
+ .toMatchValues({ viewToEdit: null })
+ expect(patchedBody).toEqual({ name: 'Renamed', visibility: 'private' })
})
it('migrates localStorage tiles into the creator-owned default row exactly once', async () => {
@@ -259,13 +294,13 @@ describe('accountsViewsLogic', () => {
let patchedBody: any = null
useMocks({
get: {
- '/api/environments/:team_id/column_configurations/': {
+ '/api/projects/:team_id/column_configurations/': {
count: 1,
results: [buildView({ properties: {} })],
},
},
patch: {
- '/api/environments/:team_id/column_configurations/:id/': async ({ request }) => {
+ '/api/projects/:team_id/column_configurations/:id/': async ({ request }) => {
patchedBody = await request.json()
return [200, buildView({ properties: patchedBody.properties })]
},
@@ -289,7 +324,7 @@ describe('accountsViewsLogic', () => {
it('does not migrate when localStorage tiles are the defaults', async () => {
useMocks({
get: {
- '/api/environments/:team_id/column_configurations/': {
+ '/api/projects/:team_id/column_configurations/': {
count: 1,
results: [buildView({ properties: {} })],
},
@@ -309,7 +344,7 @@ describe('accountsViewsLogic', () => {
it('does not migrate into a row the user did not create', async () => {
useMocks({
get: {
- '/api/environments/:team_id/column_configurations/': {
+ '/api/projects/:team_id/column_configurations/': {
count: 1,
results: [buildView({ properties: {}, created_by: 999 })],
},
@@ -334,13 +369,13 @@ describe('accountsViewsLogic', () => {
)
useMocks({
get: {
- '/api/environments/:team_id/column_configurations/': {
+ '/api/projects/:team_id/column_configurations/': {
count: 1,
results: [buildView({ properties: {} })],
},
},
patch: {
- '/api/environments/:team_id/column_configurations/:id/': async ({ request }) => {
+ '/api/projects/:team_id/column_configurations/:id/': async ({ request }) => {
const body = (await request.json()) as any
return [200, buildView({ properties: body.properties })]
},
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
index b25a5263cc85..4c1fcea8a150 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
@@ -5,14 +5,22 @@ import { loaders } from 'kea-loaders'
import { router } from 'kea-router'
import posthog from 'posthog-js'
-import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { getCurrentTeamId } from 'lib/utils/getAppContext'
import { objectsEqual } from 'lib/utils/objects'
import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
-import { ColumnConfigurationApi } from 'products/product_analytics/frontend/generated/api.schemas'
+import {
+ columnConfigurationsCreate,
+ columnConfigurationsDestroy,
+ columnConfigurationsList,
+ columnConfigurationsPartialUpdate,
+} from 'products/product_analytics/frontend/generated/api'
+import type {
+ ColumnConfigurationApi,
+ PatchedColumnConfigurationApi,
+} from 'products/product_analytics/frontend/generated/api.schemas'
import type { UserType } from '../../../../../frontend/src/types'
import { ACCOUNTS_COLUMN_CONFIG_KEY, accountsColumnConfigLogic } from './accountsColumnConfigLogic'
@@ -53,60 +61,36 @@ export interface accountsViewsLogicValues {
currentViewId: string | null
isCreating: boolean
isDirty: boolean
- isNewViewFormSubmitting: boolean
- isNewViewFormValid: boolean
- isRenameViewFormSubmitting: boolean
- isRenameViewFormValid: boolean
+ isViewFormSubmitting: boolean
+ isViewFormValid: boolean
liveViewState: AccountsViewState
- newViewForm: {
+ showViewFormErrors: boolean
+ viewForm: {
name: string
visibility: ViewVisibility
}
- newViewFormAllErrors: Record<string, any>
- newViewFormChanged: boolean
- newViewFormErrors: DeepPartialMap<
+ viewFormAllErrors: Record<string, any>
+ viewFormChanged: boolean
+ viewFormErrors: DeepPartialMap<
{
name: string
visibility: ViewVisibility
},
ValidationErrorType
>
- newViewFormHasErrors: boolean
- newViewFormManualErrors: Record<string, any>
- newViewFormTouched: boolean
- newViewFormTouches: Record<string, boolean>
- newViewFormValidationErrors: DeepPartialMap<
+ viewFormHasErrors: boolean
+ viewFormManualErrors: Record<string, any>
+ viewFormTouched: boolean
+ viewFormTouches: Record<string, boolean>
+ viewFormValidationErrors: DeepPartialMap<
{
name: string
visibility: ViewVisibility
},
ValidationErrorType
>
- renameViewForm: {
- name: string
- }
- renameViewFormAllErrors: Record<string, any>
- renameViewFormChanged: boolean
- renameViewFormErrors: DeepPartialMap<
- {
- name: string
- },
- ValidationErrorType
- >
- renameViewFormHasErrors: boolean
- renameViewFormManualErrors: Record<string, any>
- renameViewFormTouched: boolean
- renameViewFormTouches: Record<string, boolean>
- renameViewFormValidationErrors: DeepPartialMap<
- {
- name: string
- },
- ValidationErrorType
- >
- showNewViewFormErrors: boolean
- showRenameViewFormErrors: boolean
viewToDelete: string | null
- viewToRename: string | null
+ viewToEdit: string | null
views: ColumnConfigurationApi[]
viewsLoading: boolean
}
@@ -212,17 +196,12 @@ export interface accountsViewsLogicActions {
reportColumnResize: () => {
value: true
}
- resetNewViewForm: (values?: { name: string; visibility: ViewVisibility }) => {
+ resetViewForm: (values?: { name: string; visibility: ViewVisibility }) => {
values?: {
name: string
visibility: ViewVisibility
}
}
- resetRenameViewForm: (values?: { name: string }) => {
- values?: {
- name: string
- }
- }
selectView: (id: string) => {
id: string
}
@@ -239,17 +218,17 @@ export interface accountsViewsLogicActions {
setIsCreating: (isCreating: boolean) => {
isCreating: boolean
}
- setNewViewFormManualErrors: (errors: Record<string, any>) => {
+ setViewFormManualErrors: (errors: Record<string, any>) => {
errors: Record<string, any>
}
- setNewViewFormValue: (
+ setViewFormValue: (
key: FieldName,
value: any
) => {
name: FieldName
value: any
}
- setNewViewFormValues: (
+ setViewFormValues: (
values: DeepPartial<{
name: string
visibility: ViewVisibility
@@ -260,82 +239,40 @@ export interface accountsViewsLogicActions {
visibility: ViewVisibility
}>
}
- setRenameViewFormManualErrors: (errors: Record<string, any>) => {
- errors: Record<string, any>
- }
- setRenameViewFormValue: (
- key: FieldName,
- value: any
- ) => {
- name: FieldName
- value: any
- }
- setRenameViewFormValues: (
- values: DeepPartial<{
- name: string
- }>
- ) => {
- values: DeepPartial<{
- name: string
- }>
- }
setViewToDelete: (id: string | null) => {
id: string | null
}
- setViewToRename: (id: string | null) => {
+ setViewToEdit: (id: string | null) => {
id: string | null
}
- submitNewViewForm: () => {
+ submitViewForm: () => {
value: boolean
}
- submitNewViewFormFailure: (
+ submitViewFormFailure: (
error: Error,
errors: Record<string, any>
) => {
error: Error
errors: Record<string, any>
}
- submitNewViewFormRequest: (newViewForm: { name: string; visibility: ViewVisibility }) => {
- newViewForm: {
+ submitViewFormRequest: (viewForm: { name: string; visibility: ViewVisibility }) => {
+ viewForm: {
name: string
visibility: ViewVisibility
}
}
- submitNewViewFormSuccess: (newViewForm: { name: string; visibility: ViewVisibility }) => {
- newViewForm: {
+ submitViewFormSuccess: (viewForm: { name: string; visibility: ViewVisibility }) => {
+ viewForm: {
name: string
visibility: ViewVisibility
}
}
- submitRenameViewForm: () => {
- value: boolean
- }
- submitRenameViewFormFailure: (
- error: Error,
- errors: Record<string, any>
- ) => {
- error: Error
- errors: Record<string, any>
- }
- submitRenameViewFormRequest: (renameViewForm: { name: string }) => {
- renameViewForm: {
- name: string
- }
- }
- submitRenameViewFormSuccess: (renameViewForm: { name: string }) => {
- renameViewForm: {
- name: string
- }
- }
- touchNewViewFormField: (key: string) => {
+ touchViewFormField: (key: string) => {
key: string
}
- touchRenameViewFormField: (key: string) => {
- key: string
- }
- updateView: ({ id, updates }: { id: string; updates: Partial<ColumnConfigurationApi> }) => {
+ updateView: ({ id, updates }: { id: string; updates: PatchedColumnConfigurationApi }) => {
id: string
- updates: Partial<ColumnConfigurationApi>
+ updates: PatchedColumnConfigurationApi
}
updateViewFailure: (
error: string,
@@ -348,13 +285,13 @@ export interface accountsViewsLogicActions {
views: ColumnConfigurationApi[],
payload?: {
id: string
- updates: Partial<ColumnConfigurationApi>
+ updates: PatchedColumnConfigurationApi
}
) => {
views: ColumnConfigurationApi[]
payload?: {
id: string
- updates: Partial<ColumnConfigurationApi>
+ updates: PatchedColumnConfigurationApi
}
}
}
@@ -376,7 +313,7 @@ export interface accountsViewsLogicMeta {
) => AccountsViewState
currentView: (views: ColumnConfigurationApi[], currentViewId: string | null) => ColumnConfigurationApi | null
isDirty: (currentView: ColumnConfigurationApi | null, liveViewState: AccountsViewState) => boolean
- canEditCurrentView: (currentView: ColumnConfigurationApi | null, user: UserType | null) => boolean
+ canEditCurrentView: (currentView: ColumnConfigurationApi | null) => boolean
}
}
@@ -427,14 +364,16 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
reportColumnResize: true,
setIsCreating: (isCreating: boolean) => ({ isCreating }),
setViewToDelete: (id: string | null) => ({ id }),
- setViewToRename: (id: string | null) => ({ id }),
+ setViewToEdit: (id: string | null) => ({ id }),
}),
loaders(({ values }) => ({
views: [
[] as ColumnConfigurationApi[],
{
loadViews: async (): Promise<ColumnConfigurationApi[]> => {
- const response = await api.columnConfigurations.list({ context_key: ACCOUNTS_COLUMN_CONFIG_KEY })
+ const response = await columnConfigurationsList(String(values.currentTeamId), {
+ context_key: ACCOUNTS_COLUMN_CONFIG_KEY,
+ })
return response.results
},
updateView: async ({
@@ -442,15 +381,15 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
updates,
}: {
id: string
- updates: Partial<ColumnConfigurationApi>
+ updates: PatchedColumnConfigurationApi
}): Promise<ColumnConfigurationApi[]> => {
const data =
Object.keys(updates).length === 0 ? serializeAccountsView(values.liveViewState) : updates
- const response = await api.columnConfigurations.update({ id, data })
+ const response = await columnConfigurationsPartialUpdate(String(values.currentTeamId), id, data)
return values.views.map((view) => (view.id === id ? response : view))
},
deleteView: async ({ id }: { id: string }): Promise<ColumnConfigurationApi[]> => {
- await api.columnConfigurations.delete({ id })
+ await columnConfigurationsDestroy(String(values.currentTeamId), id)
return values.views.filter((view) => view.id !== id)
},
patchViewProperties: async ({
@@ -460,7 +399,9 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
id: string
properties: AccountsViewProperties
}): Promise<ColumnConfigurationApi[]> => {
- const response = await api.columnConfigurations.update({ id, data: { properties } })
+ const response = await columnConfigurationsPartialUpdate(String(values.currentTeamId), id, {
+ properties,
+ })
return values.views.map((view) => (view.id === id ? response : view))
},
},
@@ -492,20 +433,22 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
false,
{
setIsCreating: (_, { isCreating }) => isCreating,
- submitNewViewFormSuccess: () => false,
+ submitViewFormSuccess: () => false,
},
],
viewToDelete: [
null as string | null,
{
setViewToDelete: (_, { id }) => id,
+ deleteViewSuccess: () => null,
},
],
- viewToRename: [
+ viewToEdit: [
null as string | null,
{
- setViewToRename: (_, { id }) => id,
- updateViewSuccess: () => null,
+ setViewToEdit: (_, { id }) => id,
+ updateViewSuccess: (state, { payload }) =>
+ payload?.id === state && Object.keys(payload.updates).length > 0 ? null : state,
},
],
})),
@@ -565,43 +508,35 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
: false,
],
canEditCurrentView: [
- (s) => [s.currentView, s.user],
- (currentView: ColumnConfigurationApi | null, user: null | import('~/types').UserType): boolean =>
- !!currentView && !!user && currentView.created_by === user.id,
+ (s) => [s.currentView],
+ (currentView: ColumnConfigurationApi | null): boolean => !!currentView,
],
}),
forms(({ actions, values }) => ({
- newViewForm: {
+ viewForm: {
defaults: { name: '', visibility: 'private' as ViewVisibility },
errors: ({ name }: { name: string }) => ({ name: !name?.trim() ? 'Name is required' : undefined }),
submit: async ({ name, visibility }: { name: string; visibility: ViewVisibility }) => {
- const response = await api.columnConfigurations.create({
- data: {
- ...serializeAccountsView(values.liveViewState),
- context_key: ACCOUNTS_COLUMN_CONFIG_KEY,
- name: name.trim(),
- visibility,
- },
+ if (values.viewToEdit) {
+ actions.updateView({ id: values.viewToEdit, updates: { name: name.trim(), visibility } })
+ return
+ }
+ const response = await columnConfigurationsCreate(String(values.currentTeamId), {
+ ...serializeAccountsView(values.liveViewState),
+ context_key: ACCOUNTS_COLUMN_CONFIG_KEY,
+ name: name.trim(),
+ visibility,
})
actions.loadViews()
actions.applyView(response)
- actions.resetNewViewForm()
- posthog.capture(AccountsEvents.ViewSaved, { visibility })
- },
- },
- renameViewForm: {
- defaults: { name: '' },
- errors: ({ name }: { name: string }) => ({ name: !name?.trim() ? 'Name is required' : undefined }),
- submit: ({ name }: { name: string }) => {
- if (values.viewToRename) {
- actions.updateView({ id: values.viewToRename, updates: { name: name.trim() } })
- }
+ actions.resetViewForm()
+ posthog.capture(AccountsEvents.ViewSaved, { visibility }) // [PostHog] Event: dynamic event name
},
},
})),
listeners(({ actions, values }) => ({
reportColumnResize: () => {
- posthog.capture(AccountsEvents.ColumnResized)
+ posthog.capture(AccountsEvents.ColumnResized) // [PostHog] Event: dynamic event name
},
selectView: ({ id }) => {
const view = values.views.find((v) => v.id === id)
@@ -625,18 +560,20 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
actions.setTiles(state.tiles)
actions.setTileFilter(state.filters.tileFilter)
actions.setCurrentViewId(view.id)
- posthog.capture(AccountsEvents.ViewSelected, { visibility: view.visibility })
+ posthog.capture(AccountsEvents.ViewSelected, { visibility: view.visibility }) // [PostHog] Event: dynamic event name
},
- setViewToRename: ({ id }) => {
- const view = id ? values.views.find((v) => v.id === id) : undefined
+ setViewToEdit: ({ id }) => {
+ const view = id ? values.views.find((candidate) => candidate.id === id) : undefined
if (view) {
- actions.setRenameViewFormValue('name', view.name)
+ actions.setViewFormValues({ name: view.name ?? '', visibility: view.visibility ?? 'shared' })
}
},
- updateViewSuccess: () => {
+ updateViewSuccess: ({ payload }) => {
lemonToast.success('View updated')
- posthog.capture(AccountsEvents.ViewUpdated)
- actions.resetRenameViewForm()
+ posthog.capture(AccountsEvents.ViewUpdated) // [PostHog] Event: dynamic event name
+ if (payload && Object.keys(payload.updates).length > 0) {
+ actions.resetViewForm()
+ }
},
updateViewFailure: ({ error }) => {
posthog.captureException(error)
@@ -644,7 +581,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
},
deleteViewSuccess: () => {
lemonToast.success('View deleted')
- posthog.capture(AccountsEvents.ViewDeleted)
+ posthog.capture(AccountsEvents.ViewDeleted) // [PostHog] Event: dynamic event name
},
deleteViewFailure: ({ error }) => {
posthog.captureException(error)
@@ -655,7 +592,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
lemonToast.error('Failed to load views')
actions.setAwaitingSavedView(false)
},
- submitNewViewFormFailure: ({ error }) => {
+ submitViewFormFailure: ({ error }) => {
posthog.captureException(error)
lemonToast.error('Failed to save view')
},
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 6f866af7baa6..b184406a8a96 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -8869,6 +8869,11 @@ export interface PathsV2SegmentToFunnelResponseApi {
}
export type ColumnConfigurationsListParams = {
+ /**
+ * Return saved views for this context only.
+ * @minLength 1
+ */
+ context_key?: string
/**
* Number of results to return per page.
*/
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index f78e042af1f0..c7644bd2774e 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -93268,6 +93268,11 @@ export namespace Schemas {
} as const;
export type ColumnConfigurationsListParams = {
+ /**
+ * Return saved views for this context only.
+ * @minLength 1
+ */
+ context_key?: string;
/**
* Number of results to return per page.
*/