Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/app/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def new

def create
if @client.save
mark_onboarding_step("created_customer")
redirect_to app_clients_url, notice: "Cliente criado com sucesso."
else
render :new, status: :unprocessable_entity
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/app/order_services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def create
@order_service.created_without_budget = true

if @order_service.update(order_service_params_with_auto_schedule_status)
mark_onboarding_step("created_first_work_order")
redirect_to app_order_service_url(@order_service), notice: "Ordem de serviço criada com sucesso."
else
set_other_resources
Expand Down Expand Up @@ -130,6 +131,7 @@ def update_status
redirect_to schedule_app_order_service_path(@order_service)
else
if @order_service.update(status: target_status)
mark_onboarding_step("moved_work_order_status")
redirect_to app_order_service_url(@order_service), notice: "Status atualizado com sucesso."
else
redirect_to app_order_service_url(@order_service), alert: @order_service.errors.full_messages.join(', ')
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/app/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class App::ReportsController < ApplicationController
BUDGET_REJECTED_STATUSES = %w[rejeitado cancelado].freeze

def index
mark_onboarding_step("viewed_reports")

@reports = @reports.order(created_at: :desc)
@generated_reports = @reports.limit(5)

Expand Down
1 change: 1 addition & 0 deletions app/controllers/app/technicians_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def create
@technician.company_id = current_user.company_id if current_user.gestor?

if @technician.save
mark_onboarding_step("created_technician")
redirect_to app_technician_path(@technician), notice: "Técnico criado com sucesso."
else
render :new, :unprocessable_entity
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ApplicationController < ActionController::Base
include OnboardingTracking

before_action :custom_authenticate_user!, unless: :register_subdomain?
before_action :block_inactive_company_access, if: :app_subdomain?
before_action :ensure_terms_accepted!, if: :app_subdomain?
Expand Down
12 changes: 12 additions & 0 deletions app/controllers/concerns/onboarding_tracking.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module OnboardingTracking
private

def mark_onboarding_step(step_key)
return unless current_user

progress = current_user.user_onboarding_progress || current_user.create_user_onboarding_progress!
progress.complete_step!(step_key)
rescue StandardError => e
Rails.logger.warn("[OnboardingTracking] Failed to complete step '#{step_key}' for user #{current_user&.id}: #{e.class} - #{e.message}")
end
end
Loading