@dxos/observability 0.3.11-main.ff3a851 → 0.3.11-next.e28df4f

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 (82) hide show
  1. package/README.md +4 -9
  2. package/dist/lib/browser/{chunk-6ZTMPKEG.mjs → chunk-2J5YS65Q.mjs} +3 -3
  3. package/dist/lib/browser/{chunk-6ZTMPKEG.mjs.map → chunk-2J5YS65Q.mjs.map} +3 -3
  4. package/dist/lib/browser/{chunk-HPGC4HC7.mjs → chunk-ROSK6U3K.mjs} +3 -3
  5. package/dist/lib/browser/chunk-ROSK6U3K.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-OCQVYNE3.mjs → chunk-STWCJK52.mjs} +129 -223
  7. package/dist/lib/browser/chunk-STWCJK52.mjs.map +7 -0
  8. package/dist/lib/browser/datadog/index.mjs +1 -1
  9. package/dist/lib/browser/index.mjs +5 -9
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/observability-XIDFB6PJ.mjs +10 -0
  12. package/dist/lib/browser/segment/index.mjs +1 -1
  13. package/dist/lib/node/{chunk-BHF4PKAP.cjs → chunk-ARUBPK2W.cjs} +6 -6
  14. package/dist/lib/node/chunk-ARUBPK2W.cjs.map +7 -0
  15. package/dist/lib/node/{chunk-CBMRJXSL.cjs → chunk-DE7OVD7T.cjs} +119 -211
  16. package/dist/lib/node/chunk-DE7OVD7T.cjs.map +7 -0
  17. package/dist/lib/node/{chunk-ZJRKFREX.cjs → chunk-VDBBIYH6.cjs} +6 -6
  18. package/dist/lib/node/{chunk-ZJRKFREX.cjs.map → chunk-VDBBIYH6.cjs.map} +3 -3
  19. package/dist/lib/node/datadog/index.cjs +3 -3
  20. package/dist/lib/node/datadog/index.cjs.map +1 -1
  21. package/dist/lib/node/index.cjs +16 -20
  22. package/dist/lib/node/index.cjs.map +2 -2
  23. package/dist/lib/node/meta.json +1 -1
  24. package/dist/lib/node/{observability-JMKBRR4L.cjs → observability-YMIQHLME.cjs} +8 -8
  25. package/dist/lib/node/observability-YMIQHLME.cjs.map +7 -0
  26. package/dist/lib/node/segment/index.cjs +2 -2
  27. package/dist/lib/node/segment/index.cjs.map +1 -1
  28. package/dist/types/src/datadog/metrics.d.ts +1 -3
  29. package/dist/types/src/datadog/metrics.d.ts.map +1 -1
  30. package/dist/types/src/datadog/metrics.js +1 -1
  31. package/dist/types/src/datadog/metrics.js.map +1 -1
  32. package/dist/types/src/helpers/{browser-observability.d.ts → app-observability.d.ts} +6 -4
  33. package/dist/types/src/helpers/app-observability.d.ts.map +1 -0
  34. package/dist/types/src/helpers/{browser-observability.js → app-observability.js} +51 -22
  35. package/dist/types/src/helpers/app-observability.js.map +1 -0
  36. package/dist/types/src/helpers/index.d.ts +1 -3
  37. package/dist/types/src/helpers/index.d.ts.map +1 -1
  38. package/dist/types/src/helpers/index.js +1 -3
  39. package/dist/types/src/helpers/index.js.map +1 -1
  40. package/dist/types/src/helpers/setup-telemetry-listeners.d.ts.map +1 -1
  41. package/dist/types/src/helpers/setup-telemetry-listeners.js +12 -7
  42. package/dist/types/src/helpers/setup-telemetry-listeners.js.map +1 -1
  43. package/dist/types/src/observability.d.ts +4 -5
  44. package/dist/types/src/observability.d.ts.map +1 -1
  45. package/dist/types/src/observability.js +16 -29
  46. package/dist/types/src/observability.js.map +1 -1
  47. package/dist/types/src/segment/browser.d.ts.map +1 -1
  48. package/dist/types/src/segment/browser.js +2 -2
  49. package/dist/types/src/segment/browser.js.map +1 -1
  50. package/dist/types/src/segment/node.d.ts.map +1 -1
  51. package/dist/types/src/segment/node.js +2 -2
  52. package/dist/types/src/segment/node.js.map +1 -1
  53. package/dist/types/src/segment/types.d.ts +1 -3
  54. package/dist/types/src/segment/types.d.ts.map +1 -1
  55. package/package.json +14 -17
  56. package/src/datadog/metrics.ts +5 -3
  57. package/src/helpers/{browser-observability.ts → app-observability.ts} +54 -26
  58. package/src/helpers/index.ts +1 -3
  59. package/src/helpers/setup-telemetry-listeners.ts +7 -2
  60. package/src/observability.ts +20 -40
  61. package/src/segment/browser.ts +3 -3
  62. package/src/segment/node.ts +3 -3
  63. package/src/segment/types.ts +1 -1
  64. package/dist/lib/browser/chunk-HPGC4HC7.mjs.map +0 -7
  65. package/dist/lib/browser/chunk-OCQVYNE3.mjs.map +0 -7
  66. package/dist/lib/browser/observability-QNG5QON4.mjs +0 -10
  67. package/dist/lib/node/chunk-BHF4PKAP.cjs.map +0 -7
  68. package/dist/lib/node/chunk-CBMRJXSL.cjs.map +0 -7
  69. package/dist/lib/node/observability-JMKBRR4L.cjs.map +0 -7
  70. package/dist/types/src/helpers/browser-observability.d.ts.map +0 -1
  71. package/dist/types/src/helpers/browser-observability.js.map +0 -1
  72. package/dist/types/src/helpers/common.d.ts +0 -10
  73. package/dist/types/src/helpers/common.d.ts.map +0 -1
  74. package/dist/types/src/helpers/common.js +0 -23
  75. package/dist/types/src/helpers/common.js.map +0 -1
  76. package/dist/types/src/helpers/node-observability.d.ts +0 -34
  77. package/dist/types/src/helpers/node-observability.d.ts.map +0 -1
  78. package/dist/types/src/helpers/node-observability.js +0 -106
  79. package/dist/types/src/helpers/node-observability.js.map +0 -1
  80. package/src/helpers/common.ts +0 -25
  81. package/src/helpers/node-observability.ts +0 -151
  82. /package/dist/lib/browser/{observability-QNG5QON4.mjs.map → observability-XIDFB6PJ.mjs.map} +0 -0
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  DatadogMetrics
3
- } from "./chunk-6ZTMPKEG.mjs";
3
+ } from "./chunk-2J5YS65Q.mjs";
4
4
  import {
5
5
  SegmentTelemetry
6
- } from "./chunk-HPGC4HC7.mjs";
6
+ } from "./chunk-ROSK6U3K.mjs";
7
7
  import {
8
8
  captureException,
9
9
  configureTracing,
@@ -16,7 +16,7 @@ import {
16
16
  import { Event, scheduleTaskInterval } from "@dxos/async";
17
17
  import { Context } from "@dxos/context";
18
18
  import { invariant } from "@dxos/invariant";
19
- import { log as log3 } from "@dxos/log";
19
+ import { log as log2 } from "@dxos/log";
20
20
  import { ConnectionState } from "@dxos/network-manager";
21
21
  import { DeviceKind, Platform } from "@dxos/protocols/proto/dxos/client/services";
22
22
  import { isNode } from "@dxos/util";
@@ -30,19 +30,46 @@ var cli_observability_secrets_default = {
30
30
  DATADOG_APP_KEY: null
31
31
  };
32
32
 
33
- // packages/sdk/observability/src/helpers/browser-observability.ts
33
+ // packages/sdk/observability/src/helpers/app-observability.ts
34
34
  import * as localForage from "localforage";
35
35
  import { log } from "@dxos/log";
36
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/browser-observability.ts";
37
- var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
38
- var OBSERVABILITY_GROUP_KEY = "observability-group";
36
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/app-observability.ts";
37
+ var BASE_TELEMETRY_PROPERTIES = {};
38
+ var OBSERVABILITY_DISABLED_KEY = "telemetry-disabled";
39
+ var OBSERVABILITY_GROUP_KEY = "telemetry-group";
40
+ if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
41
+ setInterval(async () => {
42
+ try {
43
+ const storageEstimate = await navigator.storage.estimate();
44
+ BASE_TELEMETRY_PROPERTIES.storageUsage = storageEstimate.usage;
45
+ BASE_TELEMETRY_PROPERTIES.storageQuota = storageEstimate.quota;
46
+ } catch (error) {
47
+ log.warn("Failed to run estimate()", error, {
48
+ F: __dxlog_file,
49
+ L: 27,
50
+ S: void 0,
51
+ C: (f, a) => f(...a)
52
+ });
53
+ }
54
+ }, 1e4);
55
+ }
56
+ var getTelemetryIdentifier = (client) => {
57
+ if (!client?.initialized) {
58
+ return void 0;
59
+ }
60
+ const identity = client.halo.identity.get();
61
+ if (identity) {
62
+ return identity.identityKey.truncate();
63
+ }
64
+ return void 0;
65
+ };
39
66
  var isObservabilityDisabled = async (namespace) => {
40
67
  try {
41
68
  return await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`) === "true";
42
69
  } catch (err) {
43
70
  log.catch("Failed to check if observability is disabled, assuming it is", err, {
44
71
  F: __dxlog_file,
45
- L: 24,
72
+ L: 54,
46
73
  S: void 0,
47
74
  C: (f, a) => f(...a)
48
75
  });
@@ -55,7 +82,7 @@ var storeObservabilityDisabled = async (namespace, value) => {
55
82
  } catch (err) {
56
83
  log.catch("Failed to store observability disabled", err, {
57
84
  F: __dxlog_file,
58
- L: 33,
85
+ L: 63,
59
86
  S: void 0,
60
87
  C: (f, a) => f(...a)
61
88
  });
@@ -67,7 +94,7 @@ var getObservabilityGroup = async (namespace) => {
67
94
  } catch (err) {
68
95
  log.catch("Failed to get observability group", err, {
69
96
  F: __dxlog_file,
70
- L: 41,
97
+ L: 71,
71
98
  S: void 0,
72
99
  C: (f, a) => f(...a)
73
100
  });
@@ -79,7 +106,7 @@ var storeObservabilityGroup = async (namespace, value) => {
79
106
  } catch (err) {
80
107
  log.catch("Failed to store observability group", err, {
81
108
  F: __dxlog_file,
82
- L: 49,
109
+ L: 79,
83
110
  S: void 0,
84
111
  C: (f, a) => f(...a)
85
112
  });
@@ -90,15 +117,18 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
90
117
  config
91
118
  }, {
92
119
  F: __dxlog_file,
93
- L: 72,
120
+ L: 104,
94
121
  S: void 0,
95
122
  C: (f, a) => f(...a)
96
123
  });
97
124
  const group = await getObservabilityGroup(namespace) ?? void 0;
98
125
  const release = `${namespace}@${config.get("runtime.app.build.version")}`;
99
126
  const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
127
+ BASE_TELEMETRY_PROPERTIES.group = group;
128
+ BASE_TELEMETRY_PROPERTIES.release = release;
129
+ BASE_TELEMETRY_PROPERTIES.environment = environment;
100
130
  const observabilityDisabled = await isObservabilityDisabled(namespace);
101
- const { Observability: Observability2 } = await import("./observability-QNG5QON4.mjs");
131
+ const { Observability: Observability2 } = await import("./observability-XIDFB6PJ.mjs");
102
132
  const observability = new Observability2({
103
133
  namespace,
104
134
  group,
@@ -121,7 +151,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
121
151
  observability.setMode("disabled");
122
152
  log.info("observability disabled", void 0, {
123
153
  F: __dxlog_file,
124
- L: 113,
154
+ L: 147,
125
155
  S: void 0,
126
156
  C: (f, a) => f(...a)
127
157
  });
@@ -130,14 +160,14 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
130
160
  try {
131
161
  const getIPData = async (config2) => {
132
162
  const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1e3;
133
- const cachedData = await localForage.getItem("dxos:observability:ipdata");
163
+ const cachedData = await localForage.getItem("dxos:telemetry:ipdata");
134
164
  if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {
135
165
  return cachedData.data;
136
166
  }
137
167
  const IPDATA_API_KEY = config2.get("runtime.app.env.DX_IPDATA_API_KEY");
138
168
  if (IPDATA_API_KEY) {
139
169
  return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`).then((res) => res.json()).then((data) => {
140
- localForage.setItem("dxos:observability:ipdata", {
170
+ localForage.setItem("dxos:telemetry:ipdata", {
141
171
  data,
142
172
  timestamp: Date.now()
143
173
  }).catch((err) => observability.captureException(err));
@@ -145,29 +175,19 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
145
175
  }).catch((err) => observability.captureException(err));
146
176
  }
147
177
  };
148
- observability.initialize();
149
178
  const ipData = await getIPData(config);
150
- ipData && observability.addIPDataTelemetryTags(ipData);
151
- if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
152
- setInterval(async () => {
153
- try {
154
- const storageEstimate = await navigator.storage.estimate();
155
- storageEstimate.usage && observability.setTag("storageUsage", storageEstimate.usage.toString(), "telemetry");
156
- storageEstimate.quota && observability.setTag("storageQuota", storageEstimate.quota.toString(), "telemetry");
157
- } catch (error) {
158
- log.warn("Failed to run estimate()", error, {
159
- F: __dxlog_file,
160
- L: 168,
161
- S: void 0,
162
- C: (f, a) => f(...a)
163
- });
164
- }
165
- }, 1e4);
179
+ if (ipData && ipData.city) {
180
+ BASE_TELEMETRY_PROPERTIES.city = ipData.city;
181
+ BASE_TELEMETRY_PROPERTIES.region = ipData.region;
182
+ BASE_TELEMETRY_PROPERTIES.country = ipData.country;
183
+ BASE_TELEMETRY_PROPERTIES.latitude = ipData.latitude;
184
+ BASE_TELEMETRY_PROPERTIES.longitude = ipData.longitude;
166
185
  }
186
+ observability.initialize();
167
187
  } catch (err) {
168
188
  log.error("Failed to initialize app observability", err, {
169
189
  F: __dxlog_file,
170
- L: 173,
190
+ L: 201,
171
191
  S: void 0,
172
192
  C: (f, a) => f(...a)
173
193
  });
@@ -175,109 +195,6 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
175
195
  return observability;
176
196
  };
177
197
 
178
- // packages/sdk/observability/src/helpers/common.ts
179
- var getTelemetryIdentifier = (client) => {
180
- if (!client?.initialized) {
181
- return void 0;
182
- }
183
- const identity = client.halo.identity.get();
184
- if (identity) {
185
- return identity.identityKey.truncate();
186
- }
187
- return void 0;
188
- };
189
-
190
- // packages/sdk/observability/src/helpers/node-observability.ts
191
- import yaml from "js-yaml";
192
- import { existsSync, statSync } from "@dxos/node-std/fs";
193
- import { mkdir, readFile, writeFile } from "@dxos/node-std/fs/promises";
194
- import { join } from "@dxos/node-std/path";
195
- import { v4 as uuid, validate as validateUuid } from "uuid";
196
- import { log as log2 } from "@dxos/log";
197
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/node-observability.ts";
198
- var showObservabilityBanner = async (configDir, bannercb) => {
199
- const path = join(configDir, ".observability-banner-printed");
200
- if (existsSync(path)) {
201
- return;
202
- }
203
- bannercb(
204
- // eslint-disable-next-line no-multi-str
205
- "Basic observability data will be sent to the DXOS team in order to improve the product. This includes performance metrics, error logs, and usage data. No personally identifiable information, other than your public key, is included with this data and no private data ever leaves your devices. To disable sending observability data, set the environment variable DX_DISABLE_TELEMETRY=true."
206
- );
207
- await writeFile(path, "", "utf-8");
208
- };
209
- var getObservabilityState = async (configDir) => {
210
- if (existsSync(configDir)) {
211
- if (!statSync(configDir).isDirectory()) {
212
- throw new Error(`Config directory ${configDir} exists but is not a directory`);
213
- }
214
- } else {
215
- await mkdir(configDir, {
216
- recursive: true
217
- });
218
- }
219
- const idPath = join(configDir, "observability.yml");
220
- if (existsSync(idPath)) {
221
- const context = await readFile(idPath, "utf-8");
222
- return validate(context) ?? initializeState(idPath);
223
- }
224
- return initializeState(idPath);
225
- };
226
- var initializeState = async (idPath) => {
227
- const observabilityState = {
228
- installationId: uuid(),
229
- group: process.env.DX_TELEMETRY_GROUP ?? void 0,
230
- mode: process.env.DX_DISABLE_TELEMETRY ? "disabled" : process.env.DX_TELEMETRY_MODE ?? "basic"
231
- };
232
- await writeFile(idPath, "# This file is automatically generated by the @dxos/cli.\n" + yaml.dump(observabilityState), "utf-8");
233
- return observabilityState;
234
- };
235
- var validate = (contextString) => {
236
- const context = yaml.load(contextString);
237
- if (Boolean(context.installationId) && validateUuid(context.installationId)) {
238
- return {
239
- ...context,
240
- mode: process.env.DX_DISABLE_TELEMETRY ? "disabled" : context.mode ?? "basic"
241
- };
242
- }
243
- };
244
- var initializeNodeObservability = async ({ namespace, config, installationId, group, mode = "basic", tracingEnable = true, replayEnable = true }) => {
245
- log2("initializeCliObservability", {
246
- config
247
- }, {
248
- F: __dxlog_file2,
249
- L: 120,
250
- S: void 0,
251
- C: (f, a) => f(...a)
252
- });
253
- const release = `${namespace}@${config.get("runtime.app.build.version")}`;
254
- const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
255
- const observability = new Observability({
256
- namespace,
257
- group,
258
- mode,
259
- errorLog: {
260
- sentryInitOptions: {
261
- environment,
262
- release,
263
- // TODO(wittjosiah): Configure this.
264
- sampleRate: 1
265
- },
266
- logProcessor: true
267
- }
268
- });
269
- observability.setTag("installationId", installationId);
270
- const IPDATA_API_KEY = config.get("runtime.app.env.DX_IPDATA_API_KEY");
271
- try {
272
- const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);
273
- const ipData = await res.json();
274
- ipData && observability.addIPDataTelemetryTags(ipData);
275
- } catch (err) {
276
- observability?.captureException(err);
277
- }
278
- return observability;
279
- };
280
-
281
198
  // packages/sdk/observability/src/helpers/map-spaces.ts
