apitally 0.25.8 → 1.0.0-beta.1

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 (555) hide show
  1. package/README.md +228 -178
  2. package/dist/activation.cjs +393 -0
  3. package/dist/activation.cjs.map +1 -0
  4. package/dist/activation.d.cts +42 -0
  5. package/dist/activation.d.ts +42 -0
  6. package/dist/activation.js +383 -0
  7. package/dist/activation.js.map +1 -0
  8. package/dist/adonisjs/configure.cjs +86 -30
  9. package/dist/adonisjs/configure.cjs.map +1 -1
  10. package/dist/adonisjs/configure.d.cts +0 -4
  11. package/dist/adonisjs/configure.d.ts +0 -4
  12. package/dist/adonisjs/configure.js +83 -29
  13. package/dist/adonisjs/configure.js.map +1 -1
  14. package/dist/adonisjs/index.cjs +38 -21
  15. package/dist/adonisjs/index.cjs.map +1 -1
  16. package/dist/adonisjs/index.d.cts +5 -14
  17. package/dist/adonisjs/index.d.ts +5 -14
  18. package/dist/adonisjs/index.js +39 -18
  19. package/dist/adonisjs/index.js.map +1 -1
  20. package/dist/adonisjs/middleware.cjs +43 -109
  21. package/dist/adonisjs/middleware.cjs.map +1 -1
  22. package/dist/adonisjs/middleware.d.cts +1 -16
  23. package/dist/adonisjs/middleware.d.ts +1 -16
  24. package/dist/adonisjs/middleware.js +43 -110
  25. package/dist/adonisjs/middleware.js.map +1 -1
  26. package/dist/adonisjs/provider.cjs +19 -87
  27. package/dist/adonisjs/provider.cjs.map +1 -1
  28. package/dist/adonisjs/provider.d.cts +0 -22
  29. package/dist/adonisjs/provider.d.ts +0 -22
  30. package/dist/adonisjs/provider.js +19 -88
  31. package/dist/adonisjs/provider.js.map +1 -1
  32. package/dist/adonisjs/stubs/config/apitally.stub +11 -15
  33. package/dist/bodyCapture.cjs +128 -0
  34. package/dist/bodyCapture.cjs.map +1 -0
  35. package/dist/bodyCapture.d.cts +31 -0
  36. package/dist/bodyCapture.d.ts +31 -0
  37. package/dist/bodyCapture.js +101 -0
  38. package/dist/bodyCapture.js.map +1 -0
  39. package/dist/config.cjs +227 -0
  40. package/dist/config.cjs.map +1 -0
  41. package/dist/config.d.cts +45 -0
  42. package/dist/config.d.ts +45 -0
  43. package/dist/config.js +192 -0
  44. package/dist/config.js.map +1 -0
  45. package/dist/consumer.cjs +98 -0
  46. package/dist/consumer.cjs.map +1 -0
  47. package/dist/consumer.d.cts +15 -0
  48. package/dist/consumer.d.ts +15 -0
  49. package/dist/consumer.js +78 -0
  50. package/dist/consumer.js.map +1 -0
  51. package/dist/context.cjs +68 -0
  52. package/dist/context.cjs.map +1 -0
  53. package/dist/context.d.cts +33 -0
  54. package/dist/context.d.ts +33 -0
  55. package/dist/context.js +40 -0
  56. package/dist/context.js.map +1 -0
  57. package/dist/elysia/index.cjs +12 -3
  58. package/dist/elysia/index.cjs.map +1 -1
  59. package/dist/elysia/index.d.cts +8 -16
  60. package/dist/elysia/index.d.ts +8 -16
  61. package/dist/elysia/index.js +10 -2
  62. package/dist/elysia/index.js.map +1 -1
  63. package/dist/elysia/middleware.cjs +261 -0
  64. package/dist/elysia/middleware.cjs.map +1 -0
  65. package/dist/elysia/middleware.d.cts +14 -0
  66. package/dist/elysia/middleware.d.ts +14 -0
  67. package/dist/elysia/middleware.js +250 -0
  68. package/dist/elysia/middleware.js.map +1 -0
  69. package/dist/{otel/index.cjs → elysia/routes.cjs} +16 -7
  70. package/dist/elysia/routes.cjs.map +1 -0
  71. package/dist/elysia/routes.d.cts +7 -0
  72. package/dist/elysia/routes.d.ts +7 -0
  73. package/dist/elysia/routes.js +14 -0
  74. package/dist/elysia/routes.js.map +1 -0
  75. package/dist/exceptions.cjs +81 -0
  76. package/dist/exceptions.cjs.map +1 -0
  77. package/dist/exceptions.d.cts +7 -0
  78. package/dist/exceptions.d.ts +7 -0
  79. package/dist/exceptions.js +55 -0
  80. package/dist/exceptions.js.map +1 -0
  81. package/dist/exportSerialization.cjs +56 -0
  82. package/dist/exportSerialization.cjs.map +1 -0
  83. package/dist/exportSerialization.d.cts +7 -0
  84. package/dist/exportSerialization.d.ts +7 -0
  85. package/dist/exportSerialization.js +32 -0
  86. package/dist/exportSerialization.js.map +1 -0
  87. package/dist/exportWorker.cjs +305 -0
  88. package/dist/exportWorker.cjs.map +1 -0
  89. package/dist/exportWorker.d.cts +46 -0
  90. package/dist/exportWorker.d.ts +46 -0
  91. package/dist/exportWorker.js +279 -0
  92. package/dist/exportWorker.js.map +1 -0
  93. package/dist/express/index.cjs +9 -4
  94. package/dist/express/index.cjs.map +1 -1
  95. package/dist/express/index.d.cts +7 -10
  96. package/dist/express/index.d.ts +7 -10
  97. package/dist/express/index.js +8 -2
  98. package/dist/express/index.js.map +1 -1
  99. package/dist/express/install.cjs +45 -0
  100. package/dist/express/install.cjs.map +1 -0
  101. package/dist/express/install.d.cts +10 -0
  102. package/dist/express/install.d.ts +10 -0
  103. package/dist/express/install.js +21 -0
  104. package/dist/express/install.js.map +1 -0
  105. package/dist/express/middleware.cjs +87 -331
  106. package/dist/express/middleware.cjs.map +1 -1
  107. package/dist/express/middleware.d.cts +3 -21
  108. package/dist/express/middleware.d.ts +3 -21
  109. package/dist/express/middleware.js +91 -327
  110. package/dist/express/middleware.js.map +1 -1
  111. package/dist/express/register.cjs +20 -0
  112. package/dist/express/register.cjs.map +1 -0
  113. package/dist/express/register.d.cts +2 -0
  114. package/dist/express/register.d.ts +2 -0
  115. package/dist/express/register.js +19 -0
  116. package/dist/express/register.js.map +1 -0
  117. package/dist/express/routes.cjs +429 -0
  118. package/dist/express/routes.cjs.map +1 -0
  119. package/dist/express/routes.d.cts +14 -0
  120. package/dist/express/routes.d.ts +14 -0
  121. package/dist/express/routes.js +401 -0
  122. package/dist/express/routes.js.map +1 -0
  123. package/dist/fastify/index.cjs +10 -5
  124. package/dist/fastify/index.cjs.map +1 -1
  125. package/dist/fastify/index.d.cts +7 -11
  126. package/dist/fastify/index.d.ts +7 -11
  127. package/dist/fastify/index.js +9 -3
  128. package/dist/fastify/index.js.map +1 -1
  129. package/dist/{loggers/index.cjs → fastify/install.cjs} +17 -19
  130. package/dist/fastify/install.cjs.map +1 -0
  131. package/dist/fastify/install.d.cts +10 -0
  132. package/dist/fastify/install.d.ts +10 -0
  133. package/dist/fastify/install.js +15 -0
  134. package/dist/fastify/install.js.map +1 -0
  135. package/dist/fastify/middleware.cjs +135 -0
  136. package/dist/fastify/middleware.cjs.map +1 -0
  137. package/dist/fastify/middleware.d.cts +7 -0
  138. package/dist/fastify/middleware.d.ts +7 -0
  139. package/dist/fastify/middleware.js +114 -0
  140. package/dist/fastify/middleware.js.map +1 -0
  141. package/dist/{common/paramValidation.cjs → fastify/routes.cjs} +15 -17
  142. package/dist/fastify/routes.cjs.map +1 -0
  143. package/dist/fastify/routes.d.cts +8 -0
  144. package/dist/fastify/routes.d.ts +8 -0
  145. package/dist/fastify/routes.js +14 -0
  146. package/dist/fastify/routes.js.map +1 -0
  147. package/dist/h3/index.cjs +28 -4
  148. package/dist/h3/index.cjs.map +1 -1
  149. package/dist/h3/index.d.cts +8 -10
  150. package/dist/h3/index.d.ts +8 -10
  151. package/dist/h3/index.js +26 -2
  152. package/dist/h3/index.js.map +1 -1
  153. package/dist/h3/middleware.cjs +210 -0
  154. package/dist/h3/middleware.cjs.map +1 -0
  155. package/dist/h3/middleware.d.cts +5 -0
  156. package/dist/h3/middleware.d.ts +5 -0
  157. package/dist/h3/middleware.js +194 -0
  158. package/dist/h3/middleware.js.map +1 -0
  159. package/dist/h3/routes.cjs +66 -0
  160. package/dist/h3/routes.cjs.map +1 -0
  161. package/dist/h3/routes.d.cts +8 -0
  162. package/dist/h3/routes.d.ts +8 -0
  163. package/dist/h3/routes.js +41 -0
  164. package/dist/h3/routes.js.map +1 -0
  165. package/dist/hapi/index.cjs +15 -4
  166. package/dist/hapi/index.cjs.map +1 -1
  167. package/dist/hapi/index.d.cts +8 -10
  168. package/dist/hapi/index.d.ts +8 -10
  169. package/dist/hapi/index.js +13 -2
  170. package/dist/hapi/index.js.map +1 -1
  171. package/dist/{loggers/hapi.cjs → hapi/install.cjs} +20 -26
  172. package/dist/hapi/install.cjs.map +1 -0
  173. package/dist/hapi/install.d.cts +8 -0
  174. package/dist/hapi/install.d.ts +8 -0
  175. package/dist/hapi/install.js +22 -0
  176. package/dist/hapi/install.js.map +1 -0
  177. package/dist/hapi/middleware.cjs +158 -0
  178. package/dist/hapi/middleware.cjs.map +1 -0
  179. package/dist/hapi/middleware.d.cts +5 -0
  180. package/dist/hapi/middleware.d.ts +5 -0
  181. package/dist/hapi/middleware.js +137 -0
  182. package/dist/hapi/middleware.js.map +1 -0
  183. package/dist/{common/logging.cjs → hapi/routes.cjs} +14 -17
  184. package/dist/hapi/routes.cjs.map +1 -0
  185. package/dist/hapi/routes.d.cts +8 -0
  186. package/dist/hapi/routes.d.ts +8 -0
  187. package/dist/hapi/routes.js +12 -0
  188. package/dist/hapi/routes.js.map +1 -0
  189. package/dist/hono/index.cjs +13 -3
  190. package/dist/hono/index.cjs.map +1 -1
  191. package/dist/hono/index.d.cts +7 -10
  192. package/dist/hono/index.d.ts +7 -10
  193. package/dist/hono/index.js +13 -2
  194. package/dist/hono/index.js.map +1 -1
  195. package/dist/hono/middleware.cjs +219 -127
  196. package/dist/hono/middleware.cjs.map +1 -1
  197. package/dist/hono/middleware.d.cts +3 -18
  198. package/dist/hono/middleware.d.ts +3 -18
  199. package/dist/hono/middleware.js +229 -126
  200. package/dist/hono/middleware.js.map +1 -1
  201. package/dist/hono/routes.cjs +74 -0
  202. package/dist/hono/routes.cjs.map +1 -0
  203. package/dist/hono/routes.d.cts +8 -0
  204. package/dist/hono/routes.d.ts +8 -0
  205. package/dist/hono/routes.js +49 -0
  206. package/dist/hono/routes.js.map +1 -0
  207. package/dist/index.cjs +108 -0
  208. package/dist/index.cjs.map +1 -1
  209. package/dist/index.d.cts +29 -1
  210. package/dist/index.d.ts +29 -1
  211. package/dist/index.js +77 -0
  212. package/dist/index.js.map +1 -1
  213. package/dist/koa/index.cjs +13 -3
  214. package/dist/koa/index.cjs.map +1 -1
  215. package/dist/koa/index.d.cts +7 -10
  216. package/dist/koa/index.d.ts +7 -10
  217. package/dist/koa/index.js +13 -2
  218. package/dist/koa/index.js.map +1 -1
  219. package/dist/koa/middleware.cjs +85 -184
  220. package/dist/koa/middleware.cjs.map +1 -1
  221. package/dist/koa/middleware.d.cts +3 -13
  222. package/dist/koa/middleware.d.ts +3 -13
  223. package/dist/koa/middleware.js +88 -183
  224. package/dist/koa/middleware.js.map +1 -1
  225. package/dist/koa/routes.cjs +71 -0
  226. package/dist/koa/routes.cjs.map +1 -0
  227. package/dist/koa/routes.d.cts +8 -0
  228. package/dist/koa/routes.d.ts +8 -0
  229. package/dist/koa/routes.js +46 -0
  230. package/dist/koa/routes.js.map +1 -0
  231. package/dist/logCapture.cjs +417 -0
  232. package/dist/logCapture.cjs.map +1 -0
  233. package/dist/logCapture.d.cts +18 -0
  234. package/dist/logCapture.d.ts +18 -0
  235. package/dist/logCapture.js +390 -0
  236. package/dist/logCapture.js.map +1 -0
  237. package/dist/logRecordExporter.cjs +51 -0
  238. package/dist/logRecordExporter.cjs.map +1 -0
  239. package/dist/logRecordExporter.d.cts +14 -0
  240. package/dist/logRecordExporter.d.ts +14 -0
  241. package/dist/logRecordExporter.js +27 -0
  242. package/dist/logRecordExporter.js.map +1 -0
  243. package/dist/logRecordProcessor.cjs +137 -0
  244. package/dist/logRecordProcessor.cjs.map +1 -0
  245. package/dist/logRecordProcessor.d.cts +27 -0
  246. package/dist/logRecordProcessor.d.ts +27 -0
  247. package/dist/logRecordProcessor.js +113 -0
  248. package/dist/logRecordProcessor.js.map +1 -0
  249. package/dist/logger.cjs +62 -0
  250. package/dist/logger.cjs.map +1 -0
  251. package/dist/logger.d.cts +7 -0
  252. package/dist/logger.d.ts +7 -0
  253. package/dist/logger.js +34 -0
  254. package/dist/logger.js.map +1 -0
  255. package/dist/metrics.cjs +171 -0
  256. package/dist/metrics.cjs.map +1 -0
  257. package/dist/metrics.d.cts +26 -0
  258. package/dist/metrics.d.ts +26 -0
  259. package/dist/metrics.js +153 -0
  260. package/dist/metrics.js.map +1 -0
  261. package/dist/nestjs/index.cjs +81 -71
  262. package/dist/nestjs/index.cjs.map +1 -1
  263. package/dist/nestjs/index.d.cts +4 -11
  264. package/dist/nestjs/index.d.ts +4 -11
  265. package/dist/nestjs/index.js +81 -61
  266. package/dist/nestjs/index.js.map +1 -1
  267. package/dist/packageVersion.cjs +67 -0
  268. package/dist/packageVersion.cjs.map +1 -0
  269. package/dist/packageVersion.d.cts +5 -0
  270. package/dist/packageVersion.d.ts +5 -0
  271. package/dist/packageVersion.js +39 -0
  272. package/dist/packageVersion.js.map +1 -0
  273. package/dist/providers.cjs +149 -0
  274. package/dist/providers.cjs.map +1 -0
  275. package/dist/providers.d.cts +15 -0
  276. package/dist/providers.d.ts +15 -0
  277. package/dist/providers.js +136 -0
  278. package/dist/providers.js.map +1 -0
  279. package/dist/redaction.cjs +116 -0
  280. package/dist/redaction.cjs.map +1 -0
  281. package/dist/redaction.d.cts +17 -0
  282. package/dist/redaction.d.ts +17 -0
  283. package/dist/redaction.js +98 -0
  284. package/dist/redaction.js.map +1 -0
  285. package/dist/{common/packageVersions.cjs → requestAttributes.cjs} +21 -19
  286. package/dist/requestAttributes.cjs.map +1 -0
  287. package/dist/requestAttributes.d.cts +10 -0
  288. package/dist/requestAttributes.d.ts +10 -0
  289. package/dist/requestAttributes.js +22 -0
  290. package/dist/requestAttributes.js.map +1 -0
  291. package/dist/requestObservation.cjs +246 -0
  292. package/dist/requestObservation.cjs.map +1 -0
  293. package/dist/requestObservation.d.cts +62 -0
  294. package/dist/requestObservation.d.ts +62 -0
  295. package/dist/requestObservation.js +226 -0
  296. package/dist/requestObservation.js.map +1 -0
  297. package/dist/requestObservationNode.cjs +193 -0
  298. package/dist/requestObservationNode.cjs.map +1 -0
  299. package/dist/requestObservationNode.d.cts +31 -0
  300. package/dist/requestObservationNode.d.ts +31 -0
  301. package/dist/requestObservationNode.js +170 -0
  302. package/dist/requestObservationNode.js.map +1 -0
  303. package/dist/requestObservationWeb.cjs +202 -0
  304. package/dist/requestObservationWeb.cjs.map +1 -0
  305. package/dist/requestObservationWeb.d.cts +34 -0
  306. package/dist/requestObservationWeb.d.ts +34 -0
  307. package/dist/requestObservationWeb.js +182 -0
  308. package/dist/requestObservationWeb.js.map +1 -0
  309. package/dist/sentry.cjs +103 -0
  310. package/dist/sentry.cjs.map +1 -0
  311. package/dist/sentry.d.cts +3 -0
  312. package/dist/sentry.d.ts +3 -0
  313. package/dist/sentry.js +79 -0
  314. package/dist/sentry.js.map +1 -0
  315. package/dist/serverErrors.cjs +118 -0
  316. package/dist/serverErrors.cjs.map +1 -0
  317. package/dist/serverErrors.d.cts +8 -0
  318. package/dist/serverErrors.d.ts +8 -0
  319. package/dist/serverErrors.js +91 -0
  320. package/dist/serverErrors.js.map +1 -0
  321. package/dist/spanExporter.cjs +217 -0
  322. package/dist/spanExporter.cjs.map +1 -0
  323. package/dist/spanExporter.d.cts +34 -0
  324. package/dist/spanExporter.d.ts +34 -0
  325. package/dist/spanExporter.js +193 -0
  326. package/dist/spanExporter.js.map +1 -0
  327. package/dist/spanProcessor.cjs +535 -0
  328. package/dist/spanProcessor.cjs.map +1 -0
  329. package/dist/spanProcessor.d.cts +70 -0
  330. package/dist/spanProcessor.d.ts +70 -0
  331. package/dist/spanProcessor.js +513 -0
  332. package/dist/spanProcessor.js.map +1 -0
  333. package/dist/spool.cjs +314 -0
  334. package/dist/spool.cjs.map +1 -0
  335. package/dist/spool.d.cts +49 -0
  336. package/dist/spool.d.ts +49 -0
  337. package/dist/spool.js +297 -0
  338. package/dist/spool.js.map +1 -0
  339. package/dist/startup.cjs +98 -0
  340. package/dist/startup.cjs.map +1 -0
  341. package/dist/startup.d.cts +15 -0
  342. package/dist/startup.d.ts +15 -0
  343. package/dist/startup.js +73 -0
  344. package/dist/startup.js.map +1 -0
  345. package/dist/tracing.cjs +116 -0
  346. package/dist/tracing.cjs.map +1 -0
  347. package/dist/tracing.d.cts +5 -0
  348. package/dist/tracing.d.ts +5 -0
  349. package/dist/tracing.js +96 -0
  350. package/dist/tracing.js.map +1 -0
  351. package/dist/validationErrors.cjs +229 -0
  352. package/dist/validationErrors.cjs.map +1 -0
  353. package/dist/validationErrors.d.cts +21 -0
  354. package/dist/validationErrors.d.ts +21 -0
  355. package/dist/validationErrors.js +195 -0
  356. package/dist/validationErrors.js.map +1 -0
  357. package/package.json +113 -154
  358. package/dist/common/client.cjs +0 -335
  359. package/dist/common/client.cjs.map +0 -1
  360. package/dist/common/client.d.cts +0 -50
  361. package/dist/common/client.d.ts +0 -50
  362. package/dist/common/client.js +0 -302
  363. package/dist/common/client.js.map +0 -1
  364. package/dist/common/consumerRegistry.cjs +0 -86
  365. package/dist/common/consumerRegistry.cjs.map +0 -1
  366. package/dist/common/consumerRegistry.d.cts +0 -20
  367. package/dist/common/consumerRegistry.d.ts +0 -20
  368. package/dist/common/consumerRegistry.js +0 -62
  369. package/dist/common/consumerRegistry.js.map +0 -1
  370. package/dist/common/headers.cjs +0 -55
  371. package/dist/common/headers.cjs.map +0 -1
  372. package/dist/common/headers.d.cts +0 -6
  373. package/dist/common/headers.d.ts +0 -6
  374. package/dist/common/headers.js +0 -31
  375. package/dist/common/headers.js.map +0 -1
  376. package/dist/common/instance.cjs +0 -158
  377. package/dist/common/instance.cjs.map +0 -1
  378. package/dist/common/instance.d.cts +0 -4
  379. package/dist/common/instance.d.ts +0 -4
  380. package/dist/common/instance.js +0 -134
  381. package/dist/common/instance.js.map +0 -1
  382. package/dist/common/logging.cjs.map +0 -1
  383. package/dist/common/logging.d.cts +0 -11
  384. package/dist/common/logging.d.ts +0 -11
  385. package/dist/common/logging.js +0 -17
  386. package/dist/common/logging.js.map +0 -1
  387. package/dist/common/packageVersions.cjs.map +0 -1
  388. package/dist/common/packageVersions.d.cts +0 -3
  389. package/dist/common/packageVersions.d.ts +0 -3
  390. package/dist/common/packageVersions.js +0 -21
  391. package/dist/common/packageVersions.js.map +0 -1
  392. package/dist/common/paramValidation.cjs.map +0 -1
  393. package/dist/common/paramValidation.d.cts +0 -4
  394. package/dist/common/paramValidation.d.ts +0 -4
  395. package/dist/common/paramValidation.js +0 -17
  396. package/dist/common/paramValidation.js.map +0 -1
  397. package/dist/common/requestCounter.cjs +0 -114
  398. package/dist/common/requestCounter.cjs.map +0 -1
  399. package/dist/common/requestCounter.d.cts +0 -24
  400. package/dist/common/requestCounter.d.ts +0 -24
  401. package/dist/common/requestCounter.js +0 -91
  402. package/dist/common/requestCounter.js.map +0 -1
  403. package/dist/common/requestLogger.cjs +0 -543
  404. package/dist/common/requestLogger.cjs.map +0 -1
  405. package/dist/common/requestLogger.d.cts +0 -85
  406. package/dist/common/requestLogger.d.ts +0 -85
  407. package/dist/common/requestLogger.js +0 -508
  408. package/dist/common/requestLogger.js.map +0 -1
  409. package/dist/common/resources.cjs +0 -49
  410. package/dist/common/resources.cjs.map +0 -1
  411. package/dist/common/resources.d.cts +0 -6
  412. package/dist/common/resources.d.ts +0 -6
  413. package/dist/common/resources.js +0 -26
  414. package/dist/common/resources.js.map +0 -1
  415. package/dist/common/response.cjs +0 -104
  416. package/dist/common/response.cjs.map +0 -1
  417. package/dist/common/response.d.cts +0 -15
  418. package/dist/common/response.d.ts +0 -15
  419. package/dist/common/response.js +0 -80
  420. package/dist/common/response.js.map +0 -1
  421. package/dist/common/sentry.cjs +0 -56
  422. package/dist/common/sentry.cjs.map +0 -1
  423. package/dist/common/sentry.d.cts +0 -6
  424. package/dist/common/sentry.d.ts +0 -6
  425. package/dist/common/sentry.js +0 -23
  426. package/dist/common/sentry.js.map +0 -1
  427. package/dist/common/serverErrorCounter.cjs +0 -123
  428. package/dist/common/serverErrorCounter.cjs.map +0 -1
  429. package/dist/common/serverErrorCounter.d.cts +0 -23
  430. package/dist/common/serverErrorCounter.d.ts +0 -23
  431. package/dist/common/serverErrorCounter.js +0 -98
  432. package/dist/common/serverErrorCounter.js.map +0 -1
  433. package/dist/common/spanCollector.cjs +0 -201
  434. package/dist/common/spanCollector.cjs.map +0 -1
  435. package/dist/common/spanCollector.d.cts +0 -45
  436. package/dist/common/spanCollector.d.ts +0 -45
  437. package/dist/common/spanCollector.js +0 -177
  438. package/dist/common/spanCollector.js.map +0 -1
  439. package/dist/common/tempGzipFile.cjs +0 -127
  440. package/dist/common/tempGzipFile.cjs.map +0 -1
  441. package/dist/common/tempGzipFile.d.cts +0 -19
  442. package/dist/common/tempGzipFile.d.ts +0 -19
  443. package/dist/common/tempGzipFile.js +0 -103
  444. package/dist/common/tempGzipFile.js.map +0 -1
  445. package/dist/common/types.cjs +0 -17
  446. package/dist/common/types.cjs.map +0 -1
  447. package/dist/common/types.d.cts +0 -95
  448. package/dist/common/types.d.ts +0 -95
  449. package/dist/common/types.js +0 -1
  450. package/dist/common/types.js.map +0 -1
  451. package/dist/common/validationErrorCounter.cjs +0 -79
  452. package/dist/common/validationErrorCounter.cjs.map +0 -1
  453. package/dist/common/validationErrorCounter.d.cts +0 -20
  454. package/dist/common/validationErrorCounter.d.ts +0 -20
  455. package/dist/common/validationErrorCounter.js +0 -56
  456. package/dist/common/validationErrorCounter.js.map +0 -1
  457. package/dist/elysia/plugin.cjs +0 -242
  458. package/dist/elysia/plugin.cjs.map +0 -1
  459. package/dist/elysia/plugin.d.cts +0 -70
  460. package/dist/elysia/plugin.d.ts +0 -70
  461. package/dist/elysia/plugin.js +0 -219
  462. package/dist/elysia/plugin.js.map +0 -1
  463. package/dist/elysia/utils.cjs +0 -77
  464. package/dist/elysia/utils.cjs.map +0 -1
  465. package/dist/elysia/utils.d.cts +0 -14
  466. package/dist/elysia/utils.d.ts +0 -14
  467. package/dist/elysia/utils.js +0 -54
  468. package/dist/elysia/utils.js.map +0 -1
  469. package/dist/express/utils.cjs +0 -217
  470. package/dist/express/utils.cjs.map +0 -1
  471. package/dist/express/utils.d.cts +0 -37
  472. package/dist/express/utils.d.ts +0 -37
  473. package/dist/express/utils.js +0 -189
  474. package/dist/express/utils.js.map +0 -1
  475. package/dist/fastify/plugin.cjs +0 -319
  476. package/dist/fastify/plugin.cjs.map +0 -1
  477. package/dist/fastify/plugin.d.cts +0 -34
  478. package/dist/fastify/plugin.d.ts +0 -34
  479. package/dist/fastify/plugin.js +0 -284
  480. package/dist/fastify/plugin.js.map +0 -1
  481. package/dist/h3/plugin.cjs +0 -183
  482. package/dist/h3/plugin.cjs.map +0 -1
  483. package/dist/h3/plugin.d.cts +0 -27
  484. package/dist/h3/plugin.d.ts +0 -27
  485. package/dist/h3/plugin.js +0 -159
  486. package/dist/h3/plugin.js.map +0 -1
  487. package/dist/h3/utils.cjs +0 -77
  488. package/dist/h3/utils.cjs.map +0 -1
  489. package/dist/h3/utils.d.cts +0 -14
  490. package/dist/h3/utils.d.ts +0 -14
  491. package/dist/h3/utils.js +0 -54
  492. package/dist/h3/utils.js.map +0 -1
  493. package/dist/hapi/plugin.cjs +0 -212
  494. package/dist/hapi/plugin.cjs.map +0 -1
  495. package/dist/hapi/plugin.d.cts +0 -40
  496. package/dist/hapi/plugin.d.ts +0 -40
  497. package/dist/hapi/plugin.js +0 -188
  498. package/dist/hapi/plugin.js.map +0 -1
  499. package/dist/hapi/utils.cjs +0 -77
  500. package/dist/hapi/utils.cjs.map +0 -1
  501. package/dist/hapi/utils.d.cts +0 -16
  502. package/dist/hapi/utils.d.ts +0 -16
  503. package/dist/hapi/utils.js +0 -53
  504. package/dist/hapi/utils.js.map +0 -1
  505. package/dist/hono/utils.cjs +0 -113
  506. package/dist/hono/utils.cjs.map +0 -1
  507. package/dist/hono/utils.d.cts +0 -16
  508. package/dist/hono/utils.d.ts +0 -16
  509. package/dist/hono/utils.js +0 -88
  510. package/dist/hono/utils.js.map +0 -1
  511. package/dist/loggers/console.cjs +0 -67
  512. package/dist/loggers/console.cjs.map +0 -1
  513. package/dist/loggers/console.d.cts +0 -11
  514. package/dist/loggers/console.d.ts +0 -11
  515. package/dist/loggers/console.js +0 -44
  516. package/dist/loggers/console.js.map +0 -1
  517. package/dist/loggers/hapi.cjs.map +0 -1
  518. package/dist/loggers/hapi.d.cts +0 -12
  519. package/dist/loggers/hapi.d.ts +0 -12
  520. package/dist/loggers/hapi.js +0 -29
  521. package/dist/loggers/hapi.js.map +0 -1
  522. package/dist/loggers/index.cjs.map +0 -1
  523. package/dist/loggers/index.d.cts +0 -13
  524. package/dist/loggers/index.d.ts +0 -13
  525. package/dist/loggers/index.js +0 -13
  526. package/dist/loggers/index.js.map +0 -1
  527. package/dist/loggers/nestjs.cjs +0 -104
  528. package/dist/loggers/nestjs.cjs.map +0 -1
  529. package/dist/loggers/nestjs.d.cts +0 -11
  530. package/dist/loggers/nestjs.d.ts +0 -11
  531. package/dist/loggers/nestjs.js +0 -71
  532. package/dist/loggers/nestjs.js.map +0 -1
  533. package/dist/loggers/pino.cjs +0 -152
  534. package/dist/loggers/pino.cjs.map +0 -1
  535. package/dist/loggers/pino.d.cts +0 -11
  536. package/dist/loggers/pino.d.ts +0 -11
  537. package/dist/loggers/pino.js +0 -119
  538. package/dist/loggers/pino.js.map +0 -1
  539. package/dist/loggers/utils.cjs +0 -64
  540. package/dist/loggers/utils.cjs.map +0 -1
  541. package/dist/loggers/utils.d.cts +0 -6
  542. package/dist/loggers/utils.d.ts +0 -6
  543. package/dist/loggers/utils.js +0 -40
  544. package/dist/loggers/utils.js.map +0 -1
  545. package/dist/loggers/winston.cjs +0 -101
  546. package/dist/loggers/winston.cjs.map +0 -1
  547. package/dist/loggers/winston.d.cts +0 -11
  548. package/dist/loggers/winston.d.ts +0 -11
  549. package/dist/loggers/winston.js +0 -68
  550. package/dist/loggers/winston.js.map +0 -1
  551. package/dist/otel/index.cjs.map +0 -1
  552. package/dist/otel/index.d.cts +0 -2
  553. package/dist/otel/index.d.ts +0 -2
  554. package/dist/otel/index.js +0 -5
  555. package/dist/otel/index.js.map +0 -1
