@dxos/observability 0.8.4-main.422d1c7879 → 0.8.4-main.4668b7de9b

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 (87) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/{chunk-K4VFBKST.mjs → chunk-PSFTIG54.mjs} +9 -2
  3. package/dist/lib/browser/chunk-PSFTIG54.mjs.map +7 -0
  4. package/dist/lib/browser/index.mjs +93 -216
  5. package/dist/lib/browser/index.mjs.map +3 -3
  6. package/dist/lib/browser/{log-processor-A6PJG6CM.mjs → log-processor-HPHWNBOK.mjs} +1 -1
  7. package/dist/lib/browser/{log-processor-A6PJG6CM.mjs.map → log-processor-HPHWNBOK.mjs.map} +2 -2
  8. package/dist/lib/browser/{logs-ATTRIUTL.mjs → logs-UTNIFYHF.mjs} +7 -4
  9. package/dist/lib/browser/logs-UTNIFYHF.mjs.map +7 -0
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/{metrics-PKTV6IGF.mjs → metrics-PRGSYAZJ.mjs} +7 -21
  12. package/dist/lib/browser/metrics-PRGSYAZJ.mjs.map +7 -0
  13. package/dist/lib/browser/{traces-browser-Y4FFWRIR.mjs → traces-browser-XRINKQUA.mjs} +8 -20
  14. package/dist/lib/browser/traces-browser-XRINKQUA.mjs.map +7 -0
  15. package/dist/lib/node-esm/{chunk-FEVP3MK4.mjs → chunk-EDDZWPYV.mjs} +9 -2
  16. package/dist/lib/node-esm/chunk-EDDZWPYV.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +88 -186
  18. package/dist/lib/node-esm/index.mjs.map +3 -3
  19. package/dist/lib/node-esm/{log-processor-4TIHN5KN.mjs → log-processor-ZODHERST.mjs} +1 -1
  20. package/dist/lib/node-esm/{log-processor-4TIHN5KN.mjs.map → log-processor-ZODHERST.mjs.map} +2 -2
  21. package/dist/lib/node-esm/{logs-7J45KLM7.mjs → logs-ARJUVN3T.mjs} +7 -4
  22. package/dist/lib/node-esm/logs-ARJUVN3T.mjs.map +7 -0
  23. package/dist/lib/node-esm/meta.json +1 -1
  24. package/dist/lib/node-esm/{metrics-H7DDLYSG.mjs → metrics-DREJOOAC.mjs} +7 -21
  25. package/dist/lib/node-esm/metrics-DREJOOAC.mjs.map +7 -0
  26. package/dist/lib/node-esm/{traces-NPNTEOS6.mjs → traces-74F7JUKF.mjs} +8 -20
  27. package/dist/lib/node-esm/traces-74F7JUKF.mjs.map +7 -0
  28. package/dist/types/src/extensions/otel/extension.d.ts.map +1 -1
  29. package/dist/types/src/extensions/otel/extension.js +29 -10
  30. package/dist/types/src/extensions/otel/extension.js.map +1 -1
  31. package/dist/types/src/extensions/otel/logs.d.ts.map +1 -1
  32. package/dist/types/src/extensions/otel/logs.js +6 -3
  33. package/dist/types/src/extensions/otel/logs.js.map +1 -1
  34. package/dist/types/src/extensions/otel/metrics.d.ts.map +1 -1
  35. package/dist/types/src/extensions/otel/metrics.js +2 -2
  36. package/dist/types/src/extensions/otel/metrics.js.map +1 -1
  37. package/dist/types/src/extensions/otel/otel.d.ts +7 -0
  38. package/dist/types/src/extensions/otel/otel.d.ts.map +1 -1
  39. package/dist/types/src/extensions/otel/otel.js +12 -0
  40. package/dist/types/src/extensions/otel/otel.js.map +1 -1
  41. package/dist/types/src/extensions/otel/span-processors.d.ts.map +1 -1
  42. package/dist/types/src/extensions/otel/span-processors.js.map +1 -1
  43. package/dist/types/src/extensions/otel/traces-browser.d.ts.map +1 -1
  44. package/dist/types/src/extensions/otel/traces-browser.js +2 -1
  45. package/dist/types/src/extensions/otel/traces-browser.js.map +1 -1
  46. package/dist/types/src/extensions/otel/traces.d.ts.map +1 -1
  47. package/dist/types/src/extensions/otel/traces.js +2 -1
  48. package/dist/types/src/extensions/otel/traces.js.map +1 -1
  49. package/dist/types/src/extensions/posthog/extension.d.ts +13 -3
  50. package/dist/types/src/extensions/posthog/extension.d.ts.map +1 -1
  51. package/dist/types/src/extensions/posthog/extension.js +34 -22
  52. package/dist/types/src/extensions/posthog/extension.js.map +1 -1
  53. package/dist/types/src/extensions/posthog/log-processor.test.js.map +1 -1
  54. package/dist/types/src/observability-extension.d.ts +1 -1
  55. package/dist/types/src/observability-extension.d.ts.map +1 -1
  56. package/dist/types/src/observability.d.ts.map +1 -1
  57. package/dist/types/src/observability.js +4 -2
  58. package/dist/types/src/observability.js.map +1 -1
  59. package/dist/types/src/observability.test.js +1 -1
  60. package/dist/types/src/observability.test.js.map +1 -1
  61. package/dist/types/src/providers/client-observability.d.ts.map +1 -1
  62. package/dist/types/src/providers/client-observability.js +2 -0
  63. package/dist/types/src/providers/client-observability.js.map +1 -1
  64. package/dist/types/src/providers/ip-data.d.ts.map +1 -1
  65. package/dist/types/src/storage/browser.d.ts.map +1 -1
  66. package/dist/types/src/storage/node.d.ts.map +1 -1
  67. package/dist/types/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +31 -33
  69. package/src/extensions/otel/extension.ts +31 -10
  70. package/src/extensions/otel/logs.ts +6 -3
  71. package/src/extensions/otel/metrics.ts +2 -2
  72. package/src/extensions/otel/otel.ts +13 -0
  73. package/src/extensions/otel/traces-browser.ts +2 -2
  74. package/src/extensions/otel/traces.ts +2 -2
  75. package/src/extensions/posthog/extension.ts +47 -24
  76. package/src/observability-extension.ts +1 -1
  77. package/src/observability.test.ts +1 -1
  78. package/src/observability.ts +4 -2
  79. package/src/providers/client-observability.ts +2 -0
  80. package/dist/lib/browser/chunk-K4VFBKST.mjs.map +0 -7
  81. package/dist/lib/browser/logs-ATTRIUTL.mjs.map +0 -7
  82. package/dist/lib/browser/metrics-PKTV6IGF.mjs.map +0 -7
  83. package/dist/lib/browser/traces-browser-Y4FFWRIR.mjs.map +0 -7
  84. package/dist/lib/node-esm/chunk-FEVP3MK4.mjs.map +0 -7
  85. package/dist/lib/node-esm/logs-7J45KLM7.mjs.map +0 -7
  86. package/dist/lib/node-esm/metrics-H7DDLYSG.mjs.map +0 -7
  87. package/dist/lib/node-esm/traces-NPNTEOS6.mjs.map +0 -7
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2023 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
@@ -6,8 +6,15 @@ var setDiagLogger = (level) => {
6
6
  diag.setLogger(new DiagConsoleLogger(), logLevel);
7
7
  }
8
8
  };
9
+ var resolveOtlpUrl = (url) => {
10
+ if (typeof window !== "undefined" && url.startsWith("/")) {
11
+ return new URL(url, window.location.origin).toString();
12
+ }
13
+ return url;
14
+ };
9
15
 
10
16
  export {
11
- setDiagLogger
17
+ setDiagLogger,
18
+ resolveOtlpUrl
12
19
  };
13
- //# sourceMappingURL=chunk-K4VFBKST.mjs.map
20
+ //# sourceMappingURL=chunk-PSFTIG54.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extensions/otel/otel.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport { type Resource } from '@opentelemetry/resources';\n\nexport type OtelOptions = {\n endpoint: string;\n headers: Record<string, string>;\n resource: Resource;\n getTags: () => { [key: string]: string };\n consoleDiagLogLevel?: string;\n};\n\nexport const setDiagLogger = (level?: string) => {\n const logLevel = DiagLogLevel[level as keyof typeof DiagLogLevel];\n if (logLevel) {\n diag.setLogger(new DiagConsoleLogger(), logLevel);\n }\n};\n\n/**\n * Resolve a possibly-relative OTLP exporter URL to an absolute URL.\n * The OpenTelemetry browser HTTP exporter validates user-provided URLs with `new URL(url)`,\n * which throws on relative paths like `/api/otel/v1/logs`. In a browser context we resolve\n * against `window.location.origin`; outside the browser we return the input unchanged.\n */\nexport const resolveOtlpUrl = (url: string): string => {\n if (typeof window !== 'undefined' && url.startsWith('/')) {\n return new URL(url, window.location.origin).toString();\n }\n return url;\n};\n"],
5
+ "mappings": ";AAIA,SAASA,mBAAmBC,cAAcC,YAAY;AAW/C,IAAMC,gBAAgB,CAACC,UAAAA;AAC5B,QAAMC,WAAWJ,aAAaG,KAAAA;AAC9B,MAAIC,UAAU;AACZH,SAAKI,UAAU,IAAIN,kBAAAA,GAAqBK,QAAAA;EAC1C;AACF;AAQO,IAAME,iBAAiB,CAACC,QAAAA;AAC7B,MAAI,OAAOC,WAAW,eAAeD,IAAIE,WAAW,GAAA,GAAM;AACxD,WAAO,IAAIC,IAAIH,KAAKC,OAAOG,SAASC,MAAM,EAAEC,SAAQ;EACtD;AACA,SAAON;AACT;",
6
+ "names": ["DiagConsoleLogger", "DiagLogLevel", "diag", "setDiagLogger", "level", "logLevel", "setLogger", "resolveOtlpUrl", "url", "window", "startsWith", "URL", "location", "origin", "toString"]
7
+ }
@@ -30,23 +30,13 @@ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/observability/src/storage/browse
30
30
  var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
