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

refactor: make console logs and network performance buttons toggled ON by default #23900

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed2ead5
refactor: set console logs and network performance buttons toggled ON…
namit-chandwani Jul 21, 2024
18e63aa
Merge branch 'master' into refactor/session-replay-toggles
namit-chandwani Jul 22, 2024
a14a892
Merge branch 'master' of https://github.com/PostHog/posthog into refa…
namit-chandwani Jul 23, 2024
8905e9f
chore: add migration to set default values for Team model opt-in fields
namit-chandwani Jul 23, 2024
7c76b01
style: update disabled reason message for session replay related swit…
namit-chandwani Jul 23, 2024
5baed38
Merge branch 'master' of https://github.com/PostHog/posthog into refa…
namit-chandwani Jul 24, 2024
adfe554
chore: regenerate migration file to resolve conflicts
namit-chandwani Jul 24, 2024
c4e339c
test: resolve failing backend test cases
namit-chandwani Jul 24, 2024
9360451
Merge branch 'master' of https://github.com/PostHog/posthog into refa…
namit-chandwani Jul 24, 2024
361c832
Merge branch 'master' of https://github.com/PostHog/posthog into refa…
namit-chandwani Jul 24, 2024
4b2a3ef
chore: regenerate migration file to resolve conflicts
namit-chandwani Jul 24, 2024
62b0ae2
Merge branch 'master' into refactor/session-replay-toggles
namit-chandwani Jul 26, 2024
1ed2cda
test: update test_user_performance_opt_in unit test to cover both tog…
Jul 29, 2024
c4de457
refactor: update field types to support null values for opt-in options
namit-chandwani Aug 14, 2024
27c20d5
Merge branch 'master' of github.com:PostHog/posthog into refactor/ses…
namit-chandwani Aug 14, 2024
e017367
chore: regenerate migration file to resolve conflicts
namit-chandwani Aug 14, 2024
9e66241
Merge branch 'master' of github.com:PostHog/posthog into refactor/ses…
namit-chandwani Aug 15, 2024
10c3362
chore: regenerate migration file to resolve conflicts
namit-chandwani Aug 15, 2024
3d9c968
build: resolve the failing Frontend CI check
namit-chandwani Aug 19, 2024
d675f58
Merge branch 'master' of github.com:PostHog/posthog into refactor/ses…
namit-chandwani Aug 19, 2024
2e0b684
chore: regenerate migration file to resolve conflicts
namit-chandwani Aug 19, 2024
d18f075
Merge branch 'master' of github.com:PostHog/posthog into refactor/ses…
namit-chandwani Aug 22, 2024
0beaf18
chore: regenerate migration file to resolve conflicts
namit-chandwani Aug 22, 2024
de75d1e
Merge branch 'master' of github.com:PostHog/posthog into refactor/ses…
namit-chandwani Aug 23, 2024
aaccb9b
chore: regenerate migration file to resolve conflicts
namit-chandwani Aug 23, 2024
caf633a
Merge branch 'master' into refactor/session-replay-toggles
namit-chandwani Aug 26, 2024
70d74d7
Merge branch 'master' of github.com:PostHog/posthog into refactor/ses…
namit-chandwani Aug 28, 2024
45dfd06
chore: regenerate migration file to resolve conflicts
namit-chandwani Aug 28, 2024
f03de59
Merge branch 'master' of github.com:PostHog/posthog into refactor/ses…
namit-chandwani Aug 28, 2024
962006c
chore: regenerate migration file to resolve conflicts
namit-chandwani Aug 28, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function renderTimeBenchmark(milliseconds: number): JSX.Element {
}

