@dxos/plugin-observability 0.7.4 → 0.7.5-main.937ce75
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 +58 -0
- package/dist/lib/browser/chunk-UBDF6N5K.mjs.map +7 -0
- package/dist/lib/browser/chunk-X6XUBXZQ.mjs +12 -0
- package/dist/lib/browser/chunk-X6XUBXZQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +90 -83
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -3
- package/dist/lib/browser/types.mjs +10 -0
- package/dist/lib/browser/types.mjs.map +7 -0
- package/dist/lib/node/chunk-HZSRCP4I.cjs +78 -0
- package/dist/lib/node/chunk-HZSRCP4I.cjs.map +7 -0
- package/dist/lib/node/{chunk-RAB7T73W.cjs → chunk-SIUGGDNL.cjs} +4 -13
- package/dist/lib/node/chunk-SIUGGDNL.cjs.map +7 -0
- package/dist/lib/node/index.cjs +89 -83
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +4 -6
- package/dist/lib/node/meta.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +32 -0
- package/dist/lib/node/types.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-52FTHXHB.mjs +59 -0
- package/dist/lib/node-esm/chunk-52FTHXHB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7GGPSKXN.mjs +14 -0
- package/dist/lib/node-esm/chunk-7GGPSKXN.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +90 -83
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -3
- package/dist/lib/node-esm/types.mjs +11 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/ObservabilityPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ObservabilitySettings.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -10
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +47 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +27 -19
- package/src/ObservabilityPlugin.tsx +45 -51
- package/src/components/ObservabilitySettings.tsx +17 -24
- package/src/meta.ts +0 -13
- package/src/types.ts +54 -0
- package/dist/lib/browser/chunk-FO5EMZZO.mjs +0 -20
- package/dist/lib/browser/chunk-FO5EMZZO.mjs.map +0 -7
- package/dist/lib/node/chunk-RAB7T73W.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-UVEE3XZO.mjs +0 -22
- package/dist/lib/node-esm/chunk-UVEE3XZO.mjs.map +0 -7
package/dist/types/src/meta.d.ts
CHANGED
|
@@ -4,14 +4,4 @@ declare const _default: {
|
|
|
4
4
|
name: string;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
|
-
export declare enum ObservabilityAction {
|
|
8
|
-
TOGGLE = "dxos.org/plugin/observability/toggle",
|
|
9
|
-
SEND_EVENT = "dxos.org/plugin/observability/send-event",
|
|
10
|
-
CAPTURE_USER_FEEDBACK = "dxos.org/plugin/observability/capture-feedback"
|
|
11
|
-
}
|
|
12
|
-
export type UserFeedback = {
|
|
13
|
-
name: string;
|
|
14
|
-
email: string;
|
|
15
|
-
message: string;
|
|
16
|
-
};
|
|
17
7
|
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB,kCAAkC,CAAC;;;;;AAEpE,wBAGuB
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB,kCAAkC,CAAC;;;;;AAEpE,wBAGuB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { S } from '@dxos/echo-schema';
|
|
2
|
+
export declare const UserFeedback: S.Struct<{
|
|
3
|
+
name: S.filter<S.Schema<string, string, never>>;
|
|
4
|
+
email: S.filter<S.Schema<string, string, never>>;
|
|
5
|
+
message: S.filter<S.Schema<string, string, never>>;
|
|
6
|
+
}>;
|
|
7
|
+
export type UserFeedback = S.Schema.Type<typeof UserFeedback>;
|
|
8
|
+
export declare namespace ObservabilityAction {
|
|
9
|
+
const Toggle_base: S.TaggedClass<Toggle, "dxos.org/plugin/observability/action/toggle", {
|
|
10
|
+
readonly _tag: S.tag<"dxos.org/plugin/observability/action/toggle">;
|
|
11
|
+
} & {
|
|
12
|
+
input: S.Struct<{
|
|
13
|
+
state: S.optional<typeof S.Boolean>;
|
|
14
|
+
}>;
|
|
15
|
+
output: typeof S.Boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export class Toggle extends Toggle_base {
|
|
18
|
+
}
|
|
19
|
+
const SendEvent_base: S.TaggedClass<SendEvent, "dxos.org/plugin/observability/action/send-event", {
|
|
20
|
+
readonly _tag: S.tag<"dxos.org/plugin/observability/action/send-event">;
|
|
21
|
+
} & {
|
|
22
|
+
input: S.Struct<{
|
|
23
|
+
name: typeof S.String;
|
|
24
|
+
properties: S.optional<typeof S.Object>;
|
|
25
|
+
installationId: S.optional<typeof S.String>;
|
|
26
|
+
identityId: S.optional<typeof S.String>;
|
|
27
|
+
timestamp: S.optional<typeof S.Date>;
|
|
28
|
+
}>;
|
|
29
|
+
output: typeof S.Void;
|
|
30
|
+
}>;
|
|
31
|
+
export class SendEvent extends SendEvent_base {
|
|
32
|
+
}
|
|
33
|
+
const CaptureUserFeedback_base: S.TaggedClass<CaptureUserFeedback, "dxos.org/plugin/observability/action/capture-feedback", {
|
|
34
|
+
readonly _tag: S.tag<"dxos.org/plugin/observability/action/capture-feedback">;
|
|
35
|
+
} & {
|
|
36
|
+
input: S.Struct<{
|
|
37
|
+
name: S.filter<S.Schema<string, string, never>>;
|
|
38
|
+
email: S.filter<S.Schema<string, string, never>>;
|
|
39
|
+
message: S.filter<S.Schema<string, string, never>>;
|
|
40
|
+
}>;
|
|
41
|
+
output: typeof S.Void;
|
|
42
|
+
}>;
|
|
43
|
+
export class CaptureUserFeedback extends CaptureUserFeedback_base {
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AActC,eAAO,MAAM,YAAY;;;;EAIvB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;AAG9D,yBAAiB,mBAAmB,CAAC;;;;;;;;;IACnC,MAAM,OAAO,MAAO,SAAQ,WAK1B;KAAG;;;;;;;;;;;;;IAEL,MAAM,OAAO,SAAU,SAAQ,cAS7B;KAAG;;;;;;;;;;;IAEL,MAAM,OAAO,mBAAoB,SAAQ,wBAMxC;KAAG;;CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-observability",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-main.937ce75",
|
|
4
4
|
"description": "DXOS app framework plugin for hooking up app observability",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"types": "./dist/types/src/meta.d.ts",
|
|
18
18
|
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
19
|
"node": "./dist/lib/node-esm/meta.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./types": {
|
|
22
|
+
"types": "./dist/types/src/types.d.ts",
|
|
23
|
+
"browser": "./dist/lib/browser/types.mjs",
|
|
24
|
+
"node": "./dist/lib/node-esm/types.mjs"
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -24,6 +29,9 @@
|
|
|
24
29
|
"*": {
|
|
25
30
|
"meta": [
|
|
26
31
|
"dist/types/src/meta.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"types": [
|
|
34
|
+
"dist/types/src/types.d.ts"
|
|
27
35
|
]
|
|
28
36
|
}
|
|
29
37
|
},
|
|
@@ -34,34 +42,34 @@
|
|
|
34
42
|
"dependencies": {
|
|
35
43
|
"@preact/signals-core": "^1.6.0",
|
|
36
44
|
"localforage": "^1.10.0",
|
|
37
|
-
"@dxos/app-framework": "0.7.
|
|
38
|
-
"@dxos/async": "0.7.
|
|
39
|
-
"@dxos/context": "0.7.
|
|
40
|
-
"@dxos/echo-schema": "0.7.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/observability": "0.7.
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/react-ui-form": "0.7.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
45
|
+
"@dxos/app-framework": "0.7.5-main.937ce75",
|
|
46
|
+
"@dxos/async": "0.7.5-main.937ce75",
|
|
47
|
+
"@dxos/context": "0.7.5-main.937ce75",
|
|
48
|
+
"@dxos/echo-schema": "0.7.5-main.937ce75",
|
|
49
|
+
"@dxos/invariant": "0.7.5-main.937ce75",
|
|
50
|
+
"@dxos/log": "0.7.5-main.937ce75",
|
|
51
|
+
"@dxos/live-object": "0.7.5-main.937ce75",
|
|
52
|
+
"@dxos/local-storage": "0.7.5-main.937ce75",
|
|
53
|
+
"@dxos/observability": "0.7.5-main.937ce75",
|
|
54
|
+
"@dxos/react-client": "0.7.5-main.937ce75",
|
|
55
|
+
"@dxos/react-ui-form": "0.7.5-main.937ce75",
|
|
56
|
+
"@dxos/protocols": "0.7.5-main.937ce75",
|
|
57
|
+
"@dxos/util": "0.7.5-main.937ce75"
|
|
50
58
|
},
|
|
51
59
|
"devDependencies": {
|
|
52
60
|
"@phosphor-icons/react": "^2.1.5",
|
|
53
61
|
"@types/react": "~18.2.0",
|
|
54
62
|
"react": "~18.2.0",
|
|
55
63
|
"vite": "5.4.7",
|
|
56
|
-
"@dxos/react-ui": "0.7.
|
|
57
|
-
"@dxos/storybook-utils": "0.7.
|
|
58
|
-
"@dxos/react-ui-theme": "0.7.
|
|
64
|
+
"@dxos/react-ui": "0.7.5-main.937ce75",
|
|
65
|
+
"@dxos/storybook-utils": "0.7.5-main.937ce75",
|
|
66
|
+
"@dxos/react-ui-theme": "0.7.5-main.937ce75"
|
|
59
67
|
},
|
|
60
68
|
"peerDependencies": {
|
|
61
69
|
"@phosphor-icons/react": "^2.1.5",
|
|
62
70
|
"react": "~18.2.0",
|
|
63
|
-
"@dxos/react-ui": "0.7.
|
|
64
|
-
"@dxos/react-ui
|
|
71
|
+
"@dxos/react-ui-theme": "0.7.5-main.937ce75",
|
|
72
|
+
"@dxos/react-ui": "0.7.5-main.937ce75"
|
|
65
73
|
},
|
|
66
74
|
"publishConfig": {
|
|
67
75
|
"access": "public"
|
|
@@ -15,9 +15,13 @@ import {
|
|
|
15
15
|
parseIntentPlugin,
|
|
16
16
|
LayoutAction,
|
|
17
17
|
SettingsAction,
|
|
18
|
-
|
|
18
|
+
createSurface,
|
|
19
|
+
findPlugin,
|
|
20
|
+
createIntent,
|
|
21
|
+
createResolver,
|
|
19
22
|
} from '@dxos/app-framework';
|
|
20
23
|
import { EventSubscriptions } from '@dxos/async';
|
|
24
|
+
import { invariant } from '@dxos/invariant';
|
|
21
25
|
import { create } from '@dxos/live-object';
|
|
22
26
|
import { LocalStorageStore } from '@dxos/local-storage';
|
|
23
27
|
import {
|
|
@@ -28,12 +32,12 @@ import {
|
|
|
28
32
|
storeObservabilityDisabled,
|
|
29
33
|
getObservabilityGroup,
|
|
30
34
|
} from '@dxos/observability';
|
|
31
|
-
import type
|
|
32
|
-
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
35
|
+
import { type Client } from '@dxos/react-client';
|
|
33
36
|
|
|
34
37
|
import { ObservabilitySettings, type ObservabilitySettingsProps } from './components';
|
|
35
|
-
import meta, { OBSERVABILITY_PLUGIN
|
|
38
|
+
import meta, { OBSERVABILITY_PLUGIN } from './meta';
|
|
36
39
|
import translations from './translations';
|
|
40
|
+
import { ObservabilityAction } from './types';
|
|
37
41
|
|
|
38
42
|
export type ObservabilityPluginState = {
|
|
39
43
|
group?: string;
|
|
@@ -66,24 +70,22 @@ export const ObservabilityPlugin = (options: {
|
|
|
66
70
|
state.values.group = await getObservabilityGroup(options.namespace);
|
|
67
71
|
state.prop({ key: 'notified', type: LocalStorageStore.bool({ allowUndefined: true }) });
|
|
68
72
|
},
|
|
69
|
-
ready: async (plugins) => {
|
|
70
|
-
const
|
|
71
|
-
const clientPlugin = resolvePlugin(plugins, parseClientPlugin);
|
|
73
|
+
ready: async ({ plugins }) => {
|
|
74
|
+
const client = findPlugin<{ client: Client }>(plugins, 'dxos.org/plugin/client')?.provides.client;
|
|
72
75
|
const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
|
|
73
76
|
|
|
74
|
-
const dispatch = intentPlugin?.provides?.intent?.
|
|
77
|
+
const dispatch = intentPlugin?.provides?.intent?.dispatchPromise;
|
|
75
78
|
if (!dispatch) {
|
|
76
79
|
return;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
const sendPrivacyNotice = async () => {
|
|
80
|
-
const environment =
|
|
83
|
+
const environment = client?.config?.values.runtime?.app?.env?.DX_ENVIRONMENT;
|
|
81
84
|
const notify =
|
|
82
85
|
environment && environment !== 'ci' && !environment.endsWith('.local') && !environment.endsWith('.lan');
|
|
83
86
|
if (!state.values.notified && notify) {
|
|
84
|
-
await dispatch(
|
|
85
|
-
|
|
86
|
-
data: {
|
|
87
|
+
await dispatch(
|
|
88
|
+
createIntent(LayoutAction.SetLayout, {
|
|
87
89
|
element: 'toast',
|
|
88
90
|
subject: {
|
|
89
91
|
id: `${OBSERVABILITY_PLUGIN}/notice`,
|
|
@@ -95,10 +97,10 @@ export const ObservabilityPlugin = (options: {
|
|
|
95
97
|
actionLabel: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast action label'],
|
|
96
98
|
actionAlt: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast action alt'],
|
|
97
99
|
closeLabel: translations[0]['en-US'][OBSERVABILITY_PLUGIN]['observability toast close label'],
|
|
98
|
-
onAction: () => dispatch(
|
|
100
|
+
onAction: () => dispatch(createIntent(SettingsAction.Open, { plugin: OBSERVABILITY_PLUGIN })),
|
|
99
101
|
},
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
102
104
|
|
|
103
105
|
state.values.notified = true;
|
|
104
106
|
}
|
|
@@ -110,28 +112,24 @@ export const ObservabilityPlugin = (options: {
|
|
|
110
112
|
observability = obs;
|
|
111
113
|
|
|
112
114
|
// Ensure errors are tagged with enabled plugins to help with reproductions.
|
|
113
|
-
|
|
114
|
-
observability?.setTag(`pluginEnabled-${plugin}`, 'true', 'errors'),
|
|
115
|
-
);
|
|
115
|
+
plugins.map((plugin) => observability?.setTag(`pluginEnabled-${plugin.meta.id}`, 'true', 'errors'));
|
|
116
116
|
|
|
117
117
|
// Start client observability (i.e. not running as shared worker)
|
|
118
118
|
// TODO(nf): how to prevent multiple instances for single shared worker?
|
|
119
|
-
const client = clientPlugin?.provides?.client;
|
|
120
119
|
if (!client) {
|
|
121
120
|
return;
|
|
122
121
|
}
|
|
123
122
|
|
|
124
|
-
await dispatch(
|
|
125
|
-
|
|
126
|
-
data: {
|
|
123
|
+
await dispatch(
|
|
124
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
127
125
|
name: 'page.load',
|
|
128
126
|
properties: {
|
|
129
127
|
href: window.location.href,
|
|
130
128
|
// TODO(wittjosiah): These apis are deprecated. Is there a better way to find this information?
|
|
131
129
|
loadDuration: window.performance.timing.loadEventEnd - window.performance.timing.loadEventStart,
|
|
132
130
|
},
|
|
133
|
-
},
|
|
134
|
-
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
135
133
|
|
|
136
134
|
setupTelemetryListeners(options.namespace, client, observability);
|
|
137
135
|
|
|
@@ -161,15 +159,16 @@ export const ObservabilityPlugin = (options: {
|
|
|
161
159
|
},
|
|
162
160
|
provides: {
|
|
163
161
|
intent: {
|
|
164
|
-
|
|
165
|
-
const client =
|
|
162
|
+
resolvers: ({ plugins }) => {
|
|
163
|
+
const client = findPlugin<{ client: Client }>(plugins, 'dxos.org/plugin/client')?.provides.client;
|
|
166
164
|
if (!client || !observability) {
|
|
167
|
-
return;
|
|
165
|
+
return [];
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
return [
|
|
169
|
+
createResolver(ObservabilityAction.Toggle, async ({ state }) => {
|
|
170
|
+
invariant(observability, 'Observability instance not available');
|
|
171
|
+
settings.enabled = state ?? !settings.enabled;
|
|
173
172
|
observability.event({
|
|
174
173
|
identityId: getTelemetryIdentifier(client),
|
|
175
174
|
name: `${options.namespace}.observability.toggle`,
|
|
@@ -180,9 +179,9 @@ export const ObservabilityPlugin = (options: {
|
|
|
180
179
|
observability.setMode(settings.enabled ? 'basic' : 'disabled');
|
|
181
180
|
await storeObservabilityDisabled(options.namespace, !settings.enabled);
|
|
182
181
|
return { data: settings.enabled };
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
}),
|
|
183
|
+
createResolver(ObservabilityAction.SendEvent, async (data) => {
|
|
184
|
+
invariant(observability, 'Observability instance not available');
|
|
186
185
|
const event = {
|
|
187
186
|
identityId: getTelemetryIdentifier(client),
|
|
188
187
|
name: `${options.namespace}.${data.name}`,
|
|
@@ -191,29 +190,24 @@ export const ObservabilityPlugin = (options: {
|
|
|
191
190
|
},
|
|
192
191
|
};
|
|
193
192
|
observability.event(event);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
observability.captureUserFeedback(feedback.email, feedback.name, feedback.message);
|
|
201
|
-
return { data: true };
|
|
202
|
-
}
|
|
203
|
-
}
|
|
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
|
+
];
|
|
204
199
|
},
|
|
205
200
|
},
|
|
206
201
|
observability: state.values,
|
|
207
202
|
settings,
|
|
208
203
|
surface: {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
},
|
|
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
|
+
}),
|
|
217
211
|
},
|
|
218
212
|
translations,
|
|
219
213
|
},
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { Input, Message, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
|
-
import { OBSERVABILITY_PLUGIN
|
|
11
|
+
import { OBSERVABILITY_PLUGIN } from '../meta';
|
|
12
|
+
import { ObservabilityAction } from '../types';
|
|
12
13
|
|
|
13
14
|
export type ObservabilitySettingsProps = {
|
|
14
15
|
enabled?: boolean;
|
|
@@ -20,31 +21,23 @@ export type ObservabilitySettingsProps = {
|
|
|
20
21
|
|
|
21
22
|
export const ObservabilitySettings = ({ settings }: { settings: ObservabilitySettingsProps }) => {
|
|
22
23
|
const { t } = useTranslation(OBSERVABILITY_PLUGIN);
|
|
23
|
-
const
|
|
24
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
27
|
<>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<Message.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
plugin: OBSERVABILITY_PLUGIN,
|
|
41
|
-
action: ObservabilityAction.TOGGLE,
|
|
42
|
-
data: { state: !!checked },
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
/>
|
|
46
|
-
</DeprecatedFormInput>
|
|
47
|
-
)}
|
|
28
|
+
<DeprecatedFormInput
|
|
29
|
+
label={t('observability enabled label')}
|
|
30
|
+
secondary={
|
|
31
|
+
<Message.Root valence='info'>
|
|
32
|
+
<Message.Body>{t('observability description')}</Message.Body>
|
|
33
|
+
</Message.Root>
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
<Input.Switch
|
|
37
|
+
checked={settings.enabled}
|
|
38
|
+
onCheckedChange={(checked) => dispatch(createIntent(ObservabilityAction.Toggle, { state: !!checked }))}
|
|
39
|
+
/>
|
|
40
|
+
</DeprecatedFormInput>
|
|
48
41
|
</>
|
|
49
42
|
);
|
|
50
43
|
};
|
package/src/meta.ts
CHANGED
|
@@ -10,16 +10,3 @@ export default {
|
|
|
10
10
|
id: OBSERVABILITY_PLUGIN,
|
|
11
11
|
name: 'Telemetry',
|
|
12
12
|
} satisfies PluginMeta;
|
|
13
|
-
|
|
14
|
-
const OBSERVABILITY_ACTION = 'dxos.org/plugin/observability';
|
|
15
|
-
export enum ObservabilityAction {
|
|
16
|
-
TOGGLE = `${OBSERVABILITY_ACTION}/toggle`,
|
|
17
|
-
SEND_EVENT = `${OBSERVABILITY_ACTION}/send-event`,
|
|
18
|
-
CAPTURE_USER_FEEDBACK = `${OBSERVABILITY_ACTION}/capture-feedback`,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type UserFeedback = {
|
|
22
|
-
name: string;
|
|
23
|
-
email: string;
|
|
24
|
-
message: string;
|
|
25
|
-
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { S } from '@dxos/echo-schema';
|
|
6
|
+
|
|
7
|
+
import { OBSERVABILITY_PLUGIN } from './meta';
|
|
8
|
+
|
|
9
|
+
const Email = S.String.pipe(
|
|
10
|
+
S.nonEmptyString({ message: () => 'Email is required.' }),
|
|
11
|
+
S.pattern(/^(?!\.)(?!.*\.\.)([A-Z0-9_+-.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,}$/i, {
|
|
12
|
+
message: () => 'Invalid email address.',
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const nonEmpty = (field: string) => S.nonEmptyString({ message: () => `${field} is required.` });
|
|
17
|
+
const maxLength = (field: string, length: number) => S.maxLength(length, { message: () => `${field} is too long.` });
|
|
18
|
+
|
|
19
|
+
export const UserFeedback = S.Struct({
|
|
20
|
+
name: S.String.pipe(nonEmpty('Name'), maxLength('Name', 256)),
|
|
21
|
+
email: Email.pipe(maxLength('Email', 256)),
|
|
22
|
+
message: S.String.pipe(nonEmpty('Feedback'), maxLength('Feedback', 32_768)),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type UserFeedback = S.Schema.Type<typeof UserFeedback>;
|
|
26
|
+
|
|
27
|
+
const OBSERVABILITY_ACTION = `${OBSERVABILITY_PLUGIN}/action`;
|
|
28
|
+
export namespace ObservabilityAction {
|
|
29
|
+
export class Toggle extends S.TaggedClass<Toggle>()(`${OBSERVABILITY_ACTION}/toggle`, {
|
|
30
|
+
input: S.Struct({
|
|
31
|
+
state: S.optional(S.Boolean),
|
|
32
|
+
}),
|
|
33
|
+
output: S.Boolean,
|
|
34
|
+
}) {}
|
|
35
|
+
|
|
36
|
+
export class SendEvent extends S.TaggedClass<SendEvent>()(`${OBSERVABILITY_ACTION}/send-event`, {
|
|
37
|
+
input: S.Struct({
|
|
38
|
+
name: S.String,
|
|
39
|
+
properties: S.optional(S.Object),
|
|
40
|
+
installationId: S.optional(S.String),
|
|
41
|
+
identityId: S.optional(S.String),
|
|
42
|
+
timestamp: S.optional(S.Date),
|
|
43
|
+
}),
|
|
44
|
+
output: S.Void,
|
|
45
|
+
}) {}
|
|
46
|
+
|
|
47
|
+
export class CaptureUserFeedback extends S.TaggedClass<CaptureUserFeedback>()(
|
|
48
|
+
`${OBSERVABILITY_ACTION}/capture-feedback`,
|
|
49
|
+
{
|
|
50
|
+
input: UserFeedback,
|
|
51
|
+
output: S.Void,
|
|
52
|
+
},
|
|
53
|
+
) {}
|
|
54
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// packages/plugins/plugin-observability/src/meta.ts
|
|
2
|
-
var OBSERVABILITY_PLUGIN = "dxos.org/plugin/observability";
|
|
3
|
-
var meta_default = {
|
|
4
|
-
id: OBSERVABILITY_PLUGIN,
|
|
5
|
-
name: "Telemetry"
|
|
6
|
-
};
|
|
7
|
-
var OBSERVABILITY_ACTION = "dxos.org/plugin/observability";
|
|
8
|
-
var ObservabilityAction;
|
|
9
|
-
(function(ObservabilityAction2) {
|
|
10
|
-
ObservabilityAction2[ObservabilityAction2["TOGGLE"] = `${OBSERVABILITY_ACTION}/toggle`] = "TOGGLE";
|
|
11
|
-
ObservabilityAction2[ObservabilityAction2["SEND_EVENT"] = `${OBSERVABILITY_ACTION}/send-event`] = "SEND_EVENT";
|
|
12
|
-
ObservabilityAction2[ObservabilityAction2["CAPTURE_USER_FEEDBACK"] = `${OBSERVABILITY_ACTION}/capture-feedback`] = "CAPTURE_USER_FEEDBACK";
|
|
13
|
-
})(ObservabilityAction || (ObservabilityAction = {}));
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
OBSERVABILITY_PLUGIN,
|
|
17
|
-
meta_default,
|
|
18
|
-
ObservabilityAction
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=chunk-FO5EMZZO.mjs.map
|
|
@@ -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\nconst OBSERVABILITY_ACTION = 'dxos.org/plugin/observability';\nexport enum ObservabilityAction {\n TOGGLE = `${OBSERVABILITY_ACTION}/toggle`,\n SEND_EVENT = `${OBSERVABILITY_ACTION}/send-event`,\n CAPTURE_USER_FEEDBACK = `${OBSERVABILITY_ACTION}/capture-feedback`,\n}\n\nexport type UserFeedback = {\n name: string;\n email: string;\n message: string;\n};\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,uBAAuB;AAEpC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;AAEA,IAAMC,uBAAuB;;UACjBC,sBAAAA;wDACD,GAAGD,oBAAAA,SAA6B,IAAA;4DAC5B,GAAGA,oBAAAA,aAAiC,IAAA;uEACzB,GAAGA,oBAAAA,mBAAuC,IAAA;GAHxDC,wBAAAA,sBAAAA,CAAAA,EAAAA;",
|
|
6
|
-
"names": ["OBSERVABILITY_PLUGIN", "id", "name", "OBSERVABILITY_ACTION", "ObservabilityAction"]
|
|
7
|
-
}
|
|
@@ -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\nconst OBSERVABILITY_ACTION = 'dxos.org/plugin/observability';\nexport enum ObservabilityAction {\n TOGGLE = `${OBSERVABILITY_ACTION}/toggle`,\n SEND_EVENT = `${OBSERVABILITY_ACTION}/send-event`,\n CAPTURE_USER_FEEDBACK = `${OBSERVABILITY_ACTION}/capture-feedback`,\n}\n\nexport type UserFeedback = {\n name: string;\n email: string;\n message: string;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,uBAAuB;AAEpC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;AAEA,IAAMC,uBAAuB;;UACjBC,sBAAAA;wDACD,GAAGD,oBAAAA,SAA6B,IAAA;4DAC5B,GAAGA,oBAAAA,aAAiC,IAAA;uEACzB,GAAGA,oBAAAA,mBAAuC,IAAA;GAHxDC,wBAAAA,sBAAAA,CAAAA,EAAAA;",
|
|
6
|
-
"names": ["OBSERVABILITY_PLUGIN", "id", "name", "OBSERVABILITY_ACTION", "ObservabilityAction"]
|
|
7
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// packages/plugins/plugin-observability/src/meta.ts
|
|
4
|
-
var OBSERVABILITY_PLUGIN = "dxos.org/plugin/observability";
|
|
5
|
-
var meta_default = {
|
|
6
|
-
id: OBSERVABILITY_PLUGIN,
|
|
7
|
-
name: "Telemetry"
|
|
8
|
-
};
|
|
9
|
-
var OBSERVABILITY_ACTION = "dxos.org/plugin/observability";
|
|
10
|
-
var ObservabilityAction;
|
|
11
|
-
(function(ObservabilityAction2) {
|
|
12
|
-
ObservabilityAction2[ObservabilityAction2["TOGGLE"] = `${OBSERVABILITY_ACTION}/toggle`] = "TOGGLE";
|
|
13
|
-
ObservabilityAction2[ObservabilityAction2["SEND_EVENT"] = `${OBSERVABILITY_ACTION}/send-event`] = "SEND_EVENT";
|
|
14
|
-
ObservabilityAction2[ObservabilityAction2["CAPTURE_USER_FEEDBACK"] = `${OBSERVABILITY_ACTION}/capture-feedback`] = "CAPTURE_USER_FEEDBACK";
|
|
15
|
-
})(ObservabilityAction || (ObservabilityAction = {}));
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
OBSERVABILITY_PLUGIN,
|
|
19
|
-
meta_default,
|
|
20
|
-
ObservabilityAction
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=chunk-UVEE3XZO.mjs.map
|
|
@@ -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\nconst OBSERVABILITY_ACTION = 'dxos.org/plugin/observability';\nexport enum ObservabilityAction {\n TOGGLE = `${OBSERVABILITY_ACTION}/toggle`,\n SEND_EVENT = `${OBSERVABILITY_ACTION}/send-event`,\n CAPTURE_USER_FEEDBACK = `${OBSERVABILITY_ACTION}/capture-feedback`,\n}\n\nexport type UserFeedback = {\n name: string;\n email: string;\n message: string;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAMO,IAAMA,uBAAuB;AAEpC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;AAEA,IAAMC,uBAAuB;;UACjBC,sBAAAA;wDACD,GAAGD,oBAAAA,SAA6B,IAAA;4DAC5B,GAAGA,oBAAAA,aAAiC,IAAA;uEACzB,GAAGA,oBAAAA,mBAAuC,IAAA;GAHxDC,wBAAAA,sBAAAA,CAAAA,EAAAA;",
|
|
6
|
-
"names": ["OBSERVABILITY_PLUGIN", "id", "name", "OBSERVABILITY_ACTION", "ObservabilityAction"]
|
|
7
|
-
}
|