Ncanto Interaction Logger

Developer Documentation for Client Integration

Overview

Ncanto Interaction Logger is a microservice designed to capture, normalize, and forward user interaction events to Ncanto's personalization and recommendation API. This documentation will help you understand how to integrate your client applications with the Interaction Logger.

Architecture

The Ncanto Interaction Logger follows a clean architecture with the following components:

Clients (Web, iOS, Android)
        │
        ▼
  API Gateway (Nginx)
        │
        ▼
  Flask API (POST /interact or /interact/batch)
        │
        ▼
   Redis Queue (async)
        │
        ▼
  Celery Worker → Ncanto API (POST /interactions)
        
Note: The Interaction Logger is designed to be "fire-and-forget" — clients should not wait for server responses or implement retry logic. The service handles all retries and error recovery internally.

API Endpoints

POST /api/v1/logs

Ingests multiple interaction events in a single request.

Request Body

A JSON array of interaction objects.

Response

{
  "status": "success",
  "message": "Batch received and saved for processing",
  "count": 5,
  "skipped": 0
}
            

Status Codes

GET /health

Checks the health of the application.

Response

{
  "status": "ok",
  "uptime": 3600,
  "redis": true,
  "database": true,
  "pending_interactions": 0,
  "version": "1.0.0",
  "documentation": "/docs"
}
            

Status Codes

Interaction Standards

Guiding Principles

  1. Unified Schema: All platforms (Web, iOS, Android) MUST follow a consistent JSON format and interaction naming convention.
  2. Rating Signals: Actions are categorized as explicit (user intent) or implicit (behavior-derived). Each is mapped to a ratingEquivalent score.
  3. Non-Blocking: Interactions should be "fire-and-forget" — no client-side retries or waiting on server responses.

VOD & Content Interactions (Viusasa, Citizen Digital)

Action Type Rating Notes
View recommendation recommendationImpression 0.0 Fired when content appears on screen
Click asset select 0.25 User shows interest
Start playback play 0.25 Initial intent to consume
Watch >80% play_complete 0.5 Strong engagement
Like/thumbs up rate 1.0 Explicit preference
Dislike/thumbs down rate -1.0 Explicit negative reaction
Add to watchlist/favorites select 1.0 Explicit intent
Remove from watchlist deselect -1.0 Explicit dislike
Share share 0.75 High intent

E-Commerce Interactions (Duka)

Action Type Rating Notes
View product recommendationImpression 0.0 Recommendation impression
Click product select 0.25 Initial interest
Add to cart add_to_cart 0.5 Clear purchase intent
Purchase product purchase 0.75 Highest intent interaction
Add to wishlist select 1.0 Treated like a like
Remove from wishlist deselect -1.0 Treated like a dislike
Leave 4–5 star review rate 1.0 Explicit rating
Leave 1–2 star review rate -1.0 Explicit negative feedback
Share product share 0.75 Strong engagement

Rating Equivalents

All interactions are mapped to a standardized rating scale from -1.0 to 1.0. This allows the recommendation engine to understand the relative strength of user preferences.

Intent Level ratingEquivalent Description
Explicit Like 1.0 Like, favorite, save
High Positive 0.75 Purchase, share
Medium Positive 0.5 Watched >80%, add to cart
Low Positive 0.25 Play, click
Neutral / View 0.1 View, impression
Explicit Dislike -1.0 Dislike, remove from wishlist

Payload Format

All interactions must follow this standardized JSON format:

{
  "timestamp": "2025-07-09T09:45:00Z",
  "subscriber": "product_user_12345",
  "assetId": "product_asset_67890",
  "interaction": "interaction_type",
  "ratingEquivalent": 0.25,
  "comment": "Optional: debug message",
  "contextId": "Optional: Ncanto context",
  "setting": {
    "device": "web" // Values: 'web', 'android_app', 'ios_app'
  }
}
        

Field Descriptions

Field Type Required Description
timestamp String Yes ISO 8601 formatted date-time (UTC)
subscriber String Yes Unique identifier for the user
assetId String Yes Unique identifier for the content or product
interaction String Yes Type of interaction (see tables above)
ratingEquivalent Number Yes Rating value between -1.0 and 1.0
comment String No Optional debug message or additional context
contextId String No Optional Ncanto context identifier
setting Object Yes Contains device information
setting.device String Yes Device type: 'web', 'android_app', or 'ios_app'

Examples

Example 1: Video Playback Complete

{
  "timestamp": "2025-07-09T10:15:00Z",
  "subscriber": "viusasa_user_12345",
  "assetId": "viusasa_episode_67890",
  "interaction": "play_complete",
  "ratingEquivalent": 0.5,
  "comment": "User watched 90% of the episode.",
  "contextId": "viusasa_player_context",
  "setting": {
    "device": "android_app"
  }
}
        

Example 2: Add to Cart

{
  "timestamp": "2025-07-09T11:05:20Z",
  "subscriber": "duka_user_54321",
  "assetId": "duka_product_abcde",
  "interaction": "add_to_cart",
  "ratingEquivalent": 0.5,
  "comment": "User added product to cart from product detail page.",
  "contextId": "duka_pdp_context",
  "setting": {
    "device": "web"
  }
}
        

Example 3: Batch Request

[
  {
    "timestamp": "2025-07-09T09:30:00Z",
    "subscriber": "citizen_user_12345",
    "assetId": "citizen_article_67890",
    "interaction": "select",
    "ratingEquivalent": 0.25,
    "setting": {
      "device": "web"
    }
  },
  {
    "timestamp": "2025-07-09T09:31:00Z",
    "subscriber": "citizen_user_12345",
    "assetId": "citizen_article_67890",
    "interaction": "share",
    "ratingEquivalent": 0.75,
    "setting": {
      "device": "web"
    }
  }
]
        

Best Practices

When to Send Interactions

Error Handling

Important: Do not implement client-side retry logic. The Interaction Logger has built-in retry mechanisms with exponential backoff.

Performance Considerations

Security

Tip: For high-volume applications, consider implementing a client-side sampling strategy for very frequent events like impressions.