10000 feat(project-tree): activity log by mariusandra · Pull Request #33303 · PostHog/posthog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(project-tree): activity log #33303

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

mariusandra
Copy link
Collaborator

Problem

File system entries don't have activity logs.

Changes

Add 'em. Only storing the data in the backend now, not displaying it anywhere.

How did you test this code?

There's a test

Copy link
Contributor
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added activity logging functionality for file system entries, introducing tracking for create, update, and delete operations across the backend infrastructure.

  • Implemented log_file_system_activity() helper in posthog/api/file_system/file_system.py to track file operations consistently
  • Added activity tracking points in key file system operations (create, update, destroy, move, link) with appropriate scope and detail logging
  • Extended ActivityScope enum in frontend/src/types.ts to include 'FILE_SYSTEM' for proper type support
  • Comprehensive test coverage in test_file_system.py validates activity logging for all file system operations

While the core functionality is solid, recommend adding error handling for the activity logging to prevent operation failures if logging fails.

4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +1463 to +1471
create_resp = self.client.post(
f"/api/projects/{self.team.id}/file_system/",
{"path": "Logged/File.txt", "type": "doc"},
)
self.assertEqual(create_resp.status_code, status.HTTP_201_CREATED)
from posthog.models import ActivityLog

activity = ActivityLog.objects.filter(scope="FileSystem", activity="created").first()
assert activity is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Import ActivityLog at the top of the file with other imports rather than inside the test method

Suggested change
create_resp = self.client.post(
f"/api/projects/{self.team.id}/file_system/",
{"path": "Logged/File.txt", "type": "doc"},
)
self.assertEqual(create_resp.status_code, status.HTTP_201_CREATED)
from posthog.models import ActivityLog
activity = ActivityLog.objects.filter(scope="FileSystem", activity="created").first()
assert activity is not None
import pytest
from freezegun import freeze_time
from rest_framework import status
from rest_framework.test import APIRequestFactory
from posthog.test.base import APIBaseTest
from posthog.models import User, FeatureFlag, Dashboard, Experiment, Insight, Notebook, Team, Project, ActivityLog
from posthog.models.file_system.file_system import FileSystem
from unittest.mock import patch
from ee.models.rbac.access_control import AccessControl
from datetime import UTC

Comment on lines +1469 to +1471

activity = ActivityLog.objects.filter(scope="FileSystem", activity="created").first()
assert activity is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using assertIsNotNone() instead of assert activity is not None for consistency with other assertions in the test class

Comment on lines 527 to 541
log_file_system_activity(
activity="updated",
file_system=instance,
user=request.user,
was_impersonated=is_impersonated_session(request),
changes=[
Change(
type="FileSystem",
field="path",
action="changed",
before=old_path,
after=instance.path,
)
],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Potential bug: logging activity with instance that has no ID (pk=None was just called). Use original instance for logging.

Copy link
Contributor
github-actions bot commented Jun 6, 2025

Size Change: -98 B (0%)

Total Size: 3.76 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 3.76 MB -98 B (0%)

compressed-size-action

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0