11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4+ using System . Text . RegularExpressions ;
45using StackifyLib . Utils ;
56
67namespace StackifyLib
@@ -108,6 +109,26 @@ public static void LoadSettings()
108109 LoggingJsonMaxFields = maxFields ;
109110 }
110111 }
112+
113+ var rumScriptUrl = Get ( "Stackify.Rum_Script_Url" , "https://stckjs.stackify.com/stckjs.js" ) ;
114+
115+ if ( Uri . IsWellFormedUriString ( rumScriptUrl , UriKind . Absolute ) )
116+ {
117+ var uri = new Uri ( rumScriptUrl ) ;
118+
119+ var scheme = uri . Scheme ;
120+
121+ if ( string . Equals ( scheme , "https" , StringComparison . OrdinalIgnoreCase ) )
122+ {
123+ RumScriptUrl = rumScriptUrl ;
124+ }
125+ }
126+
127+ var rumKey = Get ( "Stackify.Rum_Key" ) ;
128+ if ( Regex . IsMatch ( rumKey , "^[A-Za-z0-9_-]+$" ) )
129+ {
130+ RumKey = rumKey ;
131+ }
111132 }
112133 catch ( Exception ex )
113134 {
@@ -150,6 +171,10 @@ public static void LoadSettings()
150171
151172 public static int LoggingJsonMaxFields { get ; set ; } = 50 ;
152173
174+ public static string RumScriptUrl { get ; set ; }
175+
176+ public static string RumKey { get ; set ; }
177+
153178
154179 /// <summary>
155180 /// Attempts to fetch a setting value given the key.
@@ -171,6 +196,13 @@ internal static string Get(string key, string defaultValue = null)
171196 {
172197 var appSettings = _configuration . GetSection ( "Stackify" ) ;
173198 v = appSettings [ key . Replace ( "Stackify." , string . Empty ) ] ;
199+
200+ if ( string . IsNullOrEmpty ( v ) )
201+ {
202+ // Search in Retrace, but key will likely still be Stackify.name, not Retrace.name in the code
203+ var retraceAppSettings = _configuration . GetSection ( "Retrace" ) ;
204+ v = retraceAppSettings [ key . Replace ( "Stackify." , string . Empty ) ] ;
205+ }
174206 }
175207#endif
176208
@@ -185,6 +217,22 @@ internal static string Get(string key, string defaultValue = null)
185217 {
186218 v = System . Environment . GetEnvironmentVariable ( key ) ;
187219 }
220+
221+ if ( string . IsNullOrEmpty ( v ) )
222+ {
223+ v = System . Environment . GetEnvironmentVariable ( key . ToUpperInvariant ( ) ) ;
224+ }
225+
226+ if ( string . IsNullOrEmpty ( v ) )
227+ {
228+ // Linux systems do not allow period in an environment variable name
229+ v = System . Environment . GetEnvironmentVariable ( key . Replace ( '.' , '_' ) . ToUpperInvariant ( ) ) ;
230+ }
231+
232+ if ( string . IsNullOrEmpty ( v ) && key . StartsWith ( "Stackify." ) )
233+ {
234+ v = System . Environment . GetEnvironmentVariable ( "RETRACE_" + key . Substring ( 9 ) . Replace ( '.' , '_' ) . ToUpperInvariant ( ) ) ;
235+ }
188236 }
189237 }
190238 finally
0 commit comments