---
title: events | CodeWeaver Docs
description: API reference for codeweaver.core.telemetry.events
url: "https://docs.knitli.com/api/core/telemetry/events"
type: static
generatedAt: "2026-04-17T17:21:08.114Z"
---

# events
       [Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[View in Markdown](/codeweaver/api/core/telemetry/events.md)       [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F)[Share on X](https://x.com/intent/tweet?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F&text=events)[Share on Threads](https://threads.net/intent/post?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F&text=events)[Share on Bluesky](https://bsky.app/intent/compose?text=events%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F)[Share on Reddit](https://reddit.com/submit?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F&title=events)[Share on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F&t=events)[Share on Email](mailto:?subject=events&body=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F)[Share on WhatsApp](https://wa.me/?text=events%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F)[Share on Telegram](https://t.me/share/url?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftelemetry%2Fevents%2F&text=events)
# `codeweaver.core.telemetry.events`
[Section titled “codeweaver.core.telemetry.events”](#codeweavercoretelemetryevents)
Telemetry event schemas for PostHog integration.

Defines two primary events that leverage PostHog’s property system:

 1. SessionEvent - Aggregated session statistics for understanding usage patterns
 1. SearchEvent - Per-search metrics for find_code with A/B testing support

All events use privacy-safe, anonymized data with support for opt-in detailed tracking.

## Class: `SearchEvent`
[Section titled “Class: SearchEvent”](#class-searchevent)
Per-search telemetry event for find_code analytics.

Tracks:

 - Search intent and strategies used
 - Performance timing
 - Result quality metrics
 - Index state
 - Feature flags for A/B testing

Supports privacy-aware detailed tracking via tools_over_privacy setting.

### Method: `to_posthog_event`
[Section titled “Method: to_posthog_event”](#method-to_posthog_event)

**

```
to_posthog_event()
```

Convert to PostHog event format with structured properties.

Uses serialize_for_telemetry() to apply anonymization rules defined in _telemetry_keys() for FindCodeResponseSummary and CodeMatch.

## Class: `SessionEvent`
[Section titled “Class: SessionEvent”](#class-sessionevent)
Session telemetry event for understanding usage patterns.

Serializes SessionStatistics to track:

 - Setup success/failure for identifying trouble spots
 - Request statistics and performance
 - Token economics and savings
 - Repository characteristics (languages, file counts)
 - Failover statistics

Leverages PostHog properties:

 - $set_once for first-session tracking
 - $set for updateable properties
 - Nested properties for logical grouping

### Method: `from_statistics`
[Section titled “Method: from_statistics”](#method-from_statistics)

**

```
from_statistics()
```

Create SessionEvent from SessionStatistics.

Args: stats: Session statistics to serialize version: CodeWeaver version setup_success: Whether setup completed successfully setup_attempts: Number of setup attempts before success config_errors: List of configuration error types encountered duration_seconds: Total session duration

Returns: SessionEvent instance

### Method: `to_posthog_event`
[Section titled “Method: to_posthog_event”](#method-to_posthog_event-1)

**

```
to_posthog_event()
```

Convert to PostHog event format with structured properties.

Uses serialize_for_telemetry() to apply anonymization rules defined in _telemetry_keys() for each statistics component.

## Class: `TelemetryEvent`
[Section titled “Class: TelemetryEvent”](#class-telemetryevent)
Protocol for telemetry events.

### Method: `to_posthog_event`
[Section titled “Method: to_posthog_event”](#method-to_posthog_event-2)

**

```
to_posthog_event()
```

Convert event to PostHog format.

Returns: Tuple of (event_name, properties_dict)

## Function: `capture_search_event`
[Section titled “Function: capture_search_event”](#function-capture_search_event)

**

```
capture_search_event()
```

Convenience function to capture a search event.

Args: response: FindCodeResponseSummary from find_code query: Original search query intent_type: Detected or specified intent strategies: Search strategies used execution_time_ms: Total execution time tools_over_privacy: Whether to include detailed query data feature_flags: Feature flag variants for A/B testing

## Function: `capture_session_event`
[Section titled “Function: capture_session_event”](#function-capture_session_event)

**

```
capture_session_event()
```

Convenience function to capture a session event.

Args: stats: Session statistics to serialize version: CodeWeaver version setup_success: Whether setup completed successfully setup_attempts: Number of setup attempts config_errors: Configuration errors encountered duration_seconds: Session duration