Using Environment variables (Such as keys to external services)

My game is open source (on Github: GitHub - stormsword/stormsword: Simple top-down 2d RPG inspired by Zelda and Secret of Mana.) which adds some interesting challenges when working with ‘protected’ data.

We are trying to implement MixPanel for tracking things like the user’s OS, how many times they’ve loaded the game, etc.

I have a background in web development and would normally set an environment variable on the server which allows different environments (dev, production, per-developer) to have different keys configured and loaded in at run-time.

I would like to avoid storing our MixPanel key in the code, both because I have learned better than doing this, and because I don’t want to expose our Mixpanel key publicly in our Github repo.

I’ve looked into GetEnvioronmentVariable but have not been able to figure out how to get Unity to read from the current environment (for example if I add something to my ~/.profile script it doesn’t show up). I also will need to figure out how to make this work on Windows as some of our devs use Windows, some OSX, some Linux.

I also have looked at the PlayerPrefs scripting API but this seems to be used more for player Data.

Any advice would be appreciated!

string dosFilePath = @“%USERPROFILE%\Documents\myFile.txt”;
Debug.Log(System.Environment.ExpandEnvironmentVariables(dosFilePath));
// C:\Users\myUser\Documents\myFile.txt