Skip to content
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

feat: adding capture events for toggling access control button #26705

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,403 changes: 4,403 additions & 0 deletions .aider.chat.history.md

Large diffs are not rendered by default.

776 changes: 776 additions & 0 deletions .aider.input.history

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .aider.tags.cache.v3/cache.db-shm
Binary file not shown.
Empty file.
Binary file not shown.
1 change: 1 addition & 0 deletions .eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"/Users/surbhijhavar/posthog/frontend/src/scenes/authentication/inviteSignupLogic.ts":"1"},{"size":5070,"mtime":1733514037453,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"9ifu3r","/Users/surbhijhavar/posthog/frontend/src/scenes/authentication/inviteSignupLogic.ts",[],[]]
20 changes: 19 additions & 1 deletion posthog/api/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from posthog.api.utils import action
from posthog.auth import PersonalAPIKeyAuthentication
from posthog.constants import AvailableFeature
from posthog.event_usage import report_user_action
from posthog.event_usage import report_user_action, groups
from posthog.geoip import get_geoip_properties
from posthog.jwt import PosthogJwtAudience, encode_jwt
from posthog.models import ProductIntent, Team, User
Expand Down Expand Up @@ -52,6 +52,7 @@
get_ip_address,
get_week_start_for_country_code,
)
import posthoganalytics


class PremiumMultiProjectPermissions(BasePermission): # TODO: Rename to include "Env" in name
Expand Down Expand Up @@ -371,6 +372,23 @@ def create(self, validated_data: dict[str, Any], **kwargs) -> Team:
def update(self, instance: Team, validated_data: dict[str, Any]) -> Team:
before_update = instance.__dict__.copy()

# Add tracking for access control changes
if "access_control" in validated_data and validated_data["access_control"] != instance.access_control:
user = cast(User, self.context["request"].user)
posthoganalytics.capture(
str(user.distinct_id),
"project access control toggled",
properties={
"enabled": validated_data["access_control"],
"project_id": str(instance.id),
"project_name": instance.name,
"organization_id": str(instance.organization_id),
"organization_name": instance.organization.name,
"user_role": user.organization_memberships.get(organization=instance.organization).level,
},
groups=groups(instance.organization),
)

if "survey_config" in validated_data:
if instance.survey_config is not None and validated_data.get("survey_config") is not None:
validated_data["survey_config"] = {
Expand Down
Loading