Skip to content

Commit

Permalink
Added comments to v2 examples (#1935)
Browse files Browse the repository at this point in the history
updated event_name in meter_event_stream to match documentation
  • Loading branch information
jar-stripe authored Oct 11, 2024
1 parent 2d5d664 commit 93e0786
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
13 changes: 12 additions & 1 deletion example/v2/meter_event_stream/meter_event_stream.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// meter_event_stream.go - use the high-throughput meter event stream to report create billing meter events.
//
// This example uses the rawrequests module to make calls to /v2 APIs.
//
// In this example, we:
// - create a meter event session and store the session's authentication token
// - define an event with a payload
// - post the event to /v2/billing/meter_event_stream to create an event stream that reports this event
//
// This example expects a billing meter with an event_name of 'alpaca_ai_tokens'. If you have
// a different meter event name, you can change it before running this example.
package main

import (
Expand Down Expand Up @@ -92,7 +103,7 @@ func main() {

client := rawrequest.Client{B: b, Key: apiKey}

err = sendMeterEvent(client, "api_requests", customerID, "25")
err = sendMeterEvent(client, "alpaca_ai_tokens", customerID, "25")
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
11 changes: 11 additions & 0 deletions example/v2/thinevent_webhook_handler/thinevent_webhook_handler.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// thinevent_webhook_handler.go - receive and process thin events like the
// v1.billing.meter.error_report_triggered event.
//
// This example uses the rawrequests module to make calls to /v2 APIs.
//
// In this example, we:
// - parse the incoming thin event payload and get the event id
// - get the full event from /v2/core/events/ with the event id from the thin event
// - if the full event is a v1.billing.meter.error_report_triggered, use the
// billing/meter package to retrieve the Billing Meter object associated with the
// event.
package main

import (
Expand Down

0 comments on commit 93e0786

Please sign in to comment.