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(flags): give users the ability to suppress override warning logs, if desired #1328

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

dmarticus
Copy link
Contributor

@dmarticus dmarticus commented Jul 29, 2024

Changes

We've supported manually overriding feature flag values in the client for years (and our toolbar natively supports it), but since this override doesn't persist to the backend, we've historically always just treated this feature as a debug feature only. However, there's been a influx of support requests (on both Twitter and in our support inbox) that are asking about this feature, and one user explicitly mentioned that the feature would be perfect for his use case if it weren't for the debug warning and logs. I started a discussion about this in Slack, and if we decide that it's safe to give users the ability to remove these logs, this PR enables it.

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 Jul 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 Jul 29, 2024 9:21pm

@posthog-bot
Copy link
Collaborator

Hey @dmarticus! 👋
This pull request seems to contain no description. Please add useful context, rationale, and/or any other information that will help make sense of this change now and in the distant Mars-based future.

Copy link

Size Change: +244 B (+0.02%)

Total Size: 1.16 MB

Filename Size Change
dist/array.full.js 331 kB +61 B (+0.02%)
dist/array.js 153 kB +61 B (+0.04%)
dist/main.js 153 kB +61 B (+0.04%)
dist/module.js 153 kB +61 B (+0.04%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 10.4 kB
dist/recorder-v2.js 110 kB
dist/recorder.js 110 kB
dist/surveys-preview.js 59.7 kB
dist/surveys.js 64.9 kB
dist/tracing-headers.js 8.26 kB
dist/web-vitals.js 5.79 kB

compressed-size-action

Copy link
Contributor

@Phanatic Phanatic left a comment

Choose a reason for hiding this comment

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

Ship it

if (!this.instance.__loaded || !this.instance.persistence) {
return logger.uninitializedWarning('posthog.feature_flags.override')
}

this._override_warning = false
this._override_warning = suppressWarning
Copy link
Contributor

Choose a reason for hiding this comment

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

this _override_warning is confusing because for a value of false, we log the debug warning.

if (!this._override_warning) {
logger.warn(' Overriding feature flags!', {
enabledFlags,
overriddenFlags,
finalFlags,
})
this._override_warning = true
}

Good fix here.

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