@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
@@ -26,26 +26,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_ED364ZBZ_exports = {};
30
- __export(chunk_ED364ZBZ_exports, {
29
+ var chunk_DE7OVD7T_exports = {};
30
+ __export(chunk_DE7OVD7T_exports, {
31
+ BASE_TELEMETRY_PROPERTIES: () => BASE_TELEMETRY_PROPERTIES,
31
32
  OBSERVABILITY_DISABLED_KEY: () => OBSERVABILITY_DISABLED_KEY,
32
33
  OBSERVABILITY_GROUP_KEY: () => OBSERVABILITY_GROUP_KEY,
33
34
  Observability: () => Observability,
34
35
  getObservabilityGroup: () => getObservabilityGroup,
35
- getObservabilityState: () => getObservabilityState,
36
36
  getTelemetryIdentifier: () => getTelemetryIdentifier,
37
37
  initializeAppObservability: () => initializeAppObservability,
38
- initializeNodeObservability: () => initializeNodeObservability,
39
38
  isObservabilityDisabled: () => isObservabilityDisabled,
40
39
  mapSpaces: () => mapSpaces,
41
40
  setupTelemetryListeners: () => setupTelemetryListeners,
42
- showObservabilityBanner: () => showObservabilityBanner,
43
41
  storeObservabilityDisabled: () => storeObservabilityDisabled,
44
42
  storeObservabilityGroup: () => storeObservabilityGroup
45
43
  });
46
- module.exports = __toCommonJS(chunk_ED364ZBZ_exports);
47
- var import_chunk_ZJRKFREX = require("./chunk-ZJRKFREX.cjs");
48
- var import_chunk_BHF4PKAP = require("./chunk-BHF4PKAP.cjs");
44
+ module.exports = __toCommonJS(chunk_DE7OVD7T_exports);
45
+ var import_chunk_VDBBIYH6 = require("./chunk-VDBBIYH6.cjs");
46
+ var import_chunk_ARUBPK2W = require("./chunk-ARUBPK2W.cjs");
49
47
  var import_chunk_FSAOBKO2 = require("./chunk-FSAOBKO2.cjs");
50
48
  var import_async = require("@dxos/async");
51
49
  var import_context = require("@dxos/context");
@@ -56,12 +54,6 @@ var import_services = require("@dxos/protocols/proto/dxos/client/services");
56
54
  var import_util = require("@dxos/util");
57
55
  var localForage = __toESM(require("localforage"));
58
56
  var import_log2 = require("@dxos/log");
59
- var import_js_yaml = __toESM(require("js-yaml"));
60
- var import_node_fs = require("node:fs");
61
- var import_promises = require("node:fs/promises");
62
- var import_node_path = require("node:path");
63
- var import_uuid = require("uuid");
64
- var import_log3 = require("@dxos/log");
65
57
  var cli_observability_secrets_default = {
66
58
  SENTRY_DESTINATION: "https://2647916221e643869965e78469479aa4@o4504012000067584.ingest.sentry.io/4504012027265029",
67
59
  TELEMETRY_API_KEY: "B00QG6PtJJrJ0VVFe0H5a6bcUUShKyZM",
@@ -69,16 +61,43 @@ var cli_observability_secrets_default = {
69
61
  DATADOG_API_KEY: null,
70
62
  DATADOG_APP_KEY: null
71
63
  };
72
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/browser-observability.ts";
73
- var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
74
- var OBSERVABILITY_GROUP_KEY = "observability-group";
64
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/app-observability.ts";
65
+ var BASE_TELEMETRY_PROPERTIES = {};
66
+ var OBSERVABILITY_DISABLED_KEY = "telemetry-disabled";
67
+ var OBSERVABILITY_GROUP_KEY = "telemetry-group";
68
+ if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
69
+ setInterval(async () => {
70
+ try {
71
+ const storageEstimate = await navigator.storage.estimate();
72
+ BASE_TELEMETRY_PROPERTIES.storageUsage = storageEstimate.usage;
73
+ BASE_TELEMETRY_PROPERTIES.storageQuota = storageEstimate.quota;
74
+ } catch (error) {
75
+ import_log2.log.warn("Failed to run estimate()", error, {
76
+ F: __dxlog_file,
77
+ L: 27,
78
+ S: void 0,
79
+ C: (f, a) => f(...a)
80
+ });
81
+ }
82
+ }, 1e4);
83
+ }
84
+ var getTelemetryIdentifier = (client) => {
85
+ if (!client?.initialized) {
86
+ return void 0;
87
+ }
88
+ const identity = client.halo.identity.get();
89
+ if (identity) {
90
+ return identity.identityKey.truncate();
91
+ }
92
+ return void 0;
93
+ };
75
94
  var isObservabilityDisabled = async (namespace) => {
76
95
  try {
77
96
  return await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`) === "true";
78
97
  } catch (err) {
79
98
  import_log2.log.catch("Failed to check if observability is disabled, assuming it is", err, {
80
99
  F: __dxlog_file,
81
- L: 24,
100
+ L: 54,
82
101
  S: void 0,
83
102
  C: (f, a) => f(...a)
84
103
  });
@@ -91,7 +110,7 @@ var storeObservabilityDisabled = async (namespace, value) => {
91
110
  } catch (err) {
92
111
  import_log2.log.catch("Failed to store observability disabled", err, {
93
112
  F: __dxlog_file,
94
- L: 33,
113
+ L: 63,
95
114
  S: void 0,
96
115
  C: (f, a) => f(...a)
97
116
  });
@@ -103,7 +122,7 @@ var getObservabilityGroup = async (namespace) => {
103
122
  } catch (err) {
104
123
  import_log2.log.catch("Failed to get observability group", err, {
105
124
  F: __dxlog_file,
106
- L: 41,
125
+ L: 71,
107
126
  S: void 0,
108
127
  C: (f, a) => f(...a)
109
128
  });
@@ -115,7 +134,7 @@ var storeObservabilityGroup = async (namespace, value) => {
115
134
  } catch (err) {
116
135
  import_log2.log.catch("Failed to store observability group", err, {
117
136
  F: __dxlog_file,
118
- L: 49,
137
+ L: 79,
119
138
  S: void 0,
120
139
  C: (f, a) => f(...a)
121
140
  });
@@ -126,15 +145,18 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
126
145
  config
127
146
  }, {
128
147
  F: __dxlog_file,
129
- L: 72,
148
+ L: 104,
130
149
  S: void 0,
131
150
  C: (f, a) => f(...a)
132
151
  });
133
152
  const group = await getObservabilityGroup(namespace) ?? void 0;
134
153
  const release = `${namespace}@${config.get("runtime.app.build.version")}`;
135
154
  const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
155
+ BASE_TELEMETRY_PROPERTIES.group = group;
156
+ BASE_TELEMETRY_PROPERTIES.release = release;
157
+ BASE_TELEMETRY_PROPERTIES.environment = environment;
136
158
  const observabilityDisabled = await isObservabilityDisabled(namespace);
137
- const { Observability: Observability2 } = await import("./observability-MN7SJ7NA.cjs");
159
+ const { Observability: Observability2 } = await import("./observability-YMIQHLME.cjs");
138
160
  const observability = new Observability2({
139
161
  namespace,
140
162
  group,
@@ -157,7 +179,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
157
179
  observability.setMode("disabled");
158
180
  import_log2.log.info("observability disabled", void 0, {
159
181
  F: __dxlog_file,
160
- L: 113,
182
+ L: 147,
161
183
  S: void 0,
162
184
  C: (f, a) => f(...a)
163
185
  });
@@ -166,14 +188,14 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
166
188
  try {
167
189
  const getIPData = async (config2) => {
168
190
  const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1e3;
169
- const cachedData = await localForage.getItem("dxos:observability:ipdata");
191
+ const cachedData = await localForage.getItem("dxos:telemetry:ipdata");
170
192
  if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {
171
193
  return cachedData.data;
172
194
  }
173
195
  const IPDATA_API_KEY = config2.get("runtime.app.env.DX_IPDATA_API_KEY");
174
196
  if (IPDATA_API_KEY) {
175
197
  return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`).then((res) => res.json()).then((data) => {
176
- localForage.setItem("dxos:observability:ipdata", {
198
+ localForage.setItem("dxos:telemetry:ipdata", {
177
199
  data,
178
200
  timestamp: Date.now()
179
201
  }).catch((err) => observability.captureException(err));
@@ -181,128 +203,25 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
181
203
  }).catch((err) => observability.captureException(err));
182
204
  }
183
205
  };
184
- observability.initialize();
185
206
  const ipData = await getIPData(config);
186
- ipData && observability.addIPDataTelemetryTags(ipData);
187
- if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
188
- setInterval(async () => {
189
- try {
190
- const storageEstimate = await navigator.storage.estimate();
191
- storageEstimate.usage && observability.setTag("storageUsage", storageEstimate.usage.toString(), "telemetry");
192
- storageEstimate.quota && observability.setTag("storageQuota", storageEstimate.quota.toString(), "telemetry");
193
- } catch (error) {
194
- import_log2.log.warn("Failed to run estimate()", error, {
195
- F: __dxlog_file,
196
- L: 168,
197
- S: void 0,
198
- C: (f, a) => f(...a)
199
- });
200
- }
201
- }, 1e4);
207
+ if (ipData && ipData.city) {
208
+ BASE_TELEMETRY_PROPERTIES.city = ipData.city;
209
+ BASE_TELEMETRY_PROPERTIES.region = ipData.region;
210
+ BASE_TELEMETRY_PROPERTIES.country = ipData.country;
211
+ BASE_TELEMETRY_PROPERTIES.latitude = ipData.latitude;
212
+ BASE_TELEMETRY_PROPERTIES.longitude = ipData.longitude;
202
213
  }
214
+ observability.initialize();
203
215
  } catch (err) {
204
216
  import_log2.log.error("Failed to initialize app observability", err, {
205
217
  F: __dxlog_file,
206
- L: 173,
218
+ L: 201,
207
219
  S: void 0,
208
220
  C: (f, a) => f(...a)
209
221
  });
210
222
  }
211
223
  return observability;
212
224
  };
213
- var getTelemetryIdentifier = (client) => {
214
- if (!client?.initialized) {
215
- return void 0;
216
- }
217
- const identity = client.halo.identity.get();
218
- if (identity) {
219
- return identity.identityKey.truncate();
220
- }
221
- return void 0;
222
- };
223
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/node-observability.ts";
224
- var showObservabilityBanner = async (configDir, bannercb) => {
225
- const path = (0, import_node_path.join)(configDir, ".observability-banner-printed");
226
- if ((0, import_node_fs.existsSync)(path)) {
227
- return;
228
- }
229
- bannercb(
230
- // eslint-disable-next-line no-multi-str
231
- "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."
232
- );
233
- await (0, import_promises.writeFile)(path, "", "utf-8");
234
- };
235
- var getObservabilityState = async (configDir) => {
236
- if ((0, import_node_fs.existsSync)(configDir)) {
237
- if (!(0, import_node_fs.statSync)(configDir).isDirectory()) {
238
- throw new Error(`Config directory ${configDir} exists but is not a directory`);
239
- }
240
- } else {
241
- await (0, import_promises.mkdir)(configDir, {
242
- recursive: true
243
- });
244
- }
245
- const idPath = (0, import_node_path.join)(configDir, "observability.yml");
246
- if ((0, import_node_fs.existsSync)(idPath)) {
247
- const context = await (0, import_promises.readFile)(idPath, "utf-8");
248
- return validate(context) ?? initializeState(idPath);
249
- }
250
- return initializeState(idPath);
251
- };
252
- var initializeState = async (idPath) => {
253
- const observabilityState = {
254
- installationId: (0, import_uuid.v4)(),
255
- group: process.env.DX_OBSERVABILITY_GROUP ?? void 0,
256
- mode: process.env.DX_DISABLE_OBSERVABILITY ? "disabled" : process.env.DX_OBSERVABILITY_MODE ?? "basic"
257
- };
258
- await (0, import_promises.writeFile)(idPath, "# This file is automatically generated by the @dxos/cli.\n" + import_js_yaml.default.dump(observabilityState), "utf-8");
259
- return observabilityState;
260
- };
261
- var validate = (contextString) => {
262
- const context = import_js_yaml.default.load(contextString);
263
- if (Boolean(context.installationId) && (0, import_uuid.validate)(context.installationId)) {
264
- return {
265
- ...context,
266
- mode: process.env.DX_DISABLE_OBSERVABILITY ? "disabled" : context.mode ?? "basic"
267
- };
268
- }
269
- };
270
- var initializeNodeObservability = async ({ namespace, config, installationId, group, mode = "basic", tracingEnable = true, replayEnable = true }) => {
271
- (0, import_log3.log)("initializeCliObservability", {
272
- config
273
- }, {
274
- F: __dxlog_file2,
275
- L: 120,
276
- S: void 0,
277
- C: (f, a) => f(...a)
278
- });
279
- const release = `${namespace}@${config.get("runtime.app.build.version")}`;
280
- const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
281
- const observability = new Observability({
282
- namespace,
283
- group,
284
- mode,
285
- errorLog: {
286
- sentryInitOptions: {
287
- environment,
288
- release,
289
- // TODO(wittjosiah): Configure this.
290
- sampleRate: 1
291
- },
292
- logProcessor: true
293
- }
294
- });
295
- observability.setTag("installationId", installationId);
296
- const IPDATA_API_KEY = config.get("runtime.app.env.DX_IPDATA_API_KEY");
297
- try {
298
- const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);
299
- const ipData = await res.json();
300
- ipData && observability.addIPDataTelemetryTags(ipData);
301
- } catch (err) {
302
- observability?.captureException(err);
303
- }
304
- return observability;
305
- };
306
225
  var mapSpaces = (spaces, options = {
307
226
  verbose: false,
308
227
  truncateKeys: false
@@ -336,13 +255,14 @@ var lastFocusEvent = /* @__PURE__ */ new Date();
336
255
  var totalTime = 0;
337
256
  var setupTelemetryListeners = (namespace, client, observability) => {
338
257
  const clickCallback = (event) => {
339
- if (observability.group === "dxos" && event.target && !event.target.id) {
258
+ if (BASE_TELEMETRY_PROPERTIES.group === "dxos" && event.target && !event.target.id) {
340
259
  console.warn("Click event on element without id:", event.target);
341
260
  }
342
261
  setTimeout(() => observability.event({
343
262
  identityId: getTelemetryIdentifier(client),
344
263
  name: `${namespace}.window.click`,
345
264
  properties: {
265
+ ...BASE_TELEMETRY_PROPERTIES,
346
266
  href: window.location.href,
347
267
  id: event.target?.id,
348
268
  path: event.path?.filter((el) => Boolean(el.tagName)).map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}`).reverse().join(">")
@@ -355,6 +275,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
355
275
  identityId: getTelemetryIdentifier(client),
356
276
  name: `${namespace}.window.focus`,
357
277
  properties: {
278
+ ...BASE_TELEMETRY_PROPERTIES,
358
279
  href: window.location.href,
359
280
  timeAway: now.getTime() - lastFocusEvent.getTime()
360
281
  }
@@ -368,6 +289,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
368
289
  identityId: getTelemetryIdentifier(client),
369
290
  name: `${namespace}.window.blur`,
370
291
  properties: {
292
+ ...BASE_TELEMETRY_PROPERTIES,
371
293
  href: window.location.href,
372
294
  timeSpent
373
295
  }
@@ -380,6 +302,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
380
302
  identityId: getTelemetryIdentifier(client),
381
303
  name: `${namespace}.page.unload`,
382
304
  properties: {
305
+ ...BASE_TELEMETRY_PROPERTIES,
383
306
  href: window.location.href,
384
307
  timeSpent: totalTime
385
308
  }
@@ -390,6 +313,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
390
313
  identityId: getTelemetryIdentifier(client),
391
314
  name: `${namespace}.window.error`,
392
315
  properties: {
316
+ ...BASE_TELEMETRY_PROPERTIES,
393
317
  href: window.location.href,
394
318
  message: event.message,
395
319
  filename: event.filename,
@@ -410,22 +334,21 @@ var setupTelemetryListeners = (namespace, client, observability) => {
410
334
  window.removeEventListener("error", errorCallback);
411
335
  };
412
336
  };
413
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
337
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
414
338
  var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
415
339
  var DATADOG_IDLE_INTERVAL = 1e3 * 60 * 1;
340
+ var ERROR_TAGS = [
341
+ "identityKey",
342
+ "username",
343
+ "deviceKey",
344
+ "group"
345
+ ];
416
346
  var Observability = class {
417
347
  // TODO(nf): make platform a required extension?
418
348
  constructor({ namespace, config, secrets, group, mode, telemetry, errorLog }) {
419
349
  this._mode = "disabled";
420
350
  this._ctx = new import_context.Context();
421
351
  this._tags = /* @__PURE__ */ new Map();
422
- this.addIPDataTelemetryTags = (ipData) => {
423
- this.setTag("city", ipData.city, "telemetry");
424
- this.setTag("region", ipData.region, "telemetry");
425
- this.setTag("country", ipData.country, "telemetry");
426
- ipData.latitude && this.setTag("latitude", ipData.latitude.toString(), "telemetry");
427
- ipData.longitude && this.setTag("longitude", ipData.longitude.toString(), "telemetry");
428
- };
429
352
  this._namespace = namespace;
430
353
  this._config = config;
431
354
  this._mode = mode ?? "disabled";
@@ -443,22 +366,11 @@ var Observability = class {
443
366
  }
444
367
  _loadSecrets(config, secrets) {
445
368
  if ((0, import_util.isNode)()) {
446
- const mergedSecrets = {
447
- ...cli_observability_secrets_default,
448
- ...secrets
449
- };
450
- process.env.DX_ENVIRONMENT && (mergedSecrets.DX_ENVIRONMENT = process.env.DX_ENVIRONMENT);
451
- process.env.DX_RELEASE && (mergedSecrets.DX_RELEASE = process.env.DX_RELEASE);
452
- process.env.SENTRY_DESTINATION && (mergedSecrets.SENTRY_DESTINATION = process.env.SENTRY_DESTINATION);
453
- process.env.TELEMETRY_API_KEY && (mergedSecrets.TELEMETRY_API_KEY = process.env.TELEMETRY_API_KEY);
454
- process.env.IPDATA_API_KEY && (mergedSecrets.IPDATA_API_KEY = process.env.IPDATA_API_KEY);
455
- process.env.DATADOG_API_KEY && (mergedSecrets.DATADOG_API_KEY = process.env.DATADOG_API_KEY);
456
- process.env.DATADOG_APP_KEY && (mergedSecrets.DATADOG_APP_KEY = process.env.DATADOG_APP_KEY);
457
- return mergedSecrets;
369
+ return cli_observability_secrets_default;
458
370
  } else {
459
371
  (0, import_invariant.invariant)(config, "runtime config is required", {
460
- F: __dxlog_file3,
461
- L: 128,
372
+ F: __dxlog_file2,
373
+ L: 117,
462
374
  S: this,
463
375
  A: [
464
376
  "config",
@@ -469,8 +381,8 @@ var Observability = class {
469
381
  rtc: this._secrets,
470
382
  config
471
383
  }, {
472
- F: __dxlog_file3,
473
- L: 129,
384
+ F: __dxlog_file2,
385
+ L: 118,
474
386
  S: this,
475
387
  C: (f, a) => f(...a)
476
388
  });
@@ -500,29 +412,20 @@ var Observability = class {
500
412
  get mode() {
501
413
  return this._mode;
502
414
  }
503
- get group() {
504
- return this._group;
505
- }
506
415
  get enabled() {
507
416
  return this._mode !== "disabled";
508
417
  }
509
418
  //
510
419
  // Tags
511
420
  //
512
- setTag(key, value, scope) {
513
- if (this.enabled && (scope === void 0 || scope === "all" || scope === "errors")) {
421
+ /**
422
+ * Set a tag for all observability services.
423
+ */
424
+ setTag(key, value) {
425
+ if (this.enabled && ERROR_TAGS.includes(key)) {
514
426
  (0, import_chunk_FSAOBKO2.setTag)(key, value);
515
427
  }
516
- if (!scope) {
517
- scope = "all";
518
- }
519
- this._tags.set(key, {
520
- value,
521
- scope
522
- });
523
- }
524
- getTag(key) {
525
- return this._tags.get(key);
428
+ this._tags.set(key, value);
526
429
  }
527
430
  // TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.
528
431
  async setIdentityTags(client) {
@@ -531,8 +434,8 @@ var Observability = class {
531
434
  (0, import_log.log)("empty response from identity service", {
532
435
  idqr
533
436
  }, {
534
- F: __dxlog_file3,
535
- L: 201,
437
+ F: __dxlog_file2,
438
+ L: 175,
536
439
  S: this,
537
440
  C: (f, a) => f(...a)
538
441
  });
@@ -545,16 +448,16 @@ var Observability = class {
545
448
  (0, import_log.log)("empty response from device service", {
546
449
  device: dqr
547
450
  }, {
548
- F: __dxlog_file3,
549
- L: 210,
451
+ F: __dxlog_file2,
452
+ L: 184,
550
453
  S: this,
551
454
  C: (f, a) => f(...a)
552
455
  });
553
456
  return;
554
457
  }
555
458
  (0, import_invariant.invariant)(dqr, "empty response from device service", {
556
- F: __dxlog_file3,
557
- L: 213,
459
+ F: __dxlog_file2,
460
+ L: 187,
558
461
  S: this,
559
462
  A: [
560
463
  "dqr",
@@ -566,8 +469,8 @@ var Observability = class {
566
469
  (0, import_log.log)("no current device", {
567
470
  device: dqr
568
471
  }, {
569
- F: __dxlog_file3,
570
- L: 217,
472
+ F: __dxlog_file2,
473
+ L: 191,
571
474
  S: this,
572
475
  C: (f, a) => f(...a)
573
476
  });
@@ -584,21 +487,16 @@ var Observability = class {
584
487
  //
585
488
  _initMetrics() {
586
489
  if (this.enabled && this._secrets.DATADOG_API_KEY) {
587
- this._metrics = new import_chunk_ZJRKFREX.DatadogMetrics({
490
+ this._metrics = new import_chunk_VDBBIYH6.DatadogMetrics({
588
491
  apiKey: this._secrets.DATADOG_API_KEY,
589
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
590
- return value.scope === "all" || value.scope === "metrics";
591
- }).map(([key, value]) => [
592
- key,
593
- value.value
594
- ])),
492
+ getTags: () => this._tags,
595
493
  // TODO(nf): move/refactor from telementryContext, needed to read CORS proxy
596
494
  config: this._config
597
495
  });
598
496
  } else {
599
497
  (0, import_log.log)("datadog disabled", void 0, {
600
- F: __dxlog_file3,
601
- L: 247,
498
+ F: __dxlog_file2,
499
+ L: 214,
602
500
  S: this,
603
501
  C: (f, a) => f(...a)
604
502
  });
@@ -617,8 +515,8 @@ var Observability = class {
617
515
  const updateSignalMetrics = new import_async.Event();
618
516
  updateSignalMetrics.on(this._ctx, async (networkStatus) => {
619
517
  (0, import_log.log)("send signal metrics", void 0, {
620
- F: __dxlog_file3,
621
- L: 267,
518
+ F: __dxlog_file2,
519
+ L: 234,
622
520
  S: this,
623
521
  C: (f, a) => f(...a)
624
522
  });
@@ -667,8 +565,8 @@ var Observability = class {
667
565
  const updateSpaceMetrics = new import_async.Event().debounce(SPACE_METRICS_MIN_INTERVAL);
668
566
  updateSpaceMetrics.on(this._ctx, async () => {
669
567
  (0, import_log.log)("send space update", void 0, {
670
- F: __dxlog_file3,
671
- L: 319,
568
+ F: __dxlog_file2,
569
+ L: 286,
672
570
  S: this,
673
571
  C: (f, a) => f(...a)
674
572
  });
@@ -690,7 +588,10 @@ var Observability = class {
690
588
  this.event({
691
589
  identityId: getTelemetryIdentifier(client),
692
590
  name: `${namespace}.space.update`,
693
- properties: data
591
+ properties: {
592
+ ...BASE_TELEMETRY_PROPERTIES,
593
+ ...data
594
+ }
694
595
  });
695
596
  }
696
597
  });
@@ -714,8 +615,8 @@ var Observability = class {
714
615
  async startRuntimeMetrics(client, frequency = DATADOG_IDLE_INTERVAL) {
715
616
  const platform = await client.services.services.SystemService?.getPlatform();
716
617
  (0, import_invariant.invariant)(platform, "platform is required", {
717
- F: __dxlog_file3,
718
- L: 362,
618
+ F: __dxlog_file2,
619
+ L: 332,
719
620
  S: this,
720
621
  A: [
721
622
  "platform",
@@ -736,8 +637,8 @@ var Observability = class {
736
637
  }
737
638
  (0, import_async.scheduleTaskInterval)(this._ctx, async () => {
738
639
  (0, import_log.log)("platform", void 0, {
739
- F: __dxlog_file3,
740
- L: 380,
640
+ F: __dxlog_file2,
641
+ L: 350,
741
642
  S: this,
742
643
  C: (f, a) => f(...a)
743
644
  });
@@ -745,8 +646,8 @@ var Observability = class {
745
646
  (0, import_log.log)("platform", {
746
647
  platform: platform2
747
648
  }, {
748
- F: __dxlog_file3,
749
- L: 383,
649
+ F: __dxlog_file2,
650
+ L: 353,
750
651
  S: this,
751
652
  C: (f, a) => f(...a)
752
653
  });
@@ -758,8 +659,8 @@ var Observability = class {
758
659
  }).catch((error) => (0, import_log.log)("platform error", {
759
660
  error
760
661
  }, {
761
- F: __dxlog_file3,
762
- L: 390,
662
+ F: __dxlog_file2,
663
+ L: 360,
763
664
  S: this,
764
665
  C: (f, a) => f(...a)
765
666
  }));
@@ -770,20 +671,15 @@ var Observability = class {
770
671
  //
771
672
  _initTelemetry() {
772
673
  if (this._secrets.TELEMETRY_API_KEY && this._mode !== "disabled") {
773
- this._telemetry = new import_chunk_BHF4PKAP.SegmentTelemetry({
674
+ this._telemetry = new import_chunk_ARUBPK2W.SegmentTelemetry({
774
675
  apiKey: this._secrets.TELEMETRY_API_KEY,
775
676
  batchSize: this._telemetryBatchSize,
776
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
777
- return value.scope === "all" || value.scope === "telemetry";
778
- }).map(([key, value]) => [
779
- key,
780
- value.value
781
- ]))
677
+ getTags: () => this._tags
782
678
  });
783
679
  } else {
784
680
  (0, import_log.log)("segment disabled", void 0, {
785
- F: __dxlog_file3,
786
- L: 415,
681
+ F: __dxlog_file2,
682
+ L: 378,
787
683
  S: this,
788
684
  C: (f, a) => f(...a)
789
685
  });
@@ -814,8 +710,8 @@ var Observability = class {
814
710
  dest: this._secrets.SENTRY_DESTINATION,
815
711
  options: this._errorReportingOptions
816
712
  }, {
817
- F: __dxlog_file3,
818
- L: 444,
713
+ F: __dxlog_file2,
714
+ L: 407,
819
715
  S: this,
820
716
  C: (f, a) => f(...a)
821
717
  });
@@ -831,14 +727,14 @@ var Observability = class {
831
727
  (0, import_chunk_FSAOBKO2.enableSentryLogProcessor)();
832
728
  }
833
729
  this._tags.forEach((v, k) => {
834
- if (v.scope === "all" || v.scope === "errors") {
835
- (0, import_chunk_FSAOBKO2.setTag)(k, v.value);
730
+ if (ERROR_TAGS.includes(k)) {
731
+ (0, import_chunk_FSAOBKO2.setTag)(k, v);
836
732
  }
837
733
  });
838
734
  } else {
839
735
  (0, import_log.log)("sentry disabled", void 0, {
840
- F: __dxlog_file3,
841
- L: 467,
736
+ F: __dxlog_file2,
737
+ L: 430,
842
738
  S: this,
843
739
  C: (f, a) => f(...a)
844
740
  });
@@ -857,19 +753,17 @@ var Observability = class {
857
753
  };
858
754
  // Annotate the CommonJS export names for ESM import in node:
859
755
  0 && (module.exports = {
756
+ BASE_TELEMETRY_PROPERTIES,
860
757
  OBSERVABILITY_DISABLED_KEY,
861
758
  OBSERVABILITY_GROUP_KEY,
862
759
  Observability,
863
760
  getObservabilityGroup,
864
- getObservabilityState,
865
761
  getTelemetryIdentifier,
866
762
  initializeAppObservability,
867
- initializeNodeObservability,
868
763
  isObservabilityDisabled,
869
764
  mapSpaces,
870
765
  setupTelemetryListeners,
871
- showObservabilityBanner,
872
766
  storeObservabilityDisabled,
873
767
  storeObservabilityGroup
874
768
  });
875
- //# sourceMappingURL=chunk-ED364ZBZ.cjs.map
769
+ //# sourceMappingURL=chunk-DE7OVD7T.cjs.map