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(web experiments): Emit web_experiment_applied event and do not render experiments for bots #1443

Merged
merged 6 commits into from
Oct 8, 2024

Conversation

Phanatic
Copy link
Contributor

Changes

  1. Replace references to className with css which assigns the value of this field to the style attribute of an HTML element.
  2. Introduce the ability to preview an Experiment variant in the browser without deploying the experiment.
  3. Do not render web experiments if the viewer is a bot.
  4. Emit the $web_experiment_applied event so we know if the visual changes actually got applied to a page.

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented Sep 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Oct 3, 2024 8:42am

Copy link

github-actions bot commented Sep 29, 2024

Size Change: +15.5 kB (+0.55%)

Total Size: 2.82 MB

Filename Size Change
dist/array.full.js 353 kB +1.72 kB (+0.49%)
dist/array.full.no-external.js 352 kB +1.72 kB (+0.49%)
dist/array.js 168 kB +1.72 kB (+1.03%)
dist/array.no-external.js 167 kB +1.72 kB (+1.04%)
dist/main.js 169 kB +1.72 kB (+1.03%)
dist/module.full.js 353 kB +1.72 kB (+0.49%)
dist/module.full.no-external.js 352 kB +1.72 kB (+0.49%)
dist/module.js 168 kB +1.72 kB (+1.03%)
dist/module.no-external.js 167 kB +1.72 kB (+1.04%)
ℹ️ View Unchanged
Filename Size
dist/all-external-dependencies.js 191 kB
dist/exception-autocapture.js 10.5 kB
dist/external-scripts-loader.js 2.35 kB
dist/recorder-v2.js 111 kB
dist/recorder.js 111 kB
dist/surveys-preview.js 59.8 kB
dist/surveys.js 66 kB
dist/tracing-headers.js 8.36 kB
dist/web-vitals.js 10.3 kB

compressed-size-action

Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable, easy to follow, nice tests – all good from me!

Comment on lines +343 to +349
_is_bot(): boolean | undefined {
if (navigator && this.instance) {
return isLikelyBot(navigator, this.instance.config.custom_blocked_useragents)
} else {
return undefined
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful!

@Phanatic Phanatic added bump major Bump major version when this PR gets merged bump minor Bump minor version when this PR gets merged and removed bump major Bump major version when this PR gets merged labels Oct 8, 2024
@Phanatic Phanatic merged commit ba1c07f into main Oct 8, 2024
19 checks passed
@Phanatic Phanatic deleted the preview-web-experiments branch October 8, 2024 02:33
@jurajmajerik
Copy link
Contributor

Sorry for not reviewing earlier, this is looking good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor Bump minor version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants