@squide/firefly 13.0.0 → 13.0.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 (69) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/AppRouter.js +17 -17
  3. package/dist/AppRouter.js.map +1 -1
  4. package/dist/AppRouterContext.js +8 -8
  5. package/dist/AppRouterContext.js.map +1 -1
  6. package/dist/AppRouterReducer.js +47 -47
  7. package/dist/AppRouterReducer.js.map +1 -1
  8. package/dist/FireflyProvider.js +3 -3
  9. package/dist/FireflyProvider.js.map +1 -1
  10. package/dist/FireflyRuntime.js +11 -11
  11. package/dist/FireflyRuntime.js.map +1 -1
  12. package/dist/RootRoute.js +10 -10
  13. package/dist/RootRoute.js.map +1 -1
  14. package/dist/honeycomb/activeSpan.js +6 -6
  15. package/dist/honeycomb/activeSpan.js.map +1 -1
  16. package/dist/honeycomb/canRegisterHoneycombInstrumentation.d.ts +1 -0
  17. package/dist/honeycomb/canRegisterHoneycombInstrumentation.js +11 -0
  18. package/dist/honeycomb/canRegisterHoneycombInstrumentation.js.map +1 -0
  19. package/dist/honeycomb/initializeHoneycomb.d.ts +2 -0
  20. package/dist/honeycomb/initializeHoneycomb.js +25 -0
  21. package/dist/honeycomb/initializeHoneycomb.js.map +1 -0
  22. package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +1 -2
  23. package/dist/honeycomb/registerHoneycombInstrumentation.js +104 -99
  24. package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
  25. package/dist/honeycomb/tracer.js +2 -2
  26. package/dist/honeycomb/tracer.js.map +1 -1
  27. package/dist/honeycomb/utils.js +12 -12
  28. package/dist/honeycomb/utils.js.map +1 -1
  29. package/dist/initializeFirefly.js +19 -18
  30. package/dist/initializeFirefly.js.map +1 -1
  31. package/dist/useAppRouterStore.js +2 -2
  32. package/dist/useAppRouterStore.js.map +1 -1
  33. package/dist/useCanFetchProtectedData.js +2 -2
  34. package/dist/useCanFetchProtectedData.js.map +1 -1
  35. package/dist/useCanFetchPublicData.js +2 -2
  36. package/dist/useCanFetchPublicData.js.map +1 -1
  37. package/dist/useCanRegisterDeferredRegistrations.js +2 -2
  38. package/dist/useCanRegisterDeferredRegistrations.js.map +1 -1
  39. package/dist/useCanUpdateDeferredRegistrations.js +2 -2
  40. package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
  41. package/dist/useDeferredRegistrations.js +13 -13
  42. package/dist/useDeferredRegistrations.js.map +1 -1
  43. package/dist/useExecuteOnce.js +3 -3
  44. package/dist/useExecuteOnce.js.map +1 -1
  45. package/dist/useIsActiveRouteProtected.js +5 -5
  46. package/dist/useIsActiveRouteProtected.js.map +1 -1
  47. package/dist/useIsBootstrapping.js +2 -2
  48. package/dist/useIsBootstrapping.js.map +1 -1
  49. package/dist/useNavigationItems.js +4 -4
  50. package/dist/useNavigationItems.js.map +1 -1
  51. package/dist/useProtectedDataHandler.js +4 -4
  52. package/dist/useProtectedDataHandler.js.map +1 -1
  53. package/dist/useProtectedDataQueries.js +20 -20
  54. package/dist/useProtectedDataQueries.js.map +1 -1
  55. package/dist/usePublicDataHandler.js +4 -4
  56. package/dist/usePublicDataHandler.js.map +1 -1
  57. package/dist/usePublicDataQueries.js +19 -19
  58. package/dist/usePublicDataQueries.js.map +1 -1
  59. package/dist/useRegisterDeferredRegistrations.js +4 -4
  60. package/dist/useRegisterDeferredRegistrations.js.map +1 -1
  61. package/dist/useStrictRegistrationMode.js +12 -12
  62. package/dist/useStrictRegistrationMode.js.map +1 -1
  63. package/dist/useUpdateDeferredRegistrations.js +6 -6
  64. package/dist/useUpdateDeferredRegistrations.js.map +1 -1
  65. package/package.json +16 -21
  66. package/src/honeycomb/canRegisterHoneycombInstrumentation.ts +5 -0
  67. package/src/honeycomb/initializeHoneycomb.ts +22 -0
  68. package/src/honeycomb/registerHoneycombInstrumentation.ts +43 -50
  69. package/src/initializeFirefly.ts +12 -9
