-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(surveys): add configurable delay to popup surveys #22780
Changes from 23 commits
bf16859
5b2c1d5
59d5f71
d19810a
1e3c800
c48c4f6
728eef7
456c864
d2a526d
1531f6f
9afbdc5
64e68b8
46a4b47
d3ca624
1557789
f77b0b7
e6e8bad
c0cc810
c2eef3a
69e3ff3
02e6ace
1a096af
daab9c7
cb1d5db
4ea8f8c
b31f67c
207ebc7
45aeb93
902352a
38273c1
7f82937
3414f79
e973579
dd015db
a73184c
c127648
cd7cc7f
1928ead
926be64
f472115
b9d82f0
9bddb36
62e8e7d
1206c9e
d2a4104
bf7e465
57a6804
3533c40
6c06b35
8c95e8e
25403ff
392c01e
28461a1
df9c769
45815fa
e7d250e
c4a77b5
aa64630
c46cc62
69c45ce
25e342c
b5d277d
e48389f
60c9ba3
837e446
7d89379
fdb4f6a
7aa6782
033b6bd
220a291
45f9546
0ba5e0f
de4fac0
a8c7f6a
2354c1f
fa28581
f537add
bf0db84
ca1d4a9
260e930
f162eef
2ee6ce7
7f9b27f
dfcb609
ec3673b
262f597
4669828
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import { LemonButton, LemonCheckbox, LemonInput, LemonSelect } from '@posthog/le | |
import { useValues } from 'kea' | ||
import { PayGateMini } from 'lib/components/PayGateMini/PayGateMini' | ||
import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic' | ||
import { LemonField } from 'lib/lemon-ui/LemonField' | ||
import { surveyLogic } from 'scenes/surveys/surveyLogic' | ||
|
||
import { | ||
|
@@ -134,6 +135,43 @@ export function Customization({ appearance, surveyQuestionItem, onAppearanceChan | |
checked={appearance?.shuffleQuestions} | ||
/> | ||
</div> | ||
<div className="mt-1"> | ||
<LemonField name="survey_popup_delay" className="font-medium"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Don't use a lemonField here since the |
||
{({ onChange }) => { | ||
return ( | ||
<div className="flex flex-row gap-2 items-center"> | ||
<LemonCheckbox | ||
checked={!!appearance?.surveyPopupDelay} | ||
onChange={(checked) => { | ||
const surveyPopupDelay = checked ? 5 : undefined | ||
onChange(surveyPopupDelay) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and then you don't need to call this onChange, since it refers to the |
||
onAppearanceChange({ ...appearance, surveyPopupDelay }) | ||
}} | ||
/> | ||
Delay survey popup after page load by{' '} | ||
dmarticus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<LemonInput | ||
type="number" | ||
data-attr="survey-popup-delay-input" | ||
size="small" | ||
min={1} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a sensible max as well? If this is seconds, I think anything above 1 hour is crazy :P |
||
value={appearance?.surveyPopupDelay || NaN} | ||
onChange={(newValue) => { | ||
if (newValue && newValue > 0) { | ||
onChange(newValue) | ||
onAppearanceChange({ ...appearance, surveyPopupDelay: newValue }) | ||
} else { | ||
onChange(null) | ||
onAppearanceChange({ ...appearance, surveyPopupDelay: undefined }) | ||
} | ||
}} | ||
className="w-12" | ||
/>{' '} | ||
seconds. | ||
</div> | ||
) | ||
}} | ||
</LemonField> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
version: "3.8" | ||
version: '3.8' | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undo changes here please :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh lmao no idea how this got here. Undoing! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pro-tip if you're unaware, when you don't have a specific commit to revert, you can bring a file back to its state on master via:
as long as master is upto date, this will effectively revert all changes in the file! |
||
services: | ||
postgres: | ||
image: postgres:16-alpine | ||
restart: always | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: liveevents | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 5s | ||
timeout: 5s | ||
postgres: | ||
image: postgres:16-alpine | ||
restart: always | ||
ports: | ||
- '5432:5432' | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: liveevents | ||
healthcheck: | ||
test: ['CMD-SHELL', 'pg_isready -U postgres'] | ||
interval: 5s | ||
timeout: 5s | ||
|
||
redis: | ||
image: redis:alpine | ||
restart: always | ||
ports: | ||
- "6379:6379" | ||
redis: | ||
image: redis:alpine | ||
restart: always | ||
ports: | ||
- '6379:6379' | ||
|
||
redpanda: | ||
image: vectorized/redpanda:v23.2.17 | ||
command: | ||
- redpanda start | ||
- --smp 1 | ||
- --overprovisioned | ||
- --node-id 0 | ||
- --kafka-addr PLAINTEXT://0.0.0.0:29092,OUTSIDE://0.0.0.0:9092 | ||
- --advertise-kafka-addr PLAINTEXT://redpanda:29092,OUTSIDE://localhost:9092 | ||
- --pandaproxy-addr 0.0.0.0:8082 | ||
- --advertise-pandaproxy-addr localhost:8082 | ||
ports: | ||
- 8081:8081 | ||
- 8082:8082 | ||
- 9092:9092 | ||
- 29092:29092 | ||
redpanda: | ||
image: vectorized/redpanda:v23.2.17 | ||
command: | ||
- redpanda start | ||
- --smp 1 | ||
- --overprovisioned | ||
- --node-id 0 | ||
- --kafka-addr PLAINTEXT://0.0.0.0:29092,OUTSIDE://0.0.0.0:9092 | ||
- --advertise-kafka-addr PLAINTEXT://redpanda:29092,OUTSIDE://localhost:9092 | ||
- --pandaproxy-addr 0.0.0.0:8082 | ||
- --advertise-pandaproxy-addr localhost:8082 | ||
ports: | ||
- 8081:8081 | ||
- 8082:8082 | ||
- 9092:9092 | ||
- 29092:29092 | ||
|
||
console: | ||
image: docker.redpanda.com/redpandadata/console:v2.3.8 | ||
restart: on-failure | ||
entrypoint: /bin/sh | ||
command: -c "echo \"$$CONSOLE_CONFIG_FILE\" > /tmp/config.yml; /app/console" | ||
environment: | ||
CONFIG_FILEPATH: /tmp/config.yml | ||
CONSOLE_CONFIG_FILE: | | ||
kafka: | ||
brokers: ["redpanda:29092"] | ||
schemaRegistry: | ||
enabled: true | ||
urls: ["http://redpanda:8081"] | ||
connect: | ||
enabled: true | ||
clusters: | ||
- name: datagen | ||
url: http://connect:8083 | ||
ports: | ||
- "8088:8088" | ||
depends_on: | ||
- redpanda | ||
console: | ||
image: docker.redpanda.com/redpandadata/console:v2.3.8 | ||
restart: on-failure | ||
entrypoint: /bin/sh | ||
command: -c "echo \"$$CONSOLE_CONFIG_FILE\" > /tmp/config.yml; /app/console" | ||
environment: | ||
CONFIG_FILEPATH: /tmp/config.yml | ||
CONSOLE_CONFIG_FILE: | | ||
kafka: | ||
brokers: ["redpanda:29092"] | ||
schemaRegistry: | ||
enabled: true | ||
urls: ["http://redpanda:8081"] | ||
connect: | ||
enabled: true | ||
clusters: | ||
- name: datagen | ||
url: http://connect:8083 | ||
ports: | ||
- '8088:8088' | ||
depends_on: | ||
- redpanda |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,10 @@ def validate_appearance(self, value): | |
"You need to upgrade to PostHog Enterprise to use HTML in survey thank you message" | ||
) | ||
|
||
survey_popup_delay_milliseconds = value.get("surveyPopupDelay") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we accept |
||
if survey_popup_delay_milliseconds and survey_popup_delay_milliseconds < 0: | ||
raise serializers.ValidationError("Survey popup delay must be a positive integer") | ||
|
||
return value | ||
|
||
def validate_questions(self, value): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you, but we might want to gate by a feature flag here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I'm electing to not feature flag this, because we