@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
@@ -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_CBMRJXSL_exports = {};
30
- __export(chunk_CBMRJXSL_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_CBMRJXSL_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-JMKBRR4L.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_TELEMETRY=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_TELEMETRY_GROUP ?? void 0,
256
- mode: process.env.DX_DISABLE_TELEMETRY ? "disabled" : process.env.DX_TELEMETRY_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_TELEMETRY ? "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";
@@ -446,8 +369,8 @@ var Observability = class {
446
369
  return cli_observability_secrets_default;
447
370
  } else {
448
371
  (0, import_invariant.invariant)(config, "runtime config is required", {
449
- F: __dxlog_file3,
450
- L: 115,
372
+ F: __dxlog_file2,
373
+ L: 117,
451
374
  S: this,
452
375
  A: [
453
376
  "config",
@@ -458,8 +381,8 @@ var Observability = class {
458
381
  rtc: this._secrets,
459
382
  config
460
383
  }, {
461
- F: __dxlog_file3,
462
- L: 116,
384
+ F: __dxlog_file2,
385
+ L: 118,
463
386
  S: this,
464
387
  C: (f, a) => f(...a)
465
388
  });
@@ -489,26 +412,20 @@ var Observability = class {
489
412
  get mode() {
490
413
  return this._mode;
491
414
  }
492
- get group() {
493
- return this._group;
494
- }
495
415
  get enabled() {
496
416
  return this._mode !== "disabled";
497
417
  }
498
418
  //
499
419
  // Tags
500
420
  //
501
- setTag(key, value, scope) {
502
- 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)) {
503
426
  (0, import_chunk_FSAOBKO2.setTag)(key, value);
504
427
  }
505
- if (!scope) {
506
- scope = "all";
507
- }
508
- this._tags.set(key, {
509
- value,
510
- scope
511
- });
428
+ this._tags.set(key, value);
512
429
  }
513
430
  // TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.
514
431
  async setIdentityTags(client) {
@@ -517,8 +434,8 @@ var Observability = class {
517
434
  (0, import_log.log)("empty response from identity service", {
518
435
  idqr
519
436
  }, {
520
- F: __dxlog_file3,
521
- L: 184,
437
+ F: __dxlog_file2,
438
+ L: 175,
522
439
  S: this,
523
440
  C: (f, a) => f(...a)
524
441
  });
@@ -531,16 +448,16 @@ var Observability = class {
531
448
  (0, import_log.log)("empty response from device service", {
532
449
  device: dqr
533
450
  }, {
534
- F: __dxlog_file3,
535
- L: 193,
451
+ F: __dxlog_file2,
452
+ L: 184,
536
453
  S: this,
537
454
  C: (f, a) => f(...a)
538
455
  });
539
456
  return;
540
457
  }
541
458
  (0, import_invariant.invariant)(dqr, "empty response from device service", {
542
- F: __dxlog_file3,
543
- L: 196,
459
+ F: __dxlog_file2,
460
+ L: 187,
544
461
  S: this,
545
462
  A: [
546
463
  "dqr",
@@ -552,8 +469,8 @@ var Observability = class {
552
469
  (0, import_log.log)("no current device", {
553
470
  device: dqr
554
471
  }, {
555
- F: __dxlog_file3,
556
- L: 200,
472
+ F: __dxlog_file2,
473
+ L: 191,
557
474
  S: this,
558
475
  C: (f, a) => f(...a)
559
476
  });
@@ -570,21 +487,16 @@ var Observability = class {
570
487
  //
571
488
  _initMetrics() {
572
489
  if (this.enabled && this._secrets.DATADOG_API_KEY) {
573
- this._metrics = new import_chunk_ZJRKFREX.DatadogMetrics({
490
+ this._metrics = new import_chunk_VDBBIYH6.DatadogMetrics({
574
491
  apiKey: this._secrets.DATADOG_API_KEY,
575
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
576
- return value.scope === "all" || value.scope === "metrics";
577
- }).map(([key, value]) => [
578
- key,
579
- value.value
580
- ])),
492
+ getTags: () => this._tags,
581
493
  // TODO(nf): move/refactor from telementryContext, needed to read CORS proxy
582
494
  config: this._config
583
495
  });
584
496
  } else {
585
497
  (0, import_log.log)("datadog disabled", void 0, {
586
- F: __dxlog_file3,
587
- L: 230,
498
+ F: __dxlog_file2,
499
+ L: 214,
588
500
  S: this,
589
501
  C: (f, a) => f(...a)
590
502
  });
@@ -603,8 +515,8 @@ var Observability = class {
603
515
  const updateSignalMetrics = new import_async.Event();
604
516
  updateSignalMetrics.on(this._ctx, async (networkStatus) => {
605
517
  (0, import_log.log)("send signal metrics", void 0, {
606
- F: __dxlog_file3,
607
- L: 250,
518
+ F: __dxlog_file2,
519
+ L: 234,
608
520
  S: this,
609
521
  C: (f, a) => f(...a)
610
522
  });
@@ -653,8 +565,8 @@ var Observability = class {
653
565
  const updateSpaceMetrics = new import_async.Event().debounce(SPACE_METRICS_MIN_INTERVAL);
654
566
  updateSpaceMetrics.on(this._ctx, async () => {
655
567
  (0, import_log.log)("send space update", void 0, {
656
- F: __dxlog_file3,
657
- L: 302,
568
+ F: __dxlog_file2,
569
+ L: 286,
658
570
  S: this,
659
571
  C: (f, a) => f(...a)
660
572
  });
@@ -676,7 +588,10 @@ var Observability = class {
676
588
  this.event({
677
589
  identityId: getTelemetryIdentifier(client),
678
590
  name: `${namespace}.space.update`,
679
- properties: data
591
+ properties: {
592
+ ...BASE_TELEMETRY_PROPERTIES,
593
+ ...data
594
+ }
680
595
  });
681
596
  }
682
597
  });
@@ -700,8 +615,8 @@ var Observability = class {
700
615
  async startRuntimeMetrics(client, frequency = DATADOG_IDLE_INTERVAL) {
701
616
  const platform = await client.services.services.SystemService?.getPlatform();
702
617
  (0, import_invariant.invariant)(platform, "platform is required", {
703
- F: __dxlog_file3,
704
- L: 345,
618
+ F: __dxlog_file2,
619
+ L: 332,
705
620
  S: this,
706
621
  A: [
707
622
  "platform",
@@ -722,8 +637,8 @@ var Observability = class {
722
637
  }
723
638
  (0, import_async.scheduleTaskInterval)(this._ctx, async () => {
724
639
  (0, import_log.log)("platform", void 0, {
725
- F: __dxlog_file3,
726
- L: 363,
640
+ F: __dxlog_file2,
641
+ L: 350,
727
642
  S: this,
728
643
  C: (f, a) => f(...a)
729
644
  });
@@ -731,8 +646,8 @@ var Observability = class {
731
646
  (0, import_log.log)("platform", {
732
647
  platform: platform2
733
648
  }, {
734
- F: __dxlog_file3,
735
- L: 366,
649
+ F: __dxlog_file2,
650
+ L: 353,
736
651
  S: this,
737
652
  C: (f, a) => f(...a)
738
653
  });
@@ -744,8 +659,8 @@ var Observability = class {
744
659
  }).catch((error) => (0, import_log.log)("platform error", {
745
660
  error
746
661
  }, {
747
- F: __dxlog_file3,
748
- L: 373,
662
+ F: __dxlog_file2,
663
+ L: 360,
749
664
  S: this,
750
665
  C: (f, a) => f(...a)
751
666
  }));
@@ -756,20 +671,15 @@ var Observability = class {
756
671
  //
757
672
  _initTelemetry() {
758
673
  if (this._secrets.TELEMETRY_API_KEY && this._mode !== "disabled") {
759
- this._telemetry = new import_chunk_BHF4PKAP.SegmentTelemetry({
674
+ this._telemetry = new import_chunk_ARUBPK2W.SegmentTelemetry({
760
675
  apiKey: this._secrets.TELEMETRY_API_KEY,
761
676
  batchSize: this._telemetryBatchSize,
762
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
763
- return value.scope === "all" || value.scope === "telemetry";
764
- }).map(([key, value]) => [
765
- key,
766
- value.value
767
- ]))
677
+ getTags: () => this._tags
768
678
  });
769
679
  } else {
770
680
  (0, import_log.log)("segment disabled", void 0, {
771
- F: __dxlog_file3,
772
- L: 398,
681
+ F: __dxlog_file2,
682
+ L: 378,
773
683
  S: this,
774
684
  C: (f, a) => f(...a)
775
685
  });
@@ -800,8 +710,8 @@ var Observability = class {
800
710
  dest: this._secrets.SENTRY_DESTINATION,
801
711
  options: this._errorReportingOptions
802
712
  }, {
803
- F: __dxlog_file3,
804
- L: 427,
713
+ F: __dxlog_file2,
714
+ L: 407,
805
715
  S: this,
806
716
  C: (f, a) => f(...a)
807
717
  });
@@ -817,14 +727,14 @@ var Observability = class {
817
727
  (0, import_chunk_FSAOBKO2.enableSentryLogProcessor)();
818
728
  }
819
729
  this._tags.forEach((v, k) => {
820
- if (v.scope === "all" || v.scope === "errors") {
821
- (0, import_chunk_FSAOBKO2.setTag)(k, v.value);
730
+ if (ERROR_TAGS.includes(k)) {
731
+ (0, import_chunk_FSAOBKO2.setTag)(k, v);
822
732
  }
823
733
  });
824
734
  } else {
825
735
  (0, import_log.log)("sentry disabled", void 0, {
826
- F: __dxlog_file3,
827
- L: 450,
736
+ F: __dxlog_file2,
737
+ L: 430,
828
738
  S: this,
829
739
  C: (f, a) => f(...a)
830
740
  });
@@ -843,19 +753,17 @@ var Observability = class {
843
753
  };
844
754
  // Annotate the CommonJS export names for ESM import in node:
845
755
  0 && (module.exports = {
756
+ BASE_TELEMETRY_PROPERTIES,
846
757
  OBSERVABILITY_DISABLED_KEY,
847
758
  OBSERVABILITY_GROUP_KEY,
848
759
  Observability,
849
760
  getObservabilityGroup,
850
- getObservabilityState,
851
761
  getTelemetryIdentifier,
852
762
  initializeAppObservability,
853
- initializeNodeObservability,
854
763
  isObservabilityDisabled,
855
764
  mapSpaces,
856
765
  setupTelemetryListeners,
857
- showObservabilityBanner,
858
766
  storeObservabilityDisabled,
859
767
  storeObservabilityGroup
860
768
  });
861
- //# sourceMappingURL=chunk-CBMRJXSL.cjs.map
769
+ //# sourceMappingURL=chunk-DE7OVD7T.cjs.map