package/dist/RootRoute.js CHANGED
@@ -1,8 +1,8 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
- import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
3
- import * as __WEBPACK_EXTERNAL_MODULE_react_router_65608a1a__ from "react-router";
4
- import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./AppRouterContext.js";
5
- import * as __WEBPACK_EXTERNAL_MODULE__useIsActiveRouteProtected_js_d94f4832__ from "./useIsActiveRouteProtected.js";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { Outlet } from "react-router";
4
+ import { useAppRouterDispatcher, useAppRouterState } from "./AppRouterContext.js";
5
+ import { useIsActiveRouteProtected } from "./useIsActiveRouteProtected.js";
6
6
 
7
7
  ;// CONCATENATED MODULE: external "react/jsx-runtime"
8
8
 
@@ -21,10 +21,10 @@ import * as __WEBPACK_EXTERNAL_MODULE__useIsActiveRouteProtected_js_d94f4832__ f
21
21
 
22
22
 
23
23
  function RootRoute() {
24
- const state = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterState)();
25
- const isActiveRouteProtected = (0,__WEBPACK_EXTERNAL_MODULE__useIsActiveRouteProtected_js_d94f4832__.useIsActiveRouteProtected)(state.areModulesReady);
26
- const dispatch = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterDispatcher)();
27
- (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
24
+ const state = useAppRouterState();
25
+ const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady);
26
+ const dispatch = useAppRouterDispatcher();
27
+ useEffect(()=>{
28
28
  // Dispatching the active route visibility must be done in a route because React Router's useLocation
29
29
  // hook throws if it's not called from a child of the router component.
30
30
  if (isActiveRouteProtected) {
@@ -40,7 +40,7 @@ function RootRoute() {
40
40
  isActiveRouteProtected,
41
41
  dispatch
42
42
  ]);
43
- return /*#__PURE__*/ (0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_router_65608a1a__.Outlet, {});
43
+ return /*#__PURE__*/ jsx(Outlet, {});
44
44
  }
45
45
 
46
46
  export { RootRoute };
@@ -1 +1 @@
1
- {"version":3,"file":"RootRoute.js","sources":["webpack://@squide/firefly/./src/RootRoute.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { Outlet } from \"react-router\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { useIsActiveRouteProtected } from \"./useIsActiveRouteProtected.ts\";\n\nexport function RootRoute() {\n const state = useAppRouterState();\n const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady);\n\n const dispatch = useAppRouterDispatcher();\n\n useEffect(() => {\n // Dispatching the active route visibility must be done in a route because React Router's useLocation\n // hook throws if it's not called from a child of the router component.\n if (isActiveRouteProtected) {\n dispatch({ type: \"active-route-is-protected\" });\n } else {\n dispatch({ type: \"active-route-is-public\" });\n }\n }, [isActiveRouteProtected, dispatch]);\n\n return (\n <Outlet />\n );\n}\n"],"names":["useEffect","Outlet","useAppRouterDispatcher","useAppRouterState","useIsActiveRouteProtected","RootRoute","state","isActiveRouteProtected","dispatch"],"mappings":";;;;;;;;;;;;;;;;;;AAAkC;AACI;AAC4C;AACP;AAEpE,SAASK;IACZ,MAAMC,QAAQH,+EAAiBA;IAC/B,MAAMI,yBAAyBH,gGAAyBA,CAACE,MAAM,eAAe;IAE9E,MAAME,WAAWN,oFAAsBA;IAEvCF,+CAASA,CAAC;QACN,qGAAqG;QACrG,uEAAuE;QACvE,IAAIO,wBAAwB;YACxBC,SAAS;gBAAE,MAAM;YAA4B;QACjD,OAAO;YACHA,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACD;QAAwBC;KAAS;IAErC,qBACI,+DAACP,wDAAMA;AAEf"}
1
+ {"version":3,"file":"RootRoute.js","sources":["webpack://@squide/firefly/./src/RootRoute.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { Outlet } from \"react-router\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { useIsActiveRouteProtected } from \"./useIsActiveRouteProtected.ts\";\n\nexport function RootRoute() {\n const state = useAppRouterState();\n const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady);\n\n const dispatch = useAppRouterDispatcher();\n\n useEffect(() => {\n // Dispatching the active route visibility must be done in a route because React Router's useLocation\n // hook throws if it's not called from a child of the router component.\n if (isActiveRouteProtected) {\n dispatch({ type: \"active-route-is-protected\" });\n } else {\n dispatch({ type: \"active-route-is-public\" });\n }\n }, [isActiveRouteProtected, dispatch]);\n\n return (\n <Outlet />\n );\n}\n"],"names":["useEffect","Outlet","useAppRouterDispatcher","useAppRouterState","useIsActiveRouteProtected","RootRoute","state","isActiveRouteProtected","dispatch"],"mappings":";;;;;;;;;;;;;;;;;;AAAkC;AACI;AAC4C;AACP;AAEpE,SAASK;IACZ,MAAMC,QAAQH,iBAAiBA;IAC/B,MAAMI,yBAAyBH,yBAAyBA,CAACE,MAAM,eAAe;IAE9E,MAAME,WAAWN,sBAAsBA;IAEvCF,SAASA,CAAC;QACN,qGAAqG;QACrG,uEAAuE;QACvE,IAAIO,wBAAwB;YACxBC,SAAS;gBAAE,MAAM;YAA4B;QACjD,OAAO;YACHA,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACD;QAAwBC;KAAS;IAErC,qBACI,IAACP,MAAMA;AAEf"}
@@ -1,6 +1,6 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__ from "@squide/core";
2
- import * as __WEBPACK_EXTERNAL_MODULE_uuid__ from "uuid";
3
- import * as __WEBPACK_EXTERNAL_MODULE__createTraceContextId_js_cda49537__ from "./createTraceContextId.js";
1
+ import { isPlainObject } from "@squide/core";
2
+ import { v4 } from "uuid";
3
+ import { createTraceContextId } from "./createTraceContextId.js";
4
4
 
5
5
  ;// CONCATENATED MODULE: external "@squide/core"
6
6
 
@@ -61,7 +61,7 @@ function getActiveSpan() {
61
61
  }
62
62
  function setActiveSpan(name, span) {
63
63
  const activeSpan = {
64
- id: (0,__WEBPACK_EXTERNAL_MODULE_uuid__.v4)(),
64
+ id: v4(),
65
65
  name: name,
66
66
  instance: span
67
67
  };
@@ -87,10 +87,10 @@ function createOverrideFetchRequestSpanWithActiveSpanContext(logger) {
87
87
  logger.debug("[squide] Found a Honeycomb active context to apply to the following fetch request: \r\n", "Request span context: ", requestSpanContext, "\r\n", "Active span context: ", activeSpanContext, "\r\n", "Request: ", request, "\r\n");
88
88
  span.setAttribute("trace.trace_id", activeSpanContext.traceId);
89
89
  span.setAttribute("trace.parent_id", activeSpanContext.spanId);
90
- const traceParent = (0,__WEBPACK_EXTERNAL_MODULE__createTraceContextId_js_cda49537__.createTraceContextId)(activeSpanContext.traceId, requestSpanContext.spanId, requestSpanContext.traceFlags);
90
+ const traceParent = createTraceContextId(activeSpanContext.traceId, requestSpanContext.spanId, requestSpanContext.traceFlags);
91
91
  if (request instanceof Request) {
92
92
  request.headers.set("traceparent", traceParent);
93
- } else if ((0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.isPlainObject)(request.headers)) {
93
+ } else if (isPlainObject(request.headers)) {
94
94
  request.headers["traceparent"] = traceParent;
95
95
  }
96
96
  // Indicates to not propagate the requests to the subsequent hooks.
@@ -1 +1 @@
1
- {"version":3,"file":"honeycomb/activeSpan.js","sources":["webpack://@squide/firefly/./src/honeycomb/activeSpan.ts"],"sourcesContent":["import type { Span } from \"@opentelemetry/api\";\nimport { isPlainObject, type RuntimeLogger } from \"@squide/core\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { createTraceContextId } from \"./createTraceContextId.ts\";\n\nexport type ActiveSpanId = string;\n\nexport interface ActiveSpan {\n id: ActiveSpanId;\n name: string;\n instance: Span;\n}\n\n// Using a stack because we want a Last In First Out implementation for this.\n// https://github.com/open-telemetry/opentelemetry-js/issues/5084\n// https://github.com/open-telemetry/opentelemetry-js/issues/3558#issuecomment-1760680244\nclass ActiveSpanStack {\n readonly #stack: ActiveSpan[] = [];\n\n push(span: ActiveSpan) {\n this.#stack.push(span);\n }\n\n pop(span: ActiveSpan) {\n const head = this.#stack.pop();\n\n if (!head) {\n throw new Error(\"[squide] Unexpected pop, the active Honeycomb span stack is empty.\");\n }\n\n if (head.id !== span.id) {\n throw new Error(`[squide] The active Honeycomb span is not the expected span. Expected to pop span with name and id \"${span.name} / ${span.id}\" but found \"${head.name} / ${head.id}\". Did you forget to end an active span?`);\n }\n\n return head;\n }\n\n peek() {\n if (this.#stack.length === 0) {\n return undefined;\n }\n\n return this.#stack[this.#stack.length - 1];\n }\n}\n\nconst GlobalActiveSpanStackVariableName = \"__SQUIDE_HONEYCOMB_ACTIVE_SPAN_STACK__\";\n\nexport function registerActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (globalThis[GlobalActiveSpanStackVariableName]) {\n throw new Error(`[squide] An ActiveSpanStack instance has already been registered to globalThis.${GlobalActiveSpanStackVariableName}. Did you register the Honeycomb instrumentation twice?`);\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[GlobalActiveSpanStackVariableName] = new ActiveSpanStack();\n}\n\nfunction getActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis[GlobalActiveSpanStackVariableName] as ActiveSpanStack;\n}\n\nfunction getActiveSpan() {\n const stack = getActiveSpanStack();\n\n if (stack) {\n return stack.peek();\n }\n}\n\nexport function setActiveSpan(name: string, span: Span) {\n const activeSpan: ActiveSpan = {\n id: uuidv4(),\n name: name,\n instance: span\n };\n\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.push(activeSpan);\n }\n\n return activeSpan;\n}\n\nexport function popActiveSpan(span: ActiveSpan) {\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.pop(span);\n }\n}\n\nexport function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RuntimeLogger) {\n return (span: Span, request: Request | RequestInit) => {\n const activeSpan = getActiveSpan();\n\n if (activeSpan) {\n const activeSpanContext = activeSpan.instance.spanContext();\n const requestSpanContext = span.spanContext();\n\n if (activeSpanContext) {\n logger.debug(\n \"[squide] Found a Honeycomb active context to apply to the following fetch request: \\r\\n\",\n \"Request span context: \", requestSpanContext, \"\\r\\n\",\n \"Active span context: \", activeSpanContext, \"\\r\\n\",\n \"Request: \", request, \"\\r\\n\"\n );\n\n span.setAttribute(\"trace.trace_id\", activeSpanContext.traceId);\n span.setAttribute(\"trace.parent_id\", activeSpanContext.spanId);\n\n const traceParent = createTraceContextId(activeSpanContext.traceId, requestSpanContext.spanId, requestSpanContext.traceFlags);\n\n if (request instanceof Request) {\n request.headers.set(\"traceparent\", traceParent);\n } else if (isPlainObject(request.headers)) {\n request.headers[\"traceparent\"] = traceParent;\n }\n\n // Indicates to not propagate the requests to the subsequent hooks.\n return true;\n }\n }\n };\n}\n"],"names":["isPlainObject","v4","uuidv4","createTraceContextId","ActiveSpanStack","span","head","Error","undefined","GlobalActiveSpanStackVariableName","registerActiveSpanStack","globalThis","getActiveSpanStack","getActiveSpan","stack","setActiveSpan","name","activeSpan","popActiveSpan","createOverrideFetchRequestSpanWithActiveSpanContext","logger","request","activeSpanContext","requestSpanContext","traceParent","Request"],"mappings":";;;;;;;;;;;AACiE;AAC7B;AAC6B;AAUjE,6EAA6E;AAC7E,iEAAiE;AACjE,yFAAyF;AACzF,MAAMI;IACO,MAAM,GAAiB,EAAE,CAAC;IAEnC,KAAKC,IAAgB,EAAE;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAACA;IACrB;IAEA,IAAIA,IAAgB,EAAE;QAClB,MAAMC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG;QAE5B,IAAI,CAACA,MAAM;YAC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J,aAAaJ;QAEnB,IAAII,YAAY;YACZ,MAAMK,oBAAoBL,WAAW,QAAQ,CAAC,WAAW;YACzD,MAAMM,qBAAqBlB,KAAK,WAAW;YAE3C,IAAIiB,mBAAmB;gBACnBF,OAAO,KAAK,CACR,2FACA,0BAA0BG,oBAAoB,QAC9C,yBAAyBD,mBAAmB,QAC5C,aAAaD,SAAS;gBAG1BhB,KAAK,YAAY,CAAC,kBAAkBiB,kBAAkB,OAAO;gBAC7DjB,KAAK,YAAY,CAAC,mBAAmBiB,kBAAkB,MAAM;gBAE7D,MAAME,cAAcrB,sFAAoBA,CAACmB,kBAAkB,OAAO,EAAEC,mBAAmB,MAAM,EAAEA,mBAAmB,UAAU;gBAE5H,IAAIF,mBAAmBI,SAAS;oBAC5BJ,QAAQ,OAAO,CAAC,GAAG,CAAC,eAAeG;gBACvC,OAAO,IAAIxB,mEAAaA,CAACqB,QAAQ,OAAO,GAAG;oBACvCA,QAAQ,OAAO,CAAC,cAAc,GAAGG;gBACrC;gBAEA,mEAAmE;gBACnE,OAAO;YACX;QACJ;IACJ;AACJ"}
1
+ {"version":3,"file":"honeycomb/activeSpan.js","sources":["webpack://@squide/firefly/./src/honeycomb/activeSpan.ts"],"sourcesContent":["import type { Span } from \"@opentelemetry/api\";\nimport { isPlainObject, type RuntimeLogger } from \"@squide/core\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { createTraceContextId } from \"./createTraceContextId.ts\";\n\nexport type ActiveSpanId = string;\n\nexport interface ActiveSpan {\n id: ActiveSpanId;\n name: string;\n instance: Span;\n}\n\n// Using a stack because we want a Last In First Out implementation for this.\n// https://github.com/open-telemetry/opentelemetry-js/issues/5084\n// https://github.com/open-telemetry/opentelemetry-js/issues/3558#issuecomment-1760680244\nclass ActiveSpanStack {\n readonly #stack: ActiveSpan[] = [];\n\n push(span: ActiveSpan) {\n this.#stack.push(span);\n }\n\n pop(span: ActiveSpan) {\n const head = this.#stack.pop();\n\n if (!head) {\n throw new Error(\"[squide] Unexpected pop, the active Honeycomb span stack is empty.\");\n }\n\n if (head.id !== span.id) {\n throw new Error(`[squide] The active Honeycomb span is not the expected span. Expected to pop span with name and id \"${span.name} / ${span.id}\" but found \"${head.name} / ${head.id}\". Did you forget to end an active span?`);\n }\n\n return head;\n }\n\n peek() {\n if (this.#stack.length === 0) {\n return undefined;\n }\n\n return this.#stack[this.#stack.length - 1];\n }\n}\n\nconst GlobalActiveSpanStackVariableName = \"__SQUIDE_HONEYCOMB_ACTIVE_SPAN_STACK__\";\n\nexport function registerActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (globalThis[GlobalActiveSpanStackVariableName]) {\n throw new Error(`[squide] An ActiveSpanStack instance has already been registered to globalThis.${GlobalActiveSpanStackVariableName}. Did you register the Honeycomb instrumentation twice?`);\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[GlobalActiveSpanStackVariableName] = new ActiveSpanStack();\n}\n\nfunction getActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis[GlobalActiveSpanStackVariableName] as ActiveSpanStack;\n}\n\nfunction getActiveSpan() {\n const stack = getActiveSpanStack();\n\n if (stack) {\n return stack.peek();\n }\n}\n\nexport function setActiveSpan(name: string, span: Span) {\n const activeSpan: ActiveSpan = {\n id: uuidv4(),\n name: name,\n instance: span\n };\n\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.push(activeSpan);\n }\n\n return activeSpan;\n}\n\nexport function popActiveSpan(span: ActiveSpan) {\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.pop(span);\n }\n}\n\nexport function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RuntimeLogger) {\n return (span: Span, request: Request | RequestInit) => {\n const activeSpan = getActiveSpan();\n\n if (activeSpan) {\n const activeSpanContext = activeSpan.instance.spanContext();\n const requestSpanContext = span.spanContext();\n\n if (activeSpanContext) {\n logger.debug(\n \"[squide] Found a Honeycomb active context to apply to the following fetch request: \\r\\n\",\n \"Request span context: \", requestSpanContext, \"\\r\\n\",\n \"Active span context: \", activeSpanContext, \"\\r\\n\",\n \"Request: \", request, \"\\r\\n\"\n );\n\n span.setAttribute(\"trace.trace_id\", activeSpanContext.traceId);\n span.setAttribute(\"trace.parent_id\", activeSpanContext.spanId);\n\n const traceParent = createTraceContextId(activeSpanContext.traceId, requestSpanContext.spanId, requestSpanContext.traceFlags);\n\n if (request instanceof Request) {\n request.headers.set(\"traceparent\", traceParent);\n } else if (isPlainObject(request.headers)) {\n request.headers[\"traceparent\"] = traceParent;\n }\n\n // Indicates to not propagate the requests to the subsequent hooks.\n return true;\n }\n }\n };\n}\n"],"names":["isPlainObject","v4","uuidv4","createTraceContextId","ActiveSpanStack","span","head","Error","undefined","GlobalActiveSpanStackVariableName","registerActiveSpanStack","globalThis","getActiveSpanStack","getActiveSpan","stack","setActiveSpan","name","activeSpan","popActiveSpan","createOverrideFetchRequestSpanWithActiveSpanContext","logger","request","activeSpanContext","requestSpanContext","traceParent","Request"],"mappings":";;;;;;;;;;;AACiE;AAC7B;AAC6B;AAUjE,6EAA6E;AAC7E,iEAAiE;AACjE,yFAAyF;AACzF,MAAMI;IACO,MAAM,GAAiB,EAAE,CAAC;IAEnC,KAAKC,IAAgB,EAAE;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAACA;IACrB;IAEA,IAAIA,IAAgB,EAAE;QAClB,MAAMC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG;QAE5B,IAAI,CAACA,MAAM;YACP,MAAM,IAAIC,MAAM;QACpB;QAEA,IAAID,KAAK,EAAE,KAAKD,KAAK,EAAE,EAAE;YACrB,MAAM,IAAIE,MAAM,CAAC,oGAAoG,EAAEF,KAAK,IAAI,CAAC,GAAG,EAAEA,KAAK,EAAE,CAAC,aAAa,EAAEC,KAAK,IAAI,CAAC,GAAG,EAAEA,KAAK,EAAE,CAAC,wCAAwC,CAAC;Q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AAY,CAAC,kBAAkBiB,kBAAkB,OAAO;gBAC7DjB,KAAK,YAAY,CAAC,mBAAmBiB,kBAAkB,MAAM;gBAE7D,MAAME,cAAcrB,oBAAoBA,CAACmB,kBAAkB,OAAO,EAAEC,mBAAmB,MAAM,EAAEA,mBAAmB,UAAU;gBAE5H,IAAIF,mBAAmBI,SAAS;oBAC5BJ,QAAQ,OAAO,CAAC,GAAG,CAAC,eAAeG;gBACvC,OAAO,IAAIxB,aAAaA,CAACqB,QAAQ,OAAO,GAAG;oBACvCA,QAAQ,OAAO,CAAC,cAAc,GAAGG;gBACrC;gBAEA,mEAAmE;gBACnE,OAAO;YACX;QACJ;IACJ;AACJ"}
@@ -0,0 +1 @@
1
+ export declare function canRegisterHoneycombInstrumentation(): boolean;
@@ -0,0 +1,11 @@
1
+
2
+ ;// CONCATENATED MODULE: ./src/honeycomb/canRegisterHoneycombInstrumentation.ts
3
+ function canRegisterHoneycombInstrumentation() {
4
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
+ // @ts-ignore
6
+ return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true;
7
+ }
8
+
9
+ export { canRegisterHoneycombInstrumentation };
10
+
11
+ //# sourceMappingURL=canRegisterHoneycombInstrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"honeycomb/canRegisterHoneycombInstrumentation.js","sources":["webpack://@squide/firefly/./src/honeycomb/canRegisterHoneycombInstrumentation.ts"],"sourcesContent":["export function canRegisterHoneycombInstrumentation() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true;\n}\n"],"names":["canRegisterHoneycombInstrumentation","globalThis"],"mappings":";;AAAO,SAASA;IACZ,6DAA6D;IAC7D,aAAa;IACb,OAAOC,WAAW,+CAA+C,KAAK;AAC1E"}
@@ -0,0 +1,2 @@
1
+ import type { FireflyRuntime } from "../FireflyRuntime.tsx";
2
+ export declare function initializeHoneycomb(runtime: FireflyRuntime): Promise<void>;
@@ -0,0 +1,25 @@
1
+ import { canRegisterHoneycombInstrumentation } from "./canRegisterHoneycombInstrumentation.js";
2
+
3
+ ;// CONCATENATED MODULE: external "./canRegisterHoneycombInstrumentation.js"
4
+
5
+ ;// CONCATENATED MODULE: ./src/honeycomb/initializeHoneycomb.ts
6
+
7
+ async function initializeHoneycomb(runtime) {
8
+ if (canRegisterHoneycombInstrumentation()) {
9
+ try {
10
+ // Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries
11
+ // if Honeycomb instrumentation is not registered by the hosting application.
12
+ const mod = await import("./registerHoneycombInstrumentation.js");
13
+ mod.registerHoneycombInstrumentation(runtime);
14
+ } catch (error) {
15
+ runtime.logger.error("[squide] Failed to register Honeycomb instrumentation. The \"./registerHoneycombInstrumentation.ts\" cannot be imported.");
16
+ throw error;
17
+ }
18
+ } else {
19
+ runtime.logger.debug("[squide] Cannot register Honeycomb instrumentation because the host application is not using the \"@workleap/honeycomb\" package.");
20
+ }
21
+ }
22
+
23
+ export { initializeHoneycomb };
24
+
25
+ //# sourceMappingURL=initializeHoneycomb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"honeycomb/initializeHoneycomb.js","sources":["webpack://@squide/firefly/./src/honeycomb/initializeHoneycomb.ts"],"sourcesContent":["import type { FireflyRuntime } from \"../FireflyRuntime.tsx\";\nimport { canRegisterHoneycombInstrumentation } from \"./canRegisterHoneycombInstrumentation.ts\";\n\nexport async function initializeHoneycomb(runtime: FireflyRuntime) {\n if (canRegisterHoneycombInstrumentation()) {\n try {\n // Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries\n // if Honeycomb instrumentation is not registered by the hosting application.\n const mod = await import(\"./registerHoneycombInstrumentation.ts\");\n\n mod.registerHoneycombInstrumentation(runtime);\n } catch (error: unknown) {\n runtime.logger.error(\"[squide] Failed to register Honeycomb instrumentation. The \\\"./registerHoneycombInstrumentation.ts\\\" cannot be imported.\");\n\n throw error;\n }\n } else {\n runtime.logger.debug(\"[squide] Cannot register Honeycomb instrumentation because the host application is not using the \\\"@workleap/honeycomb\\\" package.\");\n }\n}\n\n\n"],"names":["canRegisterHoneycombInstrumentation","initializeHoneycomb","runtime","mod","error"],"mappings":";;;;;AAC+F;AAExF,eAAeC,oBAAoBC,OAAuB;IAC7D,IAAIF,mCAAmCA,IAAI;QACvC,IAAI;YACA,kGAAkG;YAClG,6EAA6E;YAC7E,MAAMG,MAAM,MAAM,+CAA+C;YAEjEA,IAAI,gCAAgC,CAACD;QACzC,EAAE,OAAOE,OAAgB;YACrBF,QAAQ,MAAM,CAAC,KAAK,CAAC;YAErB,MAAME;QACV;IACJ,OAAO;QACHF,QAAQ,MAAM,CAAC,KAAK,CAAC;IACzB;AACJ"}
@@ -1,4 +1,3 @@
1
1
  import type { FireflyRuntime } from "../FireflyRuntime.tsx";
2
- export declare function reduceDataFetchEvents(runtime: FireflyRuntime, onDataFetchingStarted: () => void, onDataReady: () => void, onPublicDataFetchStarted: () => void, onPublicDataReady: () => void, onProtectedDataFetchStarted: () => void, onProtectedDataReady: () => void): void;
2
+ export declare function reduceDataFetchEvents(runtime: FireflyRuntime, onDataFetchStarted: () => void, onDataReady: () => void, onPublicDataFetchStarted: () => void, onPublicDataReady: () => void, onProtectedDataFetchStarted: () => void, onProtectedDataReady: () => void, onDataFetchFailed: (queriesErrors: Error[]) => void): void;
3
3
  export declare function registerHoneycombInstrumentation(runtime: FireflyRuntime): void;
4
- export declare function canRegisterHoneycombInstrumentation(): boolean;