31
31
  var OBSERVABILITY_GROUP_KEY = "observability-group";
32
32
  var showObservabilityBanner = () => {
33
- log.warn("showObservabilityBanner is not supported in browser contexts.", void 0, {
34
- F: __dxlog_file,
35
- L: 16,
36
- S: void 0,
37
- C: (f, a) => f(...a)
38
- });
33
+ log.warn("showObservabilityBanner is not supported in browser contexts.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 11, S: void 0 });
39
34
  };
40
35
  var isObservabilityDisabled = async (namespace) => {
41
36
  try {
42
37
  return await localForage.getItem(compositeKey(namespace, OBSERVABILITY_DISABLED_KEY)) === "true";
43
38
  } catch (err) {
44
- log.catch("Failed to check if observability is disabled, assuming it is", err, {
45
- F: __dxlog_file,
46
- L: 26,
47
- S: void 0,
48
- C: (f, a) => f(...a)
49
- });
39
+ log.catch("Failed to check if observability is disabled, assuming it is", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 19, S: void 0 });
50
40
  return true;
51
41
  }
52
42
  };
@@ -54,12 +44,7 @@ var storeObservabilityDisabled = async (namespace, value2) => {
54
44
  try {
55
45
  await localForage.setItem(compositeKey(namespace, OBSERVABILITY_DISABLED_KEY), String(value2));
56
46
  } catch (err) {
57
- log.catch("Failed to store observability disabled", err, {
58
- F: __dxlog_file,
59
- L: 38,
60
- S: void 0,
61
- C: (f, a) => f(...a)
62
- });
47
+ log.catch("Failed to store observability disabled", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 29, S: void 0 });
63
48
  }
64
49
  try {
65
50
  if (typeof localStorage !== "undefined") {
@@ -72,24 +57,14 @@ var getObservabilityGroup = async (namespace) => {
72
57
  try {
73
58
  return await localForage.getItem(compositeKey(namespace, OBSERVABILITY_GROUP_KEY)) ?? void 0;
74
59
  } catch (err) {
75
- log.catch("Failed to get observability group", err, {
76
- F: __dxlog_file,
77
- L: 58,
78
- S: void 0,
79
- C: (f, a) => f(...a)
80
- });
60
+ log.catch("Failed to get observability group", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 47, S: void 0 });
81
61
  }
82
62
  };
83
63
  var storeObservabilityGroup = async (namespace, value2) => {
84
64
  try {
85
65
  await localForage.setItem(compositeKey(namespace, OBSERVABILITY_GROUP_KEY), value2);
86
66
  } catch (err) {
87
- log.catch("Failed to store observability group", err, {
88
- F: __dxlog_file,
89
- L: 69,
90
- S: void 0,
91
- C: (f, a) => f(...a)
92
- });
67
+ log.catch("Failed to store observability group", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0 });
93
68
  }
94
69
  };
