mixpanel / mixpanel-unity

Official Unity Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
45 stars 38 forks source link

Allow changing settings at runtime #153

Closed Kevinsomnia closed 1 year ago

Kevinsomnia commented 2 years ago

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 commented 2 years ago

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