Sha256: 96ff687335e1eca6dbe77ffd422c30589020708c49cc2ff6875e0313fd44edda
Contents?: true
Size: 1008 Bytes
Versions: 269
Compression:
Stored size: 1008 Bytes
Contents
module ForestLiana class MixpanelController < ForestLiana::ApplicationController 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 def get_serializer_type(suffix) "#{params[:collection]}_#{suffix}" end end end
Version data entries
269 entries across 269 versions & 1 rubygems