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: more replay trigger options #27897

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export const FEATURE_FLAGS = {
WEB_REVENUE_TRACKING: 'web-revenue-tracking', // owner: @robbie-c #team-web-analytics
LLM_OBSERVABILITY: 'llm-observability', // owner: #team-ai-product-manager
ONBOARDING_SESSION_REPLAY_SEPERATE_STEP: 'onboarding-session-replay-separate-step', // owner: @joshsny #team-growth
REPLAY_TRIGGER_OPTIONS: 'replay-trigger-options', // owner: @pauldambra #team-replay
} as const
export type FeatureFlagKey = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]

Expand Down
71 changes: 58 additions & 13 deletions frontend/src/scenes/settings/environment/ReplayTriggers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { Form } from 'kea-forms'
import { EventSelect } from 'lib/components/EventSelect/EventSelect'
import { FlaggedFeature } from 'lib/components/FlaggedFeature'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { FEATURE_FLAGS } from 'lib/constants'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonInput } from 'lib/lemon-ui/LemonInput'
import { LemonLabel } from 'lib/lemon-ui/LemonLabel'
import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
import { replayTriggersLogic } from 'scenes/settings/environment/replayTriggersLogic'
import { SupportedPlatforms } from 'scenes/settings/environment/SessionRecordingSettings'

Expand All @@ -32,17 +35,59 @@ function UrlConfigForm({
className="w-full flex flex-col border rounded items-center p-2 pl-4 bg-bg-light gap-2"
>
<div className="flex flex-col gap-2 w-full">
<LemonBanner type="info" className="text-sm">
We always wrap the URL regex with anchors to avoid unexpected behavior (if you do not). This is
because <pre className="inline">https://example.com/</pre> does not only match the homepage. You'd
need <pre className="inline">^https://example.com/$</pre>
</LemonBanner>
<LemonLabel className="w-full">
Matching regex:
<LemonField name="url" className="flex-1">
<LemonInput autoFocus placeholder="Enter URL regex." data-attr="url-input" />
</LemonField>
</LemonLabel>
<FlaggedFeature flag={FEATURE_FLAGS.REPLAY_TRIGGER_OPTIONS} match={false}>
<LemonBanner type="info" className="text-sm">
We always wrap the URL regex with anchors to avoid unexpected behavior (if you do not). This is
because <pre className="inline">https://example.com/</pre> does not only match the homepage.
You'd need <pre className="inline">^https://example.com/$</pre>
</LemonBanner>
<LemonLabel className="w-full">
Matching regex:
<LemonField name="url" className="flex-1">
<LemonInput autoFocus placeholder="Enter URL regex." data-attr="url-input" />
</LemonField>
</LemonLabel>
</FlaggedFeature>
<FlaggedFeature flag={FEATURE_FLAGS.REPLAY_TRIGGER_OPTIONS} match={true}>
<LemonBanner type="info" className="text-sm">
<p>You can match based on regex, host, or path.</p>
<ul className="list-disc ml-4">
<li>
<strong>REGEX: </strong> e.g.{' '}
<pre className="inline bg-accent-3000">
^https://myapp.domain.io/(products|categories).*$
</pre>{' '}
to only start when someone reaches a product or category page. This is the most flexible
option.
</li>
<li>
<strong>HOST: </strong> <pre className="inline bg-accent-3000">myapp.domain.io</pre> to
only start when someone reaches a particular host. Useful if you want to avoid starting
recording on a landing page with high bounce rate.
</li>
<li>
<strong>PATH: </strong> <pre className="inline bg-accent-3000">products/t-shirts</pre>{' '}
to only start when someone reaches a particular path in your application.
</li>
</ul>
</LemonBanner>
<div className="flex flex-row gap-1 flex-wrap">
<LemonField name="matching">
<LemonSelect
allowClear={false}
options={[
{ value: 'hostname', label: 'Host' },
{ value: 'path', label: 'Path' },
{ value: 'regex', label: 'Regex' },
]}
/>
</LemonField>

<LemonField name="url" className="flex-1">
<LemonInput autoFocus placeholder="Enter URL regex." data-attr="url-input" />
</LemonField>
</div>
</FlaggedFeature>
</div>
<div className="flex justify-end gap-2 w-full">
<LemonButton type="secondary" onClick={onCancel}>
Expand Down Expand Up @@ -175,7 +220,7 @@ function UrlTriggerOptions(): JSX.Element | null {
return (
<UrlConfigSection
type="trigger"
title="Enable recordings when URL matches"
title="Start recording when URL matches"
description="Adding a URL trigger means recording will only be started when the user visits a page that matches the URL."
isAddFormVisible={isAddUrlTriggerConfigFormVisible}
config={urlTriggerConfig}
Expand All @@ -202,7 +247,7 @@ function UrlBlocklistOptions(): JSX.Element | null {
return (
<UrlConfigSection
type="blocklist"
title="Pause recordings when URL matches"
title="Pause recording when URL matches"
description="Recording will be paused when the user visits a page that matches the URL."
isAddFormVisible={isAddUrlBlocklistConfigFormVisible}
config={urlBlocklistConfig}
Expand Down
Loading