@zuplo/cli 7.14.2 → 7.14.5

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.
Files changed (308) hide show
  1. package/README.md +1 -0
  2. package/dist/cmds/variable/delete.d.ts +9 -0
  3. package/dist/cmds/variable/delete.d.ts.map +1 -0
  4. package/dist/cmds/variable/delete.js +72 -0
  5. package/dist/cmds/variable/delete.js.map +1 -0
  6. package/dist/cmds/variable/index.d.ts.map +1 -1
  7. package/dist/cmds/variable/index.js +2 -1
  8. package/dist/cmds/variable/index.js.map +1 -1
  9. package/dist/common/middleware/get-environment-param.d.ts.map +1 -1
  10. package/dist/common/middleware/get-environment-param.js +10 -12
  11. package/dist/common/middleware/get-environment-param.js.map +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/dist/variable/delete/handler.d.ts +9 -0
  14. package/dist/variable/delete/handler.d.ts.map +1 -0
  15. package/dist/variable/delete/handler.js +13 -0
  16. package/dist/variable/delete/handler.js.map +1 -0
  17. package/node_modules/@posthog/core/dist/error-tracking/parsers/node.d.ts.map +1 -1
  18. package/node_modules/@posthog/core/dist/error-tracking/parsers/node.js +1 -1
  19. package/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs +1 -1
  20. package/node_modules/@posthog/core/dist/index.d.ts +1 -1
  21. package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
  22. package/node_modules/@posthog/core/dist/logs/logs-utils.js +5 -5
  23. package/node_modules/@posthog/core/dist/logs/logs-utils.mjs +5 -5
  24. package/node_modules/@posthog/core/dist/metrics/index.d.ts +15 -2
  25. package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -1
  26. package/node_modules/@posthog/core/dist/metrics/index.js +88 -35
  27. package/node_modules/@posthog/core/dist/metrics/index.mjs +88 -35
  28. package/node_modules/@posthog/core/dist/metrics/types.d.ts +1 -1
  29. package/node_modules/@posthog/core/dist/metrics/types.d.ts.map +1 -1
  30. package/node_modules/@posthog/core/dist/privacy.js +3 -3
  31. package/node_modules/@posthog/core/dist/privacy.mjs +3 -3
  32. package/node_modules/@posthog/core/dist/utils/user-agent-utils.d.ts.map +1 -1
  33. package/node_modules/@posthog/core/dist/utils/user-agent-utils.js +36 -36
  34. package/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs +36 -36
  35. package/node_modules/@posthog/core/package.json +2 -2
  36. package/node_modules/@posthog/core/src/error-tracking/parsers/node.spec.ts +15 -0
  37. package/node_modules/@posthog/core/src/error-tracking/parsers/node.ts +2 -1
  38. package/node_modules/@posthog/core/src/index.ts +1 -0
  39. package/node_modules/@posthog/core/src/logs/logs-utils.ts +3 -3
  40. package/node_modules/@posthog/core/src/metrics/index.spec.ts +278 -0
  41. package/node_modules/@posthog/core/src/metrics/index.ts +160 -44
  42. package/node_modules/@posthog/core/src/metrics/types.ts +1 -0
  43. package/node_modules/@posthog/core/src/privacy.ts +3 -3
  44. package/node_modules/@posthog/core/src/utils/user-agent-utils.ts +39 -36
  45. package/node_modules/@posthog/types/dist/capture-metric.d.ts +24 -2
  46. package/node_modules/@posthog/types/dist/capture-metric.d.ts.map +1 -1
  47. package/node_modules/@posthog/types/dist/index.d.ts +1 -1
  48. package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
  49. package/node_modules/@posthog/types/dist/posthog-config.d.ts +18 -1
  50. package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
  51. package/node_modules/@posthog/types/package.json +1 -1
  52. package/node_modules/@posthog/types/src/capture-metric.ts +25 -2
  53. package/node_modules/@posthog/types/src/index.ts +1 -0
  54. package/node_modules/@posthog/types/src/posthog-config.ts +18 -1
  55. package/node_modules/@zuplo/core/package.json +1 -1
  56. package/node_modules/@zuplo/graphql/package.json +1 -1
  57. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  58. package/node_modules/@zuplo/otel/package.json +1 -1
  59. package/node_modules/@zuplo/runtime/out/esm/{chunk-MUDGPSWL.js → chunk-UGZSO3CK.js} +94 -94
  60. package/node_modules/@zuplo/runtime/out/esm/chunk-UGZSO3CK.js.map +1 -0
  61. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  62. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +12 -12
  63. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  64. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  65. package/node_modules/@zuplo/runtime/package.json +1 -1
  66. package/node_modules/graphql/error/GraphQLError.d.ts +5 -1
  67. package/node_modules/graphql/error/GraphQLError.js +12 -7
  68. package/node_modules/graphql/error/GraphQLError.mjs +13 -6
  69. package/node_modules/graphql/error/locatedError.d.ts +6 -4
  70. package/node_modules/graphql/error/locatedError.js +6 -4
  71. package/node_modules/graphql/error/locatedError.mjs +6 -4
  72. package/node_modules/graphql/execution/collectFields.d.ts +1 -0
  73. package/node_modules/graphql/execution/collectFields.js +9 -0
  74. package/node_modules/graphql/execution/collectFields.mjs +9 -0
  75. package/node_modules/graphql/execution/execute.d.ts +9 -10
  76. package/node_modules/graphql/execution/execute.js +44 -29
  77. package/node_modules/graphql/execution/execute.mjs +44 -29
  78. package/node_modules/graphql/execution/mapAsyncIterator.js +12 -11
  79. package/node_modules/graphql/execution/mapAsyncIterator.mjs +12 -11
  80. package/node_modules/graphql/execution/subscribe.d.ts +5 -2
  81. package/node_modules/graphql/execution/subscribe.js +5 -2
  82. package/node_modules/graphql/execution/subscribe.mjs +5 -2
  83. package/node_modules/graphql/execution/values.d.ts +43 -21
  84. package/node_modules/graphql/execution/values.js +52 -24
  85. package/node_modules/graphql/execution/values.mjs +51 -23
  86. package/node_modules/graphql/graphql.d.ts +8 -14
  87. package/node_modules/graphql/graphql.js +16 -15
  88. package/node_modules/graphql/graphql.mjs +11 -15
  89. package/node_modules/graphql/jsutils/SetMap.d.ts +14 -0
  90. package/node_modules/graphql/jsutils/SetMap.js +48 -0
  91. package/node_modules/graphql/jsutils/SetMap.mjs +39 -0
  92. package/node_modules/graphql/jsutils/isIterableObject.d.ts +2 -0
  93. package/node_modules/graphql/jsutils/isIterableObject.js +2 -0
  94. package/node_modules/graphql/jsutils/isIterableObject.mjs +2 -0
  95. package/node_modules/graphql/jsutils/keyMap.d.ts +2 -0
  96. package/node_modules/graphql/jsutils/keyMap.js +2 -0
  97. package/node_modules/graphql/jsutils/keyMap.mjs +2 -0
  98. package/node_modules/graphql/jsutils/keyValMap.d.ts +3 -3
  99. package/node_modules/graphql/jsutils/keyValMap.js +3 -3
  100. package/node_modules/graphql/jsutils/keyValMap.mjs +3 -3
  101. package/node_modules/graphql/language/ast.d.ts +2 -6
  102. package/node_modules/graphql/language/ast.js +2 -6
  103. package/node_modules/graphql/language/ast.mjs +2 -6
  104. package/node_modules/graphql/language/lexer.d.ts +6 -0
  105. package/node_modules/graphql/language/lexer.js +22 -0
  106. package/node_modules/graphql/language/lexer.mjs +22 -0
  107. package/node_modules/graphql/language/location.d.ts +8 -3
  108. package/node_modules/graphql/language/location.js +57 -17
  109. package/node_modules/graphql/language/location.mjs +56 -16
  110. package/node_modules/graphql/language/parser.d.ts +27 -13
  111. package/node_modules/graphql/language/parser.js +31 -9
  112. package/node_modules/graphql/language/parser.mjs +31 -9
  113. package/node_modules/graphql/language/predicates.d.ts +10 -3
  114. package/node_modules/graphql/language/predicates.js +10 -3
  115. package/node_modules/graphql/language/predicates.mjs +10 -3
  116. package/node_modules/graphql/language/printLocation.d.ts +2 -6
  117. package/node_modules/graphql/language/printLocation.js +2 -6
  118. package/node_modules/graphql/language/printLocation.mjs +2 -6
  119. package/node_modules/graphql/language/printer.d.ts +22 -3
  120. package/node_modules/graphql/language/printer.js +394 -308
  121. package/node_modules/graphql/language/printer.mjs +394 -308
  122. package/node_modules/graphql/language/reducer.d.ts +32 -0
  123. package/node_modules/graphql/language/reducer.js +95 -0
  124. package/node_modules/graphql/language/reducer.mjs +86 -0
  125. package/node_modules/graphql/language/source.d.ts +4 -5
  126. package/node_modules/graphql/language/source.js +4 -5
  127. package/node_modules/graphql/language/source.mjs +4 -5
  128. package/node_modules/graphql/language/visitor.d.ts +16 -10
  129. package/node_modules/graphql/language/visitor.js +15 -7
  130. package/node_modules/graphql/language/visitor.mjs +15 -7
  131. package/node_modules/graphql/package.json +1 -4
  132. package/node_modules/graphql/type/definition.d.ts +170 -102
  133. package/node_modules/graphql/type/definition.js +169 -96
  134. package/node_modules/graphql/type/definition.mjs +168 -95
  135. package/node_modules/graphql/type/directives.d.ts +12 -6
  136. package/node_modules/graphql/type/directives.js +12 -6
  137. package/node_modules/graphql/type/directives.mjs +12 -6
  138. package/node_modules/graphql/type/scalars.js +8 -11
  139. package/node_modules/graphql/type/scalars.mjs +1 -1
  140. package/node_modules/graphql/type/schema.d.ts +36 -11
  141. package/node_modules/graphql/type/schema.js +35 -10
  142. package/node_modules/graphql/type/schema.mjs +35 -10
  143. package/node_modules/graphql/type/validate.d.ts +1 -3
  144. package/node_modules/graphql/type/validate.js +1 -3
  145. package/node_modules/graphql/type/validate.mjs +1 -3
  146. package/node_modules/graphql/utilities/TypeInfo.d.ts +15 -11
  147. package/node_modules/graphql/utilities/TypeInfo.js +15 -11
  148. package/node_modules/graphql/utilities/TypeInfo.mjs +15 -11
  149. package/node_modules/graphql/utilities/assertValidName.d.ts +1 -1
  150. package/node_modules/graphql/utilities/assertValidName.js +1 -1
  151. package/node_modules/graphql/utilities/assertValidName.mjs +1 -1
  152. package/node_modules/graphql/utilities/astFromValue.d.ts +3 -1
  153. package/node_modules/graphql/utilities/astFromValue.js +3 -1
  154. package/node_modules/graphql/utilities/astFromValue.mjs +3 -1
  155. package/node_modules/graphql/utilities/buildASTSchema.d.ts +8 -8
  156. package/node_modules/graphql/utilities/buildASTSchema.js +9 -20
  157. package/node_modules/graphql/utilities/buildASTSchema.mjs +9 -20
  158. package/node_modules/graphql/utilities/buildClientSchema.d.ts +6 -2
  159. package/node_modules/graphql/utilities/buildClientSchema.js +6 -2
  160. package/node_modules/graphql/utilities/buildClientSchema.mjs +6 -2
  161. package/node_modules/graphql/utilities/coerceInputValue.d.ts +9 -3
  162. package/node_modules/graphql/utilities/coerceInputValue.js +60 -13
  163. package/node_modules/graphql/utilities/coerceInputValue.mjs +58 -13
  164. package/node_modules/graphql/utilities/concatAST.d.ts +4 -1
  165. package/node_modules/graphql/utilities/concatAST.js +4 -1
  166. package/node_modules/graphql/utilities/concatAST.mjs +4 -1
  167. package/node_modules/graphql/utilities/extendSchema.d.ts +7 -4
  168. package/node_modules/graphql/utilities/extendSchema.js +7 -4
  169. package/node_modules/graphql/utilities/extendSchema.mjs +7 -4
  170. package/node_modules/graphql/utilities/findBreakingChanges.d.ts +2 -2
  171. package/node_modules/graphql/utilities/findBreakingChanges.js +2 -2
  172. package/node_modules/graphql/utilities/findBreakingChanges.mjs +2 -2
  173. package/node_modules/graphql/utilities/getIntrospectionQuery.d.ts +9 -9
  174. package/node_modules/graphql/utilities/getIntrospectionQuery.js +8 -8
  175. package/node_modules/graphql/utilities/getIntrospectionQuery.mjs +8 -8
  176. package/node_modules/graphql/utilities/getOperationAST.d.ts +2 -2
  177. package/node_modules/graphql/utilities/getOperationAST.js +2 -2
  178. package/node_modules/graphql/utilities/getOperationAST.mjs +2 -2
  179. package/node_modules/graphql/utilities/getOperationRootType.d.ts +3 -1
  180. package/node_modules/graphql/utilities/getOperationRootType.js +3 -1
  181. package/node_modules/graphql/utilities/getOperationRootType.mjs +3 -1
  182. package/node_modules/graphql/utilities/introspectionFromSchema.d.ts +12 -4
  183. package/node_modules/graphql/utilities/introspectionFromSchema.js +12 -4
  184. package/node_modules/graphql/utilities/introspectionFromSchema.mjs +12 -4
  185. package/node_modules/graphql/utilities/lexicographicSortSchema.d.ts +17 -13
  186. package/node_modules/graphql/utilities/lexicographicSortSchema.js +17 -13
  187. package/node_modules/graphql/utilities/lexicographicSortSchema.mjs +17 -13
  188. package/node_modules/graphql/utilities/printSchema.d.ts +7 -4
  189. package/node_modules/graphql/utilities/printSchema.js +7 -4
  190. package/node_modules/graphql/utilities/printSchema.mjs +7 -4
  191. package/node_modules/graphql/utilities/resolveSchemaCoordinate.d.ts +9 -8
  192. package/node_modules/graphql/utilities/resolveSchemaCoordinate.js +9 -8
  193. package/node_modules/graphql/utilities/resolveSchemaCoordinate.mjs +9 -8
  194. package/node_modules/graphql/utilities/separateOperations.d.ts +2 -2
  195. package/node_modules/graphql/utilities/separateOperations.js +2 -2
  196. package/node_modules/graphql/utilities/separateOperations.mjs +2 -2
  197. package/node_modules/graphql/utilities/stripIgnoredCharacters.d.ts +19 -5
  198. package/node_modules/graphql/utilities/stripIgnoredCharacters.js +19 -5
  199. package/node_modules/graphql/utilities/stripIgnoredCharacters.mjs +19 -5
  200. package/node_modules/graphql/utilities/typeComparators.d.ts +1 -5
  201. package/node_modules/graphql/utilities/typeComparators.js +1 -5
  202. package/node_modules/graphql/utilities/typeComparators.mjs +1 -5
  203. package/node_modules/graphql/utilities/valueFromAST.js +4 -4
  204. package/node_modules/graphql/utilities/valueFromAST.mjs +4 -4
  205. package/node_modules/graphql/utilities/valueFromASTUntyped.d.ts +1 -3
  206. package/node_modules/graphql/utilities/valueFromASTUntyped.js +1 -3
  207. package/node_modules/graphql/utilities/valueFromASTUntyped.mjs +1 -3
  208. package/node_modules/graphql/validation/ValidationContext.d.ts +22 -3
  209. package/node_modules/graphql/validation/ValidationContext.js +84 -27
  210. package/node_modules/graphql/validation/ValidationContext.mjs +82 -27
  211. package/node_modules/graphql/validation/rules/ExecutableDefinitionsRule.d.ts +6 -4
  212. package/node_modules/graphql/validation/rules/ExecutableDefinitionsRule.js +6 -4
  213. package/node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs +6 -4
  214. package/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.d.ts +4 -4
  215. package/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.js +10 -6
  216. package/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.mjs +12 -6
  217. package/node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -4
  218. package/node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.js +6 -4
  219. package/node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -4
  220. package/node_modules/graphql/validation/rules/KnownArgumentNamesRule.d.ts +4 -4
  221. package/node_modules/graphql/validation/rules/KnownArgumentNamesRule.js +26 -17
  222. package/node_modules/graphql/validation/rules/KnownArgumentNamesRule.mjs +21 -11
  223. package/node_modules/graphql/validation/rules/KnownDirectivesRule.d.ts +1 -3
  224. package/node_modules/graphql/validation/rules/KnownDirectivesRule.js +1 -3
  225. package/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs +1 -3
  226. package/node_modules/graphql/validation/rules/KnownFragmentNamesRule.d.ts +4 -4
  227. package/node_modules/graphql/validation/rules/KnownFragmentNamesRule.js +4 -4
  228. package/node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs +4 -4
  229. package/node_modules/graphql/validation/rules/KnownTypeNamesRule.d.ts +1 -3
  230. package/node_modules/graphql/validation/rules/KnownTypeNamesRule.js +7 -7
  231. package/node_modules/graphql/validation/rules/KnownTypeNamesRule.mjs +7 -7
  232. package/node_modules/graphql/validation/rules/LoneAnonymousOperationRule.d.ts +6 -4
  233. package/node_modules/graphql/validation/rules/LoneAnonymousOperationRule.js +6 -4
  234. package/node_modules/graphql/validation/rules/LoneAnonymousOperationRule.mjs +6 -4
  235. package/node_modules/graphql/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -4
  236. package/node_modules/graphql/validation/rules/MaxIntrospectionDepthRule.js +44 -19
  237. package/node_modules/graphql/validation/rules/MaxIntrospectionDepthRule.mjs +44 -19
  238. package/node_modules/graphql/validation/rules/NoFragmentCyclesRule.d.ts +1 -3
  239. package/node_modules/graphql/validation/rules/NoFragmentCyclesRule.js +1 -3
  240. package/node_modules/graphql/validation/rules/NoFragmentCyclesRule.mjs +1 -3
  241. package/node_modules/graphql/validation/rules/NoUndefinedVariablesRule.d.ts +4 -4
  242. package/node_modules/graphql/validation/rules/NoUndefinedVariablesRule.js +4 -4
  243. package/node_modules/graphql/validation/rules/NoUndefinedVariablesRule.mjs +4 -4
  244. package/node_modules/graphql/validation/rules/NoUnusedFragmentsRule.d.ts +4 -4
  245. package/node_modules/graphql/validation/rules/NoUnusedFragmentsRule.js +10 -14
  246. package/node_modules/graphql/validation/rules/NoUnusedFragmentsRule.mjs +10 -14
  247. package/node_modules/graphql/validation/rules/NoUnusedVariablesRule.d.ts +4 -4
  248. package/node_modules/graphql/validation/rules/NoUnusedVariablesRule.js +4 -4
  249. package/node_modules/graphql/validation/rules/NoUnusedVariablesRule.mjs +4 -4
  250. package/node_modules/graphql/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +8 -6
  251. package/node_modules/graphql/validation/rules/OverlappingFieldsCanBeMergedRule.js +552 -354
  252. package/node_modules/graphql/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +545 -352
  253. package/node_modules/graphql/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -4
  254. package/node_modules/graphql/validation/rules/PossibleFragmentSpreadsRule.js +6 -4
  255. package/node_modules/graphql/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -4
  256. package/node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -4
  257. package/node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.js +6 -4
  258. package/node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -4
  259. package/node_modules/graphql/validation/rules/ScalarLeafsRule.d.ts +1 -3
  260. package/node_modules/graphql/validation/rules/ScalarLeafsRule.js +1 -3
  261. package/node_modules/graphql/validation/rules/ScalarLeafsRule.mjs +1 -3
  262. package/node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -4
  263. package/node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.js +50 -9
  264. package/node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.mjs +50 -9
  265. package/node_modules/graphql/validation/rules/UniqueArgumentNamesRule.d.ts +4 -4
  266. package/node_modules/graphql/validation/rules/UniqueArgumentNamesRule.js +4 -4
  267. package/node_modules/graphql/validation/rules/UniqueArgumentNamesRule.mjs +4 -4
  268. package/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -4
  269. package/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.js +6 -4
  270. package/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.mjs +6 -4
  271. package/node_modules/graphql/validation/rules/UniqueFragmentNamesRule.d.ts +4 -4
  272. package/node_modules/graphql/validation/rules/UniqueFragmentNamesRule.js +4 -4
  273. package/node_modules/graphql/validation/rules/UniqueFragmentNamesRule.mjs +4 -4
  274. package/node_modules/graphql/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -4
  275. package/node_modules/graphql/validation/rules/UniqueInputFieldNamesRule.js +6 -4
  276. package/node_modules/graphql/validation/rules/UniqueInputFieldNamesRule.mjs +6 -4
  277. package/node_modules/graphql/validation/rules/UniqueOperationNamesRule.d.ts +4 -4
  278. package/node_modules/graphql/validation/rules/UniqueOperationNamesRule.js +4 -4
  279. package/node_modules/graphql/validation/rules/UniqueOperationNamesRule.mjs +4 -4
  280. package/node_modules/graphql/validation/rules/UniqueVariableNamesRule.d.ts +4 -4
  281. package/node_modules/graphql/validation/rules/UniqueVariableNamesRule.js +4 -4
  282. package/node_modules/graphql/validation/rules/UniqueVariableNamesRule.mjs +4 -4
  283. package/node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.d.ts +4 -4
  284. package/node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.js +29 -23
  285. package/node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.mjs +24 -14
  286. package/node_modules/graphql/validation/rules/VariablesAreInputTypesRule.d.ts +6 -4
  287. package/node_modules/graphql/validation/rules/VariablesAreInputTypesRule.js +6 -4
  288. package/node_modules/graphql/validation/rules/VariablesAreInputTypesRule.mjs +6 -4
  289. package/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -4
  290. package/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.js +6 -4
  291. package/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.mjs +6 -4
  292. package/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.d.ts +4 -4
  293. package/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.js +4 -4
  294. package/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.mjs +4 -4
  295. package/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +7 -5
  296. package/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +7 -5
  297. package/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +7 -5
  298. package/node_modules/graphql/validation/validate.d.ts +2 -0
  299. package/node_modules/graphql/validation/validate.js +14 -2
  300. package/node_modules/graphql/validation/validate.mjs +13 -2
  301. package/node_modules/graphql/validation/validationAbortedError.d.ts +3 -0
  302. package/node_modules/graphql/validation/validationAbortedError.js +14 -0
  303. package/node_modules/graphql/validation/validationAbortedError.mjs +4 -0
  304. package/node_modules/graphql/version.js +3 -3
  305. package/node_modules/graphql/version.mjs +3 -3
  306. package/package.json +11 -11
  307. package/node_modules/@zuplo/runtime/out/esm/chunk-MUDGPSWL.js.map +0 -1
  308. /package/node_modules/@zuplo/runtime/out/esm/{chunk-MUDGPSWL.js.LEGAL.txt → chunk-UGZSO3CK.js.LEGAL.txt} +0 -0
