@contractspec/lib.contracts 1.61.0 → 1.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +179 -4
- package/dist/integrations/index.js +179 -4
- package/dist/integrations/providers/index.d.ts +1 -0
- package/dist/integrations/providers/index.d.ts.map +1 -1
- package/dist/integrations/providers/index.js +180 -5
- package/dist/integrations/providers/posthog-llm-telemetry.d.ts +52 -0
- package/dist/integrations/providers/posthog-llm-telemetry.d.ts.map +1 -0
- package/dist/integrations/providers/posthog-llm-telemetry.js +241 -0
- package/dist/integrations/providers/posthog.d.ts.map +1 -1
- package/dist/integrations/providers/posthog.js +6 -4
- package/dist/integrations/providers/registry.js +6 -4
- package/dist/node/index.js +179 -4
- package/dist/node/integrations/index.js +179 -4
- package/dist/node/integrations/providers/index.js +180 -5
- package/dist/node/integrations/providers/posthog-llm-telemetry.js +241 -0
- package/dist/node/integrations/providers/posthog.js +6 -4
- package/dist/node/integrations/providers/registry.js +6 -4
- package/package.json +22 -10
|
@@ -1891,13 +1891,13 @@ function registerPowensIntegration(registry2) {
|
|
|
1891
1891
|
var posthogIntegrationSpec = defineIntegration({
|
|
1892
1892
|
meta: {
|
|
1893
1893
|
key: "analytics.posthog",
|
|
1894
|
-
version: "1.
|
|
1894
|
+
version: "1.1.0",
|
|
1895
1895
|
category: "analytics",
|
|
1896
1896
|
title: "PostHog",
|
|
1897
|
-
description: "PostHog integration for product analytics, feature flags, and
|
|
1897
|
+
description: "PostHog integration for product analytics, feature flags, HogQL queries, and LLM analytics with evaluations.",
|
|
1898
1898
|
domain: "analytics",
|
|
1899
1899
|
owners: ["@platform.integrations"],
|
|
1900
|
-
tags: ["analytics", "posthog"],
|
|
1900
|
+
tags: ["analytics", "posthog", "llm", "ai"],
|
|
1901
1901
|
stability: StabilityEnum.Beta
|
|
1902
1902
|
},
|
|
1903
1903
|
supportedModes: ["managed", "byok"],
|
|
@@ -1910,7 +1910,9 @@ var posthogIntegrationSpec = defineIntegration({
|
|
|
1910
1910
|
{ key: "analytics.persons", version: "1.0.0" },
|
|
1911
1911
|
{ key: "analytics.insights", version: "1.0.0" },
|
|
1912
1912
|
{ key: "analytics.cohorts", version: "1.0.0" },
|
|
1913
|
-
{ key: "analytics.annotations", version: "1.0.0" }
|
|
1913
|
+
{ key: "analytics.annotations", version: "1.0.0" },
|
|
1914
|
+
{ key: "analytics.llm-tracing", version: "1.0.0" },
|
|
1915
|
+
{ key: "analytics.llm-evaluations", version: "1.0.0" }
|
|
1914
1916
|
]
|
|
1915
1917
|
},
|
|
1916
1918
|
configSchema: {
|
|
@@ -1969,6 +1971,174 @@ function registerPosthogIntegration(registry2) {
|
|
|
1969
1971
|
return registry2.register(posthogIntegrationSpec);
|
|
1970
1972
|
}
|
|
1971
1973
|
|
|
1974
|
+
// src/integrations/providers/posthog-llm-telemetry.ts
|
|
1975
|
+
var posthogLLMTelemetrySpec = {
|
|
1976
|
+
meta: {
|
|
1977
|
+
key: "analytics.posthog.llm",
|
|
1978
|
+
version: "1.0.0",
|
|
1979
|
+
title: "PostHog LLM Analytics Telemetry",
|
|
1980
|
+
description: "Telemetry events for PostHog LLM Analytics: generation tracing, token usage, and evaluation-ready metadata.",
|
|
1981
|
+
domain: "analytics",
|
|
1982
|
+
owners: ["@platform.integrations"],
|
|
1983
|
+
tags: ["analytics", "posthog", "llm", "ai", "telemetry"],
|
|
1984
|
+
stability: StabilityEnum.Beta
|
|
1985
|
+
},
|
|
1986
|
+
events: [
|
|
1987
|
+
{
|
|
1988
|
+
key: "posthog.llm.generation",
|
|
1989
|
+
version: "1.0.0",
|
|
1990
|
+
semantics: {
|
|
1991
|
+
who: "AI agent or LLM consumer",
|
|
1992
|
+
what: "Captures an LLM generation call with full observability metadata",
|
|
1993
|
+
why: "Enable LLM performance monitoring, cost tracking, and automated quality evaluations via PostHog"
|
|
1994
|
+
},
|
|
1995
|
+
properties: {
|
|
1996
|
+
$ai_model: {
|
|
1997
|
+
type: "string",
|
|
1998
|
+
required: true,
|
|
1999
|
+
description: "The LLM model identifier (e.g., gpt-4o, claude-sonnet-4-20250514)"
|
|
2000
|
+
},
|
|
2001
|
+
$ai_provider: {
|
|
2002
|
+
type: "string",
|
|
2003
|
+
required: true,
|
|
2004
|
+
description: "The LLM provider (e.g., openai, anthropic, contractspec)"
|
|
2005
|
+
},
|
|
2006
|
+
$ai_latency: {
|
|
2007
|
+
type: "number",
|
|
2008
|
+
required: false,
|
|
2009
|
+
description: "LLM call latency in seconds"
|
|
2010
|
+
},
|
|
2011
|
+
$ai_input_tokens: {
|
|
2012
|
+
type: "number",
|
|
2013
|
+
required: false,
|
|
2014
|
+
description: "Number of input/prompt tokens consumed"
|
|
2015
|
+
},
|
|
2016
|
+
$ai_output_tokens: {
|
|
2017
|
+
type: "number",
|
|
2018
|
+
required: false,
|
|
2019
|
+
description: "Number of output/completion tokens generated"
|
|
2020
|
+
},
|
|
2021
|
+
$ai_total_cost_usd: {
|
|
2022
|
+
type: "number",
|
|
2023
|
+
required: false,
|
|
2024
|
+
description: "Total cost in USD (input + output)"
|
|
2025
|
+
},
|
|
2026
|
+
$ai_is_error: {
|
|
2027
|
+
type: "boolean",
|
|
2028
|
+
required: false,
|
|
2029
|
+
description: "Whether the generation resulted in an error"
|
|
2030
|
+
},
|
|
2031
|
+
$ai_trace_id: {
|
|
2032
|
+
type: "string",
|
|
2033
|
+
required: false,
|
|
2034
|
+
description: "Trace ID for grouping related generations"
|
|
2035
|
+
},
|
|
2036
|
+
$ai_stream: {
|
|
2037
|
+
type: "boolean",
|
|
2038
|
+
required: false,
|
|
2039
|
+
description: "Whether the response was streamed"
|
|
2040
|
+
},
|
|
2041
|
+
$ai_time_to_first_token: {
|
|
2042
|
+
type: "number",
|
|
2043
|
+
required: false,
|
|
2044
|
+
description: "Time to first token in seconds (streaming only)"
|
|
2045
|
+
},
|
|
2046
|
+
$ai_tools: {
|
|
2047
|
+
type: "json",
|
|
2048
|
+
required: false,
|
|
2049
|
+
description: "Tools/functions available to the LLM"
|
|
2050
|
+
},
|
|
2051
|
+
$ai_input: {
|
|
2052
|
+
type: "json",
|
|
2053
|
+
required: false,
|
|
2054
|
+
pii: true,
|
|
2055
|
+
redact: true,
|
|
2056
|
+
description: "Messages sent to the LLM (may contain PII)"
|
|
2057
|
+
},
|
|
2058
|
+
$ai_output_choices: {
|
|
2059
|
+
type: "json",
|
|
2060
|
+
required: false,
|
|
2061
|
+
pii: true,
|
|
2062
|
+
redact: true,
|
|
2063
|
+
description: "Response choices from the LLM (may contain PII)"
|
|
2064
|
+
},
|
|
2065
|
+
contractspec_operation: {
|
|
2066
|
+
type: "string",
|
|
2067
|
+
required: false,
|
|
2068
|
+
description: "ContractSpec operation name"
|
|
2069
|
+
},
|
|
2070
|
+
contractspec_version: {
|
|
2071
|
+
type: "string",
|
|
2072
|
+
required: false,
|
|
2073
|
+
description: "ContractSpec operation version"
|
|
2074
|
+
},
|
|
2075
|
+
contractspec_agent_id: {
|
|
2076
|
+
type: "string",
|
|
2077
|
+
required: false,
|
|
2078
|
+
description: "ContractSpec agent identifier"
|
|
2079
|
+
},
|
|
2080
|
+
contractspec_finish_reason: {
|
|
2081
|
+
type: "string",
|
|
2082
|
+
required: false,
|
|
2083
|
+
description: "AI SDK finish reason (stop, tool-calls, error, etc.)"
|
|
2084
|
+
},
|
|
2085
|
+
contractspec_tool_count: {
|
|
2086
|
+
type: "number",
|
|
2087
|
+
required: false,
|
|
2088
|
+
description: "Number of tool calls made in this step"
|
|
2089
|
+
}
|
|
2090
|
+
},
|
|
2091
|
+
privacy: "internal",
|
|
2092
|
+
tags: ["llm", "generation", "posthog"]
|
|
2093
|
+
}
|
|
2094
|
+
],
|
|
2095
|
+
config: {
|
|
2096
|
+
defaultRetentionDays: 90,
|
|
2097
|
+
defaultSamplingRate: 1,
|
|
2098
|
+
providers: [
|
|
2099
|
+
{
|
|
2100
|
+
type: "posthog",
|
|
2101
|
+
config: {
|
|
2102
|
+
eventName: "$ai_generation",
|
|
2103
|
+
enableEvaluations: true,
|
|
2104
|
+
evaluationTemplates: [
|
|
2105
|
+
"relevance",
|
|
2106
|
+
"helpfulness",
|
|
2107
|
+
"jailbreak",
|
|
2108
|
+
"hallucination",
|
|
2109
|
+
"toxicity"
|
|
2110
|
+
]
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
]
|
|
2114
|
+
}
|
|
2115
|
+
};
|
|
2116
|
+
var POSTHOG_LLM_PII_FIELDS = [
|
|
2117
|
+
"$ai_input",
|
|
2118
|
+
"$ai_output_choices"
|
|
2119
|
+
];
|
|
2120
|
+
var POSTHOG_LLM_TELEMETRY_EVENTS = {
|
|
2121
|
+
generation: "$ai_generation",
|
|
2122
|
+
span: "$ai_span",
|
|
2123
|
+
evaluation: "$ai_evaluation"
|
|
2124
|
+
};
|
|
2125
|
+
var POSTHOG_EVALUATION_TEMPLATES = {
|
|
2126
|
+
relevance: "relevance",
|
|
2127
|
+
helpfulness: "helpfulness",
|
|
2128
|
+
jailbreak: "jailbreak",
|
|
2129
|
+
hallucination: "hallucination",
|
|
2130
|
+
toxicity: "toxicity"
|
|
2131
|
+
};
|
|
2132
|
+
function redactPostHogLLMTelemetryPayload(payload) {
|
|
2133
|
+
const redacted = { ...payload };
|
|
2134
|
+
for (const field of POSTHOG_LLM_PII_FIELDS) {
|
|
2135
|
+
if (field in redacted) {
|
|
2136
|
+
redacted[field] = "[REDACTED]";
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
return redacted;
|
|
2140
|
+
}
|
|
2141
|
+
|
|
1972
2142
|
// src/integrations/providers/linear.ts
|
|
1973
2143
|
var linearIntegrationSpec = defineIntegration({
|
|
1974
2144
|
meta: {
|
|
@@ -3755,11 +3925,13 @@ export {
|
|
|
3755
3925
|
registerFathomIntegration,
|
|
3756
3926
|
registerFalIntegration,
|
|
3757
3927
|
registerElevenLabsIntegration,
|
|
3928
|
+
redactPostHogLLMTelemetryPayload,
|
|
3758
3929
|
redactOpenBankingTelemetryPayload,
|
|
3759
3930
|
redactMeetingRecorderTelemetryPayload,
|
|
3760
3931
|
qdrantIntegrationSpec,
|
|
3761
3932
|
powensIntegrationSpec,
|
|
3762
3933
|
postmarkIntegrationSpec,
|
|
3934
|
+
posthogLLMTelemetrySpec,
|
|
3763
3935
|
posthogIntegrationSpec,
|
|
3764
3936
|
notionIntegrationSpec,
|
|
3765
3937
|
mistralIntegrationSpec,
|
|
@@ -3779,6 +3951,9 @@ export {
|
|
|
3779
3951
|
defineIntegration,
|
|
3780
3952
|
createDefaultIntegrationSpecRegistry,
|
|
3781
3953
|
assertPrimaryOpenBankingReady,
|
|
3954
|
+
POSTHOG_LLM_TELEMETRY_EVENTS,
|
|
3955
|
+
POSTHOG_LLM_PII_FIELDS,
|
|
3956
|
+
POSTHOG_EVALUATION_TEMPLATES,
|
|
3782
3957
|
OpenBankingSyncTransactions,
|
|
3783
3958
|
OpenBankingSyncAccounts,
|
|
3784
3959
|
OpenBankingRefreshBalances,
|
|
@@ -1370,13 +1370,13 @@ function registerPowensIntegration(registry) {
|
|
|
1370
1370
|
var posthogIntegrationSpec = defineIntegration({
|
|
1371
1371
|
meta: {
|
|
1372
1372
|
key: "analytics.posthog",
|
|
1373
|
-
version: "1.
|
|
1373
|
+
version: "1.1.0",
|
|
1374
1374
|
category: "analytics",
|
|
1375
1375
|
title: "PostHog",
|
|
1376
|
-
description: "PostHog integration for product analytics, feature flags, and
|
|
1376
|
+
description: "PostHog integration for product analytics, feature flags, HogQL queries, and LLM analytics with evaluations.",
|
|
1377
1377
|
domain: "analytics",
|
|
1378
1378
|
owners: ["@platform.integrations"],
|
|
1379
|
-
tags: ["analytics", "posthog"],
|
|
1379
|
+
tags: ["analytics", "posthog", "llm", "ai"],
|
|
1380
1380
|
stability: StabilityEnum.Beta
|
|
1381
1381
|
},
|
|
1382
1382
|
supportedModes: ["managed", "byok"],
|
|
@@ -1389,7 +1389,9 @@ var posthogIntegrationSpec = defineIntegration({
|
|
|
1389
1389
|
{ key: "analytics.persons", version: "1.0.0" },
|
|
1390
1390
|
{ key: "analytics.insights", version: "1.0.0" },
|
|
1391
1391
|
{ key: "analytics.cohorts", version: "1.0.0" },
|
|
1392
|
-
{ key: "analytics.annotations", version: "1.0.0" }
|
|
1392
|
+
{ key: "analytics.annotations", version: "1.0.0" },
|
|
1393
|
+
{ key: "analytics.llm-tracing", version: "1.0.0" },
|
|
1394
|
+
{ key: "analytics.llm-evaluations", version: "1.0.0" }
|
|
1393
1395
|
]
|
|
1394
1396
|
},
|
|
1395
1397
|
configSchema: {
|
|
@@ -1448,6 +1450,174 @@ function registerPosthogIntegration(registry) {
|
|
|
1448
1450
|
return registry.register(posthogIntegrationSpec);
|
|
1449
1451
|
}
|
|
1450
1452
|
|
|
1453
|
+
// src/integrations/providers/posthog-llm-telemetry.ts
|
|
1454
|
+
var posthogLLMTelemetrySpec = {
|
|
1455
|
+
meta: {
|
|
1456
|
+
key: "analytics.posthog.llm",
|
|
1457
|
+
version: "1.0.0",
|
|
1458
|
+
title: "PostHog LLM Analytics Telemetry",
|
|
1459
|
+
description: "Telemetry events for PostHog LLM Analytics: generation tracing, token usage, and evaluation-ready metadata.",
|
|
1460
|
+
domain: "analytics",
|
|
1461
|
+
owners: ["@platform.integrations"],
|
|
1462
|
+
tags: ["analytics", "posthog", "llm", "ai", "telemetry"],
|
|
1463
|
+
stability: StabilityEnum.Beta
|
|
1464
|
+
},
|
|
1465
|
+
events: [
|
|
1466
|
+
{
|
|
1467
|
+
key: "posthog.llm.generation",
|
|
1468
|
+
version: "1.0.0",
|
|
1469
|
+
semantics: {
|
|
1470
|
+
who: "AI agent or LLM consumer",
|
|
1471
|
+
what: "Captures an LLM generation call with full observability metadata",
|
|
1472
|
+
why: "Enable LLM performance monitoring, cost tracking, and automated quality evaluations via PostHog"
|
|
1473
|
+
},
|
|
1474
|
+
properties: {
|
|
1475
|
+
$ai_model: {
|
|
1476
|
+
type: "string",
|
|
1477
|
+
required: true,
|
|
1478
|
+
description: "The LLM model identifier (e.g., gpt-4o, claude-sonnet-4-20250514)"
|
|
1479
|
+
},
|
|
1480
|
+
$ai_provider: {
|
|
1481
|
+
type: "string",
|
|
1482
|
+
required: true,
|
|
1483
|
+
description: "The LLM provider (e.g., openai, anthropic, contractspec)"
|
|
1484
|
+
},
|
|
1485
|
+
$ai_latency: {
|
|
1486
|
+
type: "number",
|
|
1487
|
+
required: false,
|
|
1488
|
+
description: "LLM call latency in seconds"
|
|
1489
|
+
},
|
|
1490
|
+
$ai_input_tokens: {
|
|
1491
|
+
type: "number",
|
|
1492
|
+
required: false,
|
|
1493
|
+
description: "Number of input/prompt tokens consumed"
|
|
1494
|
+
},
|
|
1495
|
+
$ai_output_tokens: {
|
|
1496
|
+
type: "number",
|
|
1497
|
+
required: false,
|
|
1498
|
+
description: "Number of output/completion tokens generated"
|
|
1499
|
+
},
|
|
1500
|
+
$ai_total_cost_usd: {
|
|
1501
|
+
type: "number",
|
|
1502
|
+
required: false,
|
|
1503
|
+
description: "Total cost in USD (input + output)"
|
|
1504
|
+
},
|
|
1505
|
+
$ai_is_error: {
|
|
1506
|
+
type: "boolean",
|
|
1507
|
+
required: false,
|
|
1508
|
+
description: "Whether the generation resulted in an error"
|
|
1509
|
+
},
|
|
1510
|
+
$ai_trace_id: {
|
|
1511
|
+
type: "string",
|
|
1512
|
+
required: false,
|
|
1513
|
+
description: "Trace ID for grouping related generations"
|
|
1514
|
+
},
|
|
1515
|
+
$ai_stream: {
|
|
1516
|
+
type: "boolean",
|
|
1517
|
+
required: false,
|
|
1518
|
+
description: "Whether the response was streamed"
|
|
1519
|
+
},
|
|
1520
|
+
$ai_time_to_first_token: {
|
|
1521
|
+
type: "number",
|
|
1522
|
+
required: false,
|
|
1523
|
+
description: "Time to first token in seconds (streaming only)"
|
|
1524
|
+
},
|
|
1525
|
+
$ai_tools: {
|
|
1526
|
+
type: "json",
|
|
1527
|
+
required: false,
|
|
1528
|
+
description: "Tools/functions available to the LLM"
|
|
1529
|
+
},
|
|
1530
|
+
$ai_input: {
|
|
1531
|
+
type: "json",
|
|
1532
|
+
required: false,
|
|
1533
|
+
pii: true,
|
|
1534
|
+
redact: true,
|
|
1535
|
+
description: "Messages sent to the LLM (may contain PII)"
|
|
1536
|
+
},
|
|
1537
|
+
$ai_output_choices: {
|
|
1538
|
+
type: "json",
|
|
1539
|
+
required: false,
|
|
1540
|
+
pii: true,
|
|
1541
|
+
redact: true,
|
|
1542
|
+
description: "Response choices from the LLM (may contain PII)"
|
|
1543
|
+
},
|
|
1544
|
+
contractspec_operation: {
|
|
1545
|
+
type: "string",
|
|
1546
|
+
required: false,
|
|
1547
|
+
description: "ContractSpec operation name"
|
|
1548
|
+
},
|
|
1549
|
+
contractspec_version: {
|
|
1550
|
+
type: "string",
|
|
1551
|
+
required: false,
|
|
1552
|
+
description: "ContractSpec operation version"
|
|
1553
|
+
},
|
|
1554
|
+
contractspec_agent_id: {
|
|
1555
|
+
type: "string",
|
|
1556
|
+
required: false,
|
|
1557
|
+
description: "ContractSpec agent identifier"
|
|
1558
|
+
},
|
|
1559
|
+
contractspec_finish_reason: {
|
|
1560
|
+
type: "string",
|
|
1561
|
+
required: false,
|
|
1562
|
+
description: "AI SDK finish reason (stop, tool-calls, error, etc.)"
|
|
1563
|
+
},
|
|
1564
|
+
contractspec_tool_count: {
|
|
1565
|
+
type: "number",
|
|
1566
|
+
required: false,
|
|
1567
|
+
description: "Number of tool calls made in this step"
|
|
1568
|
+
}
|
|
1569
|
+
},
|
|
1570
|
+
privacy: "internal",
|
|
1571
|
+
tags: ["llm", "generation", "posthog"]
|
|
1572
|
+
}
|
|
1573
|
+
],
|
|
1574
|
+
config: {
|
|
1575
|
+
defaultRetentionDays: 90,
|
|
1576
|
+
defaultSamplingRate: 1,
|
|
1577
|
+
providers: [
|
|
1578
|
+
{
|
|
1579
|
+
type: "posthog",
|
|
1580
|
+
config: {
|
|
1581
|
+
eventName: "$ai_generation",
|
|
1582
|
+
enableEvaluations: true,
|
|
1583
|
+
evaluationTemplates: [
|
|
1584
|
+
"relevance",
|
|
1585
|
+
"helpfulness",
|
|
1586
|
+
"jailbreak",
|
|
1587
|
+
"hallucination",
|
|
1588
|
+
"toxicity"
|
|
1589
|
+
]
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
]
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
var POSTHOG_LLM_PII_FIELDS = [
|
|
1596
|
+
"$ai_input",
|
|
1597
|
+
"$ai_output_choices"
|
|
1598
|
+
];
|
|
1599
|
+
var POSTHOG_LLM_TELEMETRY_EVENTS = {
|
|
1600
|
+
generation: "$ai_generation",
|
|
1601
|
+
span: "$ai_span",
|
|
1602
|
+
evaluation: "$ai_evaluation"
|
|
1603
|
+
};
|
|
1604
|
+
var POSTHOG_EVALUATION_TEMPLATES = {
|
|
1605
|
+
relevance: "relevance",
|
|
1606
|
+
helpfulness: "helpfulness",
|
|
1607
|
+
jailbreak: "jailbreak",
|
|
1608
|
+
hallucination: "hallucination",
|
|
1609
|
+
toxicity: "toxicity"
|
|
1610
|
+
};
|
|
1611
|
+
function redactPostHogLLMTelemetryPayload(payload) {
|
|
1612
|
+
const redacted = { ...payload };
|
|
1613
|
+
for (const field of POSTHOG_LLM_PII_FIELDS) {
|
|
1614
|
+
if (field in redacted) {
|
|
1615
|
+
redacted[field] = "[REDACTED]";
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
return redacted;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1451
1621
|
// src/integrations/providers/linear.ts
|
|
1452
1622
|
var linearIntegrationSpec = defineIntegration({
|
|
1453
1623
|
meta: {
|
|
@@ -2121,9 +2291,11 @@ export {
|
|
|
2121
2291
|
registerFathomIntegration,
|
|
2122
2292
|
registerFalIntegration,
|
|
2123
2293
|
registerElevenLabsIntegration,
|
|
2294
|
+
redactPostHogLLMTelemetryPayload,
|
|
2124
2295
|
qdrantIntegrationSpec,
|
|
2125
2296
|
powensIntegrationSpec,
|
|
2126
2297
|
postmarkIntegrationSpec,
|
|
2298
|
+
posthogLLMTelemetrySpec,
|
|
2127
2299
|
posthogIntegrationSpec,
|
|
2128
2300
|
notionIntegrationSpec,
|
|
2129
2301
|
mistralIntegrationSpec,
|
|
@@ -2138,5 +2310,8 @@ export {
|
|
|
2138
2310
|
fathomIntegrationSpec,
|
|
2139
2311
|
falIntegrationSpec,
|
|
2140
2312
|
elevenLabsIntegrationSpec,
|
|
2141
|
-
createDefaultIntegrationSpecRegistry
|
|
2313
|
+
createDefaultIntegrationSpecRegistry,
|
|
2314
|
+
POSTHOG_LLM_TELEMETRY_EVENTS,
|
|
2315
|
+
POSTHOG_LLM_PII_FIELDS,
|
|
2316
|
+
POSTHOG_EVALUATION_TEMPLATES
|
|
2142
2317
|
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/ownership.ts
|
|
33
|
+
var StabilityEnum = {
|
|
34
|
+
Idea: "idea",
|
|
35
|
+
InCreation: "in_creation",
|
|
36
|
+
Experimental: "experimental",
|
|
37
|
+
Beta: "beta",
|
|
38
|
+
Stable: "stable",
|
|
39
|
+
Deprecated: "deprecated"
|
|
40
|
+
};
|
|
41
|
+
var OwnersEnum = {
|
|
42
|
+
PlatformCore: "platform.core",
|
|
43
|
+
PlatformSigil: "platform.sigil",
|
|
44
|
+
PlatformMarketplace: "platform.marketplace",
|
|
45
|
+
PlatformMessaging: "platform.messaging",
|
|
46
|
+
PlatformContent: "platform.content",
|
|
47
|
+
PlatformFeatureFlags: "platform.featureflags",
|
|
48
|
+
PlatformFinance: "platform.finance"
|
|
49
|
+
};
|
|
50
|
+
var Owners = OwnersEnum;
|
|
51
|
+
var TagsEnum = {
|
|
52
|
+
Spots: "spots",
|
|
53
|
+
Collectivity: "collectivity",
|
|
54
|
+
Marketplace: "marketplace",
|
|
55
|
+
Sellers: "sellers",
|
|
56
|
+
Auth: "auth",
|
|
57
|
+
Login: "login",
|
|
58
|
+
Signup: "signup",
|
|
59
|
+
Guide: "guide",
|
|
60
|
+
Docs: "docs",
|
|
61
|
+
I18n: "i18n",
|
|
62
|
+
Incident: "incident",
|
|
63
|
+
Automation: "automation",
|
|
64
|
+
Hygiene: "hygiene"
|
|
65
|
+
};
|
|
66
|
+
var Tags = TagsEnum;
|
|
67
|
+
|
|
68
|
+
// src/integrations/providers/posthog-llm-telemetry.ts
|
|
69
|
+
var posthogLLMTelemetrySpec = {
|
|
70
|
+
meta: {
|
|
71
|
+
key: "analytics.posthog.llm",
|
|
72
|
+
version: "1.0.0",
|
|
73
|
+
title: "PostHog LLM Analytics Telemetry",
|
|
74
|
+
description: "Telemetry events for PostHog LLM Analytics: generation tracing, token usage, and evaluation-ready metadata.",
|
|
75
|
+
domain: "analytics",
|
|
76
|
+
owners: ["@platform.integrations"],
|
|
77
|
+
tags: ["analytics", "posthog", "llm", "ai", "telemetry"],
|
|
78
|
+
stability: StabilityEnum.Beta
|
|
79
|
+
},
|
|
80
|
+
events: [
|
|
81
|
+
{
|
|
82
|
+
key: "posthog.llm.generation",
|
|
83
|
+
version: "1.0.0",
|
|
84
|
+
semantics: {
|
|
85
|
+
who: "AI agent or LLM consumer",
|
|
86
|
+
what: "Captures an LLM generation call with full observability metadata",
|
|
87
|
+
why: "Enable LLM performance monitoring, cost tracking, and automated quality evaluations via PostHog"
|
|
88
|
+
},
|
|
89
|
+
properties: {
|
|
90
|
+
$ai_model: {
|
|
91
|
+
type: "string",
|
|
92
|
+
required: true,
|
|
93
|
+
description: "The LLM model identifier (e.g., gpt-4o, claude-sonnet-4-20250514)"
|
|
94
|
+
},
|
|
95
|
+
$ai_provider: {
|
|
96
|
+
type: "string",
|
|
97
|
+
required: true,
|
|
98
|
+
description: "The LLM provider (e.g., openai, anthropic, contractspec)"
|
|
99
|
+
},
|
|
100
|
+
$ai_latency: {
|
|
101
|
+
type: "number",
|
|
102
|
+
required: false,
|
|
103
|
+
description: "LLM call latency in seconds"
|
|
104
|
+
},
|
|
105
|
+
$ai_input_tokens: {
|
|
106
|
+
type: "number",
|
|
107
|
+
required: false,
|
|
108
|
+
description: "Number of input/prompt tokens consumed"
|
|
109
|
+
},
|
|
110
|
+
$ai_output_tokens: {
|
|
111
|
+
type: "number",
|
|
112
|
+
required: false,
|
|
113
|
+
description: "Number of output/completion tokens generated"
|
|
114
|
+
},
|
|
115
|
+
$ai_total_cost_usd: {
|
|
116
|
+
type: "number",
|
|
117
|
+
required: false,
|
|
118
|
+
description: "Total cost in USD (input + output)"
|
|
119
|
+
},
|
|
120
|
+
$ai_is_error: {
|
|
121
|
+
type: "boolean",
|
|
122
|
+
required: false,
|
|
123
|
+
description: "Whether the generation resulted in an error"
|
|
124
|
+
},
|
|
125
|
+
$ai_trace_id: {
|
|
126
|
+
type: "string",
|
|
127
|
+
required: false,
|
|
128
|
+
description: "Trace ID for grouping related generations"
|
|
129
|
+
},
|
|
130
|
+
$ai_stream: {
|
|
131
|
+
type: "boolean",
|
|
132
|
+
required: false,
|
|
133
|
+
description: "Whether the response was streamed"
|
|
134
|
+
},
|
|
135
|
+
$ai_time_to_first_token: {
|
|
136
|
+
type: "number",
|
|
137
|
+
required: false,
|
|
138
|
+
description: "Time to first token in seconds (streaming only)"
|
|
139
|
+
},
|
|
140
|
+
$ai_tools: {
|
|
141
|
+
type: "json",
|
|
142
|
+
required: false,
|
|
143
|
+
description: "Tools/functions available to the LLM"
|
|
144
|
+
},
|
|
145
|
+
$ai_input: {
|
|
146
|
+
type: "json",
|
|
147
|
+
required: false,
|
|
148
|
+
pii: true,
|
|
149
|
+
redact: true,
|
|
150
|
+
description: "Messages sent to the LLM (may contain PII)"
|
|
151
|
+
},
|
|
152
|
+
$ai_output_choices: {
|
|
153
|
+
type: "json",
|
|
154
|
+
required: false,
|
|
155
|
+
pii: true,
|
|
156
|
+
redact: true,
|
|
157
|
+
description: "Response choices from the LLM (may contain PII)"
|
|
158
|
+
},
|
|
159
|
+
contractspec_operation: {
|
|
160
|
+
type: "string",
|
|
161
|
+
required: false,
|
|
162
|
+
description: "ContractSpec operation name"
|
|
163
|
+
},
|
|
164
|
+
contractspec_version: {
|
|
165
|
+
type: "string",
|
|
166
|
+
required: false,
|
|
167
|
+
description: "ContractSpec operation version"
|
|
168
|
+
},
|
|
169
|
+
contractspec_agent_id: {
|
|
170
|
+
type: "string",
|
|
171
|
+
required: false,
|
|
172
|
+
description: "ContractSpec agent identifier"
|
|
173
|
+
},
|
|
174
|
+
contractspec_finish_reason: {
|
|
175
|
+
type: "string",
|
|
176
|
+
required: false,
|
|
177
|
+
description: "AI SDK finish reason (stop, tool-calls, error, etc.)"
|
|
178
|
+
},
|
|
179
|
+
contractspec_tool_count: {
|
|
180
|
+
type: "number",
|
|
181
|
+
required: false,
|
|
182
|
+
description: "Number of tool calls made in this step"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
privacy: "internal",
|
|
186
|
+
tags: ["llm", "generation", "posthog"]
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
config: {
|
|
190
|
+
defaultRetentionDays: 90,
|
|
191
|
+
defaultSamplingRate: 1,
|
|
192
|
+
providers: [
|
|
193
|
+
{
|
|
194
|
+
type: "posthog",
|
|
195
|
+
config: {
|
|
196
|
+
eventName: "$ai_generation",
|
|
197
|
+
enableEvaluations: true,
|
|
198
|
+
evaluationTemplates: [
|
|
199
|
+
"relevance",
|
|
200
|
+
"helpfulness",
|
|
201
|
+
"jailbreak",
|
|
202
|
+
"hallucination",
|
|
203
|
+
"toxicity"
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
var POSTHOG_LLM_PII_FIELDS = [
|
|
211
|
+
"$ai_input",
|
|
212
|
+
"$ai_output_choices"
|
|
213
|
+
];
|
|
214
|
+
var POSTHOG_LLM_TELEMETRY_EVENTS = {
|
|
215
|
+
generation: "$ai_generation",
|
|
216
|
+
span: "$ai_span",
|
|
217
|
+
evaluation: "$ai_evaluation"
|
|
218
|
+
};
|
|
219
|
+
var POSTHOG_EVALUATION_TEMPLATES = {
|
|
220
|
+
relevance: "relevance",
|
|
221
|
+
helpfulness: "helpfulness",
|
|
222
|
+
jailbreak: "jailbreak",
|
|
223
|
+
hallucination: "hallucination",
|
|
224
|
+
toxicity: "toxicity"
|
|
225
|
+
};
|
|
226
|
+
function redactPostHogLLMTelemetryPayload(payload) {
|
|
227
|
+
const redacted = { ...payload };
|
|
228
|
+
for (const field of POSTHOG_LLM_PII_FIELDS) {
|
|
229
|
+
if (field in redacted) {
|
|
230
|
+
redacted[field] = "[REDACTED]";
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return redacted;
|
|
234
|
+
}
|
|
235
|
+
export {
|
|
236
|
+
redactPostHogLLMTelemetryPayload,
|
|
237
|
+
posthogLLMTelemetrySpec,
|
|
238
|
+
POSTHOG_LLM_TELEMETRY_EVENTS,
|
|
239
|
+
POSTHOG_LLM_PII_FIELDS,
|
|
240
|
+
POSTHOG_EVALUATION_TEMPLATES
|
|
241
|
+
};
|