@reactionary/feeds 0.12.0 → 0.12.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 (2) hide show
  1. package/cli.cjs +25 -5
  2. package/package.json +9 -9
package/cli.cjs CHANGED
@@ -40373,6 +40373,28 @@ var init_context3 = __esm({
40373
40373
  });
40374
40374
 
40375
40375
  // packages/core/src/analytics/dispatcher.ts
40376
+ function createHandlerScope() {
40377
+ const asyncHooks = typeof process !== "undefined" ? process.getBuiltinModule?.("node:async_hooks") : void 0;
40378
+ if (asyncHooks) {
40379
+ const storage = new asyncHooks.AsyncLocalStorage();
40380
+ return {
40381
+ run: (fn) => storage.run(true, fn),
40382
+ active: () => storage.getStore() === true
40383
+ };
40384
+ }
40385
+ let running = 0;
40386
+ return {
40387
+ async run(fn) {
40388
+ running++;
40389
+ try {
40390
+ return await fn();
40391
+ } finally {
40392
+ running--;
40393
+ }
40394
+ },
40395
+ active: () => running > 0
40396
+ };
40397
+ }
40376
40398
  function eventTypeMatches(pattern, type) {
40377
40399
  if (pattern === "*") {
40378
40400
  return true;
@@ -40388,16 +40410,15 @@ function isPurposeAllowed(purpose, consent) {
40388
40410
  }
40389
40411
  return purpose === "analytics" ? consent.analytics : consent.marketing;
40390
40412
  }
40391
- var import_node_async_hooks, DEFAULT_CONSENT, insideHandler, AnalyticsDispatcher;
40413
+ var DEFAULT_CONSENT, insideHandler, AnalyticsDispatcher;
40392
40414
  var init_dispatcher = __esm({
40393
40415
  "packages/core/src/analytics/dispatcher.ts"() {
40394
40416
  "use strict";
40395
- import_node_async_hooks = require("node:async_hooks");
40396
40417
  init_reactionary_decorator();
40397
40418
  init_schemas3();
40398
40419
  init_result();
40399
40420
  DEFAULT_CONSENT = { analytics: true, marketing: true };
40400
- insideHandler = new import_node_async_hooks.AsyncLocalStorage();
40421
+ insideHandler = createHandlerScope();
40401
40422
  AnalyticsDispatcher = class {
40402
40423
  requestContext;
40403
40424
  subscribers;
@@ -40428,7 +40449,7 @@ var init_dispatcher = __esm({
40428
40449
  * Never throws: invalid input and emits made from inside a subscriber are logged and dropped.
40429
40450
  */
40430
40451
  emit(type, input, options = {}) {
40431
- if (insideHandler.getStore()) {
40452
+ if (insideHandler.active()) {
40432
40453
  console.warn(`Analytics event '${type}' was emitted from inside a subscriber and has been dropped`);
40433
40454
  return error({ type: "InvalidInput", error: "Events cannot be emitted from inside an analytics subscriber" });
40434
40455
  }
@@ -40536,7 +40557,6 @@ var init_dispatcher = __esm({
40536
40557
  for (const event of events2) {
40537
40558
  try {
40538
40559
  const outcome = await insideHandler.run(
40539
- true,
40540
40560
  () => traceSpan(`AnalyticsSubscriber.${subscriber.name}.handle`, () => subscriber.handle(event, ctx))
40541
40561
  );
40542
40562
  if (outcome === "rejected") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/feeds",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
@@ -12,14 +12,14 @@
12
12
  "url": "git+https://github.com/Solteq/reactionary.git"
13
13
  },
14
14
  "dependencies": {
15
- "@reactionary/algolia": "0.12.0",
16
- "@reactionary/commercetools": "0.12.0",
17
- "@reactionary/core": "0.12.0",
18
- "@reactionary/fake": "0.12.0",
19
- "@reactionary/magento": "0.12.0",
20
- "@reactionary/medusa": "0.12.0",
21
- "@reactionary/meilisearch": "0.12.0",
22
- "@reactionary/unomi": "0.12.0",
15
+ "@reactionary/algolia": "0.12.1",
16
+ "@reactionary/commercetools": "0.12.1",
17
+ "@reactionary/core": "0.12.1",
18
+ "@reactionary/fake": "0.12.1",
19
+ "@reactionary/magento": "0.12.1",
20
+ "@reactionary/medusa": "0.12.1",
21
+ "@reactionary/meilisearch": "0.12.1",
22
+ "@reactionary/unomi": "0.12.1",
23
23
  "commander": "^15.0.0",
24
24
  "dotenv": "^17.2.2",
25
25
  "sitemap": "^9.0.1",