Class: ForestLiana::MixpanelController
Instance Method Summary
collapse
#authenticate_user_from_jwt, #deactivate_count_response, #forest_user, #internal_server_error, papertrail?, #serialize_model, #serialize_models
#route_not_found
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
|