apitally 0.21.2 → 0.21.3

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 (77) hide show
  1. package/dist/adonisjs/provider.cjs +15 -9
  2. package/dist/adonisjs/provider.cjs.map +1 -1
  3. package/dist/adonisjs/provider.js +15 -9
  4. package/dist/adonisjs/provider.js.map +1 -1
  5. package/dist/common/client.cjs +14 -9
  6. package/dist/common/client.cjs.map +1 -1
  7. package/dist/common/client.d.cts +1 -1
  8. package/dist/common/client.d.ts +1 -1
  9. package/dist/common/client.js +14 -9
  10. package/dist/common/client.js.map +1 -1
  11. package/dist/common/response.cjs +21 -2
  12. package/dist/common/response.cjs.map +1 -1
  13. package/dist/common/response.d.cts +2 -1
  14. package/dist/common/response.d.ts +2 -1
  15. package/dist/common/response.js +19 -1
  16. package/dist/common/response.js.map +1 -1
  17. package/dist/elysia/index.cjs +40 -16
  18. package/dist/elysia/index.cjs.map +1 -1
  19. package/dist/elysia/index.js +40 -16
  20. package/dist/elysia/index.js.map +1 -1
  21. package/dist/elysia/plugin.cjs +40 -16
  22. package/dist/elysia/plugin.cjs.map +1 -1
  23. package/dist/elysia/plugin.js +40 -16
  24. package/dist/elysia/plugin.js.map +1 -1
  25. package/dist/express/index.cjs +15 -9
  26. package/dist/express/index.cjs.map +1 -1
  27. package/dist/express/index.js +15 -9
  28. package/dist/express/index.js.map +1 -1
  29. package/dist/express/middleware.cjs +15 -9
  30. package/dist/express/middleware.cjs.map +1 -1
  31. package/dist/express/middleware.js +15 -9
  32. package/dist/express/middleware.js.map +1 -1
  33. package/dist/fastify/index.cjs +15 -9
  34. package/dist/fastify/index.cjs.map +1 -1
  35. package/dist/fastify/index.js +15 -9
  36. package/dist/fastify/index.js.map +1 -1
  37. package/dist/fastify/plugin.cjs +15 -9
  38. package/dist/fastify/plugin.cjs.map +1 -1
  39. package/dist/fastify/plugin.js +15 -9
  40. package/dist/fastify/plugin.js.map +1 -1
  41. package/dist/h3/index.cjs +15 -9
  42. package/dist/h3/index.cjs.map +1 -1
  43. package/dist/h3/index.js +15 -9
  44. package/dist/h3/index.js.map +1 -1
  45. package/dist/h3/plugin.cjs +15 -9
  46. package/dist/h3/plugin.cjs.map +1 -1
  47. package/dist/h3/plugin.js +15 -9
  48. package/dist/h3/plugin.js.map +1 -1
  49. package/dist/hapi/index.cjs +15 -9
  50. package/dist/hapi/index.cjs.map +1 -1
  51. package/dist/hapi/index.js +15 -9
  52. package/dist/hapi/index.js.map +1 -1
  53. package/dist/hapi/plugin.cjs +15 -9
  54. package/dist/hapi/plugin.cjs.map +1 -1
  55. package/dist/hapi/plugin.js +15 -9
  56. package/dist/hapi/plugin.js.map +1 -1
  57. package/dist/hono/index.cjs +15 -9
  58. package/dist/hono/index.cjs.map +1 -1
  59. package/dist/hono/index.js +15 -9
  60. package/dist/hono/index.js.map +1 -1
  61. package/dist/hono/middleware.cjs +15 -9
  62. package/dist/hono/middleware.cjs.map +1 -1
  63. package/dist/hono/middleware.js +15 -9
  64. package/dist/hono/middleware.js.map +1 -1
  65. package/dist/koa/index.cjs +15 -9
  66. package/dist/koa/index.cjs.map +1 -1
  67. package/dist/koa/index.js +15 -9
  68. package/dist/koa/index.js.map +1 -1
  69. package/dist/koa/middleware.cjs +15 -9
  70. package/dist/koa/middleware.cjs.map +1 -1
  71. package/dist/koa/middleware.js +15 -9
  72. package/dist/koa/middleware.js.map +1 -1
  73. package/dist/nestjs/index.cjs +16 -9
  74. package/dist/nestjs/index.cjs.map +1 -1
  75. package/dist/nestjs/index.js +16 -9
  76. package/dist/nestjs/index.js.map +1 -1
  77. package/package.json +1 -1
