Create an account, confirm the email, then copy the key in setup. The key is shown once. Each event is JSON posted with a bearer key: connector id, platform, phrase, tool name, timestamp, and event id.
TypeScript
const INGEST_URL = "https://www.locksteps.ai/v1/analytics/ingest";
// phrase is what the person asked. user_intent and query are accepted aliases.
export async function logConnectorEvent(input: {
connectorId: string;
apiKey: string;
phrase: string;
toolName: string;
eventId: string;
platform?: string;
}) {
await fetch(INGEST_URL, {
method: "POST",
headers: {
Authorization: `Bearer ${input.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
connector_id: input.connectorId,
platform: input.platform,
phrase: input.phrase,
tool_name: input.toolName,
ts: new Date().toISOString(),
event_id: input.eventId,
}),
});
}
Python
import json
from datetime import datetime, timezone
from urllib.request import Request, urlopen
INGEST_URL = "https://www.locksteps.ai/v1/analytics/ingest"
# phrase is what the person asked. user_intent and query are accepted aliases.
def log_connector_event(connector_id, api_key, phrase, tool_name, event_id, platform=None):
payload = {
"connector_id": connector_id,
"platform": platform,
"phrase": phrase,
"tool_name": tool_name,
"ts": datetime.now(timezone.utc).isoformat(),
"event_id": event_id,
}
request = Request(
INGEST_URL,
data=json.dumps(payload).encode(),
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
method="POST",
)
with urlopen(request, timeout=2) as response:
response.read()
TypeScript, richer event
const INGEST_URL = "https://www.locksteps.ai/v1/analytics/ingest";
// phrase is what the person asked. user_intent and query are accepted aliases. Optional fields are omitted when you do not have them.
export async function logConnectorEvent(input: {
connectorId: string;
apiKey: string;
phrase: string;
toolName: string;
eventId: string;
platform?: string;
outcome?: "success" | "no_result" | "error";
latencyMs?: number;
resultCount?: number;
country?: string;
sessionId?: string;
connectorVersion?: string;
}) {
await fetch(INGEST_URL, {
method: "POST",
headers: {
Authorization: `Bearer ${input.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
connector_id: input.connectorId,
platform: input.platform,
phrase: input.phrase,
tool_name: input.toolName,
ts: new Date().toISOString(),
event_id: input.eventId,
outcome: input.outcome,
latency_ms: input.latencyMs,
result_count: input.resultCount,
country: input.country,
session_id: input.sessionId,
connector_version: input.connectorVersion,
}),
});
}
Python, richer event
import json
from datetime import datetime, timezone
from urllib.request import Request, urlopen
INGEST_URL = "https://www.locksteps.ai/v1/analytics/ingest"
# phrase is what the person asked. user_intent and query are accepted aliases. Optional fields are omitted when you do not have them.
def log_connector_event(
connector_id,
api_key,
phrase,
tool_name,
event_id,
platform=None,
outcome=None,
latency_ms=None,
result_count=None,
country=None,
session_id=None,
connector_version=None,
):
payload = {
"connector_id": connector_id,
"platform": platform,
"phrase": phrase,
"tool_name": tool_name,
"ts": datetime.now(timezone.utc).isoformat(),
"event_id": event_id,
"outcome": outcome,
"latency_ms": latency_ms,
"result_count": result_count,
"country": country,
"session_id": session_id,
"connector_version": connector_version,
}
request = Request(
INGEST_URL,
data=json.dumps({key: value for key, value in payload.items() if value is not None}).encode(),
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
method="POST",
)
with urlopen(request, timeout=2) as response:
response.read()