-
Notifications
You must be signed in to change notification settings - Fork 135
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(experiments): Apply no-code experiments to the webpage. #1409
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +19.8 kB (+1.67%) Total Size: 1.21 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.
looks reasonable overall, nice work! A couple of questions about data modeling and one about sanitizing HTML content but the rest looks fine.
transform.attributes.forEach((attribute) => { | ||
switch (attribute.name) { | ||
case 'text': | ||
htmlElement.innerText = attribute.value | ||
break | ||
|
||
case 'html': | ||
htmlElement.innerHTML = attribute.value | ||
break | ||
|
||
case 'cssClass': | ||
htmlElement.className = attribute.value | ||
break | ||
|
||
default: | ||
htmlElement.setAttribute(attribute.name, attribute.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.
obviously users won't try to do this, and it's possible we're making this impossible on the server side, but should we sanitize the contents of these values that we're setting onto the DOM?
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.
good idea about sanitizing payload. We can do that on the server-side with nh like we do for survey HTML
Changes
This PR introduces a new extension to posthog-js called
web-experiments
which allows posthog to apply no-code experiments to elements on a web page. This PR needs PostHog/posthog#24872 to merge so it can function.To enable this feature, developers have to opt-in by setting
disable_web_experiments
to false inposthog.init
while in Beta.There are multiple ways to target an experiment within the browser here :
exact, contains, not_contains, regex, not_regex
Checklist
Coming up in following PRs