Skip to content

[AXON-293] Add _isServerEnv override for VSCODE extensions #26

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cabella-dot
Copy link

What is this change:

  • Added the ability to override the _isServerEnv() method which blocks our ability to send exposure events

Why:

  • We are working with a VSCODE extension which is a Node js project but we want to use the statsig js client
  • We cannot use the node client bc VSCODE extension code is minified and shipped to the user which makes secret sdk-keys vulnerable for exposure

Related to #23

@cabella-dot cabella-dot changed the title [AXON-293] statsig js client fork [AXON-293] Add _isServerEnv override for VSCODE extensions Apr 26, 2025
/**
* Overrides the blocking of exposure events if you are working in a Node js project
*/
overrideServerEnv?: boolean
Copy link

@marcomura marcomura Apr 28, 2025

Choose a reason for hiding this comment

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

I would rename it to forceLogExposures for clarity

@@ -119,7 +119,8 @@ export class EventLogger {
}

start(): void {
if (_isServerEnv()) {
const override = this._options?.overrideServerEnv
if (_isServerEnv() && !override) {

Choose a reason for hiding this comment

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

to improve performances, values should be checked before function calls


const override = this._options?.overrideServerEnv;

if (_isServerEnv() && !override) {

Choose a reason for hiding this comment

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

same

function _assignGlobalInstance(sdkKey: string, client: StatsigClientInterface) {
if (_isServerEnv()) {
function _assignGlobalInstance(sdkKey: string, client: StatsigClientInterface, overrideServerEnv?: boolean) {
if (_isServerEnv() && !overrideServerEnv) {

Choose a reason for hiding this comment

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

same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants