CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

pubnub/pubnub-functions

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%

Overview
Eval results
Skill reviews
Files

task.mdevals/scenario-5/

Page View Tracker with External Reporting

Context

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.

Task

Write a PubNub Before Publish function (page-tracker.js) that:

  1. Tracks the total number of views for each page using a counter that works correctly under concurrent access
  2. Stores the last viewer's information with a 1-hour expiration
  3. Reads the current total view count for the page
  4. Calls an external analytics API endpoint with the view data, using a securely stored API credential
  5. Adds the current view count to the message before it proceeds

Expected Outputs

  • A page-tracker.js file containing a complete PubNub Function for page view tracking with external reporting.
tessl i pubnub/pubnub-functions@0.1.4

evals

SKILL.md

tile.json