Develop serverless edge functions with PubNub Functions 2.0
Agent Success
Agent success rate when using this tile
93%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.79x
Baseline
Agent success rate without this tile
52%
You are building a PubNub Before Publish function that tracks page views for a content platform. When a page view event is published, the function should increment a view counter for that page, store the last viewer's information temporarily (expiring after 1 hour), and forward a summary to an external analytics service. The analytics service requires an API credential that must be kept secure.
Write a PubNub Before Publish function (page-tracker.js) that:
page-tracker.js file containing a complete PubNub Function for page view tracking with external reporting.