or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/posthog@6.7.x
tile.json

tessl/pypi-posthog

tessl install tessl/pypi-posthog@6.7.0

Integrate PostHog into any python application.

Agent Success

Agent success rate when using this tile

89%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.03x

Baseline

Agent success rate without this tile

86%

task.mdevals/scenario-2/

Event Tracker for Serverless Functions

Build an event tracking system for a serverless AWS Lambda function that processes user actions. The system must reliably track events even when the Lambda execution environment terminates immediately after processing.

Requirements

Your implementation should include:

  1. Serverless Event Handler - Create a function that handles incoming user action requests and tracks them reliably before the Lambda terminates
  2. Synchronous Tracking - Ensure all events are sent immediately without relying on background threads
  3. Proper Cleanup - Release resources appropriately after tracking events
  4. Configuration - Initialize the tracking client with appropriate settings for short-lived execution environments

Specifications

Input Format

The handler receives a dictionary with:

  • user_id (string) - Unique identifier for the user
  • action (string) - The action performed (e.g., "button_click", "page_view")
  • metadata (dict, optional) - Additional properties about the action

Expected Behavior

  1. Initialize the tracking client once (not on every invocation)
  2. Track each user action with the provided details
  3. Ensure events are sent before the function returns
  4. Return a success confirmation to the caller

Test Cases

  • Given user_id="user123", action="login", metadata={"source": "mobile"}, the handler successfully tracks the event and returns success @test
  • Given user_id="user456", action="purchase", metadata={"amount": 99.99, "product": "premium"}, the handler successfully tracks the purchase event @test
  • Given multiple rapid invocations with different events, all events are successfully tracked without loss @test

Implementation

@generates

API

def handle_user_action(event: dict) -> dict:
    """
    Handle a user action event in a serverless environment.

    Args:
        event: Dictionary containing user_id, action, and optional metadata

    Returns:
        Dictionary with 'success' boolean and optional 'message'
    """
    pass

Dependencies { .dependencies }

posthog { .dependency }

Provides analytics and event tracking capabilities.

@satisfied-by