@@ -5261,11 +5261,14 @@ var _ApitallyClient = class _ApitallyClient {
5261
5261
  if (_ApitallyClient.instance) {
5262
5262
  throw new Error("Apitally client is already initialized");
5263
5263
  }
5264
+ this.logger = logger ?? getLogger();
5264
5265
  if (!isValidClientId(clientId)) {
5265
- throw new Error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
5266
+ this.logger.error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
5267
+ this.enabled = false;
5266
5268
  }
5267
5269
  if (!isValidEnv(env)) {
5268
- throw new Error(`Invalid env '${env}' (expecting 1-32 alphanumeric lowercase characters and hyphens only)`);
5270
+ this.logger.error(`Invalid Apitally env '${env}' (expecting 1-32 alphanumeric characters and hyphens only)`);
5271
+ this.enabled = false;
5269
5272
  }
5270
5273
  if (requestLoggingConfig && !requestLogging) {
5271
5274
  console.warn("requestLoggingConfig is deprecated, use requestLogging instead.");
@@ -5280,8 +5283,6 @@ var _ApitallyClient = class _ApitallyClient {
5280
5283
  this.validationErrorCounter = new ValidationErrorCounter();
5281
5284
  this.serverErrorCounter = new ServerErrorCounter();
5282
5285
  this.consumerRegistry = new ConsumerRegistry();
5283
- this.logger = logger ?? getLogger();
5284
- this.startSync();
5285
5286
  this.handleShutdown = this.handleShutdown.bind(this);
5286
5287
  }
5287
5288
  static getInstance() {
@@ -5336,15 +5337,20 @@ var _ApitallyClient = class _ApitallyClient {
5336
5337
  }
5337
5338
  }
5338
5339
  startSync() {
5340
+ if (!this.enabled) {
5341
+ return;
5342
+ }
5339
5343
  this.sync();
5340
5344
  this.syncIntervalId = setInterval(() => {
5341
5345
  this.sync();
5342
5346
  }, INITIAL_SYNC_INTERVAL);
5343
5347
  setTimeout(() => {
5344
- clearInterval(this.syncIntervalId);
5345
- this.syncIntervalId = setInterval(() => {
5346
- this.sync();
5347
- }, SYNC_INTERVAL);
5348
+ if (this.syncIntervalId) {
5349
+ clearInterval(this.syncIntervalId);
5350
+ this.syncIntervalId = setInterval(() => {
5351
+ this.sync();
5352
+ }, SYNC_INTERVAL);
5353
+ }
5348
5354
  }, INITIAL_SYNC_INTERVAL_DURATION);
5349
5355
  }
5350
5356
  async sync() {
@@ -5372,7 +5378,6 @@ var _ApitallyClient = class _ApitallyClient {
5372
5378
  setStartupData(data) {
5373
5379
  this.startupData = data;
5374
5380
  this.startupDataSent = false;
5375
- this.sendStartupData();
5376
5381
  }
5377
5382
  async sendStartupData() {
5378
5383
  if (this.startupData) {
@@ -5863,6 +5868,7 @@ function apitallyPlugin(config) {
5863
5868
  server.ext("onPostStart", () => {
5864
5869
  const appInfo = getAppInfo(server, config.appVersion);
5865
5870
  client.setStartupData(appInfo);
5871
+ client.startSync();
5866
5872
  });
5867
5873
  server.ext("onPreStop", async () => {
5868
5874
  await client.handleShutdown();