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.
- package/README.md +122 -79
- package/dist/activation.cjs +262 -322
- package/dist/activation.cjs.map +1 -1
- package/dist/activation.d.cts +30 -38
- package/dist/activation.d.ts +30 -38
- package/dist/activation.js +244 -299
- package/dist/activation.js.map +1 -1
- package/dist/adonisjs/configure.cjs +72 -128
- package/dist/adonisjs/configure.cjs.map +1 -1
- package/dist/adonisjs/configure.d.cts +5 -5
- package/dist/adonisjs/configure.d.ts +5 -5
- package/dist/adonisjs/configure.js +70 -100
- package/dist/adonisjs/configure.js.map +1 -1
- package/dist/adonisjs/index.cjs +33 -28
- package/dist/adonisjs/index.cjs.map +1 -1
- package/dist/adonisjs/index.d.cts +8 -6
- package/dist/adonisjs/index.d.ts +8 -6
- package/dist/adonisjs/index.js +31 -4
- package/dist/adonisjs/index.js.map +1 -1
- package/dist/adonisjs/middleware.cjs +48 -67
- package/dist/adonisjs/middleware.cjs.map +1 -1
- package/dist/adonisjs/middleware.d.cts +7 -7
- package/dist/adonisjs/middleware.d.ts +7 -7
- package/dist/adonisjs/middleware.js +41 -44
- package/dist/adonisjs/middleware.js.map +1 -1
- package/dist/adonisjs/provider.cjs +35 -51
- package/dist/adonisjs/provider.cjs.map +1 -1
- package/dist/adonisjs/provider.d.cts +10 -10
- package/dist/adonisjs/provider.d.ts +10 -10
- package/dist/adonisjs/provider.js +31 -31
- package/dist/adonisjs/provider.js.map +1 -1
- package/dist/bodyCapture.cjs +91 -117
- package/dist/bodyCapture.cjs.map +1 -1
- package/dist/bodyCapture.d.cts +32 -27
- package/dist/bodyCapture.d.ts +32 -27
- package/dist/bodyCapture.js +86 -90
- package/dist/bodyCapture.js.map +1 -1
- package/dist/config.cjs +150 -177
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +42 -40
- package/dist/config.d.ts +42 -40
- package/dist/config.js +138 -141
- package/dist/config.js.map +1 -1
- package/dist/consumer.cjs +47 -84
- package/dist/consumer.cjs.map +1 -1
- package/dist/consumer.d.cts +11 -12
- package/dist/consumer.d.ts +11 -12
- package/dist/consumer.js +43 -62
- package/dist/consumer.js.map +1 -1
- package/dist/context.cjs +29 -60
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +29 -26
- package/dist/context.d.ts +29 -26
- package/dist/context.js +15 -26
- package/dist/context.js.map +1 -1
- package/dist/elysia/index.cjs +10 -33
- package/dist/elysia/index.cjs.map +1 -1
- package/dist/elysia/index.d.cts +8 -8
- package/dist/elysia/index.d.ts +8 -8
- package/dist/elysia/index.js +7 -7
- package/dist/elysia/index.js.map +1 -1
- package/dist/elysia/middleware.cjs +174 -233
- package/dist/elysia/middleware.cjs.map +1 -1
- package/dist/elysia/middleware.d.cts +10 -11
- package/dist/elysia/middleware.d.ts +10 -11
- package/dist/elysia/middleware.js +169 -219
- package/dist/elysia/middleware.js.map +1 -1
- package/dist/elysia/routes.cjs +11 -34
- package/dist/elysia/routes.cjs.map +1 -1
- package/dist/elysia/routes.d.cts +6 -7
- package/dist/elysia/routes.d.ts +6 -7
- package/dist/elysia/routes.js +10 -10
- package/dist/elysia/routes.js.map +1 -1
- package/dist/exceptions.cjs +33 -68
- package/dist/exceptions.cjs.map +1 -1
- package/dist/exceptions.d.cts +7 -7
- package/dist/exceptions.d.ts +7 -7
- package/dist/exceptions.js +29 -41
- package/dist/exceptions.js.map +1 -1
- package/dist/exportSerialization.cjs +26 -50
- package/dist/exportSerialization.cjs.map +1 -1
- package/dist/exportSerialization.d.cts +6 -7
- package/dist/exportSerialization.d.ts +6 -7
- package/dist/exportSerialization.js +24 -25
- package/dist/exportSerialization.js.map +1 -1
- package/dist/exportWorker.cjs +219 -292
- package/dist/exportWorker.cjs.map +1 -1
- package/dist/exportWorker.d.cts +43 -44
- package/dist/exportWorker.d.ts +43 -44
- package/dist/exportWorker.js +215 -263
- package/dist/exportWorker.js.map +1 -1
- package/dist/express/index.cjs +11 -33
- package/dist/express/index.cjs.map +1 -1
- package/dist/express/index.d.cts +7 -7
- package/dist/express/index.d.ts +7 -7
- package/dist/express/index.js +8 -7
- package/dist/express/index.js.map +1 -1
- package/dist/express/install.cjs +20 -42
- package/dist/express/install.cjs.map +1 -1
- package/dist/express/install.d.cts +7 -9
- package/dist/express/install.d.ts +7 -9
- package/dist/express/install.js +17 -16
- package/dist/express/install.js.map +1 -1
- package/dist/express/middleware.cjs +75 -109
- package/dist/express/middleware.cjs.map +1 -1
- package/dist/express/middleware.d.cts +5 -5
- package/dist/express/middleware.d.ts +5 -5
- package/dist/express/middleware.js +70 -85
- package/dist/express/middleware.js.map +1 -1
- package/dist/express/register.cjs +15 -14
- package/dist/express/register.cjs.map +1 -1
- package/dist/express/register.d.cts +1 -2
- package/dist/express/register.d.ts +1 -2
- package/dist/express/register.js +12 -10
- package/dist/express/register.js.map +1 -1
- package/dist/express/routes.cjs +264 -357
- package/dist/express/routes.cjs.map +1 -1
- package/dist/express/routes.d.cts +11 -12
- package/dist/express/routes.d.ts +11 -12
- package/dist/express/routes.js +258 -328
- package/dist/express/routes.js.map +1 -1
- package/dist/fastify/index.cjs +11 -33
- package/dist/fastify/index.cjs.map +1 -1
- package/dist/fastify/index.d.cts +7 -7
- package/dist/fastify/index.d.ts +7 -7
- package/dist/fastify/index.js +8 -7
- package/dist/fastify/index.js.map +1 -1
- package/dist/fastify/install.cjs +14 -36
- package/dist/fastify/install.cjs.map +1 -1
- package/dist/fastify/install.d.cts +7 -9
- package/dist/fastify/install.d.ts +7 -9
- package/dist/fastify/install.js +11 -10
- package/dist/fastify/install.js.map +1 -1
- package/dist/fastify/middleware.cjs +93 -114
- package/dist/fastify/middleware.cjs.map +1 -1
- package/dist/fastify/middleware.d.cts +6 -7
- package/dist/fastify/middleware.d.ts +6 -7
- package/dist/fastify/middleware.js +88 -89
- package/dist/fastify/middleware.js.map +1 -1
- package/dist/fastify/routes.cjs +12 -34
- package/dist/fastify/routes.cjs.map +1 -1
- package/dist/fastify/routes.d.cts +7 -8
- package/dist/fastify/routes.d.ts +7 -8
- package/dist/fastify/routes.js +10 -9
- package/dist/fastify/routes.js.map +1 -1
- package/dist/h3/index.cjs +23 -48
- package/dist/h3/index.cjs.map +1 -1
- package/dist/h3/index.d.cts +8 -8
- package/dist/h3/index.d.ts +8 -8
- package/dist/h3/index.js +19 -21
- package/dist/h3/index.js.map +1 -1
- package/dist/h3/middleware.cjs +148 -196
- package/dist/h3/middleware.cjs.map +1 -1
- package/dist/h3/middleware.d.cts +5 -5
- package/dist/h3/middleware.d.ts +5 -5
- package/dist/h3/middleware.js +143 -176
- package/dist/h3/middleware.js.map +1 -1
- package/dist/h3/routes.cjs +35 -59
- package/dist/h3/routes.cjs.map +1 -1
- package/dist/h3/routes.d.cts +7 -8
- package/dist/h3/routes.d.ts +7 -8
- package/dist/h3/routes.js +32 -33
- package/dist/h3/routes.js.map +1 -1
- package/dist/hapi/index.cjs +14 -37
- package/dist/hapi/index.cjs.map +1 -1
- package/dist/hapi/index.d.cts +8 -8
- package/dist/hapi/index.d.ts +8 -8
- package/dist/hapi/index.js +11 -11
- package/dist/hapi/index.js.map +1 -1
- package/dist/hapi/install.cjs +19 -43
- package/dist/hapi/install.cjs.map +1 -1
- package/dist/hapi/install.d.cts +6 -7
- package/dist/hapi/install.d.ts +6 -7
- package/dist/hapi/install.js +16 -17
- package/dist/hapi/install.js.map +1 -1
- package/dist/hapi/middleware.cjs +107 -146
- package/dist/hapi/middleware.cjs.map +1 -1
- package/dist/hapi/middleware.d.cts +5 -5
- package/dist/hapi/middleware.d.ts +5 -5
- package/dist/hapi/middleware.js +102 -121
- package/dist/hapi/middleware.js.map +1 -1
- package/dist/hapi/routes.cjs +11 -32
- package/dist/hapi/routes.cjs.map +1 -1
- package/dist/hapi/routes.d.cts +7 -8
- package/dist/hapi/routes.d.ts +7 -8
- package/dist/hapi/routes.js +9 -7
- package/dist/hapi/routes.js.map +1 -1
- package/dist/hono/index.cjs +16 -38
- package/dist/hono/index.cjs.map +1 -1
- package/dist/hono/index.d.cts +7 -7
- package/dist/hono/index.d.ts +7 -7
- package/dist/hono/index.js +13 -12
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/middleware.cjs +169 -219
- package/dist/hono/middleware.cjs.map +1 -1
- package/dist/hono/middleware.d.cts +5 -5
- package/dist/hono/middleware.d.ts +5 -5
- package/dist/hono/middleware.js +164 -198
- package/dist/hono/middleware.js.map +1 -1
- package/dist/hono/routes.cjs +33 -64
- package/dist/hono/routes.cjs.map +1 -1
- package/dist/hono/routes.d.cts +7 -8
- package/dist/hono/routes.d.ts +7 -8
- package/dist/hono/routes.js +30 -38
- package/dist/hono/routes.js.map +1 -1
- package/dist/index.cjs +51 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -28
- package/dist/index.d.ts +13 -28
- package/dist/index.js +39 -56
- package/dist/index.js.map +1 -1
- package/dist/koa/index.cjs +16 -38
- package/dist/koa/index.cjs.map +1 -1
- package/dist/koa/index.d.cts +6 -7
- package/dist/koa/index.d.ts +6 -7
- package/dist/koa/index.js +13 -12
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/middleware.cjs +81 -103
- package/dist/koa/middleware.cjs.map +1 -1
- package/dist/koa/middleware.d.cts +5 -5
- package/dist/koa/middleware.d.ts +5 -5
- package/dist/koa/middleware.js +76 -79
- package/dist/koa/middleware.js.map +1 -1
- package/dist/koa/routes.cjs +34 -64
- package/dist/koa/routes.cjs.map +1 -1
- package/dist/koa/routes.d.cts +7 -8
- package/dist/koa/routes.d.ts +7 -8
- package/dist/koa/routes.js +31 -38
- package/dist/koa/routes.js.map +1 -1
- package/dist/logCapture.cjs +293 -374
- package/dist/logCapture.cjs.map +1 -1
- package/dist/logCapture.d.cts +17 -15
- package/dist/logCapture.d.ts +17 -15
- package/dist/logCapture.js +285 -345
- package/dist/logCapture.js.map +1 -1
- package/dist/logRecordExporter.cjs +21 -81
- package/dist/logRecordExporter.cjs.map +1 -1
- package/dist/logRecordExporter.d.cts +12 -13
- package/dist/logRecordExporter.d.ts +12 -13
- package/dist/logRecordExporter.js +19 -56
- package/dist/logRecordExporter.js.map +1 -1
- package/dist/logRecordProcessor.cjs +82 -115
- package/dist/logRecordProcessor.cjs.map +1 -1
- package/dist/logRecordProcessor.d.cts +22 -22
- package/dist/logRecordProcessor.d.ts +22 -22
- package/dist/logRecordProcessor.js +80 -90
- package/dist/logRecordProcessor.js.map +1 -1
- package/dist/logger.cjs +17 -48
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +8 -7
- package/dist/logger.d.ts +8 -7
- package/dist/logger.js +12 -20
- package/dist/logger.js.map +1 -1
- package/dist/metrics.cjs +78 -168
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.d.cts +20 -23
- package/dist/metrics.d.ts +20 -23
- package/dist/metrics.js +77 -150
- package/dist/metrics.js.map +1 -1
- package/dist/nestjs/index.cjs +63 -88
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.d.cts +7 -7
- package/dist/nestjs/index.d.ts +7 -7
- package/dist/nestjs/index.js +59 -61
- package/dist/nestjs/index.js.map +1 -1
- package/dist/packageVersion.cjs +28 -59
- package/dist/packageVersion.cjs.map +1 -1
- package/dist/packageVersion.d.cts +6 -5
- package/dist/packageVersion.d.ts +6 -5
- package/dist/packageVersion.js +23 -29
- package/dist/packageVersion.js.map +1 -1
- package/dist/providers.cjs +77 -137
- package/dist/providers.cjs.map +1 -1
- package/dist/providers.d.cts +14 -14
- package/dist/providers.d.ts +14 -14
- package/dist/providers.js +70 -121
- package/dist/providers.js.map +1 -1
- package/dist/redaction.cjs +63 -112
- package/dist/redaction.cjs.map +1 -1
- package/dist/redaction.d.cts +17 -16
- package/dist/redaction.d.ts +17 -16
- package/dist/redaction.js +60 -93
- package/dist/redaction.js.map +1 -1
- package/dist/requestAttributes.cjs +15 -42
- package/dist/requestAttributes.cjs.map +1 -1
- package/dist/requestAttributes.d.cts +7 -8
- package/dist/requestAttributes.d.ts +7 -8
- package/dist/requestAttributes.js +12 -16
- package/dist/requestAttributes.js.map +1 -1
- package/dist/requestObservation.cjs +153 -211
- package/dist/requestObservation.cjs.map +1 -1
- package/dist/requestObservation.d.cts +53 -53
- package/dist/requestObservation.d.ts +53 -53
- package/dist/requestObservation.js +147 -189
- package/dist/requestObservation.js.map +1 -1
- package/dist/requestObservationNode.cjs +136 -181
- package/dist/requestObservationNode.cjs.map +1 -1
- package/dist/requestObservationNode.d.cts +23 -25
- package/dist/requestObservationNode.d.ts +23 -25
- package/dist/requestObservationNode.js +132 -157
- package/dist/requestObservationNode.js.map +1 -1
- package/dist/requestObservationWeb.cjs +151 -188
- package/dist/requestObservationWeb.cjs.map +1 -1
- package/dist/requestObservationWeb.d.cts +25 -27
- package/dist/requestObservationWeb.d.ts +25 -27
- package/dist/requestObservationWeb.js +146 -167
- package/dist/requestObservationWeb.js.map +1 -1
- package/dist/sentry.cjs +52 -92
- package/dist/sentry.cjs.map +1 -1
- package/dist/sentry.d.cts +4 -3
- package/dist/sentry.d.ts +4 -3
- package/dist/sentry.js +48 -65
- package/dist/sentry.js.map +1 -1
- package/dist/serverErrors.cjs +83 -0
- package/dist/serverErrors.cjs.map +1 -0
- package/dist/serverErrors.d.cts +8 -0
- package/dist/serverErrors.d.ts +8 -0
- package/dist/serverErrors.js +79 -0
- package/dist/serverErrors.js.map +1 -0
- package/dist/spanExporter.cjs +159 -211
- package/dist/spanExporter.cjs.map +1 -1
- package/dist/spanExporter.d.cts +32 -31
- package/dist/spanExporter.d.ts +32 -31
- package/dist/spanExporter.js +155 -184
- package/dist/spanExporter.js.map +1 -1
- package/dist/spanProcessor.cjs +387 -490
- package/dist/spanProcessor.cjs.map +1 -1
- package/dist/spanProcessor.d.cts +63 -62
- package/dist/spanProcessor.d.ts +63 -62
- package/dist/spanProcessor.js +376 -465
- package/dist/spanProcessor.js.map +1 -1
- package/dist/spool.cjs +239 -304
- package/dist/spool.cjs.map +1 -1
- package/dist/spool.d.cts +46 -46
- package/dist/spool.d.ts +46 -46
- package/dist/spool.js +235 -285
- package/dist/spool.js.map +1 -1
- package/dist/startup.cjs +63 -83
- package/dist/startup.cjs.map +1 -1
- package/dist/startup.d.cts +13 -13
- package/dist/startup.d.ts +13 -13
- package/dist/startup.js +60 -57
- package/dist/startup.js.map +1 -1
- package/dist/tracing.cjs +72 -100
- package/dist/tracing.cjs.map +1 -1
- package/dist/tracing.d.cts +6 -5
- package/dist/tracing.d.ts +6 -5
- package/dist/tracing.js +69 -79
- package/dist/tracing.js.map +1 -1
- package/dist/validationErrors.cjs +161 -0
- package/dist/validationErrors.cjs.map +1 -0
- package/dist/validationErrors.d.cts +21 -0
- package/dist/validationErrors.d.ts +21 -0
- package/dist/validationErrors.js +150 -0
- package/dist/validationErrors.js.map +1 -0
- package/package.json +26 -26
- package/dist/logRecordTruncation.cjs +0 -32
- package/dist/logRecordTruncation.cjs.map +0 -1
- package/dist/logRecordTruncation.d.cts +0 -6
- package/dist/logRecordTruncation.d.ts +0 -6
- package/dist/logRecordTruncation.js +0 -8
- package/dist/logRecordTruncation.js.map +0 -1
package/README.md
CHANGED
|
@@ -25,33 +25,40 @@
|
|
|
25
25
|
[](https://codecov.io/gh/apitally/apitally-js)
|
|
26
26
|
[](https://www.npmjs.com/package/apitally)
|
|
27
27
|
|
|
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
|
+
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
|
|
35
|
-
- **Request
|
|
36
|
-
- **Application logs**: Logs written via `console
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
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)
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
89
|
+
If needed, you can change settings in `config/apitally.ts`.
|
|
89
90
|
|
|
90
|
-
|
|
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", //
|
|
128
|
+
env: "dev", // or "prod" etc.
|
|
130
129
|
});
|
|
131
130
|
```
|
|
132
131
|
|
|
133
|
-
|
|
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", //
|
|
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
|
|
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", //
|
|
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", //
|
|
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", //
|
|
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
|
|
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", //
|
|
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", //
|
|
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
|
-
|
|
258
|
+
## Configuration
|
|
264
259
|
|
|
265
|
-
|
|
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
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
303
|
+
## Existing OpenTelemetry setup
|
|
279
304
|
|
|
280
|
-
If your app doesn't use OpenTelemetry, you don't need to know it's there
|
|
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
|
|
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
|
|
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
|
-
##
|
|
358
|
+
## Trusted proxies
|
|
309
359
|
|
|
310
|
-
|
|
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
|
-
|
|
362
|
+
## Graceful shutdown
|
|
363
|
+
|
|
364
|
+
Apitally sends telemetry in batches and automatically attempts a final export during normal process shutdown.
|
|
313
365
|
|
|
314
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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.
|