apitally 1.0.0-alpha.1 → 1.0.0-beta.2

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 (362) hide show
  1. package/README.md +122 -79
  2. package/dist/activation.cjs +262 -322
  3. package/dist/activation.cjs.map +1 -1
  4. package/dist/activation.d.cts +30 -38
  5. package/dist/activation.d.ts +30 -38
  6. package/dist/activation.js +244 -299
  7. package/dist/activation.js.map +1 -1
  8. package/dist/adonisjs/configure.cjs +72 -128
  9. package/dist/adonisjs/configure.cjs.map +1 -1
  10. package/dist/adonisjs/configure.d.cts +5 -5
  11. package/dist/adonisjs/configure.d.ts +5 -5
  12. package/dist/adonisjs/configure.js +70 -100
  13. package/dist/adonisjs/configure.js.map +1 -1
  14. package/dist/adonisjs/index.cjs +33 -28
  15. package/dist/adonisjs/index.cjs.map +1 -1
  16. package/dist/adonisjs/index.d.cts +8 -6
  17. package/dist/adonisjs/index.d.ts +8 -6
  18. package/dist/adonisjs/index.js +31 -4
  19. package/dist/adonisjs/index.js.map +1 -1
  20. package/dist/adonisjs/middleware.cjs +48 -67
  21. package/dist/adonisjs/middleware.cjs.map +1 -1
  22. package/dist/adonisjs/middleware.d.cts +7 -7
  23. package/dist/adonisjs/middleware.d.ts +7 -7
  24. package/dist/adonisjs/middleware.js +41 -44
  25. package/dist/adonisjs/middleware.js.map +1 -1
  26. package/dist/adonisjs/provider.cjs +35 -51
  27. package/dist/adonisjs/provider.cjs.map +1 -1
  28. package/dist/adonisjs/provider.d.cts +10 -10
  29. package/dist/adonisjs/provider.d.ts +10 -10
  30. package/dist/adonisjs/provider.js +31 -31
  31. package/dist/adonisjs/provider.js.map +1 -1
  32. package/dist/bodyCapture.cjs +91 -117
  33. package/dist/bodyCapture.cjs.map +1 -1
  34. package/dist/bodyCapture.d.cts +32 -27
  35. package/dist/bodyCapture.d.ts +32 -27
  36. package/dist/bodyCapture.js +86 -90
  37. package/dist/bodyCapture.js.map +1 -1
  38. package/dist/config.cjs +150 -177
  39. package/dist/config.cjs.map +1 -1
  40. package/dist/config.d.cts +42 -40
  41. package/dist/config.d.ts +42 -40
  42. package/dist/config.js +138 -141
  43. package/dist/config.js.map +1 -1
  44. package/dist/consumer.cjs +47 -84
  45. package/dist/consumer.cjs.map +1 -1
  46. package/dist/consumer.d.cts +11 -12
  47. package/dist/consumer.d.ts +11 -12
  48. package/dist/consumer.js +43 -62
  49. package/dist/consumer.js.map +1 -1
  50. package/dist/context.cjs +29 -60
  51. package/dist/context.cjs.map +1 -1
  52. package/dist/context.d.cts +29 -26
  53. package/dist/context.d.ts +29 -26
  54. package/dist/context.js +15 -26
  55. package/dist/context.js.map +1 -1
  56. package/dist/elysia/index.cjs +10 -33
  57. package/dist/elysia/index.cjs.map +1 -1
  58. package/dist/elysia/index.d.cts +8 -8
  59. package/dist/elysia/index.d.ts +8 -8
  60. package/dist/elysia/index.js +7 -7
  61. package/dist/elysia/index.js.map +1 -1
  62. package/dist/elysia/middleware.cjs +174 -233
  63. package/dist/elysia/middleware.cjs.map +1 -1
  64. package/dist/elysia/middleware.d.cts +10 -11
  65. package/dist/elysia/middleware.d.ts +10 -11
  66. package/dist/elysia/middleware.js +169 -219
  67. package/dist/elysia/middleware.js.map +1 -1
  68. package/dist/elysia/routes.cjs +11 -34
  69. package/dist/elysia/routes.cjs.map +1 -1
  70. package/dist/elysia/routes.d.cts +6 -7
  71. package/dist/elysia/routes.d.ts +6 -7
  72. package/dist/elysia/routes.js +10 -10
  73. package/dist/elysia/routes.js.map +1 -1
  74. package/dist/exceptions.cjs +33 -68
  75. package/dist/exceptions.cjs.map +1 -1
  76. package/dist/exceptions.d.cts +7 -7
  77. package/dist/exceptions.d.ts +7 -7
  78. package/dist/exceptions.js +29 -41
  79. package/dist/exceptions.js.map +1 -1
  80. package/dist/exportSerialization.cjs +26 -50
  81. package/dist/exportSerialization.cjs.map +1 -1
  82. package/dist/exportSerialization.d.cts +6 -7
  83. package/dist/exportSerialization.d.ts +6 -7
  84. package/dist/exportSerialization.js +24 -25
  85. package/dist/exportSerialization.js.map +1 -1
  86. package/dist/exportWorker.cjs +219 -292
  87. package/dist/exportWorker.cjs.map +1 -1
  88. package/dist/exportWorker.d.cts +43 -44
  89. package/dist/exportWorker.d.ts +43 -44
  90. package/dist/exportWorker.js +215 -263
  91. package/dist/exportWorker.js.map +1 -1
  92. package/dist/express/index.cjs +11 -33
  93. package/dist/express/index.cjs.map +1 -1
  94. package/dist/express/index.d.cts +7 -7
  95. package/dist/express/index.d.ts +7 -7
  96. package/dist/express/index.js +8 -7
  97. package/dist/express/index.js.map +1 -1
  98. package/dist/express/install.cjs +20 -42
  99. package/dist/express/install.cjs.map +1 -1
  100. package/dist/express/install.d.cts +7 -9
  101. package/dist/express/install.d.ts +7 -9
  102. package/dist/express/install.js +17 -16
  103. package/dist/express/install.js.map +1 -1
  104. package/dist/express/middleware.cjs +75 -109
  105. package/dist/express/middleware.cjs.map +1 -1
  106. package/dist/express/middleware.d.cts +5 -5
  107. package/dist/express/middleware.d.ts +5 -5
  108. package/dist/express/middleware.js +70 -85
  109. package/dist/express/middleware.js.map +1 -1
  110. package/dist/express/register.cjs +15 -14
  111. package/dist/express/register.cjs.map +1 -1
  112. package/dist/express/register.d.cts +1 -2
  113. package/dist/express/register.d.ts +1 -2
  114. package/dist/express/register.js +12 -10
  115. package/dist/express/register.js.map +1 -1
  116. package/dist/express/routes.cjs +264 -357
  117. package/dist/express/routes.cjs.map +1 -1
  118. package/dist/express/routes.d.cts +11 -12
  119. package/dist/express/routes.d.ts +11 -12
  120. package/dist/express/routes.js +258 -328
  121. package/dist/express/routes.js.map +1 -1
  122. package/dist/fastify/index.cjs +11 -33
  123. package/dist/fastify/index.cjs.map +1 -1
  124. package/dist/fastify/index.d.cts +7 -7
  125. package/dist/fastify/index.d.ts +7 -7
  126. package/dist/fastify/index.js +8 -7
  127. package/dist/fastify/index.js.map +1 -1
  128. package/dist/fastify/install.cjs +14 -36
  129. package/dist/fastify/install.cjs.map +1 -1
  130. package/dist/fastify/install.d.cts +7 -9
  131. package/dist/fastify/install.d.ts +7 -9
  132. package/dist/fastify/install.js +11 -10
  133. package/dist/fastify/install.js.map +1 -1
  134. package/dist/fastify/middleware.cjs +93 -114
  135. package/dist/fastify/middleware.cjs.map +1 -1
  136. package/dist/fastify/middleware.d.cts +6 -7
  137. package/dist/fastify/middleware.d.ts +6 -7
  138. package/dist/fastify/middleware.js +88 -89
  139. package/dist/fastify/middleware.js.map +1 -1
  140. package/dist/fastify/routes.cjs +12 -34
  141. package/dist/fastify/routes.cjs.map +1 -1
  142. package/dist/fastify/routes.d.cts +7 -8
  143. package/dist/fastify/routes.d.ts +7 -8
  144. package/dist/fastify/routes.js +10 -9
  145. package/dist/fastify/routes.js.map +1 -1
  146. package/dist/h3/index.cjs +23 -48
  147. package/dist/h3/index.cjs.map +1 -1
  148. package/dist/h3/index.d.cts +8 -8
  149. package/dist/h3/index.d.ts +8 -8
  150. package/dist/h3/index.js +19 -21
  151. package/dist/h3/index.js.map +1 -1
  152. package/dist/h3/middleware.cjs +148 -196
  153. package/dist/h3/middleware.cjs.map +1 -1
  154. package/dist/h3/middleware.d.cts +5 -5
  155. package/dist/h3/middleware.d.ts +5 -5
  156. package/dist/h3/middleware.js +143 -176
  157. package/dist/h3/middleware.js.map +1 -1
  158. package/dist/h3/routes.cjs +35 -59
  159. package/dist/h3/routes.cjs.map +1 -1
  160. package/dist/h3/routes.d.cts +7 -8
  161. package/dist/h3/routes.d.ts +7 -8
  162. package/dist/h3/routes.js +32 -33
  163. package/dist/h3/routes.js.map +1 -1
  164. package/dist/hapi/index.cjs +14 -37
  165. package/dist/hapi/index.cjs.map +1 -1
  166. package/dist/hapi/index.d.cts +8 -8
  167. package/dist/hapi/index.d.ts +8 -8
  168. package/dist/hapi/index.js +11 -11
  169. package/dist/hapi/index.js.map +1 -1
  170. package/dist/hapi/install.cjs +19 -43
  171. package/dist/hapi/install.cjs.map +1 -1
  172. package/dist/hapi/install.d.cts +6 -7
  173. package/dist/hapi/install.d.ts +6 -7
  174. package/dist/hapi/install.js +16 -17
  175. package/dist/hapi/install.js.map +1 -1
  176. package/dist/hapi/middleware.cjs +107 -146
  177. package/dist/hapi/middleware.cjs.map +1 -1
  178. package/dist/hapi/middleware.d.cts +5 -5
  179. package/dist/hapi/middleware.d.ts +5 -5
  180. package/dist/hapi/middleware.js +102 -121
  181. package/dist/hapi/middleware.js.map +1 -1
  182. package/dist/hapi/routes.cjs +11 -32
  183. package/dist/hapi/routes.cjs.map +1 -1
  184. package/dist/hapi/routes.d.cts +7 -8
  185. package/dist/hapi/routes.d.ts +7 -8
  186. package/dist/hapi/routes.js +9 -7
  187. package/dist/hapi/routes.js.map +1 -1
  188. package/dist/hono/index.cjs +16 -38
  189. package/dist/hono/index.cjs.map +1 -1
  190. package/dist/hono/index.d.cts +7 -7
  191. package/dist/hono/index.d.ts +7 -7
  192. package/dist/hono/index.js +13 -12
  193. package/dist/hono/index.js.map +1 -1
  194. package/dist/hono/middleware.cjs +169 -219
  195. package/dist/hono/middleware.cjs.map +1 -1
  196. package/dist/hono/middleware.d.cts +5 -5
  197. package/dist/hono/middleware.d.ts +5 -5
  198. package/dist/hono/middleware.js +164 -198
  199. package/dist/hono/middleware.js.map +1 -1
  200. package/dist/hono/routes.cjs +33 -64
  201. package/dist/hono/routes.cjs.map +1 -1
  202. package/dist/hono/routes.d.cts +7 -8
  203. package/dist/hono/routes.d.ts +7 -8
  204. package/dist/hono/routes.js +30 -38
  205. package/dist/hono/routes.js.map +1 -1
  206. package/dist/index.cjs +51 -91
  207. package/dist/index.cjs.map +1 -1
  208. package/dist/index.d.cts +13 -28
  209. package/dist/index.d.ts +13 -28
  210. package/dist/index.js +39 -56
  211. package/dist/index.js.map +1 -1
  212. package/dist/koa/index.cjs +16 -38
  213. package/dist/koa/index.cjs.map +1 -1
  214. package/dist/koa/index.d.cts +6 -7
  215. package/dist/koa/index.d.ts +6 -7
  216. package/dist/koa/index.js +13 -12
  217. package/dist/koa/index.js.map +1 -1
  218. package/dist/koa/middleware.cjs +81 -103
  219. package/dist/koa/middleware.cjs.map +1 -1
  220. package/dist/koa/middleware.d.cts +5 -5
  221. package/dist/koa/middleware.d.ts +5 -5
  222. package/dist/koa/middleware.js +76 -79
  223. package/dist/koa/middleware.js.map +1 -1
  224. package/dist/koa/routes.cjs +34 -64
  225. package/dist/koa/routes.cjs.map +1 -1
  226. package/dist/koa/routes.d.cts +7 -8
  227. package/dist/koa/routes.d.ts +7 -8
  228. package/dist/koa/routes.js +31 -38
  229. package/dist/koa/routes.js.map +1 -1
  230. package/dist/logCapture.cjs +293 -374
  231. package/dist/logCapture.cjs.map +1 -1
  232. package/dist/logCapture.d.cts +17 -15
  233. package/dist/logCapture.d.ts +17 -15
  234. package/dist/logCapture.js +285 -345
  235. package/dist/logCapture.js.map +1 -1
  236. package/dist/logRecordExporter.cjs +21 -81
  237. package/dist/logRecordExporter.cjs.map +1 -1
  238. package/dist/logRecordExporter.d.cts +12 -13
  239. package/dist/logRecordExporter.d.ts +12 -13
  240. package/dist/logRecordExporter.js +19 -56
  241. package/dist/logRecordExporter.js.map +1 -1
  242. package/dist/logRecordProcessor.cjs +82 -115
  243. package/dist/logRecordProcessor.cjs.map +1 -1
  244. package/dist/logRecordProcessor.d.cts +22 -22
  245. package/dist/logRecordProcessor.d.ts +22 -22
  246. package/dist/logRecordProcessor.js +80 -90
  247. package/dist/logRecordProcessor.js.map +1 -1
  248. package/dist/logger.cjs +17 -48
  249. package/dist/logger.cjs.map +1 -1
  250. package/dist/logger.d.cts +8 -7
  251. package/dist/logger.d.ts +8 -7
  252. package/dist/logger.js +12 -20
  253. package/dist/logger.js.map +1 -1
  254. package/dist/metrics.cjs +78 -168
  255. package/dist/metrics.cjs.map +1 -1
  256. package/dist/metrics.d.cts +20 -23
  257. package/dist/metrics.d.ts +20 -23
  258. package/dist/metrics.js +77 -150
  259. package/dist/metrics.js.map +1 -1
  260. package/dist/nestjs/index.cjs +63 -88
  261. package/dist/nestjs/index.cjs.map +1 -1
  262. package/dist/nestjs/index.d.cts +7 -7
  263. package/dist/nestjs/index.d.ts +7 -7
  264. package/dist/nestjs/index.js +59 -61
  265. package/dist/nestjs/index.js.map +1 -1
  266. package/dist/packageVersion.cjs +28 -59
  267. package/dist/packageVersion.cjs.map +1 -1
  268. package/dist/packageVersion.d.cts +6 -5
  269. package/dist/packageVersion.d.ts +6 -5
  270. package/dist/packageVersion.js +23 -29
  271. package/dist/packageVersion.js.map +1 -1
  272. package/dist/providers.cjs +77 -137
  273. package/dist/providers.cjs.map +1 -1
  274. package/dist/providers.d.cts +14 -14
  275. package/dist/providers.d.ts +14 -14
  276. package/dist/providers.js +70 -121
  277. package/dist/providers.js.map +1 -1
  278. package/dist/redaction.cjs +63 -112
  279. package/dist/redaction.cjs.map +1 -1
  280. package/dist/redaction.d.cts +17 -16
  281. package/dist/redaction.d.ts +17 -16
  282. package/dist/redaction.js +60 -93
  283. package/dist/redaction.js.map +1 -1
  284. package/dist/requestAttributes.cjs +15 -42
  285. package/dist/requestAttributes.cjs.map +1 -1
  286. package/dist/requestAttributes.d.cts +7 -8
  287. package/dist/requestAttributes.d.ts +7 -8
  288. package/dist/requestAttributes.js +12 -16
  289. package/dist/requestAttributes.js.map +1 -1
  290. package/dist/requestObservation.cjs +153 -211
  291. package/dist/requestObservation.cjs.map +1 -1
  292. package/dist/requestObservation.d.cts +53 -53
  293. package/dist/requestObservation.d.ts +53 -53
  294. package/dist/requestObservation.js +147 -189
  295. package/dist/requestObservation.js.map +1 -1
  296. package/dist/requestObservationNode.cjs +136 -181
  297. package/dist/requestObservationNode.cjs.map +1 -1
  298. package/dist/requestObservationNode.d.cts +23 -25
  299. package/dist/requestObservationNode.d.ts +23 -25
  300. package/dist/requestObservationNode.js +132 -157
  301. package/dist/requestObservationNode.js.map +1 -1
  302. package/dist/requestObservationWeb.cjs +151 -188
  303. package/dist/requestObservationWeb.cjs.map +1 -1
  304. package/dist/requestObservationWeb.d.cts +25 -27
  305. package/dist/requestObservationWeb.d.ts +25 -27
  306. package/dist/requestObservationWeb.js +146 -167
  307. package/dist/requestObservationWeb.js.map +1 -1
  308. package/dist/sentry.cjs +52 -92
  309. package/dist/sentry.cjs.map +1 -1
  310. package/dist/sentry.d.cts +4 -3
  311. package/dist/sentry.d.ts +4 -3
  312. package/dist/sentry.js +48 -65
  313. package/dist/sentry.js.map +1 -1
  314. package/dist/serverErrors.cjs +83 -0
  315. package/dist/serverErrors.cjs.map +1 -0
  316. package/dist/serverErrors.d.cts +8 -0
  317. package/dist/serverErrors.d.ts +8 -0
  318. package/dist/serverErrors.js +79 -0
  319. package/dist/serverErrors.js.map +1 -0
  320. package/dist/spanExporter.cjs +159 -211
  321. package/dist/spanExporter.cjs.map +1 -1
  322. package/dist/spanExporter.d.cts +32 -31
  323. package/dist/spanExporter.d.ts +32 -31
  324. package/dist/spanExporter.js +155 -184
  325. package/dist/spanExporter.js.map +1 -1
  326. package/dist/spanProcessor.cjs +387 -490
  327. package/dist/spanProcessor.cjs.map +1 -1
  328. package/dist/spanProcessor.d.cts +63 -62
  329. package/dist/spanProcessor.d.ts +63 -62
  330. package/dist/spanProcessor.js +376 -465
  331. package/dist/spanProcessor.js.map +1 -1
  332. package/dist/spool.cjs +239 -304
  333. package/dist/spool.cjs.map +1 -1
  334. package/dist/spool.d.cts +46 -46
  335. package/dist/spool.d.ts +46 -46
  336. package/dist/spool.js +235 -285
  337. package/dist/spool.js.map +1 -1
  338. package/dist/startup.cjs +63 -83
  339. package/dist/startup.cjs.map +1 -1
  340. package/dist/startup.d.cts +13 -13
  341. package/dist/startup.d.ts +13 -13
  342. package/dist/startup.js +60 -57
  343. package/dist/startup.js.map +1 -1
  344. package/dist/tracing.cjs +72 -100
  345. package/dist/tracing.cjs.map +1 -1
  346. package/dist/tracing.d.cts +6 -5
  347. package/dist/tracing.d.ts +6 -5
  348. package/dist/tracing.js +69 -79
  349. package/dist/tracing.js.map +1 -1
  350. package/dist/validationErrors.cjs +161 -0
  351. package/dist/validationErrors.cjs.map +1 -0
  352. package/dist/validationErrors.d.cts +21 -0
  353. package/dist/validationErrors.d.ts +21 -0
  354. package/dist/validationErrors.js +150 -0
  355. package/dist/validationErrors.js.map +1 -0
  356. package/package.json +26 -26
  357. package/dist/logRecordTruncation.cjs +0 -32
  358. package/dist/logRecordTruncation.cjs.map +0 -1
  359. package/dist/logRecordTruncation.d.cts +0 -6
  360. package/dist/logRecordTruncation.d.ts +0 -6
  361. package/dist/logRecordTruncation.js +0 -8
  362. package/dist/logRecordTruncation.js.map +0 -1
