-
Notifications
You must be signed in to change notification settings - Fork 123
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: add renderSurvey option #1324
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +4.08 kB (+0.35%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
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.
I think I figured out a fix for the issue I noticed, so going to push that up.
|
||
export default function Survey() { | ||
const posthog = usePostHog() | ||
const [surveys, setSurveys] = useState([] as unknown as Survey[]) |
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, when I try to build this locally, I get a failure:
./pages/survey.tsx:6:61
Type error: 'Survey' refers to a value, but is being used as a type here. Did you mean 'typeof Survey'?
4 | export default function Survey() {
5 | const posthog = usePostHog()
> 6 | const [surveys, setSurveys] = useState([] as unknown as Survey[])
| ^
7 | const [selectedSurvey, setSelectedSurvey] = useState('0190bc7b-7096-0000-126d-1e5e7021a80e')
8 | const handleChange = (event) => {
9 | setSelectedSurvey(event.target.value)
because I don't think the playground has access to these types.
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.
fixed
|
||
export default function Survey() { | ||
const posthog = usePostHog() | ||
const [surveys, setSurveys] = useState([] as unknown as Survey[]) |
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.
fixed
This is a bug fix for the scenario where we weren't removing a survey from the activated surveys list once the survey is shown.
* Add debug logic for set_config * Improve startup debug log * Add logging to persistence
Changes
Adds a
posthog.renderSurvey('[survey-id]', '[js-selector]', (survey) => !survey && console.log('survey not found'))
function which will render any survey on an element on a page. This will allow users to use surveys as forms.Decided to go unformatted so that the formatting will match wherever it's embedded
Checklist