@dxos/plugin-observability 0.7.5-main.9d26e3a → 0.7.5-main.9d2a38b
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-UBDF6N5K.mjs → chunk-BAU7OKYM.mjs} +2 -2
- package/dist/lib/browser/{chunk-X6XUBXZQ.mjs → chunk-BWEAT3RG.mjs} +3 -3
- package/dist/lib/{node-esm/chunk-7GGPSKXN.mjs.map → browser/chunk-BWEAT3RG.mjs.map} +3 -3
- package/dist/lib/browser/chunk-H2SQZM4P.mjs +18 -0
- package/dist/lib/browser/chunk-H2SQZM4P.mjs.map +7 -0
- package/dist/lib/browser/chunk-K2Y64RO7.mjs +37 -0
- package/dist/lib/browser/chunk-K2Y64RO7.mjs.map +7 -0
- package/dist/lib/browser/client-ready-3J4QVJE6.mjs +104 -0
- package/dist/lib/browser/client-ready-3J4QVJE6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +73 -206
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intents-resolver-P36HTRAG.mjs +55 -0
- package/dist/lib/browser/intents-resolver-P36HTRAG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-MPOMS7ZD.mjs +26 -0
- package/dist/lib/browser/react-surface-MPOMS7ZD.mjs.map +7 -0
- package/dist/lib/browser/settings-T23OKKWF.mjs +25 -0
- package/dist/lib/browser/settings-T23OKKWF.mjs.map +7 -0
- package/dist/lib/browser/state-FQ6WMLXG.mjs +26 -0
- package/dist/lib/browser/state-FQ6WMLXG.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +2 -2
- package/dist/lib/node/chunk-44EFFE6E.cjs +38 -0
- package/dist/lib/node/chunk-44EFFE6E.cjs.map +7 -0
- package/dist/lib/node/{chunk-HZSRCP4I.cjs → chunk-GSKCHQV5.cjs} +6 -6
- package/dist/lib/node/{chunk-SIUGGDNL.cjs → chunk-HLDDHG6J.cjs} +7 -7
- package/dist/lib/node/chunk-HLDDHG6J.cjs.map +7 -0
- package/dist/lib/node/chunk-UYLJVCUK.cjs +65 -0
- package/dist/lib/node/chunk-UYLJVCUK.cjs.map +7 -0
- package/dist/lib/node/client-ready-UQHLLUQI.cjs +115 -0
- package/dist/lib/node/client-ready-UQHLLUQI.cjs.map +7 -0
- package/dist/lib/node/index.cjs +69 -199
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intents-resolver-E7LSFPS6.cjs +66 -0
- package/dist/lib/node/intents-resolver-E7LSFPS6.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-F77LLZIF.cjs +50 -0
- package/dist/lib/node/react-surface-F77LLZIF.cjs.map +7 -0
- package/dist/lib/node/settings-BUWSSDPF.cjs +39 -0
- package/dist/lib/node/settings-BUWSSDPF.cjs.map +7 -0
- package/dist/lib/node/state-NL2ZZN3S.cjs +40 -0
- package/dist/lib/node/state-NL2ZZN3S.cjs.map +7 -0
- package/dist/lib/node/types.cjs +4 -4
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-52FTHXHB.mjs → chunk-DF2CPSQB.mjs} +2 -2
- package/dist/lib/node-esm/chunk-PZRWMBEG.mjs +38 -0
- package/dist/lib/node-esm/chunk-PZRWMBEG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SCQR7W6A.mjs +19 -0
- package/dist/lib/node-esm/chunk-SCQR7W6A.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7GGPSKXN.mjs → chunk-YK5MJX7W.mjs} +3 -3
- package/dist/lib/{browser/chunk-X6XUBXZQ.mjs.map → node-esm/chunk-YK5MJX7W.mjs.map} +3 -3
- package/dist/lib/node-esm/client-ready-LPGIUDS2.mjs +105 -0
- package/dist/lib/node-esm/client-ready-LPGIUDS2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +73 -206
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intents-resolver-QDAK6TMP.mjs +56 -0
- package/dist/lib/node-esm/intents-resolver-QDAK6TMP.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-MMGCSPXQ.mjs +27 -0
- package/dist/lib/node-esm/react-surface-MMGCSPXQ.mjs.map +7 -0
- package/dist/lib/node-esm/settings-WWUULM4T.mjs +26 -0
- package/dist/lib/node-esm/settings-WWUULM4T.mjs.map +7 -0
- package/dist/lib/node-esm/state-AM2ICAXU.mjs +27 -0
- package/dist/lib/node-esm/state-AM2ICAXU.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +2 -2
- package/dist/types/src/ObservabilityPlugin.d.ts +1 -11
- package/dist/types/src/ObservabilityPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +12 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/client-ready.d.ts +10 -0
- package/dist/types/src/capabilities/client-ready.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +16 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intents-resolver.d.ts +7 -0
- package/dist/types/src/capabilities/intents-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +6 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/components/ObservabilitySettings.d.ts +5 -3
- package/dist/types/src/components/ObservabilitySettings.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +5 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -27
- package/src/ObservabilityPlugin.ts +60 -0
- package/src/capabilities/capabilities.ts +22 -0
- package/src/capabilities/client-ready.ts +99 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intents-resolver.ts +53 -0
- package/src/capabilities/react-surface.tsx +26 -0
- package/src/capabilities/settings.ts +19 -0
- package/src/capabilities/state.ts +21 -0
- package/src/components/ObservabilitySettings.tsx +12 -7
- package/src/events.ts +14 -0
- package/src/index.ts +3 -4
- package/src/meta.ts +1 -1
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/chunk-SIUGGDNL.cjs.map +0 -7
- package/dist/lib/node/meta.cjs +0 -30
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/src/ObservabilityPlugin.tsx +0 -215
- /package/dist/lib/browser/{chunk-UBDF6N5K.mjs.map → chunk-BAU7OKYM.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-HZSRCP4I.cjs.map → chunk-GSKCHQV5.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-52FTHXHB.mjs.map → chunk-DF2CPSQB.mjs.map} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes } from '@dxos/app-framework';
|
|
6
|
+
import { LocalStorageStore } from '@dxos/local-storage';
|
|
7
|
+
import { getObservabilityGroup } from '@dxos/observability';
|
|
8
|
+
|
|
9
|
+
import { ObservabilityCapabilities } from './capabilities';
|
|
10
|
+
import { OBSERVABILITY_PLUGIN } from '../meta';
|
|
11
|
+
|
|
12
|
+
export default async ({ namespace }: { namespace: string }) => {
|
|
13
|
+
const state = new LocalStorageStore<ObservabilityCapabilities.State>(OBSERVABILITY_PLUGIN);
|
|
14
|
+
|
|
15
|
+
state.prop({ key: 'notified', type: LocalStorageStore.bool({ allowUndefined: true }) });
|
|
16
|
+
|
|
17
|
+
// NOTE: This is not stored in local storage such that it can be accessed by workers.
|
|
18
|
+
state.values.group = await getObservabilityGroup(namespace);
|
|
19
|
+
|
|
20
|
+
return contributes(ObservabilityCapabilities.State, state.values, () => state.close());
|
|
21
|
+
};
|
|
@@ -5,19 +5,24 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { S } from '@dxos/echo-schema';
|
|
8
9
|
import { Input, Message, useTranslation } from '@dxos/react-ui';
|
|
9
10
|
import { DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
10
11
|
|
|
11
12
|
import { OBSERVABILITY_PLUGIN } from '../meta';
|
|
12
13
|
import { ObservabilityAction } from '../types';
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export const ObservabilitySettingsSchema = S.mutable(
|
|
16
|
+
S.Struct({
|
|
17
|
+
enabled: S.Boolean,
|
|
18
|
+
// TODO(wittjosiah): Separate settings for each observability feature.
|
|
19
|
+
// metrics?: boolean;
|
|
20
|
+
// telemetry?: boolean;
|
|
21
|
+
// errors?: boolean;
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export type ObservabilitySettingsProps = S.Schema.Type<typeof ObservabilitySettingsSchema>;
|
|
21
26
|
|
|
22
27
|
export const ObservabilitySettings = ({ settings }: { settings: ObservabilitySettingsProps }) => {
|
|
23
28
|
const { t } = useTranslation(OBSERVABILITY_PLUGIN);
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineEvent, Events } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { OBSERVABILITY_PLUGIN } from './meta';
|
|
8
|
+
|
|
9
|
+
export namespace ObservabilityEvents {
|
|
10
|
+
export const StateReady = Events.createStateEvent(OBSERVABILITY_PLUGIN);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// NOTE: This is cloned from the client plugin to avoid circular dependencies.
|
|
14
|
+
export const ClientReadyEvent = defineEvent('dxos.org/plugin/client/event/client-ready');
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
5
|
+
export { ObservabilityCapabilities } from './capabilities';
|
|
6
|
+
export { ObservabilityEvents } from './events';
|
|
7
|
+
export * from './meta';
|
|
9
8
|
export * from './ObservabilityPlugin';
|
package/src/meta.ts
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const OBSERVABILITY_PLUGIN = 'dxos.org/plugin/observability';\n\nexport default {\n id: OBSERVABILITY_PLUGIN,\n name: 'Telemetry',\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,uBAAuB;AAEpC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
|
|
6
|
-
"names": ["OBSERVABILITY_PLUGIN", "id", "name"]
|
|
7
|
-
}
|
package/dist/lib/node/meta.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var meta_exports = {};
|
|
20
|
-
__export(meta_exports, {
|
|
21
|
-
OBSERVABILITY_PLUGIN: () => import_chunk_SIUGGDNL.OBSERVABILITY_PLUGIN,
|
|
22
|
-
default: () => import_chunk_SIUGGDNL.meta_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(meta_exports);
|
|
25
|
-
var import_chunk_SIUGGDNL = require("./chunk-SIUGGDNL.cjs");
|
|
26
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
-
0 && (module.exports = {
|
|
28
|
-
OBSERVABILITY_PLUGIN
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=meta.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["meta.cjs"],
|
|
4
|
-
"sourcesContent": ["import {\n OBSERVABILITY_PLUGIN,\n meta_default\n} from \"./chunk-SIUGGDNL.cjs\";\nexport {\n OBSERVABILITY_PLUGIN,\n meta_default as default\n};\n//# sourceMappingURL=meta.cjs.map\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAGO;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
OBSERVABILITY_PLUGIN,
|
|
4
|
-
meta_default
|
|
5
|
-
} from "./chunk-7GGPSKXN.mjs";
|
|
6
|
-
export {
|
|
7
|
-
OBSERVABILITY_PLUGIN,
|
|
8
|
-
meta_default as default
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=meta.mjs.map
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type Plugin,
|
|
9
|
-
type PluginDefinition,
|
|
10
|
-
type IntentResolverProvides,
|
|
11
|
-
type SettingsProvides,
|
|
12
|
-
type SurfaceProvides,
|
|
13
|
-
type TranslationsProvides,
|
|
14
|
-
resolvePlugin,
|
|
15
|
-
parseIntentPlugin,
|
|
16
|
-
LayoutAction,
|
|
17
|
-
SettingsAction,
|
|
18
|
-
createSurface,
|
|
19
|
-
findPlugin,
|
|
20
|
-
createIntent,
|
|
21
|
-
createResolver,
|
|
22
|
-
} from '@dxos/app-framework';
|
|
23
|
-
import { EventSubscriptions } from '@dxos/async';
|
|
24
|
-
import { invariant } from '@dxos/invariant';
|
|
25
|
-
import { create } from '@dxos/live-object';
|
|
26
|
-
import { LocalStorageStore } from '@dxos/local-storage';
|
|
27
|
-
import {
|
|
28
|
-
type Observability,
|
|
29
|
-
getTelemetryIdentifier,
|
|
30
|
-
setupTelemetryListeners,
|
|
31
|
-
isObservabilityDisabled,
|
|
32
|
-
storeObservabilityDisabled,
|
|
33
|
-
getObservabilityGroup,
|
|
34
|
-
} from '@dxos/observability';
|
|
35
|
-
import { type Client } from '@dxos/react-client';
|
|
36
|
-
|
|
37
|
-
import { ObservabilitySettings, type ObservabilitySettingsProps } from './components';
|
|
38
|
-
import meta, { OBSERVABILITY_PLUGIN } from './meta';
|
|
39
|
-
import translations from './translations';
|
|
40
|
-
import { ObservabilityAction } from './types';
|
|
41
|
-
|
|
42
|
-
export type ObservabilityPluginState = {
|
|
43
|
-
group?: string;
|
|
44
|
-
notified?: boolean;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type ObservabilityPluginProvides = IntentResolverProvides &
|
|
48
|
-
SurfaceProvides &
|
|
49
|
-
SettingsProvides<ObservabilitySettingsProps> &
|
|
50
|
-
TranslationsProvides & {
|
|
51
|
-
observability: ObservabilityPluginState;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const parseObservabilityPlugin = (plugin?: Plugin) =>
|
|
55
|
-
(plugin?.provides as any).observability ? (plugin as Plugin<ObservabilityPluginProvides>) : undefined;
|
|
56
|
-
|
|
57
|
-
export const ObservabilityPlugin = (options: {
|
|
58
|
-
namespace: string;
|
|
59
|
-
observability: () => Promise<Observability>;
|
|
60
|
-
}): PluginDefinition<ObservabilityPluginProvides> => {
|
|
61
|
-
const settings = create<ObservabilitySettingsProps>({});
|
|
62
|
-
const state = new LocalStorageStore<ObservabilityPluginState>(OBSERVABILITY_PLUGIN);
|
|
63
|
-
const subscriptions = new EventSubscriptions();
|
|
64
|
-
let observability: Observability | undefined;
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
meta,
|
|
68
|
-
initialize: async () => {
|
|
69
|
-
settings.enabled = !(await isObservabilityDisabled(options.namespace));
|
|
70
|
-
state.values.group = await getObservabilityGroup(options.namespace);
|
|
71
|
-
state.prop({ key: 'notified', type: LocalStorageStore.bool({ allowUndefined: true }) });
|
|
72
|
-
},
|
|
73
|
-
ready: async ({ plugins }) => {
|
|
74
|
-
const client = findPlugin<{ client: Client }>(plugins, 'dxos.org/plugin/client')?.provides.client;
|
|
75
|
-
const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
|
|
76
|
-
|
|
77
|
-
const dispatch = intentPlugin?.provides?.intent?.dispatchPromise;
|
|
78
|
-
if (!dispatch) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const sendPrivacyNotice = async () => {
|
|
83
|
-
const environment = client?.config?.values.runtime?.app?.env?.DX_ENVIRONMENT;
|
|
84
|
-
const notify =
|
|
85
|
-
environment && environment !== 'ci' && !environment.endsWith('.local') && !environment.endsWith('.lan');
|
|
86
|
-
if (!state.values.notified && notify) {
|
|
87
|
-
await dispatch(
|
|
88
|
-
createIntent(LayoutAction.SetLayout, {
|
|
89
|
-
element: 'toast',
|
|
90
|
-
subject: {
|
|
91
|
-
id: `${OBSERVABILITY_PLUGIN}/notice`,
|
|
92
|
-
// TODO(wittjosiah): Non-react translation utils.
|
|
93
|
-
title: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast label'],
|
|
94
|
-
description: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast description'],
|
|
95
|
-
duration: Infinity,
|
|
96
|
-
icon: 'ph--info--regular',
|
|
97
|
-
actionLabel: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast action label'],
|
|
98
|
-
actionAlt: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast action alt'],
|
|
99
|
-
closeLabel: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast close label'],
|
|
100
|
-
onAction: () => dispatch(createIntent(SettingsAction.Open, { plugin: OBSERVABILITY_PLUGIN })),
|
|
101
|
-
},
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
state.values.notified = true;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// Initialize asynchronously in the background, not in plugin initialization.
|
|
110
|
-
// Should not block application startup.
|
|
111
|
-
void options.observability().then(async (obs) => {
|
|
112
|
-
observability = obs;
|
|
113
|
-
|
|
114
|
-
// Ensure errors are tagged with enabled plugins to help with reproductions.
|
|
115
|
-
plugins.map((plugin) => observability?.setTag(`pluginEnabled-${plugin.meta.id}`, 'true', 'errors'));
|
|
116
|
-
|
|
117
|
-
// Start client observability (i.e. not running as shared worker)
|
|
118
|
-
// TODO(nf): how to prevent multiple instances for single shared worker?
|
|
119
|
-
if (!client) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
await dispatch(
|
|
124
|
-
createIntent(ObservabilityAction.SendEvent, {
|
|
125
|
-
name: 'page.load',
|
|
126
|
-
properties: {
|
|
127
|
-
href: window.location.href,
|
|
128
|
-
// TODO(wittjosiah): These apis are deprecated. Is there a better way to find this information?
|
|
129
|
-
loadDuration: window.performance.timing.loadEventEnd - window.performance.timing.loadEventStart,
|
|
130
|
-
},
|
|
131
|
-
}),
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
setupTelemetryListeners(options.namespace, client, observability);
|
|
135
|
-
|
|
136
|
-
await Promise.all([
|
|
137
|
-
observability.setIdentityTags(client.services.services),
|
|
138
|
-
observability.startRuntimeMetrics(client),
|
|
139
|
-
observability.startNetworkMetrics(client.services.services),
|
|
140
|
-
observability.startSpacesMetrics(client, options.namespace),
|
|
141
|
-
]);
|
|
142
|
-
|
|
143
|
-
if (client.halo.identity.get()) {
|
|
144
|
-
await sendPrivacyNotice();
|
|
145
|
-
} else {
|
|
146
|
-
const subscription = client.halo.identity.subscribe(async (identity) => {
|
|
147
|
-
if (identity && observability) {
|
|
148
|
-
await sendPrivacyNotice();
|
|
149
|
-
await observability.setIdentityTags(client.services.services);
|
|
150
|
-
subscription.unsubscribe();
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
unload: async () => {
|
|
157
|
-
subscriptions.clear();
|
|
158
|
-
await observability?.close();
|
|
159
|
-
},
|
|
160
|
-
provides: {
|
|
161
|
-
intent: {
|
|
162
|
-
resolvers: ({ plugins }) => {
|
|
163
|
-
const client = findPlugin<{ client: Client }>(plugins, 'dxos.org/plugin/client')?.provides.client;
|
|
164
|
-
if (!client || !observability) {
|
|
165
|
-
return [];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return [
|
|
169
|
-
createResolver(ObservabilityAction.Toggle, async ({ state }) => {
|
|
170
|
-
invariant(observability, 'Observability instance not available');
|
|
171
|
-
settings.enabled = state ?? !settings.enabled;
|
|
172
|
-
observability.event({
|
|
173
|
-
identityId: getTelemetryIdentifier(client),
|
|
174
|
-
name: `${options.namespace}.observability.toggle`,
|
|
175
|
-
properties: {
|
|
176
|
-
enabled: settings.enabled,
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
observability.setMode(settings.enabled ? 'basic' : 'disabled');
|
|
180
|
-
await storeObservabilityDisabled(options.namespace, !settings.enabled);
|
|
181
|
-
return { data: settings.enabled };
|
|
182
|
-
}),
|
|
183
|
-
createResolver(ObservabilityAction.SendEvent, async (data) => {
|
|
184
|
-
invariant(observability, 'Observability instance not available');
|
|
185
|
-
const event = {
|
|
186
|
-
identityId: getTelemetryIdentifier(client),
|
|
187
|
-
name: `${options.namespace}.${data.name}`,
|
|
188
|
-
properties: {
|
|
189
|
-
...data.properties,
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
observability.event(event);
|
|
193
|
-
}),
|
|
194
|
-
createResolver(ObservabilityAction.CaptureUserFeedback, async (data) => {
|
|
195
|
-
invariant(observability, 'Observability instance not available');
|
|
196
|
-
observability.captureUserFeedback(data.email, data.name, data.message);
|
|
197
|
-
}),
|
|
198
|
-
];
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
observability: state.values,
|
|
202
|
-
settings,
|
|
203
|
-
surface: {
|
|
204
|
-
definitions: () =>
|
|
205
|
-
createSurface({
|
|
206
|
-
id: OBSERVABILITY_PLUGIN,
|
|
207
|
-
role: 'settings',
|
|
208
|
-
filter: (data): data is any => data.subject === OBSERVABILITY_PLUGIN,
|
|
209
|
-
component: () => <ObservabilitySettings settings={settings} />,
|
|
210
|
-
}),
|
|
211
|
-
},
|
|
212
|
-
translations,
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|