lib/timber/cli/install.rb in timber-2.0.7 vs lib/timber/cli/install.rb in timber-2.0.8

- old
+ new

@@ -27,22 +27,22 @@ app = Application.new(api) puts Messages.application_details(app) puts "" - case ask_yes_no("Are the above details correct?") + case ask_yes_no("Are the above details correct?", api) when :yes if app.heroku? - update_environment_config("production", :stdout) + update_environment_config("production", :stdout, api) puts "" puts Messages.separator puts "" puts Messages.heroku_install(app) puts "" - ask_yes_no("Ready to proceed?") + ask_yes_no("Ready to proceed?", api) puts "" else puts "" puts Messages.separator @@ -51,23 +51,23 @@ puts "" puts "1) Using environment variables" puts "2) Configuring in my app" puts "" - case ask("Enter your choice: (1/2) ") + case ask("Enter your choice: (1/2) ", api) when "1" - update_environment_config("production", :http, :api_key_code => "ENV['TIMBER_API_KEY']") + update_environment_config("production", :http, api, :api_key_code => "ENV['TIMBER_API_KEY']") puts "" puts Messages.http_environment_variables(app.api_key) puts "" - ask_yes_no("Ready to proceed?") + ask_yes_no("Ready to proceed?", api) puts "" when "2" - update_environment_config("production", :http, :api_key_code => "'#{app.api_key}'") + update_environment_config("production", :http, api, :api_key_code => "'#{app.api_key}'") end send_test_messages(api_key) end @@ -105,11 +105,11 @@ return false end end private - def update_environment_config(name, log_device_type, options = {}) + def update_environment_config(name, log_device_type, api, options = {}) path = File.join("config", "environments", "#{name}.rb") puts "" task_message = "Configuring Timber in #{path}" write Messages.task_start(task_message) @@ -144,30 +144,35 @@ current_contents = File.read(path) if !current_contents.include?("Timber::Logger.new") new_contents = current_contents.sub(/\nend/, "\n\n#{logger_code}\nend") File.write(path, new_contents) + api.event!(:file_written, path: path) end puts colorize(Messages.task_complete(task_message), :green) end def send_test_messages(api_key) write Messages.task_start("Sending test logs") http_device = LogDevices::HTTP.new(api_key) logger = Logger.new(http_device) - logger.info("test") + logger.info("Welcome to Timber!") + logger.info("This is a test log to ensure the pipes are working") + logger.info("Be sure to commit and deploy your app to start seeing real logs") puts colorize(Messages.task_complete("Sending test logs"), :green) end def collect_feedback(api) puts "" puts Messages.separator puts "" - rating = ask("How would rate this install experience? 1 (bad) - 5 (perfect)") + + rating = ask("How would rate this install experience? 1 (bad) - 5 (perfect)", api) + case rating when "4", "5" api.event!(:feedback, rating: rating.to_i) puts "" puts Messages.we_love_you_too @@ -175,10 +180,10 @@ when "1", "2", "3" puts "" puts Messages.bad_experience_message puts "" - comments = ask("Type your comments (enter sends)") + comments = ask("Type your comments (enter sends)", api) api.event!(:feedback, rating: rating.to_i, comments: comments) puts "" puts "Thank you! We take feedback seriously and will work to improve this." \ No newline at end of file