As you know we recently introduced a feature to rename and merge your News@me topics. The little challenge behind this feature was the impracticality/inconvenience to actively perform the same action in the editors’ database avoiding inconsistencies between the local copy of your News@me topics and the remote merged/renamed version. Here’s how we’ve successfully overcome this limitation.

Some background

In a previous version of the Javascript Widget and API integration directives, we advised the editors to save a local copy of the News@me topics in their own database. The WordPress and Drupal plugins were also implemented this way.

You saved the article in your CMS, some News@me topics were transmitted to our database, you saved a copy of those topics in your database. The local database copy was intended to be used for two different purposes:

  • Instruct the widget on how to mark the subscriptions on any given article;
  • Have the topics ready for editing, removing the need of performing another API call to fetch them.

We spent a lot of time trying to find the best solution for the rename/merge feature. In the end we decided the local copy of the topics could not live anymore.

A silent change in the javascript widget

Previous versions of the widget were using the same javascript code for each article. Each subscription was marked with topics being read from data attributes on the page itself.
This solution had the benefit to provide a list of topics for the subscription even if the article had never been saved to News@me before.

We needed to find a solution which was compatible with this existing feature.
Another big concern was the performance impact of serving a slightly different copy of the javascript widget’s code on every page view. As you can imagine we serve thousands of widget impressions each day.

So we decided to roll out a non-breaking change in the javascript widget, and to monitor performances as we introduced this change to more and more customers.

The logic was basically this:

  1. if the article has been saved in News@me, use our topics to mark the subscriptions
  2. else, use the topics coming from the page data attributes
  3. else, don’t show the widget when there are no topics.

It all went well. After some fine-tuning we were able to serve our own copy of the article’s topics to everyone.

The topics you provide in the `data-tags` attribute are ignored if the has been previously saved to News@me.

A new API endpoint

The other aspect to work on was the need to always show the latest version of the topics in the editor’s CMS. Most of you used the WordPress plugin and we addressed that first.
In WordPress we already perform a remote API call each time the post edit page is shown. This call is needed in order to collect the “available topics” on your account to be shown inside your News@me metabox.

We wanted to minimize the number of API calls being performed by the plugin in the background and that led us to introduce a new call for the “article’s topics”. We instead created a new endpoint which was able to deliver both the site’s available topics and the article’s one. You can read more on how it works here.

With the latest WordPress plugin, each time you view the “edit page” of a post, the list of the topics you’re seeing are coming to you from the News@me database. This ensures the most recent version of the topics is being served which reflects any merge/rename action you may have taken. The same change was introduced in Drupal too.

With the latest WordPress plugin, each time you view the “edit page” of a post, the list of the topics you’re seeing are coming to you from the News@me database. This ensures the most recent version of the topics is being served which reflects any merge/rename action you may have taken. The same change was introduced in Drupal too.

Wrapping up

The new recommendation for any integration is thus to not only save News@me topics in your own database when you need to save drafts or other ‘unpublished’ states of your post, depending on your workflow, but always show the current News@me topics for the article when it’s published. If you are caching available topics too, please consider refreshing them frequently as you’re now able to rename or merge any of your topics in your News@me app.

We hope you enjoyed this little glimpse in the News@me internals, please leave feedback or question. We’ll be glad to answer.

Leave a Reply

Discover what your audience wants to read most

Start your 14-day free trial now.

It only takes 60 seconds and no credit card is required.

— or —