-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web-analytics): Add custom bounce rate control (#27121)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b09e3f0
commit e56f52b
Showing
25 changed files
with
195 additions
and
15 deletions.
There are no files selected for viewing
Binary file modified
BIN
+9.68 KB
(100%)
frontend/__snapshots__/scenes-other-settings--settings-project--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.2 KB
(100%)
frontend/__snapshots__/scenes-other-settings--settings-project--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.87 KB
(100%)
...pshots__/scenes-other-settings--settings-project-with-replay-features--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.32 KB
(100%)
...shots__/scenes-other-settings--settings-project-with-replay-features--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.68 KB
(100%)
...apshots__/scenes-other-settings--settings-session-timeout-all-options--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.2 KB
(100%)
...pshots__/scenes-other-settings--settings-session-timeout-all-options--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.68 KB
(100%)
...shots__/scenes-other-settings--settings-session-timeout-password-only--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.2 KB
(100%)
...hots__/scenes-other-settings--settings-session-timeout-password-only--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.68 KB
(100%)
..._/scenes-other-settings--settings-session-timeout-sso-enforced-github--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.2 KB
(100%)
.../scenes-other-settings--settings-session-timeout-sso-enforced-github--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.68 KB
(100%)
..._/scenes-other-settings--settings-session-timeout-sso-enforced-google--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.2 KB
(100%)
.../scenes-other-settings--settings-session-timeout-sso-enforced-google--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.68 KB
(100%)
...s__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.2 KB
(100%)
...__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9.68 KB
(100%)
..._snapshots__/scenes-other-settings--settings-session-timeout-sso-only--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.2 KB
(100%)
...snapshots__/scenes-other-settings--settings-session-timeout-sso-only--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
frontend/src/scenes/settings/environment/BounceRateDuration.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { IconX } from '@posthog/icons' | ||
import { useActions, useValues } from 'kea' | ||
import { LemonButton } from 'lib/lemon-ui/LemonButton' | ||
import { LemonInput } from 'lib/lemon-ui/LemonInput' | ||
import React, { useState } from 'react' | ||
import { teamLogic } from 'scenes/teamLogic' | ||
|
||
const MIN_BOUNCE_RATE_DURATION = 1 | ||
const MAX_BOUNCE_RATE_DURATION = 120 | ||
const DEFAULT_BOUNCE_RATE_DURATION = 10 | ||
|
||
export function BounceRateDurationSetting(): JSX.Element { | ||
const { updateCurrentTeam } = useActions(teamLogic) | ||
const { currentTeam } = useValues(teamLogic) | ||
|
||
const savedDuration = | ||
currentTeam?.modifiers?.bounceRateDurationSeconds ?? currentTeam?.default_modifiers?.bounceRateDurationSeconds | ||
const [bounceRateDuration, setBounceRateDuration] = useState<number>(savedDuration ?? DEFAULT_BOUNCE_RATE_DURATION) | ||
|
||
const handleChange = (duration: number | undefined): void => { | ||
if (Number.isNaN(duration)) { | ||
duration = undefined | ||
} | ||
updateCurrentTeam({ | ||
modifiers: { ...currentTeam?.modifiers, bounceRateDurationSeconds: duration }, | ||
}) | ||
} | ||
|
||
const inputRef = React.useRef<HTMLInputElement>(null) | ||
|
||
return ( | ||
<> | ||
<p> | ||
Choose how long a user can stay on a page, in seconds, before the session is not a bounce. Leave blank | ||
to use the default of {DEFAULT_BOUNCE_RATE_DURATION} seconds, or set a custom value between{' '} | ||
{MIN_BOUNCE_RATE_DURATION} second and {MAX_BOUNCE_RATE_DURATION} seconds inclusive. | ||
</p> | ||
<LemonInput | ||
type="number" | ||
min={MIN_BOUNCE_RATE_DURATION} | ||
max={MAX_BOUNCE_RATE_DURATION} | ||
value={bounceRateDuration ?? null} | ||
onChange={(x) => { | ||
if (x == null || Number.isNaN(x)) { | ||
setBounceRateDuration(DEFAULT_BOUNCE_RATE_DURATION) | ||
} else { | ||
setBounceRateDuration(x) | ||
} | ||
}} | ||
inputRef={inputRef} | ||
suffix={ | ||
<LemonButton | ||
size="small" | ||
noPadding | ||
icon={<IconX />} | ||
tooltip="Clear input" | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
setBounceRateDuration(DEFAULT_BOUNCE_RATE_DURATION) | ||
inputRef.current?.focus() | ||
}} | ||
/> | ||
} | ||
/> | ||
<div className="mt-4"> | ||
<LemonButton | ||
type="primary" | ||
onClick={() => handleChange(bounceRateDuration)} | ||
disabledReason={ | ||
bounceRateDuration === savedDuration | ||
? 'No changes to save' | ||
: bounceRateDuration == undefined | ||
? undefined | ||
: isNaN(bounceRateDuration) | ||
? 'Invalid number' | ||
: bounceRateDuration < MIN_BOUNCE_RATE_DURATION | ||
? `Duration must be at least ${MIN_BOUNCE_RATE_DURATION} second` | ||
: bounceRateDuration > MAX_BOUNCE_RATE_DURATION | ||
? `Duration must be less than ${MAX_BOUNCE_RATE_DURATION} seconds` | ||
: undefined | ||
} | ||
> | ||
Save | ||
</LemonButton> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters