Our SDKs give you more control over the events collected by the CTO.ai platform when you run Commands, Pipelines, or Services workflows. Available for multiple language runtimes—Node, Bash, Python, and Go—the CTO.ai Ops SDKs provide functionality for tracking key Insights Events from your workflows run on our platform.
Available SDKs
These examples show you how to track events using our Ops SDKs in each supported language.
const {sdk} =require("@cto.ai/sdk")
asyncfunctionmain() {
constevent= {
event_name:"deployment",
event_action:"success",
branch:"main",
repo:"web",
}
// The first argument to `sdk.track` is a field that isn't used
// by Insights, so it has been left blank in this example.
sdk.track([], event)
}
main()
#!/bin/bash
# The "" argument (the first argument) is a metadata field that# isn't used by Insights, but is required by the `sdk track` command,# so it has been left INTENTIONALLY blank in this example.sdk track ""\
event_name:Deployment \
event_action:Success \
branch:main \
repo:web
from cto_ai import sdk
defmain():
event = {
"event_name": "deployment",
"event_action": "success",
"branch": "main",
"repo": "web" }
# The first two arguments for sdk.track are left blank# in this example because they are not used by Insights.# They are required by the sdk.track method, however. sdk.track([], "", event)
if __name__ =="__main__":
main()
packagemainimport (
ctoai"github.com/cto-ai/sdk-go")
funcmain() {
client:=ctoai.NewClient()
event:=map[string]interface{}{
"event_name": "deployment",
"event_action": "success",
"branch": "main",
"repo": "web",
}
// The first two arguments to client.Sdk.Track are left blank
// because they are required by Track, but are not used
// by the Insights Dashboard.
err:=client.Sdk.Track([]string{}, "", event)
iferr!=nil {
panic(err)
}
}
For all of our SDKS, you must submit four key-value pairs to the tracking function of each:
event_name: The type of event being tracked.
event_action: The result of the event being tracked (either success or failure in the case of deployment events).
repo: The name of the repository originating this event.
branch: The branch that originated this event within your repo.