MCPcopy
hub / github.com/langchain-ai/langchain / create_events

Function create_events

libs/cli/langchain_cli/utils/events.py:13–41  ·  view source on GitHub ↗
(events: List[EventDict])

Source from the content-addressed store, hash-verified

11
12
13def create_events(events: List[EventDict]) -> Optional[Any]:
14 try:
15 data = {
16 "events": [
17 {
18 "write_key": WRITE_KEY,
19 "name": event["event"],
20 "properties": event.get("properties"),
21 }
22 for event in events
23 ]
24 }
25
26 conn = http.client.HTTPSConnection("app.firstpartyhq.com")
27
28 payload = json.dumps(data)
29
30 headers = {
31 "Content-Type": "application/json",
32 "Accept": "application/json",
33 }
34
35 conn.request("POST", "/events/v1/track/bulk", payload, headers)
36
37 res = conn.getresponse()
38
39 return json.loads(res.read())
40 except Exception:
41 return None

Callers 2

addFunction · 0.90
test_create_eventsFunction · 0.90

Calls 3

requestMethod · 0.80
getMethod · 0.45
readMethod · 0.45

Tested by 1

test_create_eventsFunction · 0.72