@@ -5,7 +5,8 @@ class Configuration
55 attr_accessor :api_key , :app_name , :app_location , :env , :log_level , :logger ,
66 :proxy , :mode , :base_api_url , :api_enabled , :transport , :errors , :http_endpoint , :stdout_output , :buffered_logger
77
8- attr_reader :send_interval , :flood_limit , :queue_max_size , :agent_log_url , :unix_socket_path , :http_endpoint
8+ attr_reader :send_interval , :flood_limit , :queue_max_size , :agent_log_url , :unix_socket_path , :http_endpoint ,
9+ :rum_key , :rum_script_url
910
1011 def initialize
1112 @base_api_url = 'https://api.stackify.com'
@@ -27,6 +28,11 @@ def initialize
2728 @http_endpoint = get_env 'STACKIFY_TRANSPORT_HTTP_ENDPOINT' , 'https://localhost:10601'
2829 @stdout_output = false
2930 @buffered_logger = false
31+ @default_rum_script_url = 'https://stckjs.stackify.com/stckjs.js'
32+ @default_rum_key = ''
33+
34+ self . rum_key = get_env 'RETRACE_RUM_KEY' , @default_rum_key
35+ self . rum_script_url = get_env 'RETRACE_RUM_SCRIPT_URL' , @default_rum_script_url
3036 end
3137
3238 def get_env env_key , default
@@ -52,6 +58,28 @@ def validate_transport_type
5258 @errors << 'Transport should be one of these values: [agent_socket, agent_http, default]. Should be a String.'
5359 end
5460
61+ def rum_script_url = ( rum_script_url )
62+ if rum_script_url . empty?
63+ @rum_script_url = @default_rum_script_url
64+ return
65+ end
66+
67+ if validate_rum_script_url ( rum_script_url )
68+ @rum_script_url = rum_script_url
69+ end
70+ end
71+
72+ def rum_key = ( rum_key )
73+ if rum_key . empty?
74+ @rum_key = @default_rum_key
75+ return
76+ end
77+
78+ if validate_rum_key ( rum_key )
79+ @rum_key = rum_key
80+ end
81+ end
82+
5583 private
5684
5785 def validate_config_types
@@ -110,5 +138,27 @@ def validate_mode
110138 return true if MODES . has_value? @mode
111139 @errors << 'Mode should be one of these values: [:both, :logging, :metrics]'
112140 end
141+
142+ def validate_rum_script_url ( rum_script_url )
143+ result = false
144+ if rum_script_url . is_a? ( String ) && !rum_script_url . empty?
145+ result = rum_script_url =~ /^((((https?|ftps?|gopher|telnet|nntp):\/ \/ )|(mailto:|news:))(%[0-9A-Fa-f]{2}|[\- \( \) _\. !~*';\/ ?:@&=+$,A-Za-z0-9])+)([\) \. !';\/ ?:,][\[ :blank:|:blank:\] ])?$/
146+ end
147+ if !result
148+ @errors << 'RUM Script URL is in invalid format.'
149+ end
150+ result
151+ end
152+
153+ def validate_rum_key ( rum_key )
154+ result = false
155+ if rum_key . is_a? ( String ) && !rum_key . empty?
156+ result = rum_key =~ %r{^[A-Za-z0-9_-]+$}
157+ end
158+ if !result
159+ @errors << 'RUM Key is in invalid format.'
160+ end
161+ result
162+ end
113163 end
114164end
0 commit comments