Follow these steps to implement Kable within your Go API.
Estimated completion: 10 minutes
See the latest version or contribute at:
Implement Kable
package main
import (
"encoding/json"
"net/http"
"github.com/Kable-io/kable-go"
)
// Initialize Kable with fields found on your Company page in the dashboard
var kableClient *kable.Kable = kable.New(
&kable.KableOptions{
KableClientId: "<YOUR_KABLE_CLIENT_ID>",
KableClientSecret: "<YOUR_KABLE_CLIENT_SECRET>",
Debug: true,
MaxQueueSize: 20,
})
func api(w http.ResponseWriter, r *http.Request) {
// record data from within your API
kableClient.Record(kable.Event{
ClientId: "yourcompanyuser_1234567890",
Data: map[string]interface{}{"userId": "xyz123"},
})
json.NewEncoder(w).Encode(map[string]string{"message": "Data has been recorded by Kable!"})
}
Updated 9 months ago