@dxos/observability 0.3.11-main.fc97a54 → 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-JVT4FOCC.mjs → chunk-STWCJK52.mjs} +130 -238
  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-ED364ZBZ.cjs → chunk-DE7OVD7T.cjs} +120 -226
  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-MN7SJ7NA.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 -9
  44. package/dist/types/src/observability.d.ts.map +1 -1
  45. package/dist/types/src/observability.js +17 -44
  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 -57
  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-JVT4FOCC.mjs.map +0 -7
  66. package/dist/lib/browser/observability-3UVQW6ZL.mjs +0 -10
  67. package/dist/lib/node/chunk-BHF4PKAP.cjs.map +0 -7
  68. package/dist/lib/node/chunk-ED364ZBZ.cjs.map +0 -7
  69. package/dist/lib/node/observability-MN7SJ7NA.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-3UVQW6ZL.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-3UVQW6ZL.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_OBSERVABILITY=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_OBSERVABILITY_GROUP ?? void 0,
230
- mode: process.env.DX_DISABLE_OBSERVABILITY ? "disabled" : process.env.DX_OBSERVABILITY_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_OBSERVABILITY ? "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";
@@ -424,34 +345,23 @@ var Observability = class {
424
345
  }
425
346
  _loadSecrets(config, secrets) {
426
347
  if (isNode()) {
427
- const mergedSecrets = {
428
- ...cli_observability_secrets_default,
429
- ...secrets
430
- };
431
- process.env.DX_ENVIRONMENT && (mergedSecrets.DX_ENVIRONMENT = process.env.DX_ENVIRONMENT);
432
- process.env.DX_RELEASE && (mergedSecrets.DX_RELEASE = process.env.DX_RELEASE);
433
- process.env.SENTRY_DESTINATION && (mergedSecrets.SENTRY_DESTINATION = process.env.SENTRY_DESTINATION);
434
- process.env.TELEMETRY_API_KEY && (mergedSecrets.TELEMETRY_API_KEY = process.env.TELEMETRY_API_KEY);
435
- process.env.IPDATA_API_KEY && (mergedSecrets.IPDATA_API_KEY = process.env.IPDATA_API_KEY);
436
- process.env.DATADOG_API_KEY && (mergedSecrets.DATADOG_API_KEY = process.env.DATADOG_API_KEY);
437
- process.env.DATADOG_APP_KEY && (mergedSecrets.DATADOG_APP_KEY = process.env.DATADOG_APP_KEY);
438
- return mergedSecrets;
348
+ return cli_observability_secrets_default;
439
349
  } else {
440
350
  invariant(config, "runtime config is required", {
441
- F: __dxlog_file3,
442
- L: 128,
351
+ F: __dxlog_file2,
352
+ L: 117,
443
353
  S: this,
444
354
  A: [
445
355
  "config",
446
356
  "'runtime config is required'"
447
357
  ]
448
358
  });
449
- log3("config", {
359
+ log2("config", {
450
360
  rtc: this._secrets,
451
361
  config
452
362
  }, {
453
- F: __dxlog_file3,
454
- L: 129,
363
+ F: __dxlog_file2,
364
+ L: 118,
455
365
  S: this,
456
366
  C: (f, a) => f(...a)
457
367
  });
@@ -481,39 +391,30 @@ var Observability = class {
481
391
  get mode() {
482
392
  return this._mode;
483
393
  }
484
- get group() {
485
- return this._group;
486
- }
487
394
  get enabled() {
488
395
  return this._mode !== "disabled";
489
396
  }
490
397
  //
491
398
  // Tags
492
399
  //
493
- setTag(key, value, scope) {
494
- 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)) {
495
405
  setTag(key, value);
496
406
  }
497
- if (!scope) {
498
- scope = "all";
499
- }
500
- this._tags.set(key, {
501
- value,
502
- scope
503
- });
504
- }
505
- getTag(key) {
506
- return this._tags.get(key);
407
+ this._tags.set(key, value);
507
408
  }
508
409
  // TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.
509
410
  async setIdentityTags(client) {
510
411
  client.services.services.IdentityService.queryIdentity().subscribe((idqr) => {
511
412
  if (!idqr?.identity?.identityKey) {
512
- log3("empty response from identity service", {
413
+ log2("empty response from identity service", {
513
414
  idqr
514
415
  }, {
515
- F: __dxlog_file3,
516
- L: 201,
416
+ F: __dxlog_file2,
417
+ L: 175,
517
418
  S: this,
518
419
  C: (f, a) => f(...a)
519
420
  });
@@ -523,19 +424,19 @@ var Observability = class {
523
424
  });
524
425
  client.services.services.DevicesService.queryDevices().subscribe((dqr) => {
525
426
  if (!dqr || !dqr.devices || dqr.devices.length === 0) {
526
- log3("empty response from device service", {
427
+ log2("empty response from device service", {
527
428
  device: dqr
528
429
  }, {
529
- F: __dxlog_file3,
530
- L: 210,
430
+ F: __dxlog_file2,
431
+ L: 184,
531
432
  S: this,
532
433
  C: (f, a) => f(...a)
533
434
  });
534
435
  return;
535
436
  }
536
437
  invariant(dqr, "empty response from device service", {
537
- F: __dxlog_file3,
538
- L: 213,
438
+ F: __dxlog_file2,
439
+ L: 187,
539
440
  S: this,
540
441
  A: [
541
442
  "dqr",
@@ -544,11 +445,11 @@ var Observability = class {
544
445
  });
545
446
  const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);
546
447
  if (!thisDevice) {
547
- log3("no current device", {
448
+ log2("no current device", {
548
449
  device: dqr
549
450
  }, {
550
- F: __dxlog_file3,
551
- L: 217,
451
+ F: __dxlog_file2,
452
+ L: 191,
552
453
  S: this,
553
454
  C: (f, a) => f(...a)
554
455
  });
@@ -567,19 +468,14 @@ var Observability = class {
567
468
  if (this.enabled && this._secrets.DATADOG_API_KEY) {
568
469
  this._metrics = new DatadogMetrics({
569
470
  apiKey: this._secrets.DATADOG_API_KEY,
570
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
571
- return value.scope === "all" || value.scope === "metrics";
572
- }).map(([key, value]) => [
573
- key,
574
- value.value
575
- ])),
471
+ getTags: () => this._tags,
576
472
  // TODO(nf): move/refactor from telementryContext, needed to read CORS proxy
577
473
  config: this._config
578
474
  });
579
475
  } else {
580
- log3("datadog disabled", void 0, {
581
- F: __dxlog_file3,
582
- L: 247,
476
+ log2("datadog disabled", void 0, {
477
+ F: __dxlog_file2,
478
+ L: 214,
583
479
  S: this,
584
480
  C: (f, a) => f(...a)
585
481
  });
@@ -597,9 +493,9 @@ var Observability = class {
597
493
  startNetworkMetrics(client) {
598
494
  const updateSignalMetrics = new Event();
599
495
  updateSignalMetrics.on(this._ctx, async (networkStatus) => {
600
- log3("send signal metrics", void 0, {
601
- F: __dxlog_file3,
602
- L: 267,
496
+ log2("send signal metrics", void 0, {
497
+ F: __dxlog_file2,
498
+ L: 234,
603
499
  S: this,
604
500
  C: (f, a) => f(...a)
605
501
  });
@@ -647,9 +543,9 @@ var Observability = class {
647
543
  this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
648
544
  const updateSpaceMetrics = new Event().debounce(SPACE_METRICS_MIN_INTERVAL);
649
545
  updateSpaceMetrics.on(this._ctx, async () => {
650
- log3("send space update", void 0, {
651
- F: __dxlog_file3,
652
- L: 319,
546
+ log2("send space update", void 0, {
547
+ F: __dxlog_file2,
548
+ L: 286,
653
549
  S: this,
654
550
  C: (f, a) => f(...a)
655
551
  });
@@ -671,7 +567,10 @@ var Observability = class {
671
567
  this.event({
672
568
  identityId: getTelemetryIdentifier(client),
673
569
  name: `${namespace}.space.update`,
674
- properties: data
570
+ properties: {
571
+ ...BASE_TELEMETRY_PROPERTIES,
572
+ ...data
573
+ }
675
574
  });
676
575
  }
677
576
  });
@@ -695,8 +594,8 @@ var Observability = class {
695
594
  async startRuntimeMetrics(client, frequency = DATADOG_IDLE_INTERVAL) {
696
595
  const platform = await client.services.services.SystemService?.getPlatform();
697
596
  invariant(platform, "platform is required", {
698
- F: __dxlog_file3,
699
- L: 362,
597
+ F: __dxlog_file2,
598
+ L: 332,
700
599
  S: this,
701
600
  A: [
702
601
  "platform",
@@ -716,18 +615,18 @@ var Observability = class {
716
615
  }
717
616
  }
718
617
  scheduleTaskInterval(this._ctx, async () => {
719
- log3("platform", void 0, {
720
- F: __dxlog_file3,
721
- L: 380,
618
+ log2("platform", void 0, {
619
+ F: __dxlog_file2,
620
+ L: 350,
722
621
  S: this,
723
622
  C: (f, a) => f(...a)
724
623
  });
725
624
  client.services.services.SystemService?.getPlatform().then((platform2) => {
726
- log3("platform", {
625
+ log2("platform", {
727
626
  platform: platform2
728
627
  }, {
729
- F: __dxlog_file3,
730
- L: 383,
628
+ F: __dxlog_file2,
629
+ L: 353,
731
630
  S: this,
732
631
  C: (f, a) => f(...a)
733
632
  });
@@ -736,11 +635,11 @@ var Observability = class {
736
635
  this.gauge("dxos.client.runtime.heapTotal", platform2.memory.heapTotal);
737
636
  this.gauge("dxos.client.runtime.heapUsed", platform2.memory.heapUsed);
738
637
  }
739
- }).catch((error) => log3("platform error", {
638
+ }).catch((error) => log2("platform error", {
740
639
  error
741
640
  }, {
742
- F: __dxlog_file3,
743
- L: 390,
641
+ F: __dxlog_file2,
642
+ L: 360,
744
643
  S: this,
745
644
  C: (f, a) => f(...a)
746
645
  }));
@@ -754,17 +653,12 @@ var Observability = class {
754
653
  this._telemetry = new SegmentTelemetry({
755
654
  apiKey: this._secrets.TELEMETRY_API_KEY,
756
655
  batchSize: this._telemetryBatchSize,
757
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
758
- return value.scope === "all" || value.scope === "telemetry";
759
- }).map(([key, value]) => [
760
- key,
761
- value.value
762
- ]))
656
+ getTags: () => this._tags
763
657
  });
764
658
  } else {
765
- log3("segment disabled", void 0, {
766
- F: __dxlog_file3,
767
- L: 415,
659
+ log2("segment disabled", void 0, {
660
+ F: __dxlog_file2,
661
+ L: 378,
768
662
  S: this,
769
663
  C: (f, a) => f(...a)
770
664
  });
@@ -791,12 +685,12 @@ var Observability = class {
791
685
  //
792
686
  _initErrorLogs() {
793
687
  if (this._secrets.SENTRY_DESTINATION && this._mode !== "disabled") {
794
- log3.info("Initializing Sentry", {
688
+ log2.info("Initializing Sentry", {
795
689
  dest: this._secrets.SENTRY_DESTINATION,
796
690
  options: this._errorReportingOptions
797
691
  }, {
798
- F: __dxlog_file3,
799
- L: 444,
692
+ F: __dxlog_file2,
693
+ L: 407,
800
694
  S: this,
801
695
  C: (f, a) => f(...a)
802
696
  });
@@ -812,14 +706,14 @@ var Observability = class {
812
706
  enableSentryLogProcessor();
813
707
  }
814
708
  this._tags.forEach((v, k) => {
815
- if (v.scope === "all" || v.scope === "errors") {
816
- setTag(k, v.value);
709
+ if (ERROR_TAGS.includes(k)) {
710
+ setTag(k, v);
817
711
  }
818
712
  });
819
713
  } else {
820
- log3("sentry disabled", void 0, {
821
- F: __dxlog_file3,
822
- L: 467,
714
+ log2("sentry disabled", void 0, {
715
+ F: __dxlog_file2,
716
+ L: 430,
823
717
  S: this,
824
718
  C: (f, a) => f(...a)
825
719
  });
@@ -839,18 +733,16 @@ var Observability = class {
839
733
 
840
734
  export {
841
735
  Observability,
736
+ BASE_TELEMETRY_PROPERTIES,
842
737
  OBSERVABILITY_DISABLED_KEY,
843
738
  OBSERVABILITY_GROUP_KEY,
739
+ getTelemetryIdentifier,
844
740
  isObservabilityDisabled,
845
741
  storeObservabilityDisabled,
846
742
  getObservabilityGroup,
847
743
  storeObservabilityGroup,
848
744
  initializeAppObservability,
849
- getTelemetryIdentifier,
850
- showObservabilityBanner,
851
- getObservabilityState,
852
- initializeNodeObservability,
853
745
  mapSpaces,
854
746
  setupTelemetryListeners
855
747
  };
856
- //# sourceMappingURL=chunk-JVT4FOCC.mjs.map
748
+ //# sourceMappingURL=chunk-STWCJK52.mjs.map