@@ -9,6 +9,20 @@ import {SANITY_VERSION} from '../version'
9
9
10
10
const sessionId = createSessionId ( )
11
11
12
+ // A list of common dataset / workspace names we can safely log without collecting private data
13
+ const WELL_KNOWN_NAMES = [
14
+ 'staging' ,
15
+ 'stage' ,
16
+ 'stg' ,
17
+ 'production' ,
18
+ 'prod' ,
19
+ 'preprod' ,
20
+ 'development' ,
21
+ 'dev' ,
22
+ 'qa' ,
23
+ 'test' ,
24
+ ]
25
+
12
26
// Wrap the app in a TelemetryProvider
13
27
// This will enable usage of the `useTelemetry()` hook
14
28
export function StudioTelemetryProvider ( props : { children : ReactNode ; config : Config } ) {
@@ -39,6 +53,7 @@ export function StudioTelemetryProvider(props: {children: ReactNode; config: Con
39
53
} , [ client , projectId ] )
40
54
41
55
useEffect ( ( ) => {
56
+ const workspaces = arrify ( props . config )
42
57
store . logger . updateUserProperties ( {
43
58
userAgent : navigator . userAgent ,
44
59
screen : {
@@ -49,14 +64,24 @@ export function StudioTelemetryProvider(props: {children: ReactNode; config: Con
49
64
innerWidth : window . innerWidth ,
50
65
} ,
51
66
studioVersion : SANITY_VERSION ,
52
- plugins : arrify ( props . config ) . flatMap (
53
- ( config ) =>
54
- config . plugins ?. flatMap ( ( plugin ) => ( {
67
+ plugins : workspaces . flatMap (
68
+ ( workspace ) =>
69
+ workspace . plugins ?. flatMap ( ( plugin ) => ( {
55
70
name : plugin . name || '<unnamed>' ,
56
71
} ) ) || [ ] ,
57
72
) ,
73
+ workspaceNames : workspaces . map ( ( workspace ) =>
74
+ workspace . name ? getWellKnownName ( workspace . name ) || '<custom>' : '<missing>' ,
75
+ ) ,
76
+ datasetNames : workspaces . flatMap ( ( workspace ) =>
77
+ workspace . dataset ? getWellKnownName ( workspace . dataset ) || '<custom>' : '<missing>' ,
78
+ ) ,
58
79
} )
59
80
} , [ props . config , store . logger ] )
60
81
61
82
return < TelemetryProvider store = { store } > { props . children } </ TelemetryProvider >
62
83
}
84
+
85
+ function getWellKnownName ( name : string ) {
86
+ return WELL_KNOWN_NAMES . includes ( name . toLowerCase ( ) ) ? name : undefined
87
+ }
0 commit comments