282
199
  var mapSpaces = (spaces, options = {
283
200
  verbose: false,
@@ -314,13 +231,14 @@ var lastFocusEvent = /* @__PURE__ */ new Date();
314
231
  var totalTime = 0;
315
232
  var setupTelemetryListeners = (namespace, client, observability) => {
316
233
  const clickCallback = (event) => {
317
- if (observability.group === "dxos" && event.target && !event.target.id) {
234
+ if (BASE_TELEMETRY_PROPERTIES.group === "dxos" && event.target && !event.target.id) {
318
235
  console.warn("Click event on element without id:", event.target);
319
236
  }
320
237
  setTimeout(() => observability.event({
321
238
  identityId: getTelemetryIdentifier(client),
322
239
  name: `${namespace}.window.click`,
323
240
  properties: {
241
+ ...BASE_TELEMETRY_PROPERTIES,
324
242
  href: window.location.href,
325
243
  id: event.target?.id,
326
244
  path: event.path?.filter((el) => Boolean(el.tagName)).map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}`).reverse().join(">")
@@ -333,6 +251,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
333
251
  identityId: getTelemetryIdentifier(client),
334
252
  name: `${namespace}.window.focus`,
335
253
  properties: {
254
+ ...BASE_TELEMETRY_PROPERTIES,
336
255
  href: window.location.href,
337
256
  timeAway: now.getTime() - lastFocusEvent.getTime()
338
257
  }
@@ -346,6 +265,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
346
265
  identityId: getTelemetryIdentifier(client),
347
266
  name: `${namespace}.window.blur`,
348
267
  properties: {
268
+ ...BASE_TELEMETRY_PROPERTIES,
349
269
  href: window.location.href,
350
270
  timeSpent
351
271
  }
@@ -358,6 +278,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
358
278
  identityId: getTelemetryIdentifier(client),
359
279
  name: `${namespace}.page.unload`,
360
280
  properties: {
281
+ ...BASE_TELEMETRY_PROPERTIES,
361
282
  href: window.location.href,
362
283
  timeSpent: totalTime
363
284
  }
@@ -368,6 +289,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
368
289
  identityId: getTelemetryIdentifier(client),
369
290
  name: `${namespace}.window.error`,
370
291
  properties: {
292
+ ...BASE_TELEMETRY_PROPERTIES,
371
293
  href: window.location.href,
372
294
  message: event.message,
373
295
  filename: event.filename,
@@ -390,9 +312,15 @@ var setupTelemetryListeners = (namespace, client, observability) => {
390
312
  };
391
313
 
392
314
  // packages/sdk/observability/src/observability.ts
393
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
315
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
394
316
  var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
395
317
  var DATADOG_IDLE_INTERVAL = 1e3 * 60 * 1;
318
+ var ERROR_TAGS = [
319
+ "identityKey",
320
+ "username",
321
+ "deviceKey",
322
+ "group"
323
+ ];
396
324
  var Observability = class {
397
325
  // TODO(nf): make platform a required extension?
398
326
  constructor({ namespace, config, secrets, group, mode, telemetry, errorLog }) {
@@ -400,13 +328,6 @@ var Observability = class {
400
328
  // TODO(nf): accept upstream context?
401
329
  this._ctx = new Context();
402
330
  this._tags = /* @__PURE__ */ new Map();
403
- this.addIPDataTelemetryTags = (ipData) => {
404
- this.setTag("city", ipData.city, "telemetry");
405
- this.setTag("region", ipData.region, "telemetry");
406
- this.setTag("country", ipData.country, "telemetry");
407
- ipData.latitude && this.setTag("latitude", ipData.latitude.toString(), "telemetry");
408
- ipData.longitude && this.setTag("longitude", ipData.longitude.toString(), "telemetry");
409
- };
410
331
  this._namespace = namespace;
411
332
  this._config = config;
412
333
  this._mode = mode ?? "disabled";
@@ -427,20 +348,20 @@ var Observability = class {
427
348
  return cli_observability_secrets_default;
428
349
  } else {
429
350
  invariant(config, "runtime config is required", {
430
- F: __dxlog_file3,
431
- L: 115,
351
+ F: __dxlog_file2,
352
+ L: 117,
432
353
  S: this,
433
354
  A: [
434
355
  "config",
435
356
  "'runtime config is required'"
436
357
  ]
437
358
  });
438
- log3("config", {
359
+ log2("config", {
439
360
  rtc: this._secrets,
440
361
  config
441
362
  }, {
442
- F: __dxlog_file3,
443
- L: 116,
363
+ F: __dxlog_file2,
364
+ L: 118,
444
365
  S: this,
445
366
  C: (f, a) => f(...a)
446
367
  });
@@ -470,36 +391,30 @@ var Observability = class {
470
391
  get mode() {
471
392
  return this._mode;
472
393
  }
473
- get group() {
474
- return this._group;
475
- }
476
394
  get enabled() {
477
395
  return this._mode !== "disabled";
478
396
  }
479
397
  //
480
398
  // Tags
481
399
  //
482
- setTag(key, value, scope) {
483
- if (this.enabled && (scope === void 0 || scope === "all" || scope === "errors")) {
400
+ /**
401
+ * Set a tag for all observability services.
402
+ */
403
+ setTag(key, value) {
404
+ if (this.enabled && ERROR_TAGS.includes(key)) {
484
405
  setTag(key, value);
485
406
  }
486
- if (!scope) {
487
- scope = "all";
488
- }
489
- this._tags.set(key, {
490
- value,
491
- scope
492
- });
407
+ this._tags.set(key, value);
493
408
  }
494
409
  // TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.
495
410
  async setIdentityTags(client) {
496
411
  client.services.services.IdentityService.queryIdentity().subscribe((idqr) => {
497
412
  if (!idqr?.identity?.identityKey) {
498
- log3("empty response from identity service", {
413
+ log2("empty response from identity service", {
499
414
  idqr
500
415
  }, {
501
- F: __dxlog_file3,
502
- L: 184,
416
+ F: __dxlog_file2,
417
+ L: 175,
503
418
  S: this,
504
419
  C: (f, a) => f(...a)
505
420
  });
@@ -509,19 +424,19 @@ var Observability = class {
509
424
  });
510
425
  client.services.services.DevicesService.queryDevices().subscribe((dqr) => {
511
426
  if (!dqr || !dqr.devices || dqr.devices.length === 0) {
512
- log3("empty response from device service", {
427
+ log2("empty response from device service", {
513
428
  device: dqr
514
429
  }, {
515
- F: __dxlog_file3,
516
- L: 193,
430
+ F: __dxlog_file2,
431
+ L: 184,
517
432
  S: this,
518
433
  C: (f, a) => f(...a)
519
434
  });
520
435
  return;
521
436
  }
522
437
  invariant(dqr, "empty response from device service", {
523
- F: __dxlog_file3,
524
- L: 196,
438
+ F: __dxlog_file2,
439
+ L: 187,
525
440
  S: this,
526
441
  A: [
527
442
  "dqr",
@@ -530,11 +445,11 @@ var Observability = class {
530
445
  });
531
446
  const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);
532
447
  if (!thisDevice) {
533
- log3("no current device", {
448
+ log2("no current device", {
534
449
  device: dqr
535
450
  }, {
536
- F: __dxlog_file3,
537
- L: 200,
451
+ F: __dxlog_file2,
452
+ L: 191,
538
453
  S: this,
539
454
  C: (f, a) => f(...a)
540
455
  });
@@ -553,19 +468,14 @@ var Observability = class {
553
468
  if (this.enabled && this._secrets.DATADOG_API_KEY) {
554
469
  this._metrics = new DatadogMetrics({
555
470
  apiKey: this._secrets.DATADOG_API_KEY,
556
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
557
- return value.scope === "all" || value.scope === "metrics";
558
- }).map(([key, value]) => [
559
- key,
560
- value.value
561
- ])),
471
+ getTags: () => this._tags,
562
472
  // TODO(nf): move/refactor from telementryContext, needed to read CORS proxy
563
473
  config: this._config
564
474
  });
565
475
  } else {
566
- log3("datadog disabled", void 0, {
567
- F: __dxlog_file3,
568
- L: 230,
476
+ log2("datadog disabled", void 0, {
477
+ F: __dxlog_file2,
478
+ L: 214,
569
479
  S: this,
570
480
  C: (f, a) => f(...a)
571
481
  });
@@ -583,9 +493,9 @@ var Observability = class {
583
493
  startNetworkMetrics(client) {
584
494
  const updateSignalMetrics = new Event();
585
495
  updateSignalMetrics.on(this._ctx, async (networkStatus) => {
586
- log3("send signal metrics", void 0, {
587
- F: __dxlog_file3,
588
- L: 250,
496
+ log2("send signal metrics", void 0, {
497
+ F: __dxlog_file2,
498
+ L: 234,
589
499
  S: this,
590
500
  C: (f, a) => f(...a)
591
501
  });
@@ -633,9 +543,9 @@ var Observability = class {
633
543
  this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
634
544
  const updateSpaceMetrics = new Event().debounce(SPACE_METRICS_MIN_INTERVAL);
635
545
  updateSpaceMetrics.on(this._ctx, async () => {
636
- log3("send space update", void 0, {
637
- F: __dxlog_file3,
638
- L: 302,
546
+ log2("send space update", void 0, {
547
+ F: __dxlog_file2,
548
+ L: 286,
639
549
  S: this,
640
550
  C: (f, a) => f(...a)
641
551
  });
@@ -657,7 +567,10 @@ var Observability = class {
657
567
  this.event({
658
568
  identityId: getTelemetryIdentifier(client),
659
569
  name: `${namespace}.space.update`,
660
- properties: data
570
+ properties: {
571
+ ...BASE_TELEMETRY_PROPERTIES,
572
+ ...data
573
+ }
661
574
  });
662
575
  }
663
576
  });
@@ -681,8 +594,8 @@ var Observability = class {
681
594
  async startRuntimeMetrics(client, frequency = DATADOG_IDLE_INTERVAL) {
682
595
  const platform = await client.services.services.SystemService?.getPlatform();
683
596
  invariant(platform, "platform is required", {
684
- F: __dxlog_file3,
685
- L: 345,
597
+ F: __dxlog_file2,
598
+ L: 332,
686
599
  S: this,
687
600
  A: [
688
601
  "platform",
@@ -702,18 +615,18 @@ var Observability = class {
702
615
  }
703
616
  }
704
617
  scheduleTaskInterval(this._ctx, async () => {
705
- log3("platform", void 0, {
706
- F: __dxlog_file3,
707
- L: 363,
618
+ log2("platform", void 0, {
619
+ F: __dxlog_file2,
620
+ L: 350,
708
621
  S: this,
709
622
  C: (f, a) => f(...a)
710
623
  });
711
624
  client.services.services.SystemService?.getPlatform().then((platform2) => {
712
- log3("platform", {
625
+ log2("platform", {
713
626
  platform: platform2
714
627
  }, {
715
- F: __dxlog_file3,
716
- L: 366,
628
+ F: __dxlog_file2,
629
+ L: 353,
717
630
  S: this,
718
631
  C: (f, a) => f(...a)
719
632
  });
@@ -722,11 +635,11 @@ var Observability = class {
722
635
  this.gauge("dxos.client.runtime.heapTotal", platform2.memory.heapTotal);
723
636
  this.gauge("dxos.client.runtime.heapUsed", platform2.memory.heapUsed);
724
637
  }
725
- }).catch((error) => log3("platform error", {
638
+ }).catch((error) => log2("platform error", {
726
639
  error
727
640
  }, {
728
- F: __dxlog_file3,
729
- L: 373,
641
+ F: __dxlog_file2,
642
+ L: 360,
730
643
  S: this,
731
644
  C: (f, a) => f(...a)
732
645
  }));
@@ -740,17 +653,12 @@ var Observability = class {
740
653
  this._telemetry = new SegmentTelemetry({
741
654
  apiKey: this._secrets.TELEMETRY_API_KEY,
742
655
  batchSize: this._telemetryBatchSize,
743
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
744
- return value.scope === "all" || value.scope === "telemetry";
745
- }).map(([key, value]) => [
746
- key,
747
- value.value
748
- ]))
656
+ getTags: () => this._tags
749
657
  });
750
658
  } else {
751
- log3("segment disabled", void 0, {
752
- F: __dxlog_file3,
753
- L: 398,
659
+ log2("segment disabled", void 0, {
660
+ F: __dxlog_file2,
661
+ L: 378,
754
662
  S: this,
755
663
  C: (f, a) => f(...a)
756
664
  });
@@ -777,12 +685,12 @@ var Observability = class {
777
685
  //
778
686
  _initErrorLogs() {
779
687
  if (this._secrets.SENTRY_DESTINATION && this._mode !== "disabled") {
780
- log3.info("Initializing Sentry", {
688
+ log2.info("Initializing Sentry", {
781
689
  dest: this._secrets.SENTRY_DESTINATION,
782
690
  options: this._errorReportingOptions
783
691
  }, {
784
- F: __dxlog_file3,
785
- L: 427,
692
+ F: __dxlog_file2,
693
+ L: 407,
786
694
  S: this,
787
695
  C: (f, a) => f(...a)
788
696
  });
@@ -798,14 +706,14 @@ var Observability = class {
798
706
  enableSentryLogProcessor();
799
707
  }
800
708
  this._tags.forEach((v, k) => {
801
- if (v.scope === "all" || v.scope === "errors") {
802
- setTag(k, v.value);
709
+ if (ERROR_TAGS.includes(k)) {
710
+ setTag(k, v);
803
711
  }
804
712
  });
805
713
  } else {
806
- log3("sentry disabled", void 0, {
807
- F: __dxlog_file3,
808
- L: 450,
714
+ log2("sentry disabled", void 0, {
715
+ F: __dxlog_file2,
716
+ L: 430,
809
717
  S: this,
810
718
  C: (f, a) => f(...a)
811
719
  });
@@ -825,18 +733,16 @@ var Observability = class {
825
733
 
826
734
  export {
827
735
  Observability,
736
+ BASE_TELEMETRY_PROPERTIES,
828
737
  OBSERVABILITY_DISABLED_KEY,
829
738
  OBSERVABILITY_GROUP_KEY,
739
+ getTelemetryIdentifier,
830
740
  isObservabilityDisabled,
831
741
  storeObservabilityDisabled,
832
742
  getObservabilityGroup,
833
743
  storeObservabilityGroup,
834
744
  initializeAppObservability,
835
- getTelemetryIdentifier,
836
- showObservabilityBanner,
837
- getObservabilityState,
838
- initializeNodeObservability,
839
745
  mapSpaces,
840
746
  setupTelemetryListeners
841
747
  };
842
- //# sourceMappingURL=chunk-OCQVYNE3.mjs.map
748
+ //# sourceMappingURL=chunk-STWCJK52.mjs.map