-
A metric starts its journey being added on the frontend, in Hymnal, as an impression tracker (in the tracker sidepanel). You can add as many trackers as you want per ad.
-
Separately, a clickthrough url is added, and notably, there is only one of these per ad.
- In the refactor, we'll need to update how clickthrough urls are handled, since currently they're handled by metrics_instrumentation, but we'll be refactoring HymnalAd to be the one responsible for keeping track of an ad's clickthrough url.
- We'll also need to update the rake task I wrote to migrate the current clickthrough_urls over to HymnalAds, from MetricsInstrumentation
-
From there, the tracker form is submitted, and for every tracker that was added, a new tracker object is created/saved in the db (after a check to make sure the url entered is a valid url)
-
Once it's there, it just kinda sits and waits around, until the ad is compiled, through compilers/ad.rb
-
Once the ad compiler is called, the method map_ad_to_ad_compile_context applies the metrics to the ad, and calls metrics' complete_js method, found in models/metrics_instrumentation.rb
-
The complete_js method then sends a call to read the template metrics_instrumentation.js.erb
-
That template creates a new js instance of Hymnal.MetricsInstrumentation, and creates an object with all the metrics instrumentation info for the ad. Inside this template, there are checks to see if setup js is present (and if so, adds it), and does the same check for engagement js. (both seem to call for a template result of a template with their name, and setup might be referring to basic_tracking/setup.js.erb, but engagement does not have a corresponding template)
- Questions I have: What are setup and engagement js, are they being used, and is this behavior we want to carry over with us to the new model?
-
Within metrics_instrumentation, ad_properties gets called, which takes you to two places: one is in the MetricsInstrumentation model, which creates/returns a blank hash for ad_properties; and second, to BasicTracking's ad_properties method, which also creates a blank hash, adds the click_through_url, and then returns the hash.
-
At some point basic_tracking/setup.js.erb is called, which in turn iterates through every impression tracker url and calls the ad's addTrackerImage function, from sdk/js/ad.js.
-
The addTrackerImage function creates the tracking pixel, sets its CSS properties, and adds it to the body of the page.
-
Ad.js.erb just has more file extensions, cool, i dont really know where this is getting used yet
A list of files that have mention of either metrics_instrumentation, MetricsInstrumentation, or metrics_configuration: app/models/ad.rb app/models/hymnal_ad.rb app/models/published_ad.rb app/views/ads/show.html.erb app/views/hymnal_ads/_hymnal_ads_footer.html.erb app/views/shared/_buttons.html.erb lib/ad_publisher.rb test/factories.rb test/lib/ad_publisher_test.rb test/models/ad_server_test.rb test/models/hymnal_ad_test.rb test/models/published_ad_test.rb app/controllers/ads_controller.rb app/controllers/hymnal_ads_controller.rb app/controllers/metrics_instrumentations_controller.rb app/controllers/publishes_controller.rb app/controllers/trackers_controller.rb app/models/metrics_instrumentation.rb config/application.rb config/routes.rb lib/compilers/ad/ad.js.erb lib/compilers/ad.rb lib/compilers/hymnal_compiler.rb lib/tasks/data_migrations/trackers.rake test/controllers/metrics_instrumentations_controller_test.rb test/controllers/trackers_controller_test.rb test/models/ad_test.rb