bbc / simorgh

The BBC's Open Source Web Application. Contributions welcome! Used on some of our biggest websites, e.g.
https://www.bbc.com/thai
Other
1.39k stars 220 forks source link

Add Chartbeat utilities #1986

Closed twinlensreflex closed 5 years ago

twinlensreflex commented 5 years ago

Is your feature request related to a problem? Please describe. Chartbeat - is an analytics tool which allows access to real time information about articles (how many people reading, engagements with)

We need to pass specific parameters to Chartbeat

Canonical JS Field AMP field API parameter Value Notes
_sf_async_config.uid uid g 50924 Standard across all services
_sf_async_config.domain domain h e.g. "bbc.co.uk" or "persian.bbc.co.uk" For all English-language content, "bbc.co.uk" For Non-English sites "{sitename}.bbc.co.uk" - e.g. "persian.bbc.co.uk", "cymrufyw.bbc.co.uk"   This may seem odd, but it's how it's been implemented.   News: bbc.co.uk Persian: persian.bbc.co.uk Igbo: igbo.bbc.co.uk Yoruba: yoruba.bbc.co.uk Thai: thai.bbc.co.uk Pidgin: pidgin.bbc.co.uk Punjabi: punjabi.bbc.co.uk
_sf_async_config.useCanonical N/A N/A true Always true
_sf_async_config.sections sections g0 e.g. "News, News - wales, News - wales politics, News - ART, News - wales - ART, News - wales politics - ART" Comma separated list. First value should be the name of the service, e.g. "News" or "Persian"   Articles If the service is News and the ATI Producer is not News: "News - {Producer name in lowercase}" - e.g. "News - wales" If the service is News and there is an ATI Chapter, then "News - {Final part of chapter in lower case}" - e.g. "News - africa" Then repeat the same entries again appended with " - ART" We will extend this in future when we get Category data from Optimo   Homepages Second value should be the name of the service appended with " - IDX"   It is important this does not end with an extra comma.
_sf_async_config.idSync.bbc_hid N/A _s.bbc_hid If the ckns_sylphid cookie is set Then the value of that cookie Else do not set this value at all    
_sf_async_config.title title i String Articles: SEO Headline from Optimo/Ares Homepages: Service Name + " - " + Ares metadata.title field (sometimes missing on Test)
var _cbq = window._cbq = (window._cbq || []); _cbq.push(['_acct', '\\\\\\\{value}']); N/A   lgdin anon Always anon until/unless we integrate with Sign-In
_sf_async_config.type contentType unknown   Articles: "New Article" Homepages: "Index"
N/A N/A v URL of the referring page We don't need to set this, but should test that it updates correctly when moving from page to page in our SPA

Describe the solution you'd like A good place for a helper file to generate these values would be src/app/lib/analyticsUtils and a good file name could be chartbeat.js. We want to export a value for each entry in the table above. Integrating with Chartbeat will be in another ticket. We want the utilities to be self contained and not rely on context so anything that might be required from those should be expected as parameters. This means they will be easier to test.

Note that the referrer url implementation may be similar to that for ATI here: https://github.com/bbc/simorgh/issues/1972

Before picking up this ticket - make sure you have chartbeat login details - contact @jimjohnsonrollings for access & a quick intro to how to use Chartbeat.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Testing notes Since it won't be integrated into the article yet, unit tests should be sufficient.

Dev insight: Unit tests will be sufficient as these are just helper functions.

Additional context Add any other context or screenshots about the feature request here.

12 commented 5 years ago

After discussion with @jimjohnsonrollings, we have come to the conclusion that because we have no way of getting the ATI Producer or Chapter as of yet, the section property will be formatted as follows for the time being:

News, News - ART (for an article on the News service) Persian, Persian - ART (for an article on the Persian service)

12 commented 5 years ago

_sf_async_config.title can be pulled from https://github.com/bbc/simorgh/blob/30d4a44651d93e1881d368c5bbdb45af88e49564/src/app/lib/analyticsUtils/article.js#L28-L29