Skip to content

Commit 15fbd21

Browse files
committed
Send "Schema Shared" event
1 parent 0338996 commit 15fbd21

File tree

1 file changed

+18
-0
lines changed
  • packages/compass-schema/src/stores

1 file changed

+18
-0
lines changed

packages/compass-schema/src/stores/store.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export type SchemaStore = StoreWithStateMixin<SchemaState> & {
8787
dataService: DataService;
8888

8989
handleSchemaShare(): void;
90+
_trackSchemaShared(hasSchema: boolean): void;
91+
9092
onSchemaSampled(): void;
9193
geoLayerAdded(
9294
field: string,
@@ -162,6 +164,7 @@ export function activateSchemaPlugin(
162164
JSON.stringify(this.state.schema, null, ' ')
163165
);
164166
const hasSchema = this.state.schema !== null;
167+
this._trackSchemaShared(hasSchema);
165168
openToast(
166169
'share-schema',
167170
hasSchema
@@ -181,6 +184,21 @@ export function activateSchemaPlugin(
181184
);
182185
},
183186

187+
_trackSchemaShared(this: SchemaStore, hasSchema: boolean) {
188+
const { schema } = this.state;
189+
// Use a function here to a) ensure that the calculations here
190+
// are only made when telemetry is enabled and b) that errors from
191+
// those calculations are caught and logged rather than displayed to
192+
// users as errors from the core schema sharing logic.
193+
const trackEvent = () => ({
194+
has_schema: hasSchema,
195+
schema_width: schema?.fields?.length ?? 0,
196+
schema_depth: schema ? calculateSchemaDepth(schema) : 0,
197+
geo_data: schema ? schemaContainsGeoData(schema) : false,
198+
});
199+
track('Schema Shared', trackEvent, connectionInfoRef.current);
200+
},
201+
184202
/**
185203
* Initialize the schema store.
186204
*

0 commit comments

Comments
 (0)