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

Allow changing settings at runtime #153

Merged
merged 1 commit into from
Dec 22, 2022
Merged

Allow changing settings at runtime #153

merged 1 commit into from
Dec 22, 2022

Conversation

Kevinsomnia
Copy link
Contributor

@Kevinsomnia Kevinsomnia commented Sep 30, 2022

Adds a way to change the config at runtime, which is useful when changing the API host based on app environment for example. Any changes made to MixpanelSettings.Instance will be copied over after manually initializing the library.

Closes #101 (this PR is more general-purpose)
Closes #148

Usage

Before initialization:

MixpanelSettings.Instance.APIHostAddress = "https://myproxy.com";
...
// automatically copies to internal config
Mixpanel.Init();
MixpanelSettings.Instance.APIHostAddress = "https://myproxy.com";
...
// valid but redundant since Init() will call this automatically
MixpanelSettings.Instance.ApplyToConfig();
Mixpanel.Init();

After initialization:

Mixpanel.Init();
MixpanelSettings.Instance.APIHostAddress = "https://myproxy.com";
...
// must call this for changes to take effect since changes were made after Init().
MixpanelSettings.Instance.ApplyToConfig();

@lourd
Copy link

lourd commented Sep 30, 2022

Tagging @zihejia and @jaredmixpanel as a request for review 🙏

Copy link
Contributor

@zihejia zihejia left a comment

Choose a reason for hiding this comment

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

LGTM

@zihejia zihejia closed this Dec 22, 2022
@zihejia zihejia reopened this Dec 22, 2022
@zihejia zihejia merged commit 41a5d21 into mixpanel:master Dec 22, 2022
@Kevinsomnia Kevinsomnia deleted the modifiable-settings branch January 25, 2023 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to programmatically set APIHostAddress
3 participants