Skip to main content
Using a Skills-compatible agent like Claude Code? The Greenflash agent skill handles this automatically. Run /greenflash-onboard-events instead of copying this prompt.

Add Business Event Tracking to Our Greenflash Integration

You are a coding agent tasked with extending our existing Greenflash TypeScript SDK integration to track business events. We already have message logging working. Your goal is to add event tracking so that Greenflash can connect AI interactions to real business outcomes like conversions, upgrades, and churn.

High-Level Objective

Extend the current implementation to:
  1. Track business events that represent meaningful user milestones
  2. Link events to conversations when the outcome relates to an AI interaction
  3. Assign influence and value to quantify the business impact
  4. Use the correct TypeScript SDK syntax
Reference: The full documentation for the Events API is available at: https://docs.greenflash.ai/features/events

Why Track Events?

Events close the loop between AI interactions and business outcomes. While Greenflash already analyzes conversation quality and sentiment, events provide the ground truth:
  • Attribute Success: Link specific AI responses directly to business outcomes like upgrades or purchases
  • Validate Quality: Confirm heuristic signals (like sentiment) with tangible outcome data
  • Deepen Insights: Train Greenflash to identify conversation patterns that drive real-world results

When to Send Events

Capture moments that matter. Send an event whenever a user reaches a milestone that represents value creation or loss.

Positive Indicators (Success Signals)

  • signup_completed
  • trial_started
  • task_success
  • upgrade_purchased
  • meeting_booked
  • lead_converted

Negative Indicators (Friction/Churn Signals)

  • cancellation_requested
  • error_encountered
  • workflow_abandoned
  • refund_requested

Contextual Indicators (Usage Context)

  • feature_viewed
  • step_completed
  • usage_logged

Core Event Fields


Basic Event Tracking

With Await (If Needed)


Event Examples by Use Case

Customer Support: Post-Chat Upgrade

Customer Support: Cancellation Request

Sales: Meeting Booked

Workflow: Task Completed Successfully

Workflow: Error Encountered


Linking Events to Conversations

The conversationId field is crucial for connecting business outcomes to AI interactions. Always include it when:
  • The event happened during an AI session
  • The event happened shortly after an AI interaction
  • There’s a clear causal relationship between the conversation and the outcome

Sampling for High-Volume Events

For high-volume applications, use sampling to control ingestion:

Idempotency for Reliable Event Tracking

Use insertId to prevent duplicate events when retrying failed requests:
Best Practice: For critical events like purchases, generate the insertId before attempting the request and persist it. If the request fails, retry with the same insertId to guarantee exactly-once delivery.

Fire-and-Forget Pattern

For event tracking, you typically don’t want to block your application flow. Use fire-and-forget by not awaiting the promise:
Note: The .catch() is recommended to prevent unhandled promise rejections from crashing your app, but the event call runs in the background without blocking.

Integration Checklist

Your code should:
  1. Identify key business milestones in our application (upgrades, cancellations, task completions, etc.)
  2. Add event tracking at each milestone using client.events.create(...)
  3. Link events to conversations by passing conversationId when relevant
  4. Set appropriate influence (positive, negative, neutral)
  5. Include value and valueType for revenue-impacting events
  6. Add useful properties for deeper analysis
  7. Use fire-and-forget (no await) with .catch() to avoid blocking

What You Must Deliver

  1. Event tracking at key business milestones
  2. Proper conversation linking where applicable
  3. Correct influence assignment (positive/negative/neutral)
  4. Value tracking for revenue-related events
  5. No disruption to existing message logging behavior
This will enable Greenflash to connect AI interactions to real business outcomes, validating conversation quality with tangible results.