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