package/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  </p>
20
20
  <br>
21
21
 
22
- # Apitally SDK for Node.js
22
+ # Apitally SDK for JavaScript
23
23
 
24
24
  [![Tests](https://github.com/apitally/apitally-js/actions/workflows/tests.yaml/badge.svg?event=push)](https://github.com/apitally/apitally-js/actions)
25
25
  [![Codecov](https://codecov.io/gh/apitally/apitally-js/graph/badge.svg?token=j5jqlrL7Pd)](https://codecov.io/gh/apitally/apitally-js)
@@ -28,304 +28,354 @@
28
28
  Apitally is a simple API monitoring and analytics tool that makes it easy to understand API usage, monitor performance, and troubleshoot issues.
29
29
  Get started in minutes by just adding a few lines of code. No infrastructure changes required, no dashboards to build.
30
30
 
31
- Learn more about Apitally on our 🌎 [website](https://apitally.io) or check out
32
- the 📚 [documentation](https://docs.apitally.io).
31
+ The SDK is an [OpenTelemetry](https://opentelemetry.io) distribution and works alongside an existing OpenTelemetry setup.
32
+
33
+ Learn more about Apitally on our 🌎 [website](https://apitally.io) or check out the 📚 [documentation](https://docs.apitally.io).
34
+
35
+ > [!IMPORTANT]
36
+ > **Upgrading from 0.x?** Version 1.0 is a full rewrite with a new setup API. See the [migration guide](MIGRATION.md) for a full 0.x to 1.x mapping.
33
37
 
34
38
  ## Key features
35
39
 
36
- ### API analytics
40
+ - **API analytics**: Traffic, error and performance metrics for your API, each endpoint, and per API consumer. Drill down from metrics to individual API requests.
41
+ - **Request logs and traces**: Every request as a searchable log entry, with optional capture of headers and request/response bodies. Requests are exported as OpenTelemetry spans, including spans from any other instrumentations you have.
42
+ - **Application logs**: Logs written via `console` and other supported loggers are captured automatically and correlated with the requests they belong to.
43
+ - **Error tracking**: Validation errors and exceptions with stack traces for server errors, automatically linked to Sentry events if you use Sentry.
44
+ - **Server metrics**: CPU and memory usage of your app's processes.
45
+ - **API monitoring & alerts**: Get notified if something isn't right using custom alerts, synthetic uptime checks and heartbeat monitoring. Alert notifications can be delivered via email, Slack and Microsoft Teams.
37
46
 
38
- Track traffic, error and performance metrics for your API, each endpoint and
39
- individual API consumers, allowing you to make informed, data-driven engineering
40
- and product decisions.
47
+ ## Supported frameworks
41
48
 
42
- ### Request logs
49
+ The SDK supports **Node.js** `>= 20.6` and **Bun** `>= 1.1.13`.
43
50
 
44
- Drill down from insights to individual API requests or use powerful search and filters to
45
- find specific requests. View correlated application logs and traces for a complete picture
46
- of each request, making troubleshooting faster and easier.
51
+ | Framework | Supported versions | Setup guide |
52
+ | --- | --- | --- |
53
+ | [**AdonisJS**](https://github.com/adonisjs/core) | `>= 6.3`, `< 8` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/adonisjs) |
54
+ | [**Elysia**](https://github.com/elysiajs/elysia) | `>= 1.1`, `< 2` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/elysia) |
55
+ | [**Express**](https://github.com/expressjs/express) | `>= 4.18.2`, `< 6` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/express) |
56
+ | [**Fastify**](https://github.com/fastify/fastify) | `>= 4.10.2`, `< 6` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/fastify) |
57
+ | [**H3**](https://github.com/h3js/h3) | `>= 2.0.1-rc.26`, `< 3` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/h3) |
58
+ | [**Hapi**](https://github.com/hapijs/hapi) | `21.x` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/hapi) |
59
+ | [**Hono**](https://github.com/honojs/hono) \* | `>= 4.8.4`, `< 5` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/hono) |
60
+ | [**Koa**](https://github.com/koajs/koa) | `2.x`, `3.x` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/koa) |
61
+ | [**NestJS**](https://github.com/nestjs/nest) | `10.x`, `11.x`, `12.x` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/nestjs) |
47
62
 
48
- ### Error tracking
63
+ \* For Hono on Cloudflare Workers use our [Serverless SDK](https://github.com/apitally/apitally-js-serverless) instead.
49
64
 
50
- Understand which validation rules in your endpoints cause client errors. Capture
51
- error details and stack traces for 500 error responses, and have them linked to
52
- Sentry issues automatically.
65
+ Apitally also supports many other web frameworks in [Python](https://github.com/apitally/apitally-py), [Go](https://github.com/apitally/apitally-go), [.NET](https://github.com/apitally/apitally-dotnet) and [Java](https://github.com/apitally/apitally-java) via our other SDKs.
53
66
 
54
- ### API monitoring & alerts
67
+ ## Getting started
55
68
 
56
- Get notified immediately if something isn't right using custom alerts, synthetic
57
- uptime checks and heartbeat monitoring. Alert notifications can be delivered via
58
- email, Slack and Microsoft Teams.
69
+ If you don't have an Apitally account yet, first [sign up here](https://app.apitally.io/?signup). Then create an app in the Apitally dashboard. You'll see detailed setup instructions with code snippets you can copy and paste. These also include your write token.
59
70
 
60
- ## Supported frameworks
71
+ To install the SDK as a dependency in your project run:
61
72
 
62
- | Framework | Supported versions | Setup guide |
63
- | --------------------------------------------------- | --------------------- | ------------------------------------------------------ |
64
- | [**Express**](https://github.com/expressjs/express) | `4.x`, `5.x` | [Link](https://docs.apitally.io/setup-guides/express) |
65
- | [**Fastify**](https://github.com/fastify/fastify) | `4.x`, `5.x` | [Link](https://docs.apitally.io/setup-guides/fastify) |
66
- | [**NestJS**](https://github.com/nestjs/nest) | `9.x`, `10.x`, `11.x` | [Link](https://docs.apitally.io/setup-guides/nestjs) |
67
- | [**AdonisJS**](https://github.com/adonisjs/core) | `6.x` | [Link](https://docs.apitally.io/setup-guides/adonisjs) |
68
- | [**Hono**](https://github.com/honojs/hono) \* | `4.x` | [Link](https://docs.apitally.io/setup-guides/hono) |
69
- | [**H3**](https://github.com/h3js/h3) | `2.x` | [Link](https://docs.apitally.io/setup-guides/h3) |
70
- | [**Elysia**](https://github.com/elysiajs/elysia) | `1.x` | [Link](https://docs.apitally.io/setup-guides/elysia) |
71
- | [**Koa**](https://github.com/koajs/koa) | `2.x`, `3.x` | [Link](https://docs.apitally.io/setup-guides/koa) |
72
- | [**Hapi**](https://github.com/hapijs/hapi) | `21.x` | [Link](https://docs.apitally.io/setup-guides/hapi) |
73
+ ```bash
74
+ npm install apitally
75
+ ```
73
76
 
74
- \* For Hono on Cloudflare Workers use our [Serverless SDK](https://github.com/apitally/apitally-js-serverless) instead.
77
+ See the [SDK reference](https://docs.apitally.io/sdk-reference/javascript/v1/configuration) for all available configuration options, including how to mask sensitive data, capture request and response payloads, and more.
75
78
 
76
- Apitally also supports many other web frameworks in [Python](https://github.com/apitally/apitally-py), [Go](https://github.com/apitally/apitally-go), [.NET](https://github.com/apitally/apitally-dotnet) and [Java](https://github.com/apitally/apitally-java) via our other SDKs.
79
+ ### AdonisJS
77
80
 
78
- ## Getting started
81
+ Run the Ace add command from your application directory:
79
82
 
80
- If you don't have an Apitally account yet, first [sign up here](https://app.apitally.io/?signup). Then create an app in the Apitally dashboard. You'll see detailed setup instructions with code snippets you can copy and paste. These also include your client ID.
83
+ ```bash
84
+ node ace add apitally
85
+ ```
81
86
 
82
- See the [SDK reference](https://docs.apitally.io/sdk-reference/javascript) for all available configuration options, including how to mask sensitive data, customize request logging, and more.
87
+ The command installs and configures Apitally. It creates `config/apitally.ts`, adds the required environment declarations, registers the service provider and server middleware, and updates the conventional exception handler to capture validation and server errors.
83
88
 
84
- ### Express
89
+ If needed, you can change settings in `config/apitally.ts`.
85
90
 
86
- Install the SDK:
91
+ For further instructions, see our [setup guide for AdonisJS](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/adonisjs).
87
92
 
88
- ```bash
89
- npm install apitally
93
+ ### Elysia
94
+
95
+ Register `apitallyPlugin()` immediately after creating the app, before routes or plugins that add routes:
96
+
97
+ ```javascript
98
+ import { Elysia } from "elysia";
99
+ import { apitallyPlugin } from "apitally/elysia";
100
+
101
+ const app = new Elysia()
102
+ .use(
103
+ apitallyPlugin({
104
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
105
+ env: "dev", // optional, defaults to "dev"
106
+ }),
107
+ )
108
+ // register plugins and routes below this point
109
+ .get("/items/:id", ({ params }) => ({ id: params.id }));
90
110
  ```
91
111
 
92
- Then add the Apitally middleware to your application:
112
+ For further instructions, see our [setup guide for Elysia](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/elysia).
113
+
114
+ ### Express
115
+
116
+ Import `apitally/express/register` on the first line of your entry module, then call `useApitally(app)` anywhere after creating the app:
93
117
 
94
118
  ```javascript
95
- const express = require("express");
96
- const { useApitally } = require("apitally/express");
119
+ import "apitally/express/register"; // must be the first import
120
+
121
+ import express from "express";
122
+ import { useApitally } from "apitally";
97
123
 
98
124
  const app = express();
99
- app.use(express.json());
100
125
 
101
126
  useApitally(app, {
102
- clientId: "your-client-id",
127
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
103
128
  env: "dev", // or "prod" etc.
104
129
  });
105
130
  ```
106
131
 
107
- For further instructions, see our
108
- [setup guide for Express](https://docs.apitally.io/setup-guides/express).
132
+ For further instructions, see our [setup guide for Express](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/express).
109
133
 
110
134
  ### Fastify
111
135
 
112
- Install the SDK with the `fastify-plugin` peer dependency:
113
-
114
- ```bash
115
- npm install apitally fastify-plugin
116
- ```
117
-
118
- Then register the Apitally plugin with your application:
136
+ Call `useApitally(app)` immediately after creating the app, before registering plugins and routes:
119
137
 
120
138
  ```javascript
121
139
  import Fastify from "fastify";
122
- import { apitallyPlugin } from "apitally/fastify";
140
+ import { useApitally } from "apitally";
123
141
 
124
- const fastify = Fastify({ logger: true });
142
+ const app = Fastify();
125
143
 
126
- await fastify.register(apitallyPlugin, {
127
- clientId: "your-client-id",
144
+ useApitally(app, {
145
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
128
146
  env: "dev", // or "prod" etc.
129
147
  });
130
- ```
131
148
 
132
- _Note:_ If your project uses CommonJS you need to wrap your routes in a plugin, so Apitally can detect them.
149
+ // register plugins and routes below this point
150
+ ```
133
151
 
134
- For further instructions, see our
135
- [setup guide for Fastify](https://docs.apitally.io/setup-guides/fastify).
152
+ For further instructions, see our [setup guide for Fastify](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/fastify).
136
153
 
137
154
  ### NestJS
138
155
 
139
- Install the SDK:
140
-
141
- ```bash
142
- npm install apitally
143
- ```
144
-
145
- Then add the Apitally middleware to your application:
156
+ Call `useApitally(app)` immediately after creating the Nest application, before `app.init()` or `app.listen()`:
146
157
 
147
158
  ```javascript
148
159
  import { NestFactory } from "@nestjs/core";
149
160
  import { useApitally } from "apitally/nestjs";
150
- import { AppModule } from "./app.module";
161
+ import { AppModule } from "./app.module.js";
151
162
 
152
- async function bootstrap() {
153
- const app = await NestFactory.create(AppModule);
163
+ const app = await NestFactory.create(AppModule);
154
164
 
155
- await useApitally(app, {
156
- clientId: "your-client-id",
157
- env: "dev", // or "prod" etc.
158
- });
159
-
160
- // ...
161
- }
165
+ useApitally(app, {
166
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
167
+ env: "dev", // or "prod" etc.
168
+ });
162
169
 
163
- bootstrap();
170
+ await app.listen(3000);
164
171
  ```
165
172
 
166
- For further instructions, see our
167
- [setup guide for NestJS](https://docs.apitally.io/setup-guides/nestjs).
173
+ For further instructions, see our [setup guide for NestJS](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/nestjs).
168
174
 
169
- ### AdonisJS
175
+ ### H3
170
176
 
171
- Install the SDK:
177
+ Add `apitallyPlugin()` when constructing the root H3 app:
172
178
 
173
- ```bash
174
- npm install apitally
179
+ ```javascript
180
+ import { H3 } from "h3";
181
+ import { apitallyPlugin } from "apitally/h3";
182
+
183
+ const app = new H3({
184
+ plugins: [
185
+ apitallyPlugin({
186
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
187
+ env: "dev", // or "prod" etc.
188
+ }),
189
+ ],
190
+ });
175
191
  ```
176
192
 
177
- Then use the following Ace command to configure Apitally in your AdonisJS application:
193
+ For further instructions, see our [setup guide for H3](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/h3).
178
194
 
179
- ```bash
180
- node ace configure apitally/adonisjs
181
- ```
195
+ ### Hapi
182
196
 
183
- For further instructions, see our
184
- [setup guide for AdonisJS](https://docs.apitally.io/setup-guides/adonisjs).
197
+ Register `apitallyPlugin()` before calling `server.initialize()` or `server.start()`:
185
198
 
186
- ### Hono
199
+ ```javascript
200
+ import Hapi from "@hapi/hapi";
201
+ import { apitallyPlugin } from "apitally/hapi";
187
202
 
188
- Install the SDK:
203
+ const server = Hapi.server({ port: 3000 });
189
204
 
190
- ```bash
191
- npm install apitally
205
+ await server.register(
206
+ apitallyPlugin({
207
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
208
+ env: "dev", // or "prod" etc.
209
+ }),
210
+ );
211
+
212
+ // register application plugins and routes below this point
213
+ await server.start();
192
214
  ```
193
215
 
194
- Then add the Apitally middleware to your application:
216
+ For further instructions, see our [setup guide for Hapi](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/hapi).
217
+
218
+ ### Hono
219
+
220
+ Call `useApitally(app)` immediately after creating the app, before registering middleware and routes:
195
221
 
196
222
  ```javascript
197
223
  import { Hono } from "hono";
198
- import { useApitally } from "apitally/hono";
224
+ import { useApitally } from "apitally";
199
225
 
200
226
  const app = new Hono();
201
227
 
202
228
  useApitally(app, {
203
- clientId: "your-client-id",
229
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
204
230
  env: "dev", // or "prod" etc.
205
231
  });
232
+
233
+ // register middleware and routes below this point
206
234
  ```
207
235
 
208
- For further instructions, see our
209
- [setup guide for Hono](https://docs.apitally.io/setup-guides/hono).
236
+ For further instructions, see our [setup guide for Hono](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/hono).
210
237
 
211
- ### H3
238
+ ### Koa
212
239
 
213
- Install the SDK:
240
+ Call `useApitally(app)` immediately after creating the app, before registering middleware and routes:
214
241
 
215
- ```bash
216
- npm install apitally
242
+ ```javascript
243
+ const Koa = require("koa");
244
+ const { useApitally } = require("apitally");
245
+
246
+ const app = new Koa();
247
+
248
+ useApitally(app, {
249
+ writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
250
+ env: "dev", // or "prod" etc.
251
+ });
252
+
253
+ // register middleware and routes below this point
217
254
  ```
218
255
 
219
- Then register the Apitally plugin with your application:
256
+ For further instructions, see our [setup guide for Koa](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/koa).
220
257
 
221
- ```javascript
222
- import { H3 } from "h3";
223
- import { apitallyPlugin } from "apitally/h3";
258
+ ## Configuration
224
259
 
225
- const app = new H3({
226
- plugins: [
227
- apitallyPlugin({
228
- clientId: "your-client-id",
229
- env: "dev", // or "prod" etc.
230
- }),
231
- ],
260
+ The write token and environment can also be provided via the `APITALLY_WRITE_TOKEN` and `APITALLY_ENV` environment variables instead of the `writeToken` and `env` options. The environment defaults to `dev`.
261
+
262
+ By default, Apitally captures response headers but not request headers or request and response bodies. You can opt in with options:
263
+
264
+ ```javascript
265
+ useApitally(app, {
266
+ writeToken: "your-write-token",
267
+ env: "dev",
268
+ captureRequestHeaders: true,
269
+ captureRequestBody: true,
270
+ captureResponseBody: true,
232
271
  });
233
272
  ```
234
273
 
235
- For further instructions, see our
236
- [setup guide for H3](https://docs.apitally.io/setup-guides/h3).
274
+ Sensitive values in query parameters, headers, and body fields are masked automatically based on built-in patterns, and you can add your own via the `maskQueryParams`, `maskHeaders`, and `maskBodyFields` options.
237
275
 
238
- ### Elysia
276
+ On high-traffic applications you can capture logs and traces for only a fraction of requests by setting `sampleRate` (e.g. `0.1` for 10%), or decide per request with the `sampleOnRequest` and `sampleOnResponse` callbacks. Metrics always count every request, regardless of sampling.
239
277
 
240
- Install the SDK:
278
+ Application logs written via `console` and other supported loggers are captured and correlated with requests by default. Use `maskLogRecord` to transform or drop Apitally's captured copy, or opt out with `captureLogs: false`.
241
279
 
242
- ```bash
243
- npm install apitally
244
- ```
280
+ See the [SDK reference](https://docs.apitally.io/sdk-reference/javascript/v1/configuration) for all configuration options.
245
281
 
246
- Then add the Apitally plugin to your application:
282
+ ## Identifying consumers and more
283
+
284
+ The top-level `apitally` package provides functions you can call from anywhere in your request handling code:
247
285
 
248
286
  ```javascript
249
- import { Elysia } from "elysia";
250
- import { apitallyPlugin } from "apitally/elysia";
287
+ import { setConsumer, setRequestAttribute, captureException } from "apitally";
251
288
 
252
- const app = new Elysia()
253
- .use(
254
- apitallyPlugin({
255
- clientId: "your-client-id",
256
- env: "dev", // or "prod" etc.
257
- }),
258
- )
259
- .get("/", () => "hello");
289
+ // Associate the current request with an API consumer
290
+ setConsumer({ identifier: user.identifier, name: user.name, group: user.group });
291
+
292
+ // Attach a custom attribute to the current request
293
+ setRequestAttribute("tenant", tenantId);
294
+
295
+ // Capture a handled exception for the current request
296
+ captureException(error);
260
297
  ```
261
298
 
262
- For further instructions, see our
263
- [setup guide for Elysia](https://docs.apitally.io/setup-guides/elysia).
299
+ `setConsumer()` also accepts an identifier string, for example `setConsumer(user.identifier)`.
264
300
 
265
- ### Koa
301
+ For further details, check out our [documentation](https://docs.apitally.io).
266
302
 
267
- Install the SDK:
303
+ ## Existing OpenTelemetry setup
268
304
 
269
- ```bash
270
- npm install apitally
271
- ```
305
+ If your app doesn't already use OpenTelemetry, you don't need to know it's there. The Apitally SDK configures OpenTelemetry automatically.
272
306
 
273
- Then add the Apitally middleware to your application:
307
+ If your app already registers its own tracer provider (e.g. via `NodeSDK`), Apitally does not replace it. Instead, you need to add the `ApitallySpanProcessor` to your provider's span processors:
274
308
 
275
309
  ```javascript
276
- const Koa = require("koa");
277
- const { useApitally } = require("apitally/koa");
310
+ import { NodeSDK } from "@opentelemetry/sdk-node";
311
+ import { ApitallySpanProcessor } from "apitally";
278
312
 
279
- const app = new Koa();
280
-
281
- useApitally(app, {
282
- clientId: "your-client-id",
283
- env: "dev", // or "prod" etc.
313
+ const sdk = new NodeSDK({
314
+ spanProcessors: [new ApitallySpanProcessor()],
315
+ // ...your existing configuration
284
316
  });
285
317
  ```
286
318
 
287
- For further instructions, see our
288
- [setup guide for Koa](https://docs.apitally.io/setup-guides/koa).
319
+ Your tracer provider's sampling settings also affect Apitally. Requests excluded by the sampler will not have request logs or traces in Apitally. Metrics still include all requests, regardless of sampling.
289
320
 
290
- ### Hapi
321
+ ### Sentry
291
322
 
292
- Install the SDK:
323
+ Sentry's Node.js SDK configures OpenTelemetry automatically. To use Apitally alongside Sentry, add `ApitallySpanProcessor` to Sentry's configuration and call `Sentry.init()` before `useApitally()`:
293
324
 
294
- ```bash
295
- npm install apitally
325
+ ```javascript
326
+ import * as Sentry from "@sentry/node";
327
+ import { ApitallySpanProcessor } from "apitally";
328
+
329
+ Sentry.init({
330
+ dsn: "your-sentry-dsn",
331
+ // Enable tracing
332
+ tracesSampleRate: 1.0,
333
+ // Add Apitally's span processor
334
+ openTelemetrySpanProcessors: [new ApitallySpanProcessor()],
335
+ // Optional: send only errors to Sentry
336
+ beforeSendTransaction: () => null,
337
+ });
296
338
  ```
297
339
 
298
- Then register the Apitally plugin with your application:
340
+ Apitally uses the spans recorded by Sentry, so tracing must be enabled in Sentry. Requests excluded by Sentry's sampler will also be missing from Apitally's request logs and traces.
341
+
342
+ Returning `null` from `beforeSendTransaction` prevents traces from being sent to Sentry without affecting Apitally's request logs and traces.
343
+
344
+ ### Elysia's OpenTelemetry plugin
345
+
346
+ When using Elysia's `@elysia/opentelemetry` plugin, register Apitally first so it adopts the OpenTelemetry SERVER span:
299
347
 
300
348
  ```javascript
301
- const Hapi = require("@hapi/hapi");
302
- const { apitallyPlugin } = require("apitally/hapi");
303
-
304
- const init = async () => {
305
- const server = Hapi.server({
306
- port: 3000,
307
- host: "localhost",
308
- });
309
-
310
- await server.register({
311
- plugin: apitallyPlugin({
312
- clientId: "your-client-id",
313
- env: "dev", // or "prod" etc.
314
- }),
315
- });
316
- };
349
+ import { opentelemetry } from "@elysia/opentelemetry";
350
+ import { Elysia } from "elysia";
351
+ import { apitallyPlugin } from "apitally/elysia";
317
352
 
318
- init();
353
+ const app = new Elysia()
354
+ .use(apitallyPlugin(options))
355
+ .use(opentelemetry());
319
356
  ```
320
357
 
321
- For further instructions, see our
322
- [setup guide for Hapi](https://docs.apitally.io/setup-guides/hapi).
358
+ ## Trusted proxies
359
+
360
+ If your application runs behind a reverse proxy or load balancer, configure trusted proxies in your framework so Apitally can record the real client IP for GeoIP. Apitally uses the client IP reported by your framework. It does not read forwarding headers itself to determine the client IP.
361
+
362
+ ## Graceful shutdown
363
+
364
+ Apitally sends telemetry in batches and automatically attempts a final export during normal process shutdown.
365
+
366
+ If your code calls `process.exit()`, await `shutdown()` first to give Apitally time to send buffered telemetry. Close your server and let any remaining requests finish before doing this:
367
+
368
+ ```javascript
369
+ import { shutdown } from "apitally";
370
+
371
+ // After the server has closed and requests have finished:
372
+ await shutdown();
373
+ process.exit(0);
374
+ ```
323
375
 
324
376
  ## Getting help
325
377
 
326
- If you need help please
327
- [create a new discussion](https://github.com/orgs/apitally/discussions/categories/q-a)
328
- on GitHub or email us at [support@apitally.io](mailto:support@apitally.io). We'll get back to you as soon as possible.
378
+ If you need help please [create a new discussion](https://github.com/orgs/apitally/discussions/categories/q-a) on GitHub or email us at [support@apitally.io](mailto:support@apitally.io). We'll get back to you as soon as possible.
329
379
 
330
380
  ## License
331
381