package/README.md CHANGED
@@ -25,33 +25,40 @@
25
25
  [![Codecov](https://codecov.io/gh/apitally/apitally-js/graph/badge.svg?token=j5jqlrL7Pd)](https://codecov.io/gh/apitally/apitally-js)
26
26
  [![npm](https://img.shields.io/npm/v/apitally?logo=npm&color=%23cb0000)](https://www.npmjs.com/package/apitally)
27
27
 
28
- API monitoring, analytics and request logging for [AdonisJS](https://github.com/adonisjs/core), [Elysia](https://github.com/elysiajs/elysia), [Express](https://github.com/expressjs/express), [Fastify](https://github.com/fastify/fastify), [H3](https://github.com/h3js/h3), [Hapi](https://github.com/hapijs/hapi), [Hono](https://github.com/honojs/hono), [Koa](https://github.com/koajs/koa) and [NestJS](https://github.com/nestjs/nest), built on OpenTelemetry. One line of setup instruments your app and streams traces, logs and metrics to Apitally. No OpenTelemetry knowledge, infrastructure changes or dashboards are required.
28
+ Apitally is a simple API monitoring and analytics tool that makes it easy to understand API usage, monitor performance, and troubleshoot issues.
29
+ Get started in minutes by just adding a few lines of code. No infrastructure changes required, no dashboards to build.
30
+
31
+ The SDK is an [OpenTelemetry](https://opentelemetry.io) distribution and works alongside an existing OpenTelemetry setup.
29
32
 
30
33
  Learn more about Apitally on our 🌎 [website](https://apitally.io) or check out the 📚 [documentation](https://docs.apitally.io).
31
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.
37
+
32
38
  ## Key features
33
39
 
34
- - **API analytics**: Traffic, error and performance metrics for your API, each endpoint, and individual API consumers.
35
- - **Request logging**: Every request as a searchable log entry, with optional capture of headers and request/response bodies.
36
- - **Application logs**: Logs written via `console`, winston, pino, Hapi's `request.log()` or Nest's default `ConsoleLogger` are captured automatically and correlated with the request they belong to.
37
- - **Distributed tracing**: Requests are exported as OpenTelemetry spans, including spans from any other instrumentations you run.
38
- - **Error tracking**: Exceptions with stack traces for server errors, automatically linked to Sentry events if you use Sentry.
39
- - **Server metrics**: CPU, memory and uptime of your app's processes.
40
- - **Data privacy built in**: Sensitive headers and query parameters are masked by default, with configurable masking for anything else, plus sampling to control data volume.
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.
41
46
 
42
47
  ## Supported frameworks
43
48
 
49
+ The SDK supports **Node.js** `>= 20.6` and **Bun** `>= 1.2.0`.
50
+
44
51
  | Framework | Supported versions | Setup guide |
45
52
  | --- | --- | --- |
46
- | [**AdonisJS**](https://github.com/adonisjs/core) | `>= 6.3`, `< 8` | [Link](https://docs.apitally.io/setup-guides/adonisjs) |
47
- | [**Elysia**](https://github.com/elysiajs/elysia) | `>= 1.1`, `< 2` | [Link](https://docs.apitally.io/setup-guides/elysia) |
48
- | [**Express**](https://github.com/expressjs/express) | `>= 4.18.2`, `< 6` | [Link](https://docs.apitally.io/setup-guides/express) |
49
- | [**Fastify**](https://github.com/fastify/fastify) | `>= 4.10.2`, `< 6` | [Link](https://docs.apitally.io/setup-guides/fastify) |
50
- | [**H3**](https://github.com/h3js/h3) \* | `>= 2.0.1-rc.26`, `< 3` | [Link](https://docs.apitally.io/setup-guides/h3) |
51
- | [**Hapi**](https://github.com/hapijs/hapi) | `21.x` | [Link](https://docs.apitally.io/setup-guides/hapi) |
52
- | [**Hono**](https://github.com/honojs/hono) \* | `>= 4.8.4`, `< 5` | [Link](https://docs.apitally.io/setup-guides/hono) |
53
- | [**Koa**](https://github.com/koajs/koa) | `2.x`, `3.x` | [Link](https://docs.apitally.io/setup-guides/koa) |
54
- | [**NestJS**](https://github.com/nestjs/nest) | `10.x`, `11.x` | [Link](https://docs.apitally.io/setup-guides/nestjs) |
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) |
55
62
 
56
63
  \* For Hono on Cloudflare Workers use our [Serverless SDK](https://github.com/apitally/apitally-js-serverless) instead.
57
64
 
@@ -59,15 +66,15 @@ Apitally also supports many other web frameworks in [Python](https://github.com/
59
66
 
60
67
  ## Getting started
61
68
 
62
- 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, including your write token.
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.
63
70
 
64
- Install the SDK. AdonisJS applications should use the Ace command in the next section instead.
71
+ To install the SDK as a dependency in your project run:
65
72
 
66
73
  ```bash
67
74
  npm install apitally
68
75
  ```
69
76
 
70
- Pass the write token via the `writeToken` option, or set the `APITALLY_WRITE_TOKEN` environment variable. 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.
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.
71
78
 
72
79
  ### AdonisJS
73
80
 
@@ -77,19 +84,11 @@ Run the Ace add command from your application directory:
77
84
  node ace add apitally
78
85
  ```
79
86
 
80
- 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 report unhandled 5xx errors.
81
-
82
- If Apitally is already installed, or to rerun setup, use:
83
-
84
- ```bash
85
- node ace configure apitally
86
- ```
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.
87
88
 
88
- Request headers, request bodies, and response bodies are opt-in prompts during setup. Response headers are enabled by default. You can change these settings later in `config/apitally.ts`.
89
+ If needed, you can change settings in `config/apitally.ts`.
89
90
 
90
- The SDK-wide environment default is `dev`. `APITALLY_ENV` is deployment-specific, so set it appropriately for staging and production.
91
-
92
- For further instructions, see our [setup guide for AdonisJS](https://docs.apitally.io/setup-guides/adonisjs).
91
+ For further instructions, see our [setup guide for AdonisJS](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/adonisjs).
93
92
 
94
93
  ### Elysia
95
94
 
@@ -110,7 +109,7 @@ const app = new Elysia()
110
109
  .get("/items/:id", ({ params }) => ({ id: params.id }));
111
110
  ```
112
111
 
113
- For further instructions, see our [setup guide for Elysia](https://docs.apitally.io/setup-guides/elysia).
112
+ For further instructions, see our [setup guide for Elysia](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/elysia).
114
113
 
115
114
  ### Express
116
115
 
@@ -126,13 +125,11 @@ const app = express();
126
125
 
127
126
  useApitally(app, {
128
127
  writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
129
- env: "dev", // optional, defaults to "dev"
128
+ env: "dev", // or "prod" etc.
130
129
  });
131
130
  ```
132
131
 
133
- The register import ensures routes are captured no matter where they are registered — including routers assembled at module scope. It's one rule for every app shape: first line of your entry module.
134
-
135
- For further instructions, see our [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).
136
133
 
137
134
  ### Fastify
138
135
 
@@ -146,17 +143,17 @@ const app = Fastify();
146
143
 
147
144
  useApitally(app, {
148
145
  writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
149
- env: "dev", // optional, defaults to "dev"
146
+ env: "dev", // or "prod" etc.
150
147
  });
151
148
 
152
149
  // register plugins and routes below this point
153
150
  ```
154
151
 
155
- For further instructions, see our [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).
156
153
 
157
154
  ### NestJS
158
155
 
159
- Call the synchronous `useApitally(app)` immediately after creating the Nest application, before `app.init()` or `app.listen()`:
156
+ Call `useApitally(app)` immediately after creating the Nest application, before `app.init()` or `app.listen()`:
160
157
 
161
158
  ```javascript
162
159
  import { NestFactory } from "@nestjs/core";
@@ -167,13 +164,13 @@ const app = await NestFactory.create(AppModule);
167
164
 
168
165
  useApitally(app, {
169
166
  writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
170
- env: "dev", // optional, defaults to "dev"
167
+ env: "dev", // or "prod" etc.
171
168
  });
172
169
 
173
170
  await app.listen(3000);
174
171
  ```
175
172
 
176
- For further instructions, see our [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).
177
174
 
178
175
  ### H3
179
176
 
@@ -187,13 +184,13 @@ const app = new H3({
187
184
  plugins: [
188
185
  apitallyPlugin({
189
186
  writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
190
- env: "dev", // optional, defaults to "dev"
187
+ env: "dev", // or "prod" etc.
191
188
  }),
192
189
  ],
193
190
  });
194
191
  ```
195
192
 
196
- For further instructions, see our [setup guide for H3](https://docs.apitally.io/setup-guides/h3).
193
+ For further instructions, see our [setup guide for H3](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/h3).
197
194
 
198
195
  ### Hapi
199
196
 
@@ -208,7 +205,7 @@ const server = Hapi.server({ port: 3000 });
208
205
  await server.register(
209
206
  apitallyPlugin({
210
207
  writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
211
- env: "dev", // optional, defaults to "dev"
208
+ env: "dev", // or "prod" etc.
212
209
  }),
213
210
  );
214
211
 
@@ -216,11 +213,11 @@ await server.register(
216
213
  await server.start();
217
214
  ```
218
215
 
219
- For further instructions, see our [setup guide for Hapi](https://docs.apitally.io/setup-guides/hapi).
216
+ For further instructions, see our [setup guide for Hapi](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/hapi).
220
217
 
221
218
  ### Hono
222
219
 
223
- Call `useApitally(app)` immediately after creating the app — before registering middleware and routes, and before `app.fetch` is handed to the server:
220
+ Call `useApitally(app)` immediately after creating the app, before registering middleware and routes:
224
221
 
225
222
  ```javascript
226
223
  import { Hono } from "hono";
@@ -230,13 +227,13 @@ const app = new Hono();
230
227
 
231
228
  useApitally(app, {
232
229
  writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
233
- env: "dev", // optional, defaults to "dev"
230
+ env: "dev", // or "prod" etc.
234
231
  });
235
232
 
236
233
  // register middleware and routes below this point
237
234
  ```
238
235
 
239
- For further instructions, see our [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).
240
237
 
241
238
  ### Koa
242
239
 
@@ -250,36 +247,64 @@ const app = new Koa();
250
247
 
251
248
  useApitally(app, {
252
249
  writeToken: "your-write-token", // or set APITALLY_WRITE_TOKEN
253
- env: "dev", // optional, defaults to "dev"
250
+ env: "dev", // or "prod" etc.
254
251
  });
255
252
 
256
253
  // register middleware and routes below this point
257
254
  ```
258
255
 
259
- For further instructions, see our [setup guide for Koa](https://docs.apitally.io/setup-guides/koa).
260
-
261
- ## Trusted proxies
256
+ For further instructions, see our [setup guide for Koa](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/koa).
262
257
 
263
- When your application runs behind a reverse proxy, configure the framework's trusted-proxy setting so Apitally can record the client IP for GeoIP. The SDK uses the client address resolved by Express, Fastify, Koa, AdonisJS, or the corresponding NestJS adapter. It does not trust forwarding headers directly.
258
+ ## Configuration
264
259
 
265
- ## Using Sentry
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`.
266
261
 
267
- Sentry's Node.js SDK registers an OpenTelemetry tracer provider by default. If you use Sentry for error monitoring without performance tracing, let Apitally configure OpenTelemetry by disabling Sentry's setup:
262
+ By default, Apitally captures response headers but not request headers or request and response bodies. You can opt in with options:
268
263
 
269
264
  ```javascript
270
- Sentry.init({
271
- dsn: "your-sentry-dsn",
272
- skipOpenTelemetrySetup: true,
265
+ useApitally(app, {
266
+ writeToken: "your-write-token",
267
+ env: "dev",
268
+ captureRequestHeaders: true,
269
+ captureRequestBody: true,
270
+ captureResponseBody: true,
273
271
  });
274
272
  ```
275
273
 
276
- This keeps Sentry error reporting and Apitally's request logs and traces working together. If you use Sentry performance tracing, configure a shared OpenTelemetry provider and include `ApitallySpanProcessor` as described below.
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.
275
+
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.
277
+
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`.
279
+
280
+ See the [SDK reference](https://docs.apitally.io/sdk-reference/javascript/v1/configuration) for all configuration options.
281
+
282
+ ## Identifying consumers and more
283
+
284
+ The top-level `apitally` package provides functions you can call from anywhere in your request handling code:
285
+
286
+ ```javascript
287
+ import { setConsumer, setRequestAttribute, captureException } from "apitally";
288
+
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);
297
+ ```
298
+
299
+ `setConsumer()` also accepts an identifier string, for example `setConsumer(user.identifier)`.
300
+
301
+ For further details, check out our [documentation](https://docs.apitally.io).
277
302
 
278
- ## Works with your existing OpenTelemetry setup
303
+ ## Existing OpenTelemetry setup
279
304
 
280
- If your app doesn't use OpenTelemetry, you don't need to know it's there — the SDK sets up a private, fully configured pipeline.
305
+ If your app doesn't already use OpenTelemetry, you don't need to know it's there. The Apitally SDK configures OpenTelemetry automatically.
281
306
 
282
- If your app already registers its own tracer provider (e.g. via `NodeSDK`), Apitally never replaces it. Instead, add the `ApitallySpanProcessor` to your provider's span processors:
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:
283
308
 
284
309
  ```javascript
285
310
  import { NodeSDK } from "@opentelemetry/sdk-node";
@@ -291,7 +316,32 @@ const sdk = new NodeSDK({
291
316
  });
292
317
  ```
293
318
 
294
- Your existing exporters keep seeing everything they already see: Apitally adopts the spans your instrumentation produces instead of creating duplicates, and its meter and logger providers stay private, so nothing leaks into your own pipelines.
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.
320
+
321
+ ### Sentry
322
+
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()`:
324
+
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
+ });
338
+ ```
339
+
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
295
345
 
296
346
  When using Elysia's `@elysia/opentelemetry` plugin, register Apitally first so it adopts the OpenTelemetry SERVER span:
297
347
 
@@ -305,31 +355,24 @@ const app = new Elysia()
305
355
  .use(opentelemetry());
306
356
  ```
307
357
 
308
- ## Graceful shutdown
358
+ ## Trusted proxies
309
359
 
310
- Telemetry is exported in the background roughly every 15 seconds. After successful activation, Apitally installs `SIGTERM` and `SIGINT` listeners by default on supported POSIX main-thread processes. There is no opt-out, and the fixed five-second timeout is not configurable.
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.
311
361
 
312
- On either signal, Apitally makes a non-destructive best-effort final drain of completed telemetry for up to five seconds. If another listener exists for that signal, that listener retains application lifecycle ownership. It must eventually terminate the process or allow it to drain naturally. If Apitally is the sole listener, it removes its listeners before draining and then restores the signal's original termination behavior. A repeated signal is therefore not delayed by another Apitally drain.
362
+ ## Graceful shutdown
363
+
364
+ Apitally sends telemetry in batches and automatically attempts a final export during normal process shutdown.
313
365
 
314
- Use the `shutdown()` function for the coordinated full teardown path. Stop traffic and wait for in-flight work before awaiting it:
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:
315
367
 
316
368
  ```javascript
317
369
  import { shutdown } from "apitally";
318
370
 
319
- process.on("SIGTERM", () => {
320
- server.close(async () => {
321
- await shutdown();
322
- });
323
- });
371
+ // After the server has closed and requests have finished:
372
+ await shutdown();
373
+ process.exit(0);
324
374
  ```
325
375
 
326
- ## Runtime support
327
-
328
- - **Node.js** `>= 20.6`
329
- - **Bun** is supported for Elysia, H3 and Hono apps
330
-
331
- For edge and serverless runtimes like Cloudflare Workers, use our [Serverless SDK](https://github.com/apitally/apitally-js-serverless) instead.
332
-
333
376
  ## Getting help
334
377
 
335
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.