@dxos/observability 0.4.3-main.e5bbcda → 0.4.3-next.ebc6139
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/dist/lib/browser/{chunk-MLA3ZYPW.mjs → chunk-V6THSHYS.mjs} +32 -44
- package/dist/lib/browser/{chunk-MLA3ZYPW.mjs.map → chunk-V6THSHYS.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{observability-4VFPABBL.mjs → observability-5GM33EWR.mjs} +2 -2
- package/dist/lib/node/{chunk-Y2O6GPIG.cjs → chunk-NIGBDV2L.cjs} +21 -33
- package/dist/lib/node/{chunk-Y2O6GPIG.cjs.map → chunk-NIGBDV2L.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +15 -15
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{observability-5OWT3KAT.cjs → observability-KLYDIJPY.cjs} +6 -6
- package/dist/lib/node/{observability-5OWT3KAT.cjs.map → observability-KLYDIJPY.cjs.map} +2 -2
- package/dist/types/src/helpers/setup-telemetry-listeners.d.ts.map +1 -1
- package/dist/types/src/helpers/setup-telemetry-listeners.js +0 -4
- package/dist/types/src/helpers/setup-telemetry-listeners.js.map +1 -1
- package/package.json +14 -14
- package/src/helpers/setup-telemetry-listeners.ts +0 -5
- /package/dist/lib/browser/{observability-4VFPABBL.mjs.map → observability-5GM33EWR.mjs.map} +0 -0
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { Event, scheduleTaskInterval } from "@dxos/async";
|
|
17
17
|
import { Context } from "@dxos/context";
|
|
18
18
|
import { invariant } from "@dxos/invariant";
|
|
19
|
-
import { log as
|
|
19
|
+
import { log as log3 } from "@dxos/log";
|
|
20
20
|
import { ConnectionState } from "@dxos/network-manager";
|
|
21
21
|
import { DeviceKind, Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
22
22
|
import { isNode } from "@dxos/util";
|
|
@@ -98,7 +98,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
98
98
|
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
99
99
|
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
100
100
|
const observabilityDisabled = await isObservabilityDisabled(namespace);
|
|
101
|
-
const { Observability: Observability2 } = await import("./observability-
|
|
101
|
+
const { Observability: Observability2 } = await import("./observability-5GM33EWR.mjs");
|
|
102
102
|
const observability = new Observability2({
|
|
103
103
|
namespace,
|
|
104
104
|
group,
|
|
@@ -310,22 +310,10 @@ var mapSpaces = (spaces, options = {
|
|
|
310
310
|
};
|
|
311
311
|
|
|
312
312
|
// packages/sdk/observability/src/helpers/setup-telemetry-listeners.ts
|
|
313
|
-
import { log as log3 } from "@dxos/log";
|
|
314
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/setup-telemetry-listeners.ts";
|
|
315
313
|
var lastFocusEvent = /* @__PURE__ */ new Date();
|
|
316
314
|
var totalTime = 0;
|
|
317
315
|
var setupTelemetryListeners = (namespace, client, observability) => {
|
|
318
316
|
const clickCallback = (event) => {
|
|
319
|
-
if (observability.group === "dxos" && event.target && !event.target.id) {
|
|
320
|
-
log3.info("click event on element without id", {
|
|
321
|
-
target: event.target
|
|
322
|
-
}, {
|
|
323
|
-
F: __dxlog_file3,
|
|
324
|
-
L: 17,
|
|
325
|
-
S: void 0,
|
|
326
|
-
C: (f, a) => f(...a)
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
317
|
setTimeout(() => observability.event({
|
|
330
318
|
identityId: getTelemetryIdentifier(client),
|
|
331
319
|
name: `${namespace}.window.click`,
|
|
@@ -399,7 +387,7 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
399
387
|
};
|
|
400
388
|
|
|
401
389
|
// packages/sdk/observability/src/observability.ts
|
|
402
|
-
var
|
|
390
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
|
|
403
391
|
var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
|
|
404
392
|
var DATADOG_IDLE_INTERVAL = 1e3 * 60 * 1;
|
|
405
393
|
var Observability = class {
|
|
@@ -446,11 +434,11 @@ var Observability = class {
|
|
|
446
434
|
process.env.DATADOG_APP_KEY && (mergedSecrets.DATADOG_APP_KEY = process.env.DATADOG_APP_KEY);
|
|
447
435
|
return mergedSecrets;
|
|
448
436
|
} else {
|
|
449
|
-
|
|
437
|
+
log3("config", {
|
|
450
438
|
rtc: this._secrets,
|
|
451
439
|
config
|
|
452
440
|
}, {
|
|
453
|
-
F:
|
|
441
|
+
F: __dxlog_file3,
|
|
454
442
|
L: 128,
|
|
455
443
|
S: this,
|
|
456
444
|
C: (f, a) => f(...a)
|
|
@@ -509,10 +497,10 @@ var Observability = class {
|
|
|
509
497
|
async setIdentityTags(client) {
|
|
510
498
|
client.services.services.IdentityService.queryIdentity().subscribe((idqr) => {
|
|
511
499
|
if (!idqr?.identity?.identityKey) {
|
|
512
|
-
|
|
500
|
+
log3("empty response from identity service", {
|
|
513
501
|
idqr
|
|
514
502
|
}, {
|
|
515
|
-
F:
|
|
503
|
+
F: __dxlog_file3,
|
|
516
504
|
L: 200,
|
|
517
505
|
S: this,
|
|
518
506
|
C: (f, a) => f(...a)
|
|
@@ -523,10 +511,10 @@ var Observability = class {
|
|
|
523
511
|
});
|
|
524
512
|
client.services.services.DevicesService.queryDevices().subscribe((dqr) => {
|
|
525
513
|
if (!dqr || !dqr.devices || dqr.devices.length === 0) {
|
|
526
|
-
|
|
514
|
+
log3("empty response from device service", {
|
|
527
515
|
device: dqr
|
|
528
516
|
}, {
|
|
529
|
-
F:
|
|
517
|
+
F: __dxlog_file3,
|
|
530
518
|
L: 209,
|
|
531
519
|
S: this,
|
|
532
520
|
C: (f, a) => f(...a)
|
|
@@ -534,7 +522,7 @@ var Observability = class {
|
|
|
534
522
|
return;
|
|
535
523
|
}
|
|
536
524
|
invariant(dqr, "empty response from device service", {
|
|
537
|
-
F:
|
|
525
|
+
F: __dxlog_file3,
|
|
538
526
|
L: 212,
|
|
539
527
|
S: this,
|
|
540
528
|
A: [
|
|
@@ -544,10 +532,10 @@ var Observability = class {
|
|
|
544
532
|
});
|
|
545
533
|
const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);
|
|
546
534
|
if (!thisDevice) {
|
|
547
|
-
|
|
535
|
+
log3("no current device", {
|
|
548
536
|
device: dqr
|
|
549
537
|
}, {
|
|
550
|
-
F:
|
|
538
|
+
F: __dxlog_file3,
|
|
551
539
|
L: 216,
|
|
552
540
|
S: this,
|
|
553
541
|
C: (f, a) => f(...a)
|
|
@@ -577,8 +565,8 @@ var Observability = class {
|
|
|
577
565
|
config: this._config
|
|
578
566
|
});
|
|
579
567
|
} else {
|
|
580
|
-
|
|
581
|
-
F:
|
|
568
|
+
log3("datadog disabled", void 0, {
|
|
569
|
+
F: __dxlog_file3,
|
|
582
570
|
L: 246,
|
|
583
571
|
S: this,
|
|
584
572
|
C: (f, a) => f(...a)
|
|
@@ -597,8 +585,8 @@ var Observability = class {
|
|
|
597
585
|
startNetworkMetrics(client) {
|
|
598
586
|
const updateSignalMetrics = new Event();
|
|
599
587
|
updateSignalMetrics.on(this._ctx, async (networkStatus) => {
|
|
600
|
-
|
|
601
|
-
F:
|
|
588
|
+
log3("send signal metrics", void 0, {
|
|
589
|
+
F: __dxlog_file3,
|
|
602
590
|
L: 266,
|
|
603
591
|
S: this,
|
|
604
592
|
C: (f, a) => f(...a)
|
|
@@ -647,8 +635,8 @@ var Observability = class {
|
|
|
647
635
|
this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
|
|
648
636
|
const updateSpaceMetrics = new Event().debounce(SPACE_METRICS_MIN_INTERVAL);
|
|
649
637
|
updateSpaceMetrics.on(this._ctx, async () => {
|
|
650
|
-
|
|
651
|
-
F:
|
|
638
|
+
log3("send space update", void 0, {
|
|
639
|
+
F: __dxlog_file3,
|
|
652
640
|
L: 318,
|
|
653
641
|
S: this,
|
|
654
642
|
C: (f, a) => f(...a)
|
|
@@ -695,7 +683,7 @@ var Observability = class {
|
|
|
695
683
|
async startRuntimeMetrics(client, frequency = DATADOG_IDLE_INTERVAL) {
|
|
696
684
|
const platform = await client.services.services.SystemService?.getPlatform();
|
|
697
685
|
invariant(platform, "platform is required", {
|
|
698
|
-
F:
|
|
686
|
+
F: __dxlog_file3,
|
|
699
687
|
L: 361,
|
|
700
688
|
S: this,
|
|
701
689
|
A: [
|
|
@@ -716,17 +704,17 @@ var Observability = class {
|
|
|
716
704
|
}
|
|
717
705
|
}
|
|
718
706
|
scheduleTaskInterval(this._ctx, async () => {
|
|
719
|
-
|
|
720
|
-
F:
|
|
707
|
+
log3("platform", void 0, {
|
|
708
|
+
F: __dxlog_file3,
|
|
721
709
|
L: 379,
|
|
722
710
|
S: this,
|
|
723
711
|
C: (f, a) => f(...a)
|
|
724
712
|
});
|
|
725
713
|
client.services.services.SystemService?.getPlatform().then((platform2) => {
|
|
726
|
-
|
|
714
|
+
log3("platform", {
|
|
727
715
|
platform: platform2
|
|
728
716
|
}, {
|
|
729
|
-
F:
|
|
717
|
+
F: __dxlog_file3,
|
|
730
718
|
L: 382,
|
|
731
719
|
S: this,
|
|
732
720
|
C: (f, a) => f(...a)
|
|
@@ -736,10 +724,10 @@ var Observability = class {
|
|
|
736
724
|
this.gauge("dxos.client.runtime.heapTotal", platform2.memory.heapTotal);
|
|
737
725
|
this.gauge("dxos.client.runtime.heapUsed", platform2.memory.heapUsed);
|
|
738
726
|
}
|
|
739
|
-
}).catch((error) =>
|
|
727
|
+
}).catch((error) => log3("platform error", {
|
|
740
728
|
error
|
|
741
729
|
}, {
|
|
742
|
-
F:
|
|
730
|
+
F: __dxlog_file3,
|
|
743
731
|
L: 389,
|
|
744
732
|
S: this,
|
|
745
733
|
C: (f, a) => f(...a)
|
|
@@ -762,8 +750,8 @@ var Observability = class {
|
|
|
762
750
|
]))
|
|
763
751
|
});
|
|
764
752
|
} else {
|
|
765
|
-
|
|
766
|
-
F:
|
|
753
|
+
log3("segment disabled", void 0, {
|
|
754
|
+
F: __dxlog_file3,
|
|
767
755
|
L: 414,
|
|
768
756
|
S: this,
|
|
769
757
|
C: (f, a) => f(...a)
|
|
@@ -791,11 +779,11 @@ var Observability = class {
|
|
|
791
779
|
//
|
|
792
780
|
_initErrorLogs() {
|
|
793
781
|
if (this._secrets.SENTRY_DESTINATION && this._mode !== "disabled") {
|
|
794
|
-
|
|
782
|
+
log3.info("Initializing Sentry", {
|
|
795
783
|
dest: this._secrets.SENTRY_DESTINATION,
|
|
796
784
|
options: this._errorReportingOptions
|
|
797
785
|
}, {
|
|
798
|
-
F:
|
|
786
|
+
F: __dxlog_file3,
|
|
799
787
|
L: 443,
|
|
800
788
|
S: this,
|
|
801
789
|
C: (f, a) => f(...a)
|
|
@@ -817,8 +805,8 @@ var Observability = class {
|
|
|
817
805
|
}
|
|
818
806
|
});
|
|
819
807
|
} else {
|
|
820
|
-
|
|
821
|
-
F:
|
|
808
|
+
log3("sentry disabled", void 0, {
|
|
809
|
+
F: __dxlog_file3,
|
|
822
810
|
L: 466,
|
|
823
811
|
S: this,
|
|
824
812
|
C: (f, a) => f(...a)
|
|
@@ -853,4 +841,4 @@ export {
|
|
|
853
841
|
mapSpaces,
|
|
854
842
|
setupTelemetryListeners
|
|
855
843
|
};
|
|
856
|
-
//# sourceMappingURL=chunk-
|
|
844
|
+
//# sourceMappingURL=chunk-V6THSHYS.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/observability.ts", "../../../src/cli-observability-secrets.json", "../../../src/helpers/browser-observability.ts", "../../../src/helpers/common.ts", "../../../src/helpers/node-observability.ts", "../../../src/helpers/map-spaces.ts", "../../../src/helpers/setup-telemetry-listeners.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Event, scheduleTaskInterval } from '@dxos/async';\nimport { type Client, type Config } from '@dxos/client';\nimport { type Space } from '@dxos/client-protocol';\nimport { Context } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { ConnectionState } from '@dxos/network-manager';\nimport { DeviceKind, type NetworkStatus, Platform } from '@dxos/protocols/proto/dxos/client/services';\nimport { isNode } from '@dxos/util';\n\nimport buildSecrets from './cli-observability-secrets.json';\nimport { DatadogMetrics } from './datadog';\nimport { type IPData, getTelemetryIdentifier, mapSpaces } from './helpers';\nimport { SegmentTelemetry, type EventOptions, type PageOptions } from './segment';\nimport {\n captureException as sentryCaptureException,\n enableSentryLogProcessor,\n configureTracing as sentryConfigureTracing,\n init as sentryInit,\n type InitOptions,\n setTag as sentrySetTag,\n} from './sentry';\n\nconst SPACE_METRICS_MIN_INTERVAL = 1000 * 60;\n// const DATADOG_IDLE_INTERVAL = 1000 * 60 * 5;\nconst DATADOG_IDLE_INTERVAL = 1000 * 60 * 1;\n\n// Secrets? EnvironmentConfig?\n\nexport type ObservabilitySecrets = {\n DX_ENVIRONMENT: string | null;\n DX_RELEASE: string | null;\n SENTRY_DESTINATION: string | null;\n TELEMETRY_API_KEY: string | null;\n IPDATA_API_KEY: string | null;\n DATADOG_API_KEY: string | null;\n DATADOG_APP_KEY: string | null;\n};\n\nexport type Mode = 'basic' | 'full' | 'disabled';\nexport type TagScope = 'errors' | 'telemetry' | 'metrics' | 'all';\n\nexport type ObservabilityOptions = {\n /// The webapp (e.g. 'composer.dxos.org'), 'cli', or 'agent'.\n namespace: string;\n // TODO(nf): make platform a required extension?\n // platform: Platform;\n config?: Config;\n secrets?: Record<string, string>;\n group?: string;\n mode?: Mode;\n\n telemetry?: {\n batchSize?: number;\n };\n\n errorLog?: {\n sentryInitOptions?: InitOptions;\n logProcessor?: boolean;\n };\n};\n\n/*\n * Observability provides a common interface for error logging, metrics, and telemetry.\n * It currently provides these capabilities using Sentry, Datadog, and Segment.\n */\nexport class Observability {\n // TODO(wittjosiah): Generic metrics interface.\n private _metrics?: DatadogMetrics;\n // TODO(wittjosiah): Generic telemetry interface.\n private _telemetryBatchSize: number;\n private _telemetry?: SegmentTelemetry;\n // TODO(wittjosiah): Generic error logging interface.\n private _errorReportingOptions?: InitOptions;\n private _errorLogProcessor: boolean;\n\n private _secrets: ObservabilitySecrets;\n private _namespace: string;\n private _config?: Config;\n private _mode: Mode = 'disabled';\n private _group?: string;\n // TODO(nf): accept upstream context?\n private _ctx = new Context();\n private _tags = new Map<string, { value: string; scope: TagScope }>();\n\n // TODO(nf): make platform a required extension?\n constructor({ namespace, config, secrets, group, mode, telemetry, errorLog }: ObservabilityOptions) {\n this._namespace = namespace;\n this._config = config;\n this._mode = mode ?? 'disabled';\n this._group = group;\n this._secrets = this._loadSecrets(config, secrets);\n this._telemetryBatchSize = telemetry?.batchSize ?? 30;\n this._errorReportingOptions = errorLog?.sentryInitOptions;\n this._errorLogProcessor = errorLog?.logProcessor ?? false;\n\n if (this._group) {\n this.setTag('group', this._group);\n }\n this.setTag('namespace', this._namespace);\n\n if (this._mode === 'full') {\n // TODO(nf): set group and hostname?\n }\n }\n\n private _loadSecrets(config: Config | undefined, secrets?: Record<string, string>) {\n if (isNode()) {\n const mergedSecrets = {\n ...(buildSecrets as ObservabilitySecrets),\n ...secrets,\n };\n\n process.env.DX_ENVIRONMENT && (mergedSecrets.DX_ENVIRONMENT = process.env.DX_ENVIRONMENT);\n process.env.DX_RELEASE && (mergedSecrets.DX_RELEASE = process.env.DX_RELEASE);\n process.env.SENTRY_DESTINATION && (mergedSecrets.SENTRY_DESTINATION = process.env.SENTRY_DESTINATION);\n process.env.TELEMETRY_API_KEY && (mergedSecrets.TELEMETRY_API_KEY = process.env.TELEMETRY_API_KEY);\n process.env.IPDATA_API_KEY && (mergedSecrets.IPDATA_API_KEY = process.env.IPDATA_API_KEY);\n process.env.DATADOG_API_KEY && (mergedSecrets.DATADOG_API_KEY = process.env.DATADOG_API_KEY);\n process.env.DATADOG_APP_KEY && (mergedSecrets.DATADOG_APP_KEY = process.env.DATADOG_APP_KEY);\n\n return mergedSecrets;\n } else {\n log('config', { rtc: this._secrets, config });\n return {\n DX_ENVIRONMENT: config?.get('runtime.app.env.DX_ENVIRONMENT'),\n DX_RELEASE: config?.get('runtime.app.env.DX_RELEASE'),\n SENTRY_DESTINATION: config?.get('runtime.app.env.DX_SENTRY_DESTINATION'),\n TELEMETRY_API_KEY: config?.get('runtime.app.env.DX_TELEMETRY_API_KEY'),\n IPDATA_API_KEY: config?.get('runtime.app.env.DX_IPDATA_API_KEY'),\n DATADOG_API_KEY: config?.get('runtime.app.env.DX_DATADOG_API_KEY'),\n DATADOG_APP_KEY: config?.get('runtime.app.env.DX_DATADOG_APP_KEY'),\n ...secrets,\n };\n }\n }\n\n initialize() {\n this._initMetrics();\n this._initTelemetry();\n this._initErrorLogs();\n }\n\n async close() {\n await this._ctx.dispose();\n\n // TODO(wittjosiah): Remove telemetry, etc. scripts.\n }\n\n setMode(mode: Mode) {\n this._mode = mode;\n }\n\n get mode() {\n return this._mode;\n }\n\n get group() {\n return this._group;\n }\n\n get enabled() {\n return this._mode !== 'disabled';\n }\n\n //\n // Tags\n //\n\n setTag(key: string, value: string, scope?: TagScope) {\n if (this.enabled && (scope === undefined || scope === 'all' || scope === 'errors')) {\n sentrySetTag(key, value);\n }\n if (!scope) {\n scope = 'all';\n }\n this._tags.set(key, { value, scope });\n }\n\n getTag(key: string) {\n return this._tags.get(key);\n }\n\n addIPDataTelemetryTags = (ipData: IPData) => {\n this.setTag('city', ipData.city, 'telemetry');\n this.setTag('region', ipData.region, 'telemetry');\n this.setTag('country', ipData.country, 'telemetry');\n ipData.latitude && this.setTag('latitude', ipData.latitude.toString(), 'telemetry');\n ipData.longitude && this.setTag('longitude', ipData.longitude.toString(), 'telemetry');\n };\n\n // TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.\n async setIdentityTags(client: Client) {\n client.services.services.IdentityService!.queryIdentity().subscribe((idqr) => {\n if (!idqr?.identity?.identityKey) {\n log('empty response from identity service', { idqr });\n return;\n }\n\n this.setTag('identityKey', idqr.identity.identityKey.truncate());\n });\n\n client.services.services.DevicesService!.queryDevices().subscribe((dqr) => {\n if (!dqr || !dqr.devices || dqr.devices.length === 0) {\n log('empty response from device service', { device: dqr });\n return;\n }\n invariant(dqr, 'empty response from device service');\n\n const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);\n if (!thisDevice) {\n log('no current device', { device: dqr });\n return;\n }\n this.setTag('deviceKey', thisDevice.deviceKey.truncate());\n if (thisDevice.profile?.label) {\n this.setTag('deviceProfile', thisDevice.profile.label);\n }\n });\n }\n\n //\n // Metrics\n //\n\n private _initMetrics() {\n if (this.enabled && this._secrets.DATADOG_API_KEY) {\n this._metrics = new DatadogMetrics({\n apiKey: this._secrets.DATADOG_API_KEY,\n getTags: () =>\n Object.fromEntries(\n Array.from(this._tags)\n .filter(([key, value]) => {\n return value.scope === 'all' || value.scope === 'metrics';\n })\n .map(([key, value]) => [key, value.value]),\n ),\n // TODO(nf): move/refactor from telementryContext, needed to read CORS proxy\n config: this._config!,\n });\n } else {\n log('datadog disabled');\n }\n }\n\n /**\n * Gauge metric.\n *\n * The default implementation uses Datadog.\n */\n gauge(name: string, value: number | any, extraTags?: any) {\n this._metrics?.gauge(name, value, extraTags);\n }\n\n // TODO(nf): Refactor into ObservabilityExtensions.\n\n startNetworkMetrics(client: Client) {\n const updateSignalMetrics = new Event<NetworkStatus>();\n\n // const lcsh = (csp as LocalClientServices).host;\n updateSignalMetrics.on(this._ctx, async (networkStatus) => {\n log('send signal metrics');\n (networkStatus.signaling as NetworkStatus.Signal[]).forEach(({ server, state }) => {\n this.gauge('dxos.client.network.signal.connectionState', state, { server });\n });\n\n let swarmCount = 0;\n const connectionStates = new Map<string, number>();\n for (const state in ConnectionState) {\n connectionStates.set(state, 0);\n }\n\n let totalReadBufferSize = 0;\n let totalWriteBufferSize = 0;\n let totalChannelBufferSize = 0;\n\n networkStatus.connectionInfo?.forEach((connectionInfo) => {\n swarmCount++;\n\n for (const conn of connectionInfo.connections ?? []) {\n connectionStates.set(conn.state, (connectionStates.get(conn.state) ?? 0) + 1);\n totalReadBufferSize += conn.readBufferSize ?? 0;\n totalWriteBufferSize += conn.writeBufferSize ?? 0;\n\n for (const stream of conn.streams ?? []) {\n totalChannelBufferSize += stream.writeBufferSize ?? 0;\n }\n }\n\n this.gauge('dxos.client.network.swarm.count', swarmCount);\n for (const state in ConnectionState) {\n this.gauge('dxos.client.network.connection.count', connectionStates.get(state) ?? 0, { state });\n }\n this.gauge('dxox.client.network.totalReadBufferSize', totalReadBufferSize);\n this.gauge('dxos.client.network.totalWriteBufferSize', totalWriteBufferSize);\n this.gauge('dxos.client.network.totalChannelBufferSize', totalChannelBufferSize);\n });\n });\n\n client.services.services.NetworkService?.queryStatus().subscribe((networkStatus) => {\n updateSignalMetrics.emit(networkStatus);\n });\n\n // scheduleTaskInterval(ctx, async () => updateSignalMetrics.emit(), DATADOG_IDLE_INTERVAL);\n }\n\n startSpacesMetrics(client: Client, namespace: string) {\n const spaces = client.spaces.get();\n const subscriptions = new Map<string, { unsubscribe: () => void }>();\n this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));\n\n const updateSpaceMetrics = new Event<Space>().debounce(SPACE_METRICS_MIN_INTERVAL);\n updateSpaceMetrics.on(this._ctx, async () => {\n log('send space update');\n for (const data of mapSpaces(spaces, { truncateKeys: true })) {\n // Metrics\n this.gauge('dxos.client.space.members', data.members, { key: data.key });\n this.gauge('dxos.client.space.objects', data.objects, { key: data.key });\n this.gauge('dxos.client.space.epoch', data.epoch, { key: data.key });\n this.gauge('dxos.client.space.currentDataMutations', data.currentDataMutations, { key: data.key });\n\n // Telemetry\n this.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.space.update`,\n properties: data,\n });\n }\n });\n\n const subscribeToSpaceUpdate = (space: Space) =>\n space.pipeline.subscribe({\n next: () => {\n updateSpaceMetrics.emit();\n },\n });\n\n spaces.forEach((space) => {\n subscriptions.set(space.key.toHex(), subscribeToSpaceUpdate(space));\n });\n\n client.spaces.subscribe({\n next: async (spaces) => {\n spaces\n .filter((space) => !subscriptions.has(space.key.toHex()))\n .forEach((space) => {\n subscriptions.set(space.key.toHex(), subscribeToSpaceUpdate(space));\n });\n },\n });\n\n scheduleTaskInterval(this._ctx, async () => updateSpaceMetrics.emit(), DATADOG_IDLE_INTERVAL);\n }\n\n async startRuntimeMetrics(client: Client, frequency: number = DATADOG_IDLE_INTERVAL) {\n const platform = await client.services.services.SystemService?.getPlatform();\n invariant(platform, 'platform is required');\n\n this.setTag('platform_type', Platform.PLATFORM_TYPE[platform.type as number].toLowerCase());\n if (this._mode === 'full') {\n // platform[foo] does not work?\n if (platform.platform) {\n this.setTag('platform', platform.platform);\n }\n if (platform.arch) {\n this.setTag('arch', platform.arch);\n }\n if (platform.runtime) {\n this.setTag('runtime', platform.runtime);\n }\n }\n scheduleTaskInterval(\n this._ctx,\n async () => {\n log('platform');\n client.services.services.SystemService?.getPlatform()\n .then((platform) => {\n log('platform', { platform });\n if (platform.memory) {\n this.gauge('dxos.client.runtime.rss', platform.memory.rss);\n this.gauge('dxos.client.runtime.heapTotal', platform.memory.heapTotal);\n this.gauge('dxos.client.runtime.heapUsed', platform.memory.heapUsed);\n }\n })\n .catch((error) => log('platform error', { error }));\n },\n frequency,\n );\n }\n\n //\n // Telemetry\n //\n\n private _initTelemetry() {\n if (this._secrets.TELEMETRY_API_KEY && this._mode !== 'disabled') {\n this._telemetry = new SegmentTelemetry({\n apiKey: this._secrets.TELEMETRY_API_KEY,\n batchSize: this._telemetryBatchSize,\n getTags: () =>\n Object.fromEntries(\n Array.from(this._tags)\n .filter(([key, value]) => {\n return value.scope === 'all' || value.scope === 'telemetry';\n })\n .map(([key, value]) => [key, value.value]),\n ),\n });\n } else {\n log('segment disabled');\n }\n }\n\n /**\n * A telemetry event.\n *\n * The default implementation uses Segment.\n */\n event(options: EventOptions) {\n this._telemetry?.event(options);\n }\n\n /**\n * A telemetry page view.\n *\n * The default implementation uses Segment.\n */\n page(options: PageOptions) {\n this._telemetry?.page(options);\n }\n\n //\n // Error Logs\n //\n\n private _initErrorLogs() {\n if (this._secrets.SENTRY_DESTINATION && this._mode !== 'disabled') {\n // TODO(nf): refactor package into this one?\n log.info('Initializing Sentry', {\n dest: this._secrets.SENTRY_DESTINATION,\n options: this._errorReportingOptions,\n });\n sentryInit({\n ...this._errorReportingOptions,\n destination: this._secrets.SENTRY_DESTINATION,\n scrubFilenames: this._mode !== 'full',\n });\n if (this._errorReportingOptions?.tracing) {\n sentryConfigureTracing();\n }\n // TODO(nf): set platform at instantiation? needed for node.\n if (this._errorLogProcessor) {\n enableSentryLogProcessor();\n }\n // TODO(nf): is this different than passing as properties in options?\n this._tags.forEach((v, k) => {\n if (v.scope === 'all' || v.scope === 'errors') {\n sentrySetTag(k, v.value);\n }\n });\n } else {\n log('sentry disabled');\n }\n }\n\n /**\n * Manually capture an exception.\n *\n * The default implementation uses Sentry.\n */\n captureException(err: any) {\n if (this.enabled) {\n sentryCaptureException(err);\n }\n }\n}\n", "{\n \"SENTRY_DESTINATION\": \"https://2647916221e643869965e78469479aa4@o4504012000067584.ingest.sentry.io/4504012027265029\",\n \"TELEMETRY_API_KEY\": \"B00QG6PtJJrJ0VVFe0H5a6bcUUShKyZM\",\n \"IPDATA_API_KEY\": \"73dfdecdf979c18f07d50cf841bbdd9e589f237256326ac8cca23786\",\n \"DATADOG_API_KEY\": null,\n \"DATADOG_APP_KEY\": null\n}", "//\n// Copyright 2022 DXOS.org\n//\n\n// NOTE: localStorage is not available in web workers.\nimport * as localForage from 'localforage';\n\n// import { type Platform } from '@dxos/client-services';\n// import { type InitOptions as TelemetryInitOptions } from '@dxos/telemetry';\n\nimport type { Config } from '@dxos/client';\nimport { log } from '@dxos/log';\n\nimport type { IPData } from './common';\nimport type { Mode, Observability } from '../observability';\n\nexport const OBSERVABILITY_DISABLED_KEY = 'observability-disabled';\nexport const OBSERVABILITY_GROUP_KEY = 'observability-group';\n\nexport const isObservabilityDisabled = async (namespace: string): Promise<boolean> => {\n try {\n return (await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`)) === 'true';\n } catch (err) {\n log.catch('Failed to check if observability is disabled, assuming it is', err);\n return true;\n }\n};\n\nexport const storeObservabilityDisabled = async (namespace: string, value: boolean) => {\n try {\n await localForage.setItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`, String(value));\n } catch (err) {\n log.catch('Failed to store observability disabled', err);\n }\n};\n\nexport const getObservabilityGroup = async (namespace: string): Promise<string | undefined> => {\n try {\n return (await localForage.getItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`)) ?? undefined;\n } catch (err) {\n log.catch('Failed to get observability group', err);\n }\n};\n\nexport const storeObservabilityGroup = async (namespace: string, value: string) => {\n try {\n await localForage.setItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`, value);\n } catch (err) {\n log.catch('Failed to store observability group', err);\n }\n};\n\nexport type AppObservabilityOptions = {\n namespace: string;\n config: Config;\n mode?: Mode;\n tracingEnable?: boolean;\n replayEnable?: boolean;\n // TODO(nf): options for providers?\n};\n\n// TODO(wittjosiah): Store preference for disabling observability.\n// At minimum should be stored locally (i.e., localstorage), possibly in halo preference.\n// Needs to be hooked up to settings page for user visibility.\nexport const initializeAppObservability = async ({\n namespace,\n config,\n mode = 'basic',\n tracingEnable = true,\n replayEnable = true,\n}: AppObservabilityOptions): Promise<Observability> => {\n log('initializeAppObservability', { config });\n\n /*\n const platform = (await client.services.services.SystemService?.getPlatform()) as Platform;\n if (!platform) {\n log.error('failed to get platform, could not initialize observability');\n return undefined;\n }\n */\n\n const group = (await getObservabilityGroup(namespace)) ?? undefined;\n const release = `${namespace}@${config.get('runtime.app.build.version')}`;\n const environment = config.get('runtime.app.env.DX_ENVIRONMENT');\n\n const observabilityDisabled = await isObservabilityDisabled(namespace);\n\n const { Observability } = await import('../observability');\n\n // TODO(nf): configure mode\n const observability = new Observability({\n namespace,\n group,\n mode,\n config,\n errorLog: {\n sentryInitOptions: {\n environment,\n release,\n tracing: tracingEnable,\n replay: replayEnable,\n // TODO(wittjosiah): Configure these.\n sampleRate: 1.0,\n replaySampleRate: 0.1,\n replaySampleRateOnError: 1.0,\n },\n },\n });\n\n // global kill switch\n if (observabilityDisabled) {\n observability.setMode('disabled');\n log.info('observability disabled');\n return observability;\n }\n\n try {\n const getIPData = async (config: Config): Promise<IPData | void> => {\n const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1000; // 6 hours\n type CachedIPData = {\n data: IPData;\n timestamp: number;\n };\n\n // Check cache first.\n const cachedData: null | CachedIPData = await localForage.getItem('dxos:observability:ipdata');\n if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {\n return cachedData.data;\n }\n\n // Fetch data if not cached.\n const IPDATA_API_KEY = config.get('runtime.app.env.DX_IPDATA_API_KEY');\n if (IPDATA_API_KEY) {\n return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`)\n .then((res) => res.json())\n .then((data) => {\n // Cache data.\n localForage\n .setItem('dxos:observability:ipdata', {\n data,\n timestamp: Date.now(),\n })\n .catch((err) => observability.captureException(err));\n\n return data;\n })\n .catch((err) => observability.captureException(err));\n }\n };\n\n // TODO(nf): plugin state?\n\n // TODO(nf): should provide capability to init Sentry earlier in booting process to capture errors during initialization.\n\n observability.initialize();\n\n const ipData = await getIPData(config);\n\n ipData && observability.addIPDataTelemetryTags(ipData);\n\n if (typeof navigator !== 'undefined' && navigator.storage?.estimate) {\n setInterval(async () => {\n try {\n const storageEstimate = await navigator.storage.estimate();\n storageEstimate.usage && observability.setTag('storageUsage', storageEstimate.usage.toString(), 'telemetry');\n storageEstimate.quota && observability.setTag('storageQuota', storageEstimate.quota.toString(), 'telemetry');\n } catch (error) {\n log.warn('Failed to run estimate()', error);\n }\n }, 10e3);\n }\n } catch (err: any) {\n log.error('Failed to initialize app observability', err);\n }\n\n return observability;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport type { Client } from '@dxos/client';\n\n// TODO(wittjosiah): Improve privacy of telemetry identifiers.\n// - Identifier should be generated client-side with no attachment to identity.\n// - Identifier can then be reset by user.\n// - Identifier can be synced via HALO to allow for correlation of events bewteen devices.\n// - Identifier should also be stored outside of HALO such that it is available immediately on startup.\nexport const getTelemetryIdentifier = (client: Client) => {\n if (!client?.initialized) {\n return undefined;\n }\n\n const identity = client.halo.identity.get();\n if (identity) {\n return identity.identityKey.truncate();\n }\n\n return undefined;\n};\n\nexport type IPData = { city: string; region: string; country: string; latitude: number; longitude: number };\n", "//\n// Copyright 2022 DXOS.org\n//\nimport yaml from 'js-yaml';\nimport { existsSync, statSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { v4 as uuid, validate as validateUuid } from 'uuid';\n\nimport type { Config } from '@dxos/client';\nimport { log } from '@dxos/log';\n\nimport { Observability, type Mode } from '../observability';\n\n/**\n * Print observability banner once per installation.\n */\nexport const showObservabilityBanner = async (configDir: string, bannercb: (input: string) => void) => {\n const path = join(configDir, '.observability-banner-printed');\n if (existsSync(path)) {\n return;\n }\n bannercb(\n // eslint-disable-next-line no-multi-str\n 'Basic observability data will be sent to the DXOS team in order to improve the product. This includes \\\n performance metrics, error logs, and usage data. No personally identifiable information, other than your \\\n public key, is included with this data and no private data ever leaves your devices. To disable sending \\\n observability data, set the environment variable DX_DISABLE_OBSERVABILITY=true.',\n );\n\n await writeFile(path, '', 'utf-8');\n};\n\nexport const getObservabilityState = async (configDir: string): Promise<PersistentObservabilityState> => {\n // check whether configDir exists and if it's a directory\n\n if (existsSync(configDir)) {\n if (!statSync(configDir).isDirectory()) {\n throw new Error(`Config directory ${configDir} exists but is not a directory`);\n }\n } else {\n await mkdir(configDir, { recursive: true });\n }\n\n const idPath = join(configDir, 'observability.yml');\n if (existsSync(idPath)) {\n const context = await readFile(idPath, 'utf-8');\n return validate(context) ?? initializeState(idPath);\n }\n\n return initializeState(idPath);\n};\n\nexport type TelemetryContext = {\n mode: Mode;\n installationId?: string;\n group?: string;\n timezone: string;\n runtime: string;\n os: string;\n arch: string;\n ci: boolean;\n [key: string]: any;\n};\n\nexport type PersistentObservabilityState = {\n installationId: string;\n group?: string;\n mode: Mode;\n};\n\n// create initial state and write to file, using environment variables to override defaults.\nconst initializeState = async (idPath: string): Promise<PersistentObservabilityState> => {\n // TODO(nf): read initial values from config or seed file\n const observabilityState = {\n installationId: uuid(),\n group: process.env.DX_OBSERVABILITY_GROUP ?? undefined,\n mode: (process.env.DX_DISABLE_OBSERVABILITY ? 'disabled' : process.env.DX_OBSERVABILITY_MODE ?? 'basic') as Mode,\n };\n\n await writeFile(\n idPath,\n '# This file is automatically generated by the @dxos/cli.\\n' + yaml.dump(observabilityState),\n 'utf-8',\n );\n\n return observabilityState;\n};\n\nconst validate = (contextString: string) => {\n const context = yaml.load(contextString) as PersistentObservabilityState;\n if (Boolean(context.installationId) && validateUuid(context.installationId!)) {\n return {\n ...context,\n mode: process.env.DX_DISABLE_OBSERVABILITY ? 'disabled' : context.mode ?? 'basic',\n };\n }\n};\n\nexport type NodeObservabilityOptions = {\n installationId: string;\n group?: string;\n namespace: string;\n config: Config;\n mode?: Mode;\n tracingEnable?: boolean;\n replayEnable?: boolean;\n // TODO(nf): options for providers?\n};\n\nexport const initializeNodeObservability = async ({\n namespace,\n config,\n installationId,\n group,\n mode = 'basic',\n tracingEnable = true,\n replayEnable = true,\n}: NodeObservabilityOptions): Promise<Observability> => {\n log('initializeCliObservability', { config });\n\n const release = `${namespace}@${config.get('runtime.app.build.version')}`;\n const environment = config.get('runtime.app.env.DX_ENVIRONMENT');\n\n const observability = new Observability({\n namespace,\n group,\n mode,\n errorLog: {\n sentryInitOptions: {\n environment,\n release,\n // TODO(wittjosiah): Configure this.\n sampleRate: 1.0,\n },\n logProcessor: true,\n },\n });\n\n observability.setTag('installationId', installationId);\n\n const IPDATA_API_KEY = config.get('runtime.app.env.DX_IPDATA_API_KEY');\n try {\n const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);\n const ipData = await res.json();\n ipData && observability.addIPDataTelemetryTags(ipData);\n } catch (err) {\n observability?.captureException(err);\n }\n return observability;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Space } from '@dxos/client-protocol';\n\nexport type MapSpacesOptions = {\n verbose?: boolean;\n truncateKeys?: boolean;\n};\n\nexport const mapSpaces = (spaces: Space[], options: MapSpacesOptions = { verbose: false, truncateKeys: false }) => {\n return spaces.map((space) => {\n // TODO(burdon): Factor out.\n // TODO(burdon): Agent needs to restart before `ready` is available.\n const { open, ready } = space.internal.data.metrics ?? {};\n const startup = open && ready && ready.getTime() - open.getTime();\n\n // TODO(burdon): Get feeds from client-services if verbose (factor out from devtools/diagnostics).\n // const host = client.services.services.DevtoolsHost!;\n const pipeline = space.internal.data.pipeline;\n const startDataMutations = pipeline?.currentEpoch?.subject.assertion.timeframe.totalMessages() ?? 0;\n const epoch = pipeline?.currentEpoch?.subject.assertion.number;\n // const appliedEpoch = pipeline?.appliedEpoch?.subject.assertion.number;\n const currentDataMutations = pipeline?.currentDataTimeframe?.totalMessages() ?? 0;\n const totalDataMutations = pipeline?.targetDataTimeframe?.totalMessages() ?? 0;\n\n return {\n // TODO(nf): truncate keys for DD?\n key: space.key.truncate(),\n open: space.isOpen,\n members: space.members.get().length,\n objects: space.db.query().objects.length,\n startup,\n epoch,\n // appliedEpoch,\n startDataMutations,\n currentDataMutations,\n totalDataMutations,\n\n // TODO(burdon): Negative?\n progress: (\n Math.min(Math.abs((currentDataMutations - startDataMutations) / (totalDataMutations - startDataMutations)), 1) *\n 100\n ).toFixed(0),\n };\n });\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport type { Client } from '@dxos/client';\nimport { log } from '@dxos/log';\n\nimport { getTelemetryIdentifier } from './common';\nimport type { Observability } from '../observability';\n\nlet lastFocusEvent = new Date();\nlet totalTime = 0;\n\nexport const setupTelemetryListeners = (namespace: string, client: Client, observability: Observability) => {\n const clickCallback = (event: any) => {\n if (observability.group === 'dxos' && event.target && !event.target.id) {\n log.info('click event on element without id', { target: event.target });\n }\n\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.click`,\n properties: {\n href: window.location.href,\n id: (event.target as HTMLElement)?.id,\n path: (event.path as HTMLElement[])\n ?.filter((el) => Boolean(el.tagName))\n .map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ''}`)\n .reverse()\n .join('>'),\n },\n }),\n );\n };\n\n const focusCallback = () => {\n const now = new Date();\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.focus`,\n properties: {\n href: window.location.href,\n timeAway: now.getTime() - lastFocusEvent.getTime(),\n },\n }),\n );\n lastFocusEvent = now;\n };\n\n const blurCallback = () => {\n const now = new Date();\n const timeSpent = now.getTime() - lastFocusEvent.getTime();\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.blur`,\n properties: {\n href: window.location.href,\n timeSpent,\n },\n }),\n );\n lastFocusEvent = now;\n totalTime = totalTime + timeSpent;\n };\n\n const unloadCallback = () => {\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.page.unload`,\n properties: {\n href: window.location.href,\n timeSpent: totalTime,\n },\n }),\n );\n };\n\n const errorCallback = (event: ErrorEvent) => {\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.error`,\n properties: {\n href: window.location.href,\n message: event.message,\n filename: event.filename,\n stack: (event.error as Error).stack,\n },\n }),\n );\n };\n\n window.addEventListener('click', clickCallback, true);\n window.addEventListener('focus', focusCallback);\n window.addEventListener('blur', blurCallback);\n window.addEventListener('beforeunload', unloadCallback);\n window.addEventListener('error', errorCallback);\n\n return () => {\n window.removeEventListener('click', clickCallback, true);\n window.removeEventListener('focus', focusCallback);\n window.removeEventListener('blur', blurCallback);\n window.removeEventListener('beforeunload', unloadCallback);\n window.removeEventListener('error', errorCallback);\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAIA,SAASA,OAAOC,4BAA4B;AAG5C,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,OAAAA,YAAW;AACpB,SAASC,uBAAuB;AAChC,SAASC,YAAgCC,gBAAgB;AACzD,SAASC,cAAc;;;ACZvB;AAAA,EACE,oBAAsB;AAAA,EACtB,mBAAqB;AAAA,EACrB,gBAAkB;AAAA,EAClB,iBAAmB;AAAA,EACnB,iBAAmB;AACrB;;;ACDA,YAAYC,iBAAiB;AAM7B,SAASC,WAAW;;AAKb,IAAMC,6BAA6B;AACnC,IAAMC,0BAA0B;AAEhC,IAAMC,0BAA0B,OAAOC,cAAAA;AAC5C,MAAI;AACF,WAAQ,MAAkBC,oBAAQ,GAAGD,SAAAA,IAAaH,0BAAAA,EAA4B,MAAO;EACvF,SAASK,KAAK;AACZN,QAAIO,MAAM,gEAAgED,KAAAA;;;;;;AAC1E,WAAO;EACT;AACF;AAEO,IAAME,6BAA6B,OAAOJ,WAAmBK,UAAAA;AAClE,MAAI;AACF,UAAkBC,oBAAQ,GAAGN,SAAAA,IAAaH,0BAAAA,IAA8BU,OAAOF,KAAAA,CAAAA;EACjF,SAASH,KAAK;AACZN,QAAIO,MAAM,0CAA0CD,KAAAA;;;;;;EACtD;AACF;AAEO,IAAMM,wBAAwB,OAAOR,cAAAA;AAC1C,MAAI;AACF,WAAQ,MAAkBC,oBAAQ,GAAGD,SAAAA,IAAaF,uBAAAA,EAAyB,KAAMW;EACnF,SAASP,KAAK;AACZN,QAAIO,MAAM,qCAAqCD,KAAAA;;;;;;EAC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KF,YAAY7B,MAAM+B,OAAAA;EACzB;;;;;;EAOAC,KAAKD,SAAsB;AACzB,SAAKF,YAAYG,KAAKD,OAAAA;EACxB;;;;EAMQzH,iBAAiB;AACvB,QAAI,KAAK1B,SAASe,sBAAsB,KAAKhC,UAAU,YAAY;AAEjEqC,MAAAA,KAAIiI,KAAK,uBAAuB;QAC9BC,MAAM,KAAKtJ,SAASe;QACpBoI,SAAS,KAAK/I;MAChB,GAAA;;;;;;AACAmJ,WAAW;QACT,GAAG,KAAKnJ;QACRoJ,aAAa,KAAKxJ,SAASe;QAC3B0I,gBAAgB,KAAK1K,UAAU;MACjC,CAAA;AACA,UAAI,KAAKqB,wBAAwBsJ,SAAS;AACxCC,yBAAAA;MACF;AAEA,UAAI,KAAKrJ,oBAAoB;AAC3BsJ,iCAAAA;MACF;AAEA,WAAK1K,MAAMgG,QAAQ,CAAC2E,GAAGC,MAAAA;AACrB,YAAID,EAAE5H,UAAU,SAAS4H,EAAE5H,UAAU,UAAU;AAC7CE,iBAAa2H,GAAGD,EAAE7H,KAAK;QACzB;MACF,CAAA;IACF,OAAO;AACLZ,MAAAA,KAAI,mBAAA,QAAA;;;;;;IACN;EACF;;;;;;EAOA2I,iBAAiBC,KAAU;AACzB,QAAI,KAAKlI,SAAS;AAChBmI,uBAAuBD,GAAAA;IACzB;EACF;AACF;",
|
|
6
|
-
"names": ["Event", "scheduleTaskInterval", "Context", "invariant", "log", "ConnectionState", "DeviceKind", "Platform", "isNode", "localForage", "log", "OBSERVABILITY_DISABLED_KEY", "OBSERVABILITY_GROUP_KEY", "isObservabilityDisabled", "namespace", "getItem", "err", "catch", "storeObservabilityDisabled", "value", "setItem", "String", "getObservabilityGroup", "undefined", "storeObservabilityGroup", "initializeAppObservability", "config", "mode", "tracingEnable", "replayEnable", "group", "release", "get", "environment", "observabilityDisabled", "Observability", "observability", "errorLog", "sentryInitOptions", "tracing", "replay", "sampleRate", "replaySampleRate", "replaySampleRateOnError", "setMode", "info", "getIPData", "IP_DATA_CACHE_TIMEOUT", "cachedData", "timestamp", "Date", "now", "data", "IPDATA_API_KEY", "fetch", "then", "res", "json", "captureException", "initialize", "ipData", "addIPDataTelemetryTags", "navigator", "storage", "estimate", "setInterval", "storageEstimate", "usage", "setTag", "toString", "quota", "error", "warn", "getTelemetryIdentifier", "client", "initialized", "undefined", "identity", "halo", "get", "identityKey", "truncate", "yaml", "existsSync", "statSync", "mkdir", "readFile", "writeFile", "join", "v4", "uuid", "validate", "validateUuid", "log", "showObservabilityBanner", "configDir", "bannercb", "path", "join", "existsSync", "writeFile", "getObservabilityState", "statSync", "isDirectory", "Error", "mkdir", "recursive", "idPath", "context", "readFile", "validate", "initializeState", "observabilityState", "installationId", "uuid", "group", "process", "env", "DX_OBSERVABILITY_GROUP", "undefined", "mode", "DX_DISABLE_OBSERVABILITY", "DX_OBSERVABILITY_MODE", "yaml", "dump", "contextString", "load", "Boolean", "validateUuid", "initializeNodeObservability", "namespace", "config", "tracingEnable", "replayEnable", "log", "release", "get", "environment", "observability", "Observability", "errorLog", "sentryInitOptions", "sampleRate", "logProcessor", "setTag", "IPDATA_API_KEY", "res", "fetch", "ipData", "json", "addIPDataTelemetryTags", "err", "captureException", "mapSpaces", "spaces", "options", "verbose", "truncateKeys", "map", "space", "open", "ready", "internal", "data", "metrics", "startup", "getTime", "pipeline", "startDataMutations", "currentEpoch", "subject", "assertion", "timeframe", "totalMessages", "epoch", "number", "currentDataMutations", "currentDataTimeframe", "totalDataMutations", "targetDataTimeframe", "key", "truncate", "isOpen", "members", "get", "length", "objects", "db", "query", "progress", "Math", "min", "abs", "toFixed", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Event, scheduleTaskInterval } from '@dxos/async';\nimport { type Client, type Config } from '@dxos/client';\nimport { type Space } from '@dxos/client-protocol';\nimport { Context } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { ConnectionState } from '@dxos/network-manager';\nimport { DeviceKind, type NetworkStatus, Platform } from '@dxos/protocols/proto/dxos/client/services';\nimport { isNode } from '@dxos/util';\n\nimport buildSecrets from './cli-observability-secrets.json';\nimport { DatadogMetrics } from './datadog';\nimport { type IPData, getTelemetryIdentifier, mapSpaces } from './helpers';\nimport { SegmentTelemetry, type EventOptions, type PageOptions } from './segment';\nimport {\n captureException as sentryCaptureException,\n enableSentryLogProcessor,\n configureTracing as sentryConfigureTracing,\n init as sentryInit,\n type InitOptions,\n setTag as sentrySetTag,\n} from './sentry';\n\nconst SPACE_METRICS_MIN_INTERVAL = 1000 * 60;\n// const DATADOG_IDLE_INTERVAL = 1000 * 60 * 5;\nconst DATADOG_IDLE_INTERVAL = 1000 * 60 * 1;\n\n// Secrets? EnvironmentConfig?\n\nexport type ObservabilitySecrets = {\n DX_ENVIRONMENT: string | null;\n DX_RELEASE: string | null;\n SENTRY_DESTINATION: string | null;\n TELEMETRY_API_KEY: string | null;\n IPDATA_API_KEY: string | null;\n DATADOG_API_KEY: string | null;\n DATADOG_APP_KEY: string | null;\n};\n\nexport type Mode = 'basic' | 'full' | 'disabled';\nexport type TagScope = 'errors' | 'telemetry' | 'metrics' | 'all';\n\nexport type ObservabilityOptions = {\n /// The webapp (e.g. 'composer.dxos.org'), 'cli', or 'agent'.\n namespace: string;\n // TODO(nf): make platform a required extension?\n // platform: Platform;\n config?: Config;\n secrets?: Record<string, string>;\n group?: string;\n mode?: Mode;\n\n telemetry?: {\n batchSize?: number;\n };\n\n errorLog?: {\n sentryInitOptions?: InitOptions;\n logProcessor?: boolean;\n };\n};\n\n/*\n * Observability provides a common interface for error logging, metrics, and telemetry.\n * It currently provides these capabilities using Sentry, Datadog, and Segment.\n */\nexport class Observability {\n // TODO(wittjosiah): Generic metrics interface.\n private _metrics?: DatadogMetrics;\n // TODO(wittjosiah): Generic telemetry interface.\n private _telemetryBatchSize: number;\n private _telemetry?: SegmentTelemetry;\n // TODO(wittjosiah): Generic error logging interface.\n private _errorReportingOptions?: InitOptions;\n private _errorLogProcessor: boolean;\n\n private _secrets: ObservabilitySecrets;\n private _namespace: string;\n private _config?: Config;\n private _mode: Mode = 'disabled';\n private _group?: string;\n // TODO(nf): accept upstream context?\n private _ctx = new Context();\n private _tags = new Map<string, { value: string; scope: TagScope }>();\n\n // TODO(nf): make platform a required extension?\n constructor({ namespace, config, secrets, group, mode, telemetry, errorLog }: ObservabilityOptions) {\n this._namespace = namespace;\n this._config = config;\n this._mode = mode ?? 'disabled';\n this._group = group;\n this._secrets = this._loadSecrets(config, secrets);\n this._telemetryBatchSize = telemetry?.batchSize ?? 30;\n this._errorReportingOptions = errorLog?.sentryInitOptions;\n this._errorLogProcessor = errorLog?.logProcessor ?? false;\n\n if (this._group) {\n this.setTag('group', this._group);\n }\n this.setTag('namespace', this._namespace);\n\n if (this._mode === 'full') {\n // TODO(nf): set group and hostname?\n }\n }\n\n private _loadSecrets(config: Config | undefined, secrets?: Record<string, string>) {\n if (isNode()) {\n const mergedSecrets = {\n ...(buildSecrets as ObservabilitySecrets),\n ...secrets,\n };\n\n process.env.DX_ENVIRONMENT && (mergedSecrets.DX_ENVIRONMENT = process.env.DX_ENVIRONMENT);\n process.env.DX_RELEASE && (mergedSecrets.DX_RELEASE = process.env.DX_RELEASE);\n process.env.SENTRY_DESTINATION && (mergedSecrets.SENTRY_DESTINATION = process.env.SENTRY_DESTINATION);\n process.env.TELEMETRY_API_KEY && (mergedSecrets.TELEMETRY_API_KEY = process.env.TELEMETRY_API_KEY);\n process.env.IPDATA_API_KEY && (mergedSecrets.IPDATA_API_KEY = process.env.IPDATA_API_KEY);\n process.env.DATADOG_API_KEY && (mergedSecrets.DATADOG_API_KEY = process.env.DATADOG_API_KEY);\n process.env.DATADOG_APP_KEY && (mergedSecrets.DATADOG_APP_KEY = process.env.DATADOG_APP_KEY);\n\n return mergedSecrets;\n } else {\n log('config', { rtc: this._secrets, config });\n return {\n DX_ENVIRONMENT: config?.get('runtime.app.env.DX_ENVIRONMENT'),\n DX_RELEASE: config?.get('runtime.app.env.DX_RELEASE'),\n SENTRY_DESTINATION: config?.get('runtime.app.env.DX_SENTRY_DESTINATION'),\n TELEMETRY_API_KEY: config?.get('runtime.app.env.DX_TELEMETRY_API_KEY'),\n IPDATA_API_KEY: config?.get('runtime.app.env.DX_IPDATA_API_KEY'),\n DATADOG_API_KEY: config?.get('runtime.app.env.DX_DATADOG_API_KEY'),\n DATADOG_APP_KEY: config?.get('runtime.app.env.DX_DATADOG_APP_KEY'),\n ...secrets,\n };\n }\n }\n\n initialize() {\n this._initMetrics();\n this._initTelemetry();\n this._initErrorLogs();\n }\n\n async close() {\n await this._ctx.dispose();\n\n // TODO(wittjosiah): Remove telemetry, etc. scripts.\n }\n\n setMode(mode: Mode) {\n this._mode = mode;\n }\n\n get mode() {\n return this._mode;\n }\n\n get group() {\n return this._group;\n }\n\n get enabled() {\n return this._mode !== 'disabled';\n }\n\n //\n // Tags\n //\n\n setTag(key: string, value: string, scope?: TagScope) {\n if (this.enabled && (scope === undefined || scope === 'all' || scope === 'errors')) {\n sentrySetTag(key, value);\n }\n if (!scope) {\n scope = 'all';\n }\n this._tags.set(key, { value, scope });\n }\n\n getTag(key: string) {\n return this._tags.get(key);\n }\n\n addIPDataTelemetryTags = (ipData: IPData) => {\n this.setTag('city', ipData.city, 'telemetry');\n this.setTag('region', ipData.region, 'telemetry');\n this.setTag('country', ipData.country, 'telemetry');\n ipData.latitude && this.setTag('latitude', ipData.latitude.toString(), 'telemetry');\n ipData.longitude && this.setTag('longitude', ipData.longitude.toString(), 'telemetry');\n };\n\n // TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.\n async setIdentityTags(client: Client) {\n client.services.services.IdentityService!.queryIdentity().subscribe((idqr) => {\n if (!idqr?.identity?.identityKey) {\n log('empty response from identity service', { idqr });\n return;\n }\n\n this.setTag('identityKey', idqr.identity.identityKey.truncate());\n });\n\n client.services.services.DevicesService!.queryDevices().subscribe((dqr) => {\n if (!dqr || !dqr.devices || dqr.devices.length === 0) {\n log('empty response from device service', { device: dqr });\n return;\n }\n invariant(dqr, 'empty response from device service');\n\n const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);\n if (!thisDevice) {\n log('no current device', { device: dqr });\n return;\n }\n this.setTag('deviceKey', thisDevice.deviceKey.truncate());\n if (thisDevice.profile?.label) {\n this.setTag('deviceProfile', thisDevice.profile.label);\n }\n });\n }\n\n //\n // Metrics\n //\n\n private _initMetrics() {\n if (this.enabled && this._secrets.DATADOG_API_KEY) {\n this._metrics = new DatadogMetrics({\n apiKey: this._secrets.DATADOG_API_KEY,\n getTags: () =>\n Object.fromEntries(\n Array.from(this._tags)\n .filter(([key, value]) => {\n return value.scope === 'all' || value.scope === 'metrics';\n })\n .map(([key, value]) => [key, value.value]),\n ),\n // TODO(nf): move/refactor from telementryContext, needed to read CORS proxy\n config: this._config!,\n });\n } else {\n log('datadog disabled');\n }\n }\n\n /**\n * Gauge metric.\n *\n * The default implementation uses Datadog.\n */\n gauge(name: string, value: number | any, extraTags?: any) {\n this._metrics?.gauge(name, value, extraTags);\n }\n\n // TODO(nf): Refactor into ObservabilityExtensions.\n\n startNetworkMetrics(client: Client) {\n const updateSignalMetrics = new Event<NetworkStatus>();\n\n // const lcsh = (csp as LocalClientServices).host;\n updateSignalMetrics.on(this._ctx, async (networkStatus) => {\n log('send signal metrics');\n (networkStatus.signaling as NetworkStatus.Signal[]).forEach(({ server, state }) => {\n this.gauge('dxos.client.network.signal.connectionState', state, { server });\n });\n\n let swarmCount = 0;\n const connectionStates = new Map<string, number>();\n for (const state in ConnectionState) {\n connectionStates.set(state, 0);\n }\n\n let totalReadBufferSize = 0;\n let totalWriteBufferSize = 0;\n let totalChannelBufferSize = 0;\n\n networkStatus.connectionInfo?.forEach((connectionInfo) => {\n swarmCount++;\n\n for (const conn of connectionInfo.connections ?? []) {\n connectionStates.set(conn.state, (connectionStates.get(conn.state) ?? 0) + 1);\n totalReadBufferSize += conn.readBufferSize ?? 0;\n totalWriteBufferSize += conn.writeBufferSize ?? 0;\n\n for (const stream of conn.streams ?? []) {\n totalChannelBufferSize += stream.writeBufferSize ?? 0;\n }\n }\n\n this.gauge('dxos.client.network.swarm.count', swarmCount);\n for (const state in ConnectionState) {\n this.gauge('dxos.client.network.connection.count', connectionStates.get(state) ?? 0, { state });\n }\n this.gauge('dxox.client.network.totalReadBufferSize', totalReadBufferSize);\n this.gauge('dxos.client.network.totalWriteBufferSize', totalWriteBufferSize);\n this.gauge('dxos.client.network.totalChannelBufferSize', totalChannelBufferSize);\n });\n });\n\n client.services.services.NetworkService?.queryStatus().subscribe((networkStatus) => {\n updateSignalMetrics.emit(networkStatus);\n });\n\n // scheduleTaskInterval(ctx, async () => updateSignalMetrics.emit(), DATADOG_IDLE_INTERVAL);\n }\n\n startSpacesMetrics(client: Client, namespace: string) {\n const spaces = client.spaces.get();\n const subscriptions = new Map<string, { unsubscribe: () => void }>();\n this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));\n\n const updateSpaceMetrics = new Event<Space>().debounce(SPACE_METRICS_MIN_INTERVAL);\n updateSpaceMetrics.on(this._ctx, async () => {\n log('send space update');\n for (const data of mapSpaces(spaces, { truncateKeys: true })) {\n // Metrics\n this.gauge('dxos.client.space.members', data.members, { key: data.key });\n this.gauge('dxos.client.space.objects', data.objects, { key: data.key });\n this.gauge('dxos.client.space.epoch', data.epoch, { key: data.key });\n this.gauge('dxos.client.space.currentDataMutations', data.currentDataMutations, { key: data.key });\n\n // Telemetry\n this.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.space.update`,\n properties: data,\n });\n }\n });\n\n const subscribeToSpaceUpdate = (space: Space) =>\n space.pipeline.subscribe({\n next: () => {\n updateSpaceMetrics.emit();\n },\n });\n\n spaces.forEach((space) => {\n subscriptions.set(space.key.toHex(), subscribeToSpaceUpdate(space));\n });\n\n client.spaces.subscribe({\n next: async (spaces) => {\n spaces\n .filter((space) => !subscriptions.has(space.key.toHex()))\n .forEach((space) => {\n subscriptions.set(space.key.toHex(), subscribeToSpaceUpdate(space));\n });\n },\n });\n\n scheduleTaskInterval(this._ctx, async () => updateSpaceMetrics.emit(), DATADOG_IDLE_INTERVAL);\n }\n\n async startRuntimeMetrics(client: Client, frequency: number = DATADOG_IDLE_INTERVAL) {\n const platform = await client.services.services.SystemService?.getPlatform();\n invariant(platform, 'platform is required');\n\n this.setTag('platform_type', Platform.PLATFORM_TYPE[platform.type as number].toLowerCase());\n if (this._mode === 'full') {\n // platform[foo] does not work?\n if (platform.platform) {\n this.setTag('platform', platform.platform);\n }\n if (platform.arch) {\n this.setTag('arch', platform.arch);\n }\n if (platform.runtime) {\n this.setTag('runtime', platform.runtime);\n }\n }\n scheduleTaskInterval(\n this._ctx,\n async () => {\n log('platform');\n client.services.services.SystemService?.getPlatform()\n .then((platform) => {\n log('platform', { platform });\n if (platform.memory) {\n this.gauge('dxos.client.runtime.rss', platform.memory.rss);\n this.gauge('dxos.client.runtime.heapTotal', platform.memory.heapTotal);\n this.gauge('dxos.client.runtime.heapUsed', platform.memory.heapUsed);\n }\n })\n .catch((error) => log('platform error', { error }));\n },\n frequency,\n );\n }\n\n //\n // Telemetry\n //\n\n private _initTelemetry() {\n if (this._secrets.TELEMETRY_API_KEY && this._mode !== 'disabled') {\n this._telemetry = new SegmentTelemetry({\n apiKey: this._secrets.TELEMETRY_API_KEY,\n batchSize: this._telemetryBatchSize,\n getTags: () =>\n Object.fromEntries(\n Array.from(this._tags)\n .filter(([key, value]) => {\n return value.scope === 'all' || value.scope === 'telemetry';\n })\n .map(([key, value]) => [key, value.value]),\n ),\n });\n } else {\n log('segment disabled');\n }\n }\n\n /**\n * A telemetry event.\n *\n * The default implementation uses Segment.\n */\n event(options: EventOptions) {\n this._telemetry?.event(options);\n }\n\n /**\n * A telemetry page view.\n *\n * The default implementation uses Segment.\n */\n page(options: PageOptions) {\n this._telemetry?.page(options);\n }\n\n //\n // Error Logs\n //\n\n private _initErrorLogs() {\n if (this._secrets.SENTRY_DESTINATION && this._mode !== 'disabled') {\n // TODO(nf): refactor package into this one?\n log.info('Initializing Sentry', {\n dest: this._secrets.SENTRY_DESTINATION,\n options: this._errorReportingOptions,\n });\n sentryInit({\n ...this._errorReportingOptions,\n destination: this._secrets.SENTRY_DESTINATION,\n scrubFilenames: this._mode !== 'full',\n });\n if (this._errorReportingOptions?.tracing) {\n sentryConfigureTracing();\n }\n // TODO(nf): set platform at instantiation? needed for node.\n if (this._errorLogProcessor) {\n enableSentryLogProcessor();\n }\n // TODO(nf): is this different than passing as properties in options?\n this._tags.forEach((v, k) => {\n if (v.scope === 'all' || v.scope === 'errors') {\n sentrySetTag(k, v.value);\n }\n });\n } else {\n log('sentry disabled');\n }\n }\n\n /**\n * Manually capture an exception.\n *\n * The default implementation uses Sentry.\n */\n captureException(err: any) {\n if (this.enabled) {\n sentryCaptureException(err);\n }\n }\n}\n", "{\n \"SENTRY_DESTINATION\": \"https://2647916221e643869965e78469479aa4@o4504012000067584.ingest.sentry.io/4504012027265029\",\n \"TELEMETRY_API_KEY\": \"B00QG6PtJJrJ0VVFe0H5a6bcUUShKyZM\",\n \"IPDATA_API_KEY\": \"73dfdecdf979c18f07d50cf841bbdd9e589f237256326ac8cca23786\",\n \"DATADOG_API_KEY\": null,\n \"DATADOG_APP_KEY\": null\n}", "//\n// Copyright 2022 DXOS.org\n//\n\n// NOTE: localStorage is not available in web workers.\nimport * as localForage from 'localforage';\n\n// import { type Platform } from '@dxos/client-services';\n// import { type InitOptions as TelemetryInitOptions } from '@dxos/telemetry';\n\nimport type { Config } from '@dxos/client';\nimport { log } from '@dxos/log';\n\nimport type { IPData } from './common';\nimport type { Mode, Observability } from '../observability';\n\nexport const OBSERVABILITY_DISABLED_KEY = 'observability-disabled';\nexport const OBSERVABILITY_GROUP_KEY = 'observability-group';\n\nexport const isObservabilityDisabled = async (namespace: string): Promise<boolean> => {\n try {\n return (await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`)) === 'true';\n } catch (err) {\n log.catch('Failed to check if observability is disabled, assuming it is', err);\n return true;\n }\n};\n\nexport const storeObservabilityDisabled = async (namespace: string, value: boolean) => {\n try {\n await localForage.setItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`, String(value));\n } catch (err) {\n log.catch('Failed to store observability disabled', err);\n }\n};\n\nexport const getObservabilityGroup = async (namespace: string): Promise<string | undefined> => {\n try {\n return (await localForage.getItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`)) ?? undefined;\n } catch (err) {\n log.catch('Failed to get observability group', err);\n }\n};\n\nexport const storeObservabilityGroup = async (namespace: string, value: string) => {\n try {\n await localForage.setItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`, value);\n } catch (err) {\n log.catch('Failed to store observability group', err);\n }\n};\n\nexport type AppObservabilityOptions = {\n namespace: string;\n config: Config;\n mode?: Mode;\n tracingEnable?: boolean;\n replayEnable?: boolean;\n // TODO(nf): options for providers?\n};\n\n// TODO(wittjosiah): Store preference for disabling observability.\n// At minimum should be stored locally (i.e., localstorage), possibly in halo preference.\n// Needs to be hooked up to settings page for user visibility.\nexport const initializeAppObservability = async ({\n namespace,\n config,\n mode = 'basic',\n tracingEnable = true,\n replayEnable = true,\n}: AppObservabilityOptions): Promise<Observability> => {\n log('initializeAppObservability', { config });\n\n /*\n const platform = (await client.services.services.SystemService?.getPlatform()) as Platform;\n if (!platform) {\n log.error('failed to get platform, could not initialize observability');\n return undefined;\n }\n */\n\n const group = (await getObservabilityGroup(namespace)) ?? undefined;\n const release = `${namespace}@${config.get('runtime.app.build.version')}`;\n const environment = config.get('runtime.app.env.DX_ENVIRONMENT');\n\n const observabilityDisabled = await isObservabilityDisabled(namespace);\n\n const { Observability } = await import('../observability');\n\n // TODO(nf): configure mode\n const observability = new Observability({\n namespace,\n group,\n mode,\n config,\n errorLog: {\n sentryInitOptions: {\n environment,\n release,\n tracing: tracingEnable,\n replay: replayEnable,\n // TODO(wittjosiah): Configure these.\n sampleRate: 1.0,\n replaySampleRate: 0.1,\n replaySampleRateOnError: 1.0,\n },\n },\n });\n\n // global kill switch\n if (observabilityDisabled) {\n observability.setMode('disabled');\n log.info('observability disabled');\n return observability;\n }\n\n try {\n const getIPData = async (config: Config): Promise<IPData | void> => {\n const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1000; // 6 hours\n type CachedIPData = {\n data: IPData;\n timestamp: number;\n };\n\n // Check cache first.\n const cachedData: null | CachedIPData = await localForage.getItem('dxos:observability:ipdata');\n if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {\n return cachedData.data;\n }\n\n // Fetch data if not cached.\n const IPDATA_API_KEY = config.get('runtime.app.env.DX_IPDATA_API_KEY');\n if (IPDATA_API_KEY) {\n return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`)\n .then((res) => res.json())\n .then((data) => {\n // Cache data.\n localForage\n .setItem('dxos:observability:ipdata', {\n data,\n timestamp: Date.now(),\n })\n .catch((err) => observability.captureException(err));\n\n return data;\n })\n .catch((err) => observability.captureException(err));\n }\n };\n\n // TODO(nf): plugin state?\n\n // TODO(nf): should provide capability to init Sentry earlier in booting process to capture errors during initialization.\n\n observability.initialize();\n\n const ipData = await getIPData(config);\n\n ipData && observability.addIPDataTelemetryTags(ipData);\n\n if (typeof navigator !== 'undefined' && navigator.storage?.estimate) {\n setInterval(async () => {\n try {\n const storageEstimate = await navigator.storage.estimate();\n storageEstimate.usage && observability.setTag('storageUsage', storageEstimate.usage.toString(), 'telemetry');\n storageEstimate.quota && observability.setTag('storageQuota', storageEstimate.quota.toString(), 'telemetry');\n } catch (error) {\n log.warn('Failed to run estimate()', error);\n }\n }, 10e3);\n }\n } catch (err: any) {\n log.error('Failed to initialize app observability', err);\n }\n\n return observability;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport type { Client } from '@dxos/client';\n\n// TODO(wittjosiah): Improve privacy of telemetry identifiers.\n// - Identifier should be generated client-side with no attachment to identity.\n// - Identifier can then be reset by user.\n// - Identifier can be synced via HALO to allow for correlation of events bewteen devices.\n// - Identifier should also be stored outside of HALO such that it is available immediately on startup.\nexport const getTelemetryIdentifier = (client: Client) => {\n if (!client?.initialized) {\n return undefined;\n }\n\n const identity = client.halo.identity.get();\n if (identity) {\n return identity.identityKey.truncate();\n }\n\n return undefined;\n};\n\nexport type IPData = { city: string; region: string; country: string; latitude: number; longitude: number };\n", "//\n// Copyright 2022 DXOS.org\n//\nimport yaml from 'js-yaml';\nimport { existsSync, statSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { v4 as uuid, validate as validateUuid } from 'uuid';\n\nimport type { Config } from '@dxos/client';\nimport { log } from '@dxos/log';\n\nimport { Observability, type Mode } from '../observability';\n\n/**\n * Print observability banner once per installation.\n */\nexport const showObservabilityBanner = async (configDir: string, bannercb: (input: string) => void) => {\n const path = join(configDir, '.observability-banner-printed');\n if (existsSync(path)) {\n return;\n }\n bannercb(\n // eslint-disable-next-line no-multi-str\n 'Basic observability data will be sent to the DXOS team in order to improve the product. This includes \\\n performance metrics, error logs, and usage data. No personally identifiable information, other than your \\\n public key, is included with this data and no private data ever leaves your devices. To disable sending \\\n observability data, set the environment variable DX_DISABLE_OBSERVABILITY=true.',\n );\n\n await writeFile(path, '', 'utf-8');\n};\n\nexport const getObservabilityState = async (configDir: string): Promise<PersistentObservabilityState> => {\n // check whether configDir exists and if it's a directory\n\n if (existsSync(configDir)) {\n if (!statSync(configDir).isDirectory()) {\n throw new Error(`Config directory ${configDir} exists but is not a directory`);\n }\n } else {\n await mkdir(configDir, { recursive: true });\n }\n\n const idPath = join(configDir, 'observability.yml');\n if (existsSync(idPath)) {\n const context = await readFile(idPath, 'utf-8');\n return validate(context) ?? initializeState(idPath);\n }\n\n return initializeState(idPath);\n};\n\nexport type TelemetryContext = {\n mode: Mode;\n installationId?: string;\n group?: string;\n timezone: string;\n runtime: string;\n os: string;\n arch: string;\n ci: boolean;\n [key: string]: any;\n};\n\nexport type PersistentObservabilityState = {\n installationId: string;\n group?: string;\n mode: Mode;\n};\n\n// create initial state and write to file, using environment variables to override defaults.\nconst initializeState = async (idPath: string): Promise<PersistentObservabilityState> => {\n // TODO(nf): read initial values from config or seed file\n const observabilityState = {\n installationId: uuid(),\n group: process.env.DX_OBSERVABILITY_GROUP ?? undefined,\n mode: (process.env.DX_DISABLE_OBSERVABILITY ? 'disabled' : process.env.DX_OBSERVABILITY_MODE ?? 'basic') as Mode,\n };\n\n await writeFile(\n idPath,\n '# This file is automatically generated by the @dxos/cli.\\n' + yaml.dump(observabilityState),\n 'utf-8',\n );\n\n return observabilityState;\n};\n\nconst validate = (contextString: string) => {\n const context = yaml.load(contextString) as PersistentObservabilityState;\n if (Boolean(context.installationId) && validateUuid(context.installationId!)) {\n return {\n ...context,\n mode: process.env.DX_DISABLE_OBSERVABILITY ? 'disabled' : context.mode ?? 'basic',\n };\n }\n};\n\nexport type NodeObservabilityOptions = {\n installationId: string;\n group?: string;\n namespace: string;\n config: Config;\n mode?: Mode;\n tracingEnable?: boolean;\n replayEnable?: boolean;\n // TODO(nf): options for providers?\n};\n\nexport const initializeNodeObservability = async ({\n namespace,\n config,\n installationId,\n group,\n mode = 'basic',\n tracingEnable = true,\n replayEnable = true,\n}: NodeObservabilityOptions): Promise<Observability> => {\n log('initializeCliObservability', { config });\n\n const release = `${namespace}@${config.get('runtime.app.build.version')}`;\n const environment = config.get('runtime.app.env.DX_ENVIRONMENT');\n\n const observability = new Observability({\n namespace,\n group,\n mode,\n errorLog: {\n sentryInitOptions: {\n environment,\n release,\n // TODO(wittjosiah): Configure this.\n sampleRate: 1.0,\n },\n logProcessor: true,\n },\n });\n\n observability.setTag('installationId', installationId);\n\n const IPDATA_API_KEY = config.get('runtime.app.env.DX_IPDATA_API_KEY');\n try {\n const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);\n const ipData = await res.json();\n ipData && observability.addIPDataTelemetryTags(ipData);\n } catch (err) {\n observability?.captureException(err);\n }\n return observability;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Space } from '@dxos/client-protocol';\n\nexport type MapSpacesOptions = {\n verbose?: boolean;\n truncateKeys?: boolean;\n};\n\nexport const mapSpaces = (spaces: Space[], options: MapSpacesOptions = { verbose: false, truncateKeys: false }) => {\n return spaces.map((space) => {\n // TODO(burdon): Factor out.\n // TODO(burdon): Agent needs to restart before `ready` is available.\n const { open, ready } = space.internal.data.metrics ?? {};\n const startup = open && ready && ready.getTime() - open.getTime();\n\n // TODO(burdon): Get feeds from client-services if verbose (factor out from devtools/diagnostics).\n // const host = client.services.services.DevtoolsHost!;\n const pipeline = space.internal.data.pipeline;\n const startDataMutations = pipeline?.currentEpoch?.subject.assertion.timeframe.totalMessages() ?? 0;\n const epoch = pipeline?.currentEpoch?.subject.assertion.number;\n // const appliedEpoch = pipeline?.appliedEpoch?.subject.assertion.number;\n const currentDataMutations = pipeline?.currentDataTimeframe?.totalMessages() ?? 0;\n const totalDataMutations = pipeline?.targetDataTimeframe?.totalMessages() ?? 0;\n\n return {\n // TODO(nf): truncate keys for DD?\n key: space.key.truncate(),\n open: space.isOpen,\n members: space.members.get().length,\n objects: space.db.query().objects.length,\n startup,\n epoch,\n // appliedEpoch,\n startDataMutations,\n currentDataMutations,\n totalDataMutations,\n\n // TODO(burdon): Negative?\n progress: (\n Math.min(Math.abs((currentDataMutations - startDataMutations) / (totalDataMutations - startDataMutations)), 1) *\n 100\n ).toFixed(0),\n };\n });\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport type { Client } from '@dxos/client';\n\nimport { getTelemetryIdentifier } from './common';\nimport type { Observability } from '../observability';\n\nlet lastFocusEvent = new Date();\nlet totalTime = 0;\n\nexport const setupTelemetryListeners = (namespace: string, client: Client, observability: Observability) => {\n const clickCallback = (event: any) => {\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.click`,\n properties: {\n href: window.location.href,\n id: (event.target as HTMLElement)?.id,\n path: (event.path as HTMLElement[])\n ?.filter((el) => Boolean(el.tagName))\n .map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ''}`)\n .reverse()\n .join('>'),\n },\n }),\n );\n };\n\n const focusCallback = () => {\n const now = new Date();\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.focus`,\n properties: {\n href: window.location.href,\n timeAway: now.getTime() - lastFocusEvent.getTime(),\n },\n }),\n );\n lastFocusEvent = now;\n };\n\n const blurCallback = () => {\n const now = new Date();\n const timeSpent = now.getTime() - lastFocusEvent.getTime();\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.blur`,\n properties: {\n href: window.location.href,\n timeSpent,\n },\n }),\n );\n lastFocusEvent = now;\n totalTime = totalTime + timeSpent;\n };\n\n const unloadCallback = () => {\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.page.unload`,\n properties: {\n href: window.location.href,\n timeSpent: totalTime,\n },\n }),\n );\n };\n\n const errorCallback = (event: ErrorEvent) => {\n setTimeout(() =>\n observability.event({\n identityId: getTelemetryIdentifier(client),\n name: `${namespace}.window.error`,\n properties: {\n href: window.location.href,\n message: event.message,\n filename: event.filename,\n stack: (event.error as Error).stack,\n },\n }),\n );\n };\n\n window.addEventListener('click', clickCallback, true);\n window.addEventListener('focus', focusCallback);\n window.addEventListener('blur', blurCallback);\n window.addEventListener('beforeunload', unloadCallback);\n window.addEventListener('error', errorCallback);\n\n return () => {\n window.removeEventListener('click', clickCallback, true);\n window.removeEventListener('focus', focusCallback);\n window.removeEventListener('blur', blurCallback);\n window.removeEventListener('beforeunload', unloadCallback);\n window.removeEventListener('error', errorCallback);\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAIA,SAASA,OAAOC,4BAA4B;AAG5C,SAASC,eAAe;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AoB;AAC3BsJ,iCAAAA;MACF;AAEA,WAAK1K,MAAMgG,QAAQ,CAAC2E,GAAGC,MAAAA;AACrB,YAAID,EAAE5H,UAAU,SAAS4H,EAAE5H,UAAU,UAAU;AAC7CE,iBAAa2H,GAAGD,EAAE7H,KAAK;QACzB;MACF,CAAA;IACF,OAAO;AACLZ,MAAAA,KAAI,mBAAA,QAAA;;;;;;IACN;EACF;;;;;;EAOA2I,iBAAiBC,KAAU;AACzB,QAAI,KAAKlI,SAAS;AAChBmI,uBAAuBD,GAAAA;IACzB;EACF;AACF;",
|
|
6
|
+
"names": ["Event", "scheduleTaskInterval", "Context", "invariant", "log", "ConnectionState", "DeviceKind", "Platform", "isNode", "localForage", "log", "OBSERVABILITY_DISABLED_KEY", "OBSERVABILITY_GROUP_KEY", "isObservabilityDisabled", "namespace", "getItem", "err", "catch", "storeObservabilityDisabled", "value", "setItem", "String", "getObservabilityGroup", "undefined", "storeObservabilityGroup", "initializeAppObservability", "config", "mode", "tracingEnable", "replayEnable", "group", "release", "get", "environment", "observabilityDisabled", "Observability", "observability", "errorLog", "sentryInitOptions", "tracing", "replay", "sampleRate", "replaySampleRate", "replaySampleRateOnError", "setMode", "info", "getIPData", "IP_DATA_CACHE_TIMEOUT", "cachedData", "timestamp", "Date", "now", "data", "IPDATA_API_KEY", "fetch", "then", "res", "json", "captureException", "initialize", "ipData", "addIPDataTelemetryTags", "navigator", "storage", "estimate", "setInterval", "storageEstimate", "usage", "setTag", "toString", "quota", "error", "warn", "getTelemetryIdentifier", "client", "initialized", "undefined", "identity", "halo", "get", "identityKey", "truncate", "yaml", "existsSync", "statSync", "mkdir", "readFile", "writeFile", "join", "v4", "uuid", "validate", "validateUuid", "log", "showObservabilityBanner", "configDir", "bannercb", "path", "join", "existsSync", "writeFile", "getObservabilityState", "statSync", "isDirectory", "Error", "mkdir", "recursive", "idPath", "context", "readFile", "validate", "initializeState", "observabilityState", "installationId", "uuid", "group", "process", "env", "DX_OBSERVABILITY_GROUP", "undefined", "mode", "DX_DISABLE_OBSERVABILITY", "DX_OBSERVABILITY_MODE", "yaml", "dump", "contextString", "load", "Boolean", "validateUuid", "initializeNodeObservability", "namespace", "config", "tracingEnable", "replayEnable", "log", "release", "get", "environment", "observability", "Observability", "errorLog", "sentryInitOptions", "sampleRate", "logProcessor", "setTag", "IPDATA_API_KEY", "res", "fetch", "ipData", "json", "addIPDataTelemetryTags", "err", "captureException", "mapSpaces", "spaces", "options", "verbose", "truncateKeys", "map", "space", "open", "ready", "internal", "data", "metrics", "startup", "getTime", "pipeline", "startDataMutations", "currentEpoch", "subject", "assertion", "timeframe", "totalMessages", "epoch", "number", "currentDataMutations", "currentDataTimeframe", "totalDataMutations", "targetDataTimeframe", "key", "truncate", "isOpen", "members", "get", "length", "objects", "db", "query", "progress", "Math", "min", "abs", "toFixed", "lastFocusEvent", "Date", "totalTime", "setupTelemetryListeners", "namespace", "client", "observability", "clickCallback", "event", "setTimeout", "identityId", "getTelemetryIdentifier", "name", "properties", "href", "window", "location", "id", "target", "path", "filter", "el", "Boolean", "tagName", "map", "toLowerCase", "reverse", "join", "focusCallback", "now", "timeAway", "getTime", "blurCallback", "timeSpent", "unloadCallback", "errorCallback", "message", "filename", "stack", "error", "addEventListener", "removeEventListener", "SPACE_METRICS_MIN_INTERVAL", "DATADOG_IDLE_INTERVAL", "Observability", "constructor", "namespace", "config", "secrets", "group", "mode", "telemetry", "errorLog", "_mode", "_ctx", "Context", "_tags", "Map", "addIPDataTelemetryTags", "ipData", "setTag", "city", "region", "country", "latitude", "toString", "longitude", "_namespace", "_config", "_group", "_secrets", "_loadSecrets", "_telemetryBatchSize", "batchSize", "_errorReportingOptions", "sentryInitOptions", "_errorLogProcessor", "logProcessor", "isNode", "mergedSecrets", "buildSecrets", "process", "env", "DX_ENVIRONMENT", "DX_RELEASE", "SENTRY_DESTINATION", "TELEMETRY_API_KEY", "IPDATA_API_KEY", "DATADOG_API_KEY", "DATADOG_APP_KEY", "log", "rtc", "get", "initialize", "_initMetrics", "_initTelemetry", "_initErrorLogs", "close", "dispose", "setMode", "enabled", "key", "value", "scope", "undefined", "sentrySetTag", "set", "getTag", "setIdentityTags", "client", "services", "IdentityService", "queryIdentity", "subscribe", "idqr", "identity", "identityKey", "truncate", "DevicesService", "queryDevices", "dqr", "devices", "length", "device", "invariant", "thisDevice", "find", "kind", "DeviceKind", "CURRENT", "deviceKey", "profile", "label", "_metrics", "DatadogMetrics", "apiKey", "getTags", "Object", "fromEntries", "Array", "from", "filter", "map", "gauge", "name", "extraTags", "startNetworkMetrics", "updateSignalMetrics", "Event", "on", "networkStatus", "signaling", "forEach", "server", "state", "swarmCount", "connectionStates", "ConnectionState", "totalReadBufferSize", "totalWriteBufferSize", "totalChannelBufferSize", "connectionInfo", "conn", "connections", "readBufferSize", "writeBufferSize", "stream", "streams", "NetworkService", "queryStatus", "emit", "startSpacesMetrics", "spaces", "subscriptions", "onDispose", "subscription", "unsubscribe", "updateSpaceMetrics", "debounce", "data", "mapSpaces", "truncateKeys", "members", "objects", "epoch", "currentDataMutations", "event", "identityId", "getTelemetryIdentifier", "properties", "subscribeToSpaceUpdate", "space", "pipeline", "next", "toHex", "has", "scheduleTaskInterval", "startRuntimeMetrics", "frequency", "platform", "SystemService", "getPlatform", "Platform", "PLATFORM_TYPE", "type", "toLowerCase", "arch", "runtime", "then", "memory", "rss", "heapTotal", "heapUsed", "catch", "error", "_telemetry", "SegmentTelemetry", "options", "page", "info", "dest", "sentryInit", "destination", "scrubFilenames", "tracing", "sentryConfigureTracing", "enableSentryLogProcessor", "v", "k", "captureException", "err", "sentryCaptureException"]
|
|
7
7
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
showObservabilityBanner,
|
|
14
14
|
storeObservabilityDisabled,
|
|
15
15
|
storeObservabilityGroup
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-V6THSHYS.mjs";
|
|
17
17
|
import "./chunk-6ZTMPKEG.mjs";
|
|
18
18
|
import "./chunk-HPGC4HC7.mjs";
|
|
19
19
|
import "./chunk-6KUJPLEH.mjs";
|