95
70
 
@@ -116,12 +91,7 @@ var ObservabilityImpl = class {
116
91
  this._subscriptions.add(...cleanups.filter((cleanup) => cleanup !== void 0));
117
92
  this._initialized = true;
118
93
  }).pipe(Effect.catchAll((error) => Effect.gen(this, function* () {
119
- log2.catch(error, void 0, {
120
- F: __dxlog_file2,
121
- L: 85,
122
- S: this,
123
- C: (f, a) => f(...a)
124
- });
94
+ log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 32, S: this });
125
95
  for (const extension of initializedExtensions) {
126
96
  if (extension.close) {
127
97
  yield* extension.close().pipe(Effect.catchAll(() => Effect.succeed(void 0)));
@@ -170,27 +140,11 @@ var ObservabilityImpl = class {
170
140
  });
171
141
  }
172
142
  _addExtension(extension) {
173
- invariant(!this._initialized, "Observability is already initialized", {
174
- F: __dxlog_file2,
175
- L: 142,
176
- S: this,
177
- A: [
178
- "!this._initialized",
179
- "'Observability is already initialized'"
180
- ]
181
- });
143
+ invariant(!this._initialized, "Observability is already initialized", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 82, S: this, A: ["!this._initialized", "'Observability is already initialized'"] });
182
144
  this._extensions.push(extension);
183
145
  }
184
146
  _addDataProvider(dataProvider) {
185
- invariant(!this._initialized, "Observability is already initialized", {
186
- F: __dxlog_file2,
187
- L: 147,
188
- S: this,
189
- A: [
190
- "!this._initialized",
191
- "'Observability is already initialized'"
192
- ]
193
- });
147
+ invariant(!this._initialized, "Observability is already initialized", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 86, S: this, A: ["!this._initialized", "'Observability is already initialized'"] });
194
148
  this._dataProviders.push(dataProvider);
195
149
  }
196
150
  /**
@@ -250,10 +204,12 @@ var ObservabilityImpl = class {
250
204
  }
251
205
  get feedback() {
252
206
  return {
253
- captureUserFeedback: (form) => {
207
+ captureUserFeedback: async (form) => {
208
+ let eventUuid;
254
209
  for (const extension of this._getExtensions("feedback")) {
255
- extension.captureUserFeedback(form);
210
+ eventUuid = await extension.captureUserFeedback(form) ?? eventUuid;
256
211
  }
212
+ return eventUuid;
257
213
  }
258
214
  };
259
215
  }
@@ -299,29 +255,13 @@ var make = () => Effect.succeed(new ObservabilityImpl());
299
255
  var addExtension = (_extension) => Effect.fn(function* (_observability) {
300
256
  const observability = yield* _observability;
301
257
  const extension = yield* _extension;
302
- invariant("_addExtension" in observability && typeof observability._addExtension === "function", void 0, {
303
- F: __dxlog_file2,
304
- L: 276,
305
- S: this,
306
- A: [
307
- "'_addExtension' in observability && typeof observability._addExtension === 'function'",
308
- ""
309
- ]
310
- });
258
+ invariant("_addExtension" in observability && typeof observability._addExtension === "function", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 196, S: this, A: ["'_addExtension' in observability && typeof observability._addExtension === 'function'", ""] });
311
259
  observability._addExtension(extension);
312
260
  return observability;
313
261
  });
314
262
  var addDataProvider = (dataProvider) => Effect.fn(function* (_observability) {
315
263
  const observability = yield* _observability;
316
- invariant("_addDataProvider" in observability && typeof observability._addDataProvider === "function", void 0, {
317
- F: __dxlog_file2,
318
- L: 284,
319
- S: this,
320
- A: [
321
- "'_addDataProvider' in observability && typeof observability._addDataProvider === 'function'",
322
- ""
323
- ]
324
- });
264
+ invariant("_addDataProvider" in observability && typeof observability._addDataProvider === "function", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 202, S: this, A: ["'_addDataProvider' in observability && typeof observability._addDataProvider === 'function'", ""] });
325
265
  observability._addDataProvider(dataProvider);
326
266
  return observability;
327
267
  });
@@ -395,24 +335,22 @@ var extensions = Effect3.fn(function* ({
395
335
  metrics: metricsEnabled = false,
396
336
  traces: tracesEnabled = false
397
337
  }) {
398
- const { OtelLogs } = yield* Effect3.promise(() => import("./logs-ATTRIUTL.mjs"));
399
- const { OtelMetrics } = yield* Effect3.promise(() => import("./metrics-PKTV6IGF.mjs"));
400
- const { OtelTraces } = yield* Effect3.promise(() => import("./traces-browser-Y4FFWRIR.mjs"));
338
+ const { OtelLogs } = yield* Effect3.promise(() => import("./logs-UTNIFYHF.mjs"));
339
+ const { OtelMetrics } = yield* Effect3.promise(() => import("./metrics-PRGSYAZJ.mjs"));
340
+ const { OtelTraces } = yield* Effect3.promise(() => import("./traces-browser-XRINKQUA.mjs"));
401
341
  const cachedDisabled = yield* Effect3.promise(() => isObservabilityDisabled(serviceName));
402
342
  const disabled = cachedDisabled || isObservabilityDisabledSync(serviceName);
403
343
  const enabledRef = yield* Ref.make(!disabled);
404
344
  const tags = /* @__PURE__ */ new Map();
