Class: ForestLiana::MixpanelController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- BaseController
- ApplicationController
- ForestLiana::MixpanelController
- Defined in:
- app/controllers/forest_liana/mixpanel_controller.rb
Constant Summary
Constants inherited from ApplicationController
ApplicationController::REGEX_COOKIE_SESSION_TOKEN
Instance Method Summary collapse
Methods inherited from ApplicationController
#authenticate_user_from_jwt, #forest_user, #get_smart_action_context, #internal_server_error, papertrail?, #route_not_found, #serialize_model, #serialize_models
Instance Method Details
#get_serializer_type(suffix) ⇒ Object
23 24 25 |
# File 'app/controllers/forest_liana/mixpanel_controller.rb', line 23 def get_serializer_type(suffix) "#{params[:collection]}_#{suffix}" end |
#last_events ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/forest_liana/mixpanel_controller.rb', line 3 def last_events collection_name = params[:collection] mapping = ForestLiana.integrations[:mixpanel][:mapping] mapping_for_current_collection = mapping.find { |item| item.start_with?(collection_name) } field_name = mapping_for_current_collection.split('.')[1] id = params[:id] field_value = collection_name.constantize.find_by('id': id)[field_name] getter = ForestLiana::MixpanelLastEventsGetter.new(params) getter.perform(field_name, field_value) custom_properties = ForestLiana.integrations[:mixpanel][:custom_properties] MixpanelEventSerializer.attributes(*custom_properties) render serializer: nil, json: serialize_models(getter.records, { context: { type: get_serializer_type('mixpanel_events') }, count: getter.count, }) end |