@@ -203,6 +203,272 @@ describe('PostHogMetrics', () => {
203
203
  })
204
204
  })
205
205
 
206
+ describe('histogram bounds', () => {
207
+ const DEFAULT_BOUNDS = [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000]
208
+ const histogramPoints = (name: string) =>
209
+ sentMetrics()
210
+ .filter((m) => m.name === name)
211
+ .flatMap((m) => m.histogram!.dataPoints)
212
+ const warnings = () => (logger.warn as vi.Mock).mock.calls.map((c) => String(c[0]))
213
+
214
+ it('uses the OpenTelemetry default bounds when none are passed', async () => {
215
+ const metrics = createMetrics()
216
+ metrics.histogram('h', 1)
217
+ await metrics.flush()
218
+
219
+ expect(histogramPoints('h')[0].explicitBounds).toEqual(DEFAULT_BOUNDS)
220
+ })
221
+
222
+ it('buckets values with the bounds the caller passes', async () => {
223
+ const metrics = createMetrics()
224
+ // (-inf, 100] ← 50 and 100, (100, 200] ← 150, overflow ← 201.
225
+ for (const v of [50, 100, 150, 201]) {
226
+ metrics.histogram('h', v, { bounds: [100, 200] })
227
+ }
228
+ await metrics.flush()
229
+
230
+ const dp = histogramPoints('h')[0]
231
+ expect(dp.explicitBounds).toEqual([100, 200])
232
+ expect(dp.bucketCounts).toEqual([2, 1, 1])
233
+ expect(dp.min).toBe(50)
234
+ expect(dp.max).toBe(201)
235
+ })
236
+
237
+ it('copies the bounds so a caller mutating its array cannot change the buckets', async () => {
238
+ const metrics = createMetrics()
239
+ const bounds = [100, 200]
240
+ metrics.histogram('h', 150, { bounds })
241
+ bounds[0] = 175
242
+ metrics.histogram('h', 150, { bounds: [100, 200] })
243
+ await metrics.flush()
244
+
245
+ const dp = histogramPoints('h')[0]
246
+ expect(dp.explicitBounds).toEqual([100, 200])
247
+ expect(dp.bucketCounts).toEqual([0, 2, 0])
248
+ // The second call passes equal bounds in a new array, which is not a conflict.
249
+ expect(logger.warn).not.toHaveBeenCalled()
250
+ })
251
+
252
+ it('records a sample with conflicting bounds in the first bounds and warns once', async () => {
253
+ const metrics = createMetrics()
254
+ metrics.histogram('h', 150, { bounds: [100, 200] })
255
+ metrics.histogram('h', 150, { bounds: [10, 20, 30] })
256
+ metrics.histogram('h', 150, { bounds: [10, 20, 30] })
257
+ metrics.histogram('h', 150)
258
+ await metrics.flush()
259
+
260
+ const dp = histogramPoints('h')[0]
261
+ expect(dp.explicitBounds).toEqual([100, 200])
262
+ expect(dp.bucketCounts).toEqual([0, 4, 0])
263
+ expect(warnings().filter((w) => w.includes("Histogram 'h' already uses the bounds"))).toHaveLength(1)
264
+ })
265
+
266
+ it('treats omitted bounds as the default when checking for a conflict', async () => {
267
+ const metrics = createMetrics()
268
+ metrics.histogram('h', 1)
269
+ metrics.histogram('h', 1, { bounds: [100, 200] })
270
+ await metrics.flush()
271
+
272
+ expect(histogramPoints('h')[0].explicitBounds).toHaveLength(15)
273
+ expect(warnings().some((w) => w.includes("Histogram 'h' already uses the bounds"))).toBe(true)
274
+ })
275
+
276
+ it('fixes the bounds per histogram across attribute series', async () => {
277
+ const metrics = createMetrics()
278
+ metrics.histogram('h', 150, { bounds: [100, 200], attributes: { route: 'a' } })
279
+ metrics.histogram('h', 150, { bounds: [10, 20], attributes: { route: 'b' } })
280
+ await metrics.flush()
281
+
282
+ const points = histogramPoints('h')
283
+ expect(points).toHaveLength(2)
284
+ expect(points.map((dp) => dp.explicitBounds)).toEqual([
285
+ [100, 200],
286
+ [100, 200],
287
+ ])
288
+ })
289
+
290
+ it('keeps the bounds of a histogram separate per unit', async () => {
291
+ const metrics = createMetrics()
292
+ metrics.histogram('h', 1, { unit: 'ms', bounds: [100, 200] })
293
+ metrics.histogram('h', 1, { unit: 's', bounds: [1, 2, 3] })
294
+ await metrics.flush()
295
+
296
+ const byUnit = Object.fromEntries(sentMetrics().map((m) => [m.unit, m.histogram!.dataPoints[0].explicitBounds]))
297
+ expect(byUnit).toEqual({ ms: [100, 200], s: [1, 2, 3] })
298
+ expect(logger.warn).not.toHaveBeenCalled()
299
+ })
300
+
301
+ it('keeps the first bounds across flush windows and warns on a conflict once per window', async () => {
302
+ const metrics = createMetrics()
303
+ metrics.histogram('h', 150, { bounds: [100, 200] })
304
+ metrics.histogram('h', 150, { bounds: [10, 20] })
305
+ await metrics.flush()
306
+ metrics.histogram('h', 150, { bounds: [10, 20] })
307
+ await metrics.flush()
308
+
309
+ expect(histogramPoints('h').map((dp) => dp.explicitBounds)).toEqual([
310
+ [100, 200],
311
+ [100, 200],
312
+ ])
313
+ expect(warnings().filter((w) => w.includes("Histogram 'h' already uses the bounds"))).toHaveLength(2)
314
+ })
315
+
316
+ it('merges a failed window back into a live window with the same bounds', async () => {
317
+ mockInstance._sendMetricsBatch
318
+ .mockResolvedValueOnce({ kind: 'retry-later', error: new Error('offline') })
319
+ .mockResolvedValue({ kind: 'ok' })
320
+ const metrics = createMetrics()
321
+ metrics.histogram('h', 50, { bounds: [100, 200] })
322
+ await metrics.flush()
323
+ metrics.histogram('h', 150, { bounds: [10, 20] })
324
+ await metrics.flush()
325
+
326
+ const dp = histogramPoints('h')[1]
327
+ expect(dp.explicitBounds).toEqual([100, 200])
328
+ expect(dp.bucketCounts).toEqual([1, 1, 0])
329
+ expect(dp.count).toBe(2)
330
+ expect(dp.sum).toBe(200)
331
+ expect(dp.min).toBe(50)
332
+ expect(dp.max).toBe(150)
333
+ })
334
+
335
+ it('lets reset() clear the bounds so the next sample sets them again', async () => {
336
+ const metrics = createMetrics()
337
+ metrics.histogram('h', 150, { bounds: [100, 200] })
338
+ metrics.reset()
339
+ metrics.histogram('h', 15, { bounds: [10, 20] })
340
+ await metrics.flush()
341
+
342
+ expect(histogramPoints('h').map((dp) => dp.explicitBounds)).toEqual([[10, 20]])
343
+ expect(logger.warn).not.toHaveBeenCalled()
344
+ })
345
+
346
+ it.each([
347
+ ['empty', []],
348
+ ['not an array', 'nope'],
349
+ ['not increasing', [100, 100]],
350
+ ['decreasing', [200, 100]],
351
+ ['non-finite', [100, Infinity]],
352
+ ['NaN', [NaN]],
353
+ ['non-number', [100, '200']],
354
+ ])('drops a sample whose bounds are %s', async (_name, bounds) => {
355
+ const metrics = createMetrics()
356
+ metrics.histogram('h', 1, { bounds: bounds as any })
357
+ await metrics.flush()
358
+
359
+ expect(sentMetrics()).toHaveLength(0)
360
+ expect(warnings().some((w) => w.includes("Dropping histogram 'h': bounds must be"))).toBe(true)
361
+ })
362
+
363
+ it('does not fix the bounds from a sample with invalid bounds', async () => {
364
+ const metrics = createMetrics()
365
+ metrics.histogram('h', 1, { bounds: [200, 100] })
366
+ metrics.histogram('h', 150, { bounds: [100, 200] })
367
+ await metrics.flush()
368
+
369
+ expect(histogramPoints('h')[0].explicitBounds).toEqual([100, 200])
370
+ })
371
+
372
+ it('drops new histograms that pass custom bounds past the bounds limit, and warns once', async () => {
373
+ const metrics = createMetrics({ maxSeriesPerFlush: 2 })
374
+ metrics.histogram('a', 1)
375
+ metrics.histogram('b', 1)
376
+ await metrics.flush()
377
+ metrics.histogram('c', 15, { bounds: [10, 20] })
378
+ metrics.histogram('d', 1)
379
+ await metrics.flush()
380
+ metrics.histogram('c', 150, { bounds: [100, 200] })
381
+ metrics.histogram('d', 1, { bounds: [...DEFAULT_BOUNDS] })
382
+ await metrics.flush()
383
+
384
+ expect(sentMetrics().map((m) => m.name)).toEqual(['a', 'b', 'd', 'd'])
385
+ expect(histogramPoints('d').map((dp) => dp.explicitBounds)).toEqual([DEFAULT_BOUNDS, DEFAULT_BOUNDS])
386
+ expect(warnings().filter((w) => w.includes('Histogram bounds limit reached'))).toHaveLength(1)
387
+ })
388
+
389
+ it('never sends one histogram with different bounds from two clients when only one is past the bounds limit', async () => {
390
+ const instanceA = createMockInstance()
391
+ const instanceB = createMockInstance()
392
+ const clientA = createMetrics({ maxSeriesPerFlush: 1 }, instanceA)
393
+ const clientB = createMetrics({ maxSeriesPerFlush: 1 }, instanceB)
394
+
395
+ clientA.histogram('h', 150, { bounds: [100, 200] })
396
+ await clientA.flush()
397
+ clientB.histogram('other', 1)
398
+ await clientB.flush()
399
+ clientB.histogram('h', 150, { bounds: [100, 200] })
400
+ await clientB.flush()
401
+
402
+ const bounds = [...sentMetrics(instanceA), ...sentMetrics(instanceB)]
403
+ .filter((m) => m.name === 'h')
404
+ .map((m) => m.histogram!.dataPoints[0].explicitBounds)
405
+ expect(bounds).toEqual([[100, 200]])
406
+ })
407
+
408
+ it('merges a failed window of a histogram past the bounds limit into the live window', async () => {
409
+ let traceparent: string | null = null
410
+ mockInstance = createMockInstance({ getActiveSpan: () => ({ traceparent: () => traceparent }) })
411
+ const metrics = createMetrics({ maxSeriesPerFlush: 1 })
412
+ metrics.histogram('a', 1)
413
+ await metrics.flush()
414
+ let resolveSend!: (outcome: SendMetricsBatchOutcome) => void
415
+ mockInstance._sendMetricsBatch.mockImplementationOnce(
416
+ () => new Promise<SendMetricsBatchOutcome>((resolve) => (resolveSend = resolve))
417
+ )
418
+
419
+ traceparent = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
420
+ metrics.histogram('c', 15)
421
+ const inflight = metrics.flush()
422
+ traceparent = null
423
+ metrics.histogram('c', 150)
424
+ resolveSend({ kind: 'retry-later', error: new Error('offline') })
425
+ await inflight
426
+ await metrics.flush()
427
+
428
+ const dp = histogramPoints('c')[1]
429
+ expect(dp.explicitBounds).toEqual(DEFAULT_BOUNDS)
430
+ expect(dp.count).toBe(2)
431
+ expect(dp.sum).toBe(165)
432
+ // 15 falls in (10, 25] and 150 in (100, 250].
433
+ expect(dp.bucketCounts).toEqual([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0])
434
+ expect(dp.min).toBe(15)
435
+ expect(dp.max).toBe(150)
436
+ expect(dp.exemplars?.map((e) => e.asDouble)).toEqual([15])
437
+ })
438
+
439
+ it('keeps the caller bounds intact when beforeSend edits them in place', async () => {
440
+ const metrics = createMetrics({
441
+ beforeSend: (m) => {
442
+ m.bounds?.forEach((b, i) => (m.bounds![i] = b / 1000))
443
+ m.value /= 1000
444
+ m.unit = 's'
445
+ return m
446
+ },
447
+ })
448
+ const bounds = [100, 1000]
449
+ metrics.histogram('h', 500, { unit: 'ms', bounds })
450
+ metrics.histogram('h', 500, { unit: 'ms', bounds })
451
+ await metrics.flush()
452
+
453
+ expect(bounds).toEqual([100, 1000])
454
+ const dp = histogramPoints('h')[0]
455
+ expect(dp.explicitBounds).toEqual([0.1, 1])
456
+ expect(dp.bucketCounts).toEqual([0, 2, 0])
457
+ expect(logger.warn).not.toHaveBeenCalled()
458
+ })
459
+
460
+ it('does not fix the bounds for a sample the series cap drops', async () => {
461
+ const metrics = createMetrics({ maxSeriesPerFlush: 1 })
462
+ metrics.count('fills_the_window', 1)
463
+ metrics.histogram('h', 1, { bounds: [10, 20] })
464
+ await metrics.flush()
465
+ metrics.histogram('h', 150, { bounds: [100, 200] })
466
+ await metrics.flush()
467
+
468
+ expect(histogramPoints('h').map((dp) => dp.explicitBounds)).toEqual([[100, 200]])
469
+ })
470
+ })
471
+
206
472
  describe('exemplars', () => {
207
473
  const TRACE_ID = '4bf92f3577b34da6a3ce929d0e0e4736'
208
474
  const SPAN_ID = '00f067aa0ba902b7'
@@ -828,6 +1094,18 @@ describe('PostHogMetrics', () => {
828
1094
  expect(mockInstance._sendMetricsBatch).not.toHaveBeenCalled()
829
1095
  })
830
1096
 
1097
+ it('drops a sample whose beforeSend result has an unknown type and still sends the rest', async () => {
1098
+ const metrics = createMetrics({
1099
+ beforeSend: (m) => (m.name === 'bad' ? ({ name: m.name, value: m.value } as any) : m),
1100
+ })
1101
+ metrics.count('good', 1)
1102
+ metrics.count('bad', 1)
1103
+ await metrics.flush()
1104
+
1105
+ expect(sentMetrics().map((m) => m.name)).toEqual(['good'])
1106
+ expect((logger.warn as vi.Mock).mock.calls.some((c) => String(c[0]).includes('unknown type'))).toBe(true)
1107
+ })
1108
+
831
1109
  it('drops the sample when beforeSend throws', async () => {
832
1110
  const metrics = createMetrics({
833
1111
  beforeSend: () => {
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  CaptureMetricOptions,
3
+ HistogramOptions,
3
4
  MetricAttributes,
4
5
  MetricSample,
5
6
  MetricType,
@@ -36,6 +37,7 @@ interface ExemplarState {
36
37
  }
37
38
 
38
39
  interface HistogramState {
40
+ bounds: number[]
39
41
  count: number
40
42
  sum: number
41
43
  min: number
@@ -95,6 +97,14 @@ export class PostHogMetrics {
95
97
  // types under one name produces charts that blend both series.
96
98
  private _typeByName = new Map<string, MetricType>()
97
99
  private _typeCollisionWarned = new Set<string>()
100
+ // Bounds per histogram (name and unit), fixed by its first sample. They
101
+ // outlive the flush window because buckets from two windows with different
102
+ // bounds cannot be merged. Only reset() clears them. The map holds at most
103
+ // maxSeriesPerFlush histograms.
104
+ private _boundsByHistogram = new Map<string, number[]>()
105
+ // Histograms warned about conflicting bounds this window.
106
+ private _boundsConflictWarned = new Set<string>()
107
+ private _boundsCapWarned = false
98
108
  private _retryAfter = new RetryAfterWindow()
99
109
  private _consecutiveFlushFailures = 0
100
110
  private _flushJitter = NO_JITTER
@@ -117,8 +127,16 @@ export class PostHogMetrics {
117
127
  this._capture({ name, type: 'gauge', value, unit: options?.unit, attributes: options?.attributes })
118
128
  }
119
129
 
120
- histogram(name: string, value: number, options?: CaptureMetricOptions): void {
121
- this._capture({ name, type: 'histogram', value, unit: options?.unit, attributes: options?.attributes })
130
+ histogram(name: string, value: number, options?: HistogramOptions): void {
131
+ this._capture({
132
+ name,
133
+ type: 'histogram',
134
+ value,
135
+ unit: options?.unit,
136
+ attributes: options?.attributes,
137
+ // The copy keeps a beforeSend that edits the bounds in place from changing the caller's array.
138
+ bounds: isArray(options?.bounds) ? options.bounds.slice() : options?.bounds,
139
+ })
122
140
  }
123
141
 
124
142
  /** Sends everything aggregated so far without waiting for the flush interval. */
@@ -151,10 +169,7 @@ export class PostHogMetrics {
151
169
  return null
152
170
  }
153
171
  const window = this._series
154
- this._series = new Map()
155
- this._seriesCapWarned = false
156
- this._typeByName = new Map()
157
- this._typeCollisionWarned = new Set()
172
+ this._startWindow()
158
173
  return this._buildPayload(window)
159
174
  }
160
175
 
@@ -165,11 +180,19 @@ export class PostHogMetrics {
165
180
  this._consecutiveFlushFailures = 0
166
181
  this._flushJitter = NO_JITTER
167
182
  this._flushTimer.clear()
168
- this._series = new Map()
169
183
  this._flushPromise = null
184
+ this._startWindow()
185
+ this._boundsByHistogram = new Map()
186
+ this._boundsCapWarned = false
187
+ }
188
+
189
+ /** Clears the state that lives for one flush window. */
190
+ private _startWindow(): void {
191
+ this._series = new Map()
170
192
  this._seriesCapWarned = false
171
193
  this._typeByName = new Map()
172
194
  this._typeCollisionWarned = new Set()
195
+ this._boundsConflictWarned = new Set()
173
196
  }
174
197
 
175
198
  private _capture(sample: MetricSample): void {
@@ -190,6 +213,10 @@ export class PostHogMetrics {
190
213
  this._logger.warn(`Dropping metric '${filtered.name}': value must be a finite number`)
191
214
  return
192
215
  }
216
+ if (filtered.type !== 'count' && filtered.type !== 'gauge' && filtered.type !== 'histogram') {
217
+ this._logger.warn(`Dropping metric '${filtered.name}': unknown type '${String(filtered.type)}'`)
218
+ return
219
+ }
193
220
  // Checked after beforeSend so a hook can't turn a count negative either.
194
221
  if (filtered.type === 'count' && filtered.value < 0) {
195
222
  this._logger.warn(`Dropping count '${filtered.name}': counters are monotonic, value must be >= 0`)
@@ -211,16 +238,26 @@ export class PostHogMetrics {
211
238
  }
212
239
 
213
240
  let state = this._series.get(key)
214
- if (!state) {
215
- if (!this._admitNewSeries()) {
241
+ if (!state && !this._admitNewSeries()) {
242
+ return
243
+ }
244
+
245
+ let bounds: number[] | undefined
246
+ if (filtered.type === 'histogram') {
247
+ bounds = this._histogramBounds(filtered.name, filtered.unit, filtered.bounds)
248
+ if (!bounds) {
216
249
  return
217
250
  }
251
+ }
252
+
253
+ if (!state) {
218
254
  state = {
219
255
  name: filtered.name,
220
256
  type: filtered.type,
221
257
  unit: filtered.unit,
222
258
  attributes,
223
259
  windowStartMs: Date.now(),
260
+ hist: bounds && emptyHistogram(bounds),
224
261
  }
225
262
  this._series.set(key, state)
226
263
  }
@@ -280,6 +317,68 @@ export class PostHogMetrics {
280
317
  return false
281
318
  }
282
319
 
320
+ /**
321
+ * The bounds a histogram sample folds into: the ones its histogram already
322
+ * has, or the requested bounds (default when absent) for a new histogram.
323
+ * A histogram past the bounds limit has no map entry and gets only the
324
+ * default bounds. Returns `undefined` when the sample must be dropped.
325
+ */
326
+ private _histogramBounds(
327
+ name: string,
328
+ unit: string | undefined,
329
+ requested: number[] | undefined
330
+ ): number[] | undefined {
331
+ if (requested !== undefined && !isValidBounds(requested)) {
332
+ this._logger.warn(
333
+ `Dropping histogram '${name}': bounds must be a non-empty array of finite, strictly increasing numbers`
334
+ )
335
+ return undefined
336
+ }
337
+ const histogramKey = seriesKey('histogram', name, unit, undefined)
338
+ const fixed = this._boundsByHistogram.get(histogramKey)
339
+ if (fixed) {
340
+ this._warnOnBoundsConflict(name, histogramKey, fixed, requested)
341
+ return fixed
342
+ }
343
+ // The limit keeps histogram names with interpolated IDs from growing the
344
+ // map without bound. The backend stores one set of bounds per series. A
345
+ // histogram that is not in the map therefore sends only the default bounds,
346
+ // and a sample that asks for other bounds is dropped. Otherwise this client
347
+ // could send other bounds than earlier windows or other clients sent.
348
+ if (this._boundsByHistogram.size >= this._config.maxSeriesPerFlush) {
349
+ if (!this._boundsCapWarned) {
350
+ this._boundsCapWarned = true
351
+ this._logger.warn(
352
+ `Histogram bounds limit reached (${this._config.maxSeriesPerFlush} distinct histograms); ` +
353
+ `new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.`
354
+ )
355
+ }
356
+ if (requested && !sameBounds(requested, DEFAULT_HISTOGRAM_BOUNDS)) {
357
+ return undefined
358
+ }
359
+ return DEFAULT_HISTOGRAM_BOUNDS
360
+ }
361
+ const bounds = requested ? requested.slice() : DEFAULT_HISTOGRAM_BOUNDS
362
+ this._boundsByHistogram.set(histogramKey, bounds)
363
+ return bounds
364
+ }
365
+
366
+ private _warnOnBoundsConflict(
367
+ name: string,
368
+ histogramKey: string,
369
+ fixed: number[],
370
+ requested: number[] | undefined
371
+ ): void {
372
+ if (sameBounds(fixed, requested ?? DEFAULT_HISTOGRAM_BOUNDS) || this._boundsConflictWarned.has(histogramKey)) {
373
+ return
374
+ }
375
+ this._boundsConflictWarned.add(histogramKey)
376
+ this._logger.warn(
377
+ `Histogram '${name}' already uses the bounds [${fixed.join(', ')}]; ` +
378
+ `samples that pass different bounds are recorded in those buckets.`
379
+ )
380
+ }
381
+
283
382
  private _fold(state: SeriesState, value: number): void {
284
383
  switch (state.type) {
285
384
  case 'count':
@@ -289,21 +388,12 @@ export class PostHogMetrics {
289
388
  state.last = value
290
389
  break
291
390
  case 'histogram': {
292
- if (!state.hist) {
293
- state.hist = {
294
- count: 0,
295
- sum: 0,
296
- min: value,
297
- max: value,
298
- bucketCounts: new Array(DEFAULT_HISTOGRAM_BOUNDS.length + 1).fill(0),
299
- }
300
- }
301
- const hist = state.hist
391
+ const hist = state.hist!
302
392
  hist.count += 1
303
393
  hist.sum += value
304
394
  hist.min = Math.min(hist.min, value)
305
395
  hist.max = Math.max(hist.max, value)
306
- hist.bucketCounts[bucketIndexFor(value, DEFAULT_HISTOGRAM_BOUNDS)] += 1
396
+ hist.bucketCounts[bucketIndexFor(value, hist.bounds)] += 1
307
397
  break
308
398
  }
309
399
  }
@@ -368,10 +458,7 @@ export class PostHogMetrics {
368
458
  // Snapshot and reset the window; samples captured while the send is in
369
459
  // flight fold into a fresh window instead of the one being sent.
370
460
  const window = this._series
371
- this._series = new Map()
372
- this._seriesCapWarned = false
373
- this._typeByName = new Map()
374
- this._typeCollisionWarned = new Set()
461
+ this._startWindow()
375
462
 
376
463
  const generation = this._generation
377
464
  const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window))
@@ -467,17 +554,18 @@ export class PostHogMetrics {
467
554
  ...exemplars,
468
555
  }
469
556
  metric.gauge!.dataPoints.push(dp)
470
- } else if (state.hist) {
557
+ } else {
558
+ const hist = state.hist!
471
559
  const dp: OtlpHistogramDataPoint = {
472
560
  attributes,
473
561
  startTimeUnixNano: startNano,
474
562
  timeUnixNano: nowNano,
475
- count: state.hist.count,
476
- sum: state.hist.sum,
477
- min: state.hist.min,
478
- max: state.hist.max,
479
- bucketCounts: state.hist.bucketCounts,
480
- explicitBounds: DEFAULT_HISTOGRAM_BOUNDS,
563
+ count: hist.count,
564
+ sum: hist.sum,
565
+ min: hist.min,
566
+ max: hist.max,
567
+ bucketCounts: hist.bucketCounts,
568
+ explicitBounds: hist.bounds,
481
569
  ...exemplars,
482
570
  }
483
571
  metric.histogram!.dataPoints.push(dp)
@@ -509,26 +597,54 @@ export class PostHogMetrics {
509
597
  case 'gauge':
510
598
  // The live window's value is newer — keep it.
511
599
  break
512
- case 'histogram':
513
- if (old.hist) {
514
- if (!current.hist) {
515
- current.hist = old.hist
516
- } else {
517
- current.hist.count += old.hist.count
518
- current.hist.sum += old.hist.sum
519
- current.hist.min = Math.min(current.hist.min, old.hist.min)
520
- current.hist.max = Math.max(current.hist.max, old.hist.max)
521
- for (let i = 0; i < current.hist.bucketCounts.length; i++) {
522
- current.hist.bucketCounts[i] += old.hist.bucketCounts[i]
523
- }
524
- }
600
+ case 'histogram': {
601
+ const hist = current.hist!
602
+ const oldHist = old.hist!
603
+ hist.count += oldHist.count
604
+ hist.sum += oldHist.sum
605
+ hist.min = Math.min(hist.min, oldHist.min)
606
+ hist.max = Math.max(hist.max, oldHist.max)
607
+ for (let i = 0; i < hist.bucketCounts.length; i++) {
608
+ hist.bucketCounts[i] += oldHist.bucketCounts[i]
525
609
  }
526
610
  break
611
+ }
527
612
  }
528
613
  }
529
614
  }
530
615
  }
531
616
 
617
+ function isValidBounds(bounds: unknown): bounds is number[] {
618
+ if (!isArray(bounds) || bounds.length === 0) {
619
+ return false
620
+ }
621
+ for (let i = 0; i < bounds.length; i++) {
622
+ if (!Number.isFinite(bounds[i]) || (i > 0 && bounds[i] <= bounds[i - 1])) {
623
+ return false
624
+ }
625
+ }
626
+ return true
627
+ }
628
+
629
+ function sameBounds(a: number[], b: number[]): boolean {
630
+ if (a === b) {
631
+ return true
632
+ }
633
+ if (a.length !== b.length) {
634
+ return false
635
+ }
636
+ for (let i = 0; i < a.length; i++) {
637
+ if (a[i] !== b[i]) {
638
+ return false
639
+ }
640
+ }
641
+ return true
642
+ }
643
+
644
+ function emptyHistogram(bounds: number[]): HistogramState {
645
+ return { bounds, count: 0, sum: 0, min: Infinity, max: -Infinity, bucketCounts: new Array(bounds.length + 1).fill(0) }
646
+ }
647
+
532
648
  // Spread into the data point, so a point without an exemplar keeps its exact
533
649
  // pre-exemplar wire shape.
534
650
  function toOtlpExemplars(exemplar: ExemplarState | undefined): { exemplars?: OtlpExemplar[] } {
@@ -6,6 +6,7 @@ export type {
6
6
  MetricType,
7
7
  MetricsConfig,
8
8
  CaptureMetricOptions,
9
+ HistogramOptions,
9
10
  MetricSample,
10
11
  BeforeSendMetricFn,
11
12
  Metrics,
@@ -40,13 +40,13 @@ const URL_PATTERN = /[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi
40
40
  // A character no URL match can contain, so a cut just after one splits no URL.
41
41
  const URL_END_PATTERN = /[\s<>"]/
42
42
  /** The same pattern without `g`, for asking whether a value holds a URL at all. */
43
- const URL_PATTERN_ONCE = new RegExp(URL_PATTERN.source, 'i')
43
+ const URL_PATTERN_ONCE = /* @__PURE__ */ (() => new RegExp(URL_PATTERN.source, 'i'))()
44
44
  /** Finds the first scheme that brings a real authority, i.e. what the pattern required before it went authority-less. */
45
45
  const URL_AUTHORITY_SEARCH = /[a-z][a-z0-9+.-]{0,63}:\/\//i
46
46
  /** The same, anchored: does this match *open* with an authority? */
47
- const URL_AUTHORITY_PATTERN = new RegExp(`^${URL_AUTHORITY_SEARCH.source}`, 'i')
47
+ const URL_AUTHORITY_PATTERN = /* @__PURE__ */ (() => new RegExp(`^${URL_AUTHORITY_SEARCH.source}`, 'i'))()
48
48
  /** Every authority start in a value, in order. */
49
- const URL_AUTHORITY_SEARCH_ALL = new RegExp(URL_AUTHORITY_SEARCH.source, 'gi')
49
+ const URL_AUTHORITY_SEARCH_ALL = /* @__PURE__ */ (() => new RegExp(URL_AUTHORITY_SEARCH.source, 'gi'))()
50
50
  /** The field separators. `?` and `#` are structural only as delimiters — see {@link isStructural}. */
51
51
  const URL_FIELD_CHARACTERS = '=&'
52
52
  /** The legacy field separator. Never split on, only checked; see {@link sanitizeUrlFieldValue}. */