function emptyPayloadMessage(
payloadCaptureIsEnabled: undefined | boolean,
payloadCaptureIsEnabled: boolean | undefined | null,
item: PerformanceEvent,
label: 'Request' | 'Response'
): JSX.Element | string {
Expand Down
18 changes: 5 additions & 13 deletions frontend/src/scenes/settings/project/SessionRecordingSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ function LogCaptureSettings(): JSX.Element {
}}
label="Capture console logs"
bordered
checked={currentTeam?.session_recording_opt_in ? !!currentTeam?.capture_console_log_opt_in : false}
disabledReason={
!currentTeam?.session_recording_opt_in ? 'session recording must be enabled' : undefined
}
checked={!!currentTeam?.capture_console_log_opt_in}
daibhin marked this conversation as resolved.
Show resolved Hide resolved
disabledReason={!currentTeam?.session_recording_opt_in ? 'Session replay must be enabled' : undefined}
/>
</div>
)
Expand Down Expand Up @@ -89,9 +87,7 @@ function CanvasCaptureSettings(): JSX.Element | null {
checked={
currentTeam?.session_replay_config ? !!currentTeam?.session_replay_config?.record_canvas : false
}
disabledReason={
!currentTeam?.session_recording_opt_in ? 'session recording must be enabled' : undefined
}
disabledReason={!currentTeam?.session_recording_opt_in ? 'Session replay must be enabled' : undefined}
/>
</div>
)
Expand Down Expand Up @@ -134,10 +130,8 @@ export function NetworkCaptureSettings(): JSX.Element {
}}
label="Capture network performance"
bordered
checked={currentTeam?.session_recording_opt_in ? !!currentTeam?.capture_performance_opt_in : false}
disabledReason={
!currentTeam?.session_recording_opt_in ? 'session recording must be enabled' : undefined
}
checked={!!currentTeam?.capture_performance_opt_in}
disabledReason={!currentTeam?.session_recording_opt_in ? 'Session replay must be enabled' : undefined}
/>
<div className="mt-4">
<p>
Expand Down Expand Up @@ -676,8 +670,6 @@ export function ReplayGeneral(): JSX.Element {
// when switching replay on or off,
// we set defaults for some of the other settings
session_recording_opt_in: checked,
capture_console_log_opt_in: checked,
capture_performance_opt_in: checked,
})
}}
label="Record user sessions"
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,9 @@ export interface TeamType extends TeamBasicType {
slack_incoming_webhook: string
autocapture_opt_out: boolean
session_recording_opt_in: boolean
capture_console_log_opt_in: boolean
capture_performance_opt_in: boolean
// These fields in the database accept null values and were previously set to NULL by default
capture_console_log_opt_in: boolean | null
capture_performance_opt_in: boolean | null
// a string representation of the decimal value between 0 and 1
session_recording_sample_rate: string
session_recording_minimum_duration_milliseconds: number | null
Expand Down
2 changes: 1 addition & 1 deletion latest_migrations.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ contenttypes: 0002_remove_content_type_name
ee: 0016_rolemembership_organization_member
otp_static: 0002_throttling
otp_totp: 0002_auto_20190420_0723
posthog: 0461_alter_externaldatasource_source_type
posthog: 0462_change_replay_team_setting_defaults
sessions: 0001_initial
social_django: 0010_uid_db_index
two_factor: 0007_auto_20201201_1019
24 changes: 12 additions & 12 deletions posthog/api/test/test_decide.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_user_session_recording_opt_in(self, *args):
assert response["sessionRecording"] == {
"endpoint": "/s/",
"recorderVersion": "v2",
"consoleLogRecordingEnabled": False,
"consoleLogRecordingEnabled": True,
"sampleRate": None,
"linkedFlag": None,
"minimumDurationMilliseconds": None,
Expand Down Expand Up @@ -189,12 +189,12 @@ def test_user_console_log_opt_in(self, *args):
def test_user_performance_opt_in(self, *args):
# :TRICKY: Test for regression around caching
response = self._post_decide().json()
self.assertEqual(response["capturePerformance"], False)
self.assertEqual(response["capturePerformance"], {"network_timing": True, "web_vitals": False})

self._update_team({"capture_performance_opt_in": True})
self._update_team({"capture_performance_opt_in": False})

response = self._post_decide().json()
self.assertEqual(response["capturePerformance"], {"network_timing": True, "web_vitals": False})
self.assertEqual(response["capturePerformance"], False)

def test_session_recording_sample_rate(self, *args):
# :TRICKY: Test for regression around caching
Expand Down Expand Up @@ -376,14 +376,14 @@ def test_exception_autocapture_opt_in(self, *args):

def test_web_vitals_autocapture_opt_in(self, *args):
response = self._post_decide().json()
self.assertEqual(response["capturePerformance"], False)
daibhin marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(response["capturePerformance"], {"web_vitals": False, "network_timing": True})

self._update_team({"autocapture_web_vitals_opt_in": True})

response = self._post_decide().json()
self.assertEqual(
response["capturePerformance"],
{"web_vitals": True, "network_timing": False},
{"web_vitals": True, "network_timing": True},
)

def test_user_session_recording_opt_in_wildcard_domain(self, *args):
Expand All @@ -402,7 +402,7 @@ def test_user_session_recording_opt_in_wildcard_domain(self, *args):
assert response["sessionRecording"] == {
"endpoint": "/s/",
"recorderVersion": "v2",
"consoleLogRecordingEnabled": False,
"consoleLogRecordingEnabled": True,
"sampleRate": None,
"linkedFlag": None,
"minimumDurationMilliseconds": None,
Expand All @@ -429,7 +429,7 @@ def test_user_session_recording_evil_site(self, *args):
assert response["sessionRecording"] == {
"endpoint": "/s/",
"recorderVersion": "v2",
"consoleLogRecordingEnabled": False,
"consoleLogRecordingEnabled": True,
"sampleRate": None,
"linkedFlag": None,
"minimumDurationMilliseconds": None,
Expand Down Expand Up @@ -463,7 +463,7 @@ def test_user_session_recording_allowed_when_no_permitted_domains_are_set(self,
assert response["sessionRecording"] == {
"endpoint": "/s/",
"recorderVersion": "v2",
"consoleLogRecordingEnabled": False,
"consoleLogRecordingEnabled": True,
"sampleRate": None,
"linkedFlag": None,
"minimumDurationMilliseconds": None,
Expand All @@ -477,7 +477,7 @@ def test_user_session_recording_allowed_for_android(self, *args) -> None:
assert response["sessionRecording"] == {
"endpoint": "/s/",
"recorderVersion": "v2",
"consoleLogRecordingEnabled": False,
"consoleLogRecordingEnabled": True,
"sampleRate": None,
"linkedFlag": None,
"minimumDurationMilliseconds": None,
Expand All @@ -491,7 +491,7 @@ def test_user_session_recording_allowed_for_ios(self, *args) -> None:
assert response["sessionRecording"] == {
"endpoint": "/s/",
"recorderVersion": "v2",
"consoleLogRecordingEnabled": False,
"consoleLogRecordingEnabled": True,
"sampleRate": None,
"linkedFlag": None,
"minimumDurationMilliseconds": None,
Expand All @@ -510,7 +510,7 @@ def test_user_session_recording_allowed_when_permitted_domains_are_not_http_base
assert response["sessionRecording"] == {
"endpoint": "/s/",
"recorderVersion": "v2",
"consoleLogRecordingEnabled": False,
"consoleLogRecordingEnabled": True,
"sampleRate": None,
"linkedFlag": None,
"minimumDurationMilliseconds": None,
Expand Down
22 changes: 22 additions & 0 deletions posthog/migrations/0462_change_replay_team_setting_defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.14 on 2024-08-28 08:55

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("posthog", "0461_alter_externaldatasource_source_type"),
]

operations = [
migrations.AlterField(
model_name="team",
name="capture_console_log_opt_in",
field=models.BooleanField(blank=True, default=True, null=True),
),
migrations.AlterField(
model_name="team",
name="capture_performance_opt_in",
field=models.BooleanField(blank=True, default=True, null=True),
),
]
4 changes: 2 additions & 2 deletions posthog/models/team/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ class Meta:
session_recording_linked_flag = models.JSONField(null=True, blank=True)
session_recording_network_payload_capture_config = models.JSONField(null=True, blank=True)
session_replay_config = models.JSONField(null=True, blank=True)
capture_console_log_opt_in = models.BooleanField(null=True, blank=True)
capture_performance_opt_in = models.BooleanField(null=True, blank=True)
capture_console_log_opt_in = models.BooleanField(null=True, blank=True, default=True)
capture_performance_opt_in = models.BooleanField(null=True, blank=True, default=True)
surveys_opt_in = models.BooleanField(null=True, blank=True)
heatmaps_opt_in = models.BooleanField(null=True, blank=True)
session_recording_version = models.CharField(null=True, blank=True, max_length=24)
Expand Down
Loading