405
- const endpoint = isNode() ? process.env.DX_OTEL_ENDPOINT ?? _endpoint ?? cli_observability_secrets_default.OTEL_ENDPOINT : config.values.runtime?.app?.env?.DX_OTEL_ENDPOINT;
345
+ const rawEndpoint = isNode() ? process.env.DX_OTEL_ENDPOINT ?? _endpoint ?? cli_observability_secrets_default.OTEL_ENDPOINT : config.values.runtime?.app?.env?.DX_OTEL_ENDPOINT ?? _endpoint;
346
+ const endpoint = !isNode() && rawEndpoint?.startsWith("/") ? resolveRelativeEndpoint(rawEndpoint) : rawEndpoint;
406
347
  const headers = _headers ?? Match.value(isNode()).pipe(Match.when(true, () => Option.fromNullable(process.env.DX_OTEL_HEADERS ?? cli_observability_secrets_default.OTEL_HEADERS)), Match.when(false, () => Option.fromNullable(config.values.runtime?.app?.env?.DX_OTEL_HEADERS)), Match.exhaustive, Option.map((raw) => parseHeaders(raw)), Option.getOrElse(() => void 0));
407
- if (!endpoint || !headers) {
408
- log3.info("Missing OTEL_ENDPOINT or OTEL_HEADERS", void 0, {
409
- F: __dxlog_file3,
410
- L: 78,
411
- S: this,
412
- C: (f, a) => f(...a)
413
- });
348
+ if (!endpoint) {
349
+ log3.info("Missing OTEL_ENDPOINT", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 35, S: this });
414
350
  return stubExtension;
415
351
  }
352
+ const resolvedHeaders = headers ?? {};
353
+ const resolvedEndpoint = !isNode() && endpoint.startsWith("/") ? `${globalThis.location.origin}${endpoint}` : endpoint;
416
354
  const clientTag = resolveTelemetryTag(config);
417
355
  if (clientTag) {
418
356
  tags.set("ctx.tag", clientTag);
@@ -428,21 +366,21 @@ var extensions = Effect3.fn(function* ({
428
366
  } : {}
429
367
  }));
430
368
  const logs = logsEnabled ? new OtelLogs({
431
- endpoint,
432
- headers,
369
+ endpoint: resolvedEndpoint,
370
+ headers: resolvedHeaders,
433
371
  resource,
434
372
  getTags: () => Object.fromEntries(tags),
435
373
  logLevel
436
374
  }) : void 0;
437
375
  const metrics = metricsEnabled ? new OtelMetrics({
438
- endpoint,
439
- headers,
376
+ endpoint: resolvedEndpoint,
377
+ headers: resolvedHeaders,
440
378
  resource,
441
379
  getTags: () => Object.fromEntries(tags)
442
380
  }) : void 0;
443
381
  const traces = tracesEnabled ? new OtelTraces({
444
- endpoint,
445
- headers,
382
+ endpoint: resolvedEndpoint,
383
+ headers: resolvedHeaders,
446
384
  resource,
447
385
  getTags: () => Object.fromEntries(tags)
448
386
  }) : void 0;
@@ -473,12 +411,7 @@ var extensions = Effect3.fn(function* ({
473
411
  ]);
474
412
  for (const result of results) {
475
413
  if (result.status === "rejected") {
476
- log3.catch(result.reason, void 0, {
477
- F: __dxlog_file3,
478
- L: 170,
479
- S: this,
480
- C: (f, a) => f(...a)
481
- });
414
+ log3.catch(result.reason, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 120, S: this });
482
415
  }
483
416
  }
484
417
  await traces?.close();
@@ -490,12 +423,7 @@ var extensions = Effect3.fn(function* ({
490
423
  ]);
491
424
  for (const result of results) {
492
425
  if (result.status === "rejected") {
493
- log3.catch(result.reason, void 0, {
494
- F: __dxlog_file3,
495
- L: 183,
496
- S: this,
497
- C: (f, a) => f(...a)
498
- });
426
+ log3.catch(result.reason, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 135, S: this });
499
427
  }
500
428
  }
501
429
  await traces?.flush();
@@ -555,6 +483,10 @@ var detectProcessType = () => {
555
483
  }
556
484
  return "dedicated-worker";
557
485
  };
486
+ var resolveRelativeEndpoint = (path) => {
487
+ const origin = globalThis.location?.origin;
488
+ return origin ? `${origin}${path}` : path;
489
+ };
558
490
  var parseHeaders = (unparsedHeaders) => {
559
491
  return unparsedHeaders.split(";").reduce((acc, header) => {
560
492
  const [key, ...rest] = header.split(":");
@@ -573,7 +505,7 @@ __export(posthog_exports, {
573
505
 
574
506
  // src/extensions/posthog/extension.ts
575
507
  import * as Effect4 from "effect/Effect";
576
- import { LogBuffer, log as log4 } from "@dxos/log";
508
+ import { log as log4 } from "@dxos/log";
577
509
  var __dxlog_file4 = "/__w/dxos/dxos/packages/sdk/observability/src/extensions/posthog/extension.ts";
578
510
  var uploadLogs = async (body) => {
579
511
  try {
@@ -587,12 +519,7 @@ var uploadLogs = async (body) => {
587
519
  if (!response.ok) {
588
520
  log4.warn("feedback log upload failed", {
589
521
  status: response.status
590
- }, {
591
- F: __dxlog_file4,
592
- L: 34,
593
- S: void 0,
594
- C: (f, a) => f(...a)
595
- });
522
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 17, S: void 0 });
596
523
  return void 0;
597
524
  }
598
525
  const { key } = await response.json();
@@ -600,40 +527,24 @@ var uploadLogs = async (body) => {
600
527
  } catch (err) {
601
528
  log4.warn("feedback log upload error", {
602
529
  error: err
603
- }, {
604
- F: __dxlog_file4,
605
- L: 40,
606
- S: void 0,
607
- C: (f, a) => f(...a)
608
- });
530
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 25, S: void 0 });
609
531
  return void 0;
610
532
  }
611
533
  };
612
- var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog: posthogConfig, logBuffer: externalLogBuffer }) {
534
+ var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog: posthogConfig, logStore, feedbackLogMaxSize }) {
613
535
  if (typeof window === "undefined") {
614
- log4("PostHog is being stubbed because it is running in a worker.", void 0, {
615
- F: __dxlog_file4,
616
- L: 54,
617
- S: this,
618
- C: (f, a) => f(...a)
619
- });
536
+ log4("PostHog is being stubbed because it is running in a worker.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 33, S: this });
620
537
  return stubExtension;
621
538
  }
622
539
  const feedbackSurveyId = config.get("runtime.app.env.DX_POSTHOG_FEEDBACK_SURVEY_ID");
623
540
  const apiKey = config.get("runtime.app.env.DX_POSTHOG_API_KEY");
624
541
  const api_host = config.get("runtime.app.env.DX_POSTHOG_API_HOST");
625
542
  if (!apiKey || !api_host) {
626
- log4.info("Missing POSTHOG_API_KEY or POSTHOG_API_HOST", void 0, {
627
- F: __dxlog_file4,
628
- L: 62,
629
- S: this,
630
- C: (f, a) => f(...a)
631
- });
543
+ log4.info("Missing POSTHOG_API_KEY or POSTHOG_API_HOST", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 40, S: this });
632
544
  return stubExtension;
633
545
  }
634
546
  const { default: posthog } = yield* Effect4.promise(() => import("posthog-js"));
635
- const { logProcessor } = yield* Effect4.promise(() => import("./log-processor-A6PJG6CM.mjs"));
636
- const logBuffer = externalLogBuffer ?? new LogBuffer();
547
+ const { logProcessor } = yield* Effect4.promise(() => import("./log-processor-HPHWNBOK.mjs"));
637
548
  let feedbackSurveyAvailable = null;
638
549
  let unregisterPosthogProcessors;
639
550
  const checkFeedbackSurveyAvailable = () => feedbackSurveyId ? Effect4.promise(() => {
@@ -667,21 +578,9 @@ var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog:
667
578
  });
668
579
  }
669
580
  unregisterPosthogProcessors?.();
670
- const removePosthogLog = log4.addProcessor(logProcessor, void 0, {
671
- F: __dxlog_file4,
672
- L: 105,
673
- S: this,
674
- C: (f, a) => f(...a)
675
- });
676
- const removeLogBuffer = log4.addProcessor(logBuffer.logProcessor, void 0, {
677
- F: __dxlog_file4,
678
- L: 106,
679
- S: this,
680
- C: (f, a) => f(...a)
681
- });
581
+ const removePosthogLog = log4.addProcessor(logProcessor, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 79, S: this });
682
582
  unregisterPosthogProcessors = () => {
683
583
  removePosthogLog();
684
- removeLogBuffer();
685
584
  };
686
585
  }),
687
586
  close: () => Effect4.sync(() => {
@@ -721,34 +620,47 @@ var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog:
721
620
  kind: "feedback",
722
621
  // TODO(wittjosiah): Support custom surveys.
723
622
  captureUserFeedback: (form) => {
724
- posthog.getSurveys(async (surveys) => {
725
- const survey = surveys.find((survey2) => survey2.id === feedbackSurveyId);
726
- if (!survey || survey.questions.length === 0) {
727
- log4.error("Missing feedback survey or survey has no questions", {
728
- feedbackSurveyId
729
- }, {
730
- F: __dxlog_file4,
731
- L: 153,
732
- S: this,
733
- C: (f, a) => f(...a)
734
- });
735
- return;
736
- }
737
- let debugLogDumpKey = null;
738
- if (form.includeLogs !== false && logBuffer.size > 0) {
739
- debugLogDumpKey = await uploadLogs(logBuffer.serialize()) ?? "failed";
740
- }
741
- const question = survey.questions[0];
742
- posthog.capture("survey sent", {
743
- $survey_id: survey.id,
744
- $survey_questions: [
745
- {
746
- id: question.id,
747
- question: question.question
623
+ return new Promise((resolve, reject) => {
624
+ posthog.getSurveys((surveys) => {
625
+ void (async () => {
626
+ try {
627
+ const survey = surveys.find((survey2) => survey2.id === feedbackSurveyId);
628
+ if (!survey || survey.questions.length === 0) {
629
+ log4.error("Missing feedback survey or survey has no questions", {
630
+ feedbackSurveyId
631
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 127, S: this });
632
+ resolve(void 0);
633
+ return;
634
+ }
635
+ let debugLogDumpKey = null;
636
+ if (form.includeLogs !== false && logStore !== void 0) {
637
+ const ndjson = await logStore.export({
638
+ maxSize: feedbackLogMaxSize
639
+ });
640
+ if (ndjson.length > 0) {
641
+ debugLogDumpKey = await uploadLogs(ndjson) ?? "failed";
642
+ }
643
+ }
644
+ const question = survey.questions[0];
645
+ const result = posthog.capture("survey sent", {
646
+ $survey_id: survey.id,
647
+ $survey_questions: [
648
+ {
649
+ id: question.id,
650
+ question: question.question
651
+ }
652
+ ],
653
+ [`$survey_response_${question.id}`]: form.message,
654
+ debug_log_dump_key: debugLogDumpKey
655
+ });
656
+ resolve(result?.uuid);
657
+ } catch (err) {
658
+ log4.error("Failed to capture user feedback", {
659
+ err
660
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 157, S: this });
661
+ reject(err);
748
662
  }
749
- ],
750
- [`$survey_response_${question.id}`]: form.message,
751
- debug_log_dump_key: debugLogDumpKey
663
+ })();
752
664
  });
753
665
  });
754
666
  },
@@ -814,19 +726,11 @@ var identityProvider = (clientServices) => Effect5.fn(function* (observability)
814
726
  });
815
727
  });
816
728
  var networkMetricsProvider = (clientServices) => Effect5.fn(function* (observability) {
817
- const ctx = new Context(void 0, {
818
- F: __dxlog_file5,
819
- L: 61
820
- });
729
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 50 });
821
730
  let lastNetworkStatus;
822
731
  const updateSignalMetrics = new Event().debounce(NETWORK_METRICS_MIN_INTERVAL);
823
732
  updateSignalMetrics.on(ctx, async () => {
824
- log5("send signal metrics", void 0, {
825
- F: __dxlog_file5,
826
- L: 67,
827
- S: this,
828
- C: (f, a) => f(...a)
829
- });
733
+ log5("send signal metrics", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 55, S: this });
830
734
  lastNetworkStatus?.signaling?.forEach(({ server, state }) => {
831
735
  observability.metrics.gauge("dxos.client.network.signal.connectionState", state, {
832
736
  server
@@ -871,20 +775,11 @@ var networkMetricsProvider = (clientServices) => Effect5.fn(function* (observabi
871
775
  };
872
776
  });
873
777
  var runtimeMetricsProvider = (clientServices) => Effect5.fn(function* (observability) {
874
- const ctx = new Context(void 0, {
875
- F: __dxlog_file5,
876
- L: 121
877
- });
778
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 100 });
779
+ log5("runtimeMetricsProvider: requesting platform from SystemService", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 101, S: this });
878
780
  const platform = yield* Effect5.promise(() => clientServices.SystemService.getPlatform());
879
- invariant2(platform, "platform is required", {
880
- F: __dxlog_file5,
881
- L: 123,
882
- S: this,
883
- A: [
884
- "platform",
885
- "'platform is required'"
886
- ]
887
- });
781
+ log5("runtimeMetricsProvider: platform received", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 103, S: this });
782
+ invariant2(platform, "platform is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 104, S: this, A: ["platform", "'platform is required'"] });
888
783
  observability.setTags({
889
784
  platformType: Platform.PLATFORM_TYPE[platform.type].toLowerCase(),
890
785
  platform: platform.platform,
@@ -908,33 +803,20 @@ var runtimeMetricsProvider = (clientServices) => Effect5.fn(function* (observabi
908
803
  }
909
804
  }).catch((error) => log5("platform error", {
910
805
  error
911
- }, {
912
- F: __dxlog_file5,
913
- L: 152,
914
- S: this,
915
- C: (f, a) => f(...a)
916
- }));
806
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 126, S: this }));
917
807
  }, RUNTIME_METRICS_MIN_INTERVAL);
918
808
  return async () => {
919
809
  await ctx.dispose();
920
810
  };
921
811
  });
922
812
  var spacesMetricsProvider = (client) => Effect5.fn(function* (observability) {
923
- const ctx = new Context(void 0, {
924
- F: __dxlog_file5,
925
- L: 165
926
- });
813
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 135 });
927
814
  const spaces = client.spaces.get();
928
815
  const subscriptions = /* @__PURE__ */ new Map();
929
816
  ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
930
817
  const updateSpaceMetrics = new Event().debounce(SPACE_METRICS_MIN_INTERVAL);
931
818
  updateSpaceMetrics.on(ctx, async () => {
932
- log5("send space metrics", void 0, {
933
- F: __dxlog_file5,
934
- L: 173,
935
- S: this,
936
- C: (f, a) => f(...a)
937
- });
819
+ log5("send space metrics", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 142, S: this });
938
820
  for (const data of mapSpaces(spaces, {
939
821
  truncateKeys: true
940
822
  })) {
@@ -1055,12 +937,7 @@ var provider = (config) => (observability) => Effect6.gen(function* () {
1055
937
  }).pipe(Effect6.provide(FetchHttpClient.layer), Effect6.catchAll((err) => Effect6.sync(() => {
1056
938
  log6.verbose("ipdata fetch failed", {
1057
939
  err
1058
- }, {
1059
- F: __dxlog_file6,
1060
- L: 88,
1061
- S: void 0,
1062
- C: (f, a) => f(...a)
1063
- });
940
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 54, S: void 0 });
1064
941
  })));
1065
942
 
1066
943
  // src/providers/storage.ts