@finos/legend-application-query 13.8.52 → 13.8.53

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.
Files changed (95) hide show
  1. package/lib/__lib__/LegendQueryEvent.d.ts +6 -0
  2. package/lib/__lib__/LegendQueryEvent.d.ts.map +1 -1
  3. package/lib/__lib__/LegendQueryEvent.js +6 -0
  4. package/lib/__lib__/LegendQueryEvent.js.map +1 -1
  5. package/lib/__lib__/LegendQueryLifecycleTelemetry.d.ts +58 -0
  6. package/lib/__lib__/LegendQueryLifecycleTelemetry.d.ts.map +1 -0
  7. package/lib/__lib__/LegendQueryLifecycleTelemetry.js +90 -0
  8. package/lib/__lib__/LegendQueryLifecycleTelemetry.js.map +1 -0
  9. package/lib/__lib__/LegendQueryNavigation.d.ts +1 -1
  10. package/lib/__lib__/LegendQueryNavigation.d.ts.map +1 -1
  11. package/lib/__lib__/LegendQueryNavigation.js +11 -1
  12. package/lib/__lib__/LegendQueryNavigation.js.map +1 -1
  13. package/lib/__lib__/LegendQuerySourceInfo.d.ts +137 -0
  14. package/lib/__lib__/LegendQuerySourceInfo.d.ts.map +1 -0
  15. package/lib/__lib__/LegendQuerySourceInfo.js +33 -0
  16. package/lib/__lib__/LegendQuerySourceInfo.js.map +1 -0
  17. package/lib/__lib__/LegendQueryTelemetryHelper.d.ts +73 -1
  18. package/lib/__lib__/LegendQueryTelemetryHelper.d.ts.map +1 -1
  19. package/lib/__lib__/LegendQueryTelemetryHelper.js +18 -0
  20. package/lib/__lib__/LegendQueryTelemetryHelper.js.map +1 -1
  21. package/lib/application/LegendQueryApplicationConfig.d.ts +2 -0
  22. package/lib/application/LegendQueryApplicationConfig.d.ts.map +1 -1
  23. package/lib/application/LegendQueryApplicationConfig.js +2 -0
  24. package/lib/application/LegendQueryApplicationConfig.js.map +1 -1
  25. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -1
  26. package/lib/components/Core_LegendQueryApplicationPlugin.js +13 -2
  27. package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -1
  28. package/lib/index.css +1 -1
  29. package/lib/index.d.ts +2 -1
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +2 -1
  32. package/lib/index.js.map +1 -1
  33. package/lib/light-mode.css +1 -1
  34. package/lib/package.json +1 -1
  35. package/lib/stores/EditExistingQuerySetupStore.d.ts.map +1 -1
  36. package/lib/stores/EditExistingQuerySetupStore.js +4 -13
  37. package/lib/stores/EditExistingQuerySetupStore.js.map +1 -1
  38. package/lib/stores/LegendQueryApplicationPlugin.d.ts +2 -1
  39. package/lib/stores/LegendQueryApplicationPlugin.d.ts.map +1 -1
  40. package/lib/stores/LegendQueryApplicationPlugin.js +23 -0
  41. package/lib/stores/LegendQueryApplicationPlugin.js.map +1 -1
  42. package/lib/stores/QueryEditorStore.d.ts +30 -2
  43. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  44. package/lib/stores/QueryEditorStore.js +123 -79
  45. package/lib/stores/QueryEditorStore.js.map +1 -1
  46. package/lib/stores/QueryProductionizerSetupStore.d.ts.map +1 -1
  47. package/lib/stores/QueryProductionizerSetupStore.js +4 -13
  48. package/lib/stores/QueryProductionizerSetupStore.js.map +1 -1
  49. package/lib/stores/QuerySetupStore.d.ts.map +1 -1
  50. package/lib/stores/QuerySetupStore.js +1 -0
  51. package/lib/stores/QuerySetupStore.js.map +1 -1
  52. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.d.ts +2 -0
  53. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.d.ts.map +1 -1
  54. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.js +12 -1
  55. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.js.map +1 -1
  56. package/lib/stores/data-space/DataProductQueryCreatorStore.d.ts +10 -0
  57. package/lib/stores/data-space/DataProductQueryCreatorStore.d.ts.map +1 -1
  58. package/lib/stores/data-space/DataProductQueryCreatorStore.js +63 -19
  59. package/lib/stores/data-space/DataProductQueryCreatorStore.js.map +1 -1
  60. package/lib/stores/data-space/DataProductSelectorState.d.ts +4 -2
  61. package/lib/stores/data-space/DataProductSelectorState.d.ts.map +1 -1
  62. package/lib/stores/data-space/DataProductSelectorState.js +30 -9
  63. package/lib/stores/data-space/DataProductSelectorState.js.map +1 -1
  64. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts +2 -0
  65. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts.map +1 -1
  66. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js +13 -7
  67. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js.map +1 -1
  68. package/lib/stores/data-space/LegendQueryBareQueryBuilderState.d.ts.map +1 -1
  69. package/lib/stores/data-space/LegendQueryBareQueryBuilderState.js +1 -1
  70. package/lib/stores/data-space/LegendQueryBareQueryBuilderState.js.map +1 -1
  71. package/lib/stores/ingest/IngestQueryCreatorStore.d.ts +2 -0
  72. package/lib/stores/ingest/IngestQueryCreatorStore.d.ts.map +1 -1
  73. package/lib/stores/ingest/IngestQueryCreatorStore.js +10 -3
  74. package/lib/stores/ingest/IngestQueryCreatorStore.js.map +1 -1
  75. package/package.json +13 -13
  76. package/src/__lib__/LegendQueryEvent.ts +7 -0
  77. package/src/__lib__/LegendQueryLifecycleTelemetry.ts +132 -0
  78. package/src/__lib__/LegendQueryNavigation.ts +20 -1
  79. package/src/__lib__/LegendQuerySourceInfo.ts +162 -0
  80. package/src/__lib__/LegendQueryTelemetryHelper.ts +120 -1
  81. package/src/application/LegendQueryApplicationConfig.ts +5 -1
  82. package/src/components/Core_LegendQueryApplicationPlugin.tsx +21 -2
  83. package/src/index.ts +6 -1
  84. package/src/stores/EditExistingQuerySetupStore.ts +8 -20
  85. package/src/stores/LegendQueryApplicationPlugin.tsx +38 -0
  86. package/src/stores/QueryEditorStore.ts +178 -86
  87. package/src/stores/QueryProductionizerSetupStore.ts +8 -20
  88. package/src/stores/QuerySetupStore.ts +2 -0
  89. package/src/stores/data-product/DataProductSampleQueryCreatorStore.ts +17 -0
  90. package/src/stores/data-space/DataProductQueryCreatorStore.ts +99 -33
  91. package/src/stores/data-space/DataProductSelectorState.ts +58 -13
  92. package/src/stores/data-space/DataSpaceTemplateQueryCreatorStore.ts +17 -6
  93. package/src/stores/data-space/LegendQueryBareQueryBuilderState.ts +5 -1
  94. package/src/stores/ingest/IngestQueryCreatorStore.ts +16 -5
  95. package/tsconfig.json +2 -0
@@ -16,9 +16,16 @@
16
16
 
17
17
  import { LegendApplicationPlugin } from '@finos/legend-application';
18
18
  import type {
19
+ DataProductAccessRequestLinkBuilder,
19
20
  QueryBuilder_LegendApplicationPlugin_Extension,
20
21
  QueryBuilderState,
21
22
  } from '@finos/legend-query-builder';
23
+ import {
24
+ isSnapshotVersion,
25
+ SNAPSHOT_VERSION_ALIAS,
26
+ } from '@finos/legend-server-depot';
27
+ import { LegendQueryDataProductQueryBuilderState } from './data-product/query-builder/LegendQueryDataProductQueryBuilderState.js';
28
+ import { EXTERNAL_APPLICATION_NAVIGATION__generateMarketplaceDataProductUrl } from '../__lib__/LegendQueryNavigation.js';
22
29
  import type { LegendQueryPluginManager } from '../application/LegendQueryPluginManager.js';
23
30
  import type {
24
31
  ExistingQueryEditorStore,
@@ -136,4 +143,35 @@ export class LegendQueryApplicationPlugin
136
143
  request: QueryTitleDescriptionAISuggestionRequest,
137
144
  legendAIUrl: string,
138
145
  ) => Promise<QueryTitleDescriptionSuggestion>;
146
+
147
+ getDataProductAccessRequestLinkBuilders(): DataProductAccessRequestLinkBuilder[] {
148
+ return [
149
+ (info, queryBuilderState): string | undefined => {
150
+ if (
151
+ !(
152
+ queryBuilderState instanceof LegendQueryDataProductQueryBuilderState
153
+ ) ||
154
+ info.deploymentId === undefined
155
+ ) {
156
+ return undefined;
157
+ }
158
+ const versionId = queryBuilderState.project.versionId;
159
+ const marketplaceUrl =
160
+ isSnapshotVersion(versionId) || versionId === SNAPSHOT_VERSION_ALIAS
161
+ ? queryBuilderState.applicationStore.config
162
+ .marketplaceProductionParallelUrl
163
+ : queryBuilderState.applicationStore.config
164
+ .marketplaceApplicationUrl;
165
+ if (marketplaceUrl === undefined) {
166
+ return undefined;
167
+ }
168
+ return EXTERNAL_APPLICATION_NAVIGATION__generateMarketplaceDataProductUrl(
169
+ marketplaceUrl,
170
+ info.dataProductId,
171
+ info.deploymentId,
172
+ info.accessPointGroupId,
173
+ );
174
+ },
175
+ ];
176
+ }
139
177
  }
@@ -39,6 +39,7 @@ import {
39
39
  returnUndefOnError,
40
40
  UnsupportedOperationError,
41
41
  filterByType,
42
+ buildTelemetryErrorFields,
42
43
  } from '@finos/legend-shared';
43
44
  import {
44
45
  type LightQuery,
@@ -138,9 +139,29 @@ import {
138
139
  ModelAccessPointDataProductExecutionState,
139
140
  LakehouseDataProductExecutionState,
140
141
  resolveDataProductAccessor,
142
+ QUERY_BUILDER_OPENED_FROM,
141
143
  } from '@finos/legend-query-builder';
142
144
  import { LegendQueryUserDataHelper } from '../__lib__/LegendQueryUserDataHelper.js';
143
- import { LegendQueryTelemetryHelper } from '../__lib__/LegendQueryTelemetryHelper.js';
145
+ import {
146
+ buildQueryCreateFailureData,
147
+ buildQueryIdentity,
148
+ buildQueryLifecycleFailureData,
149
+ buildQueryLoaderLifecycleTelemetryHandlers,
150
+ } from '../__lib__/LegendQueryLifecycleTelemetry.js';
151
+ import {
152
+ LegendQueryTelemetryHelper,
153
+ type InitializeTelemetrySource,
154
+ } from '../__lib__/LegendQueryTelemetryHelper.js';
155
+ import {
156
+ type LegendQueryDataProductSampleSourceInfo,
157
+ type LegendQueryDataProductSourceInfo,
158
+ type LegendQueryDataSpaceSourceInfo,
159
+ type LegendQueryIngestSourceInfo,
160
+ type LegendQueryMappingSourceInfo,
161
+ type LegendQueryServiceSourceInfo,
162
+ type LegendQuerySourceInfo,
163
+ LegendQuerySourceType,
164
+ } from '../__lib__/LegendQuerySourceInfo.js';
144
165
  import { type ResolvedDataSpaceEntityWithOrigin } from '@finos/legend-extension-dsl-data-space/application';
145
166
  import {
146
167
  type DataSpace,
@@ -276,13 +297,7 @@ export class QueryCreatorState {
276
297
  LegendQueryTelemetryHelper.logEvent_CreateQuerySucceeded(
277
298
  this.editorStore.applicationStore.telemetryService,
278
299
  {
279
- query: {
280
- id: query.id,
281
- name: query.name,
282
- groupId: query.groupId,
283
- artifactId: query.artifactId,
284
- versionId: query.versionId,
285
- },
300
+ ...buildQueryIdentity(query),
286
301
  ...queryBuilderState.getExtraTelemetryMetadata(),
287
302
  },
288
303
  );
@@ -300,6 +315,10 @@ export class QueryCreatorState {
300
315
  error,
301
316
  );
302
317
  this.editorStore.applicationStore.notificationService.notifyError(error);
318
+ LegendQueryTelemetryHelper.logEvent_CreateQueryFailed(
319
+ this.editorStore.applicationStore.telemetryService,
320
+ buildQueryCreateFailureData(this.queryName, error),
321
+ );
303
322
  } finally {
304
323
  this.createQueryState.reset();
305
324
  }
@@ -430,25 +449,13 @@ export abstract class QueryEditorStore {
430
449
  'recently viewed queries',
431
450
  )}`
432
451
  : `No recently viewed queries`,
433
- onQueryDeleted: (queryId): void =>
434
- LegendQueryUserDataHelper.removeRecentlyViewedQuery(
435
- this.applicationStore.userDataService,
436
- queryId,
437
- ),
438
- onQueryRenamed: (query): void => {
439
- LegendQueryTelemetryHelper.logEvent_RenameQuerySucceeded(
440
- applicationStore.telemetryService,
441
- {
442
- query: {
443
- id: query.id,
444
- name: query.name,
445
- groupId: query.groupId,
446
- artifactId: query.artifactId,
447
- versionId: query.versionId,
448
- },
449
- },
450
- );
451
- },
452
+ ...buildQueryLoaderLifecycleTelemetryHandlers(this.applicationStore, {
453
+ onQueryDeleted: (queryId): void =>
454
+ LegendQueryUserDataHelper.removeRecentlyViewedQuery(
455
+ this.applicationStore.userDataService,
456
+ queryId,
457
+ ),
458
+ }),
452
459
  handleFetchDefaultQueriesFailure: (): void =>
453
460
  LegendQueryUserDataHelper.removeRecentlyViewedQueries(
454
461
  this.applicationStore.userDataService,
@@ -608,9 +615,9 @@ export abstract class QueryEditorStore {
608
615
  return;
609
616
  }
610
617
 
618
+ const stopWatch = new StopWatch();
611
619
  try {
612
620
  this.initState.inProgress();
613
- const stopWatch = new StopWatch();
614
621
 
615
622
  // TODO: when we genericize the way to initialize an application page
616
623
  this.applicationStore.assistantService.setIsHidden(true);
@@ -624,6 +631,8 @@ export abstract class QueryEditorStore {
624
631
  baseUrl: this.applicationStore.config.engineServerUrl,
625
632
  queryBaseUrl: this.applicationStore.config.engineQueryServerUrl,
626
633
  enableCompression: true,
634
+ useCookieAuthOnly:
635
+ this.applicationStore.config.engineUseCookieAuthOnly,
627
636
  },
628
637
  },
629
638
  {
@@ -638,6 +647,15 @@ export abstract class QueryEditorStore {
638
647
  )) as QueryBuilderState;
639
648
  this.queryLoaderState.initialize(this.queryBuilderState);
640
649
  this.initState.pass();
650
+ // the canonical "a query builder is loaded" signal, emitted for every
651
+ // route — creator and saved alike. Reported here rather than from each
652
+ // route's own load event so that counting opens does not require a union
653
+ // of differently shaped, half-covering events.
654
+ this.queryBuilderState.logOpened(this.getOpenedFrom(), {
655
+ ...this.getInitializeTelemetrySource(),
656
+ timings:
657
+ this.applicationStore.timeService.finalizeTimingsRecord(stopWatch),
658
+ });
641
659
  } catch (error) {
642
660
  assertErrorThrown(error);
643
661
  this.applicationStore.logService.error(
@@ -645,6 +663,9 @@ export abstract class QueryEditorStore {
645
663
  error,
646
664
  );
647
665
  this.applicationStore.notificationService.notifyError(error);
666
+ // NOTE: log before handling the failure, which may reset the editor
667
+ // state that the telemetry source is derived from
668
+ this.logInitializeFailureMetrics(stopWatch, error);
648
669
  this.onInitializeFailure();
649
670
  this.initState.fail();
650
671
  }
@@ -654,6 +675,53 @@ export abstract class QueryEditorStore {
654
675
  // Do Nothing
655
676
  }
656
677
 
678
+ /**
679
+ * Where the query was started from, used as the source info of the query
680
+ * builder state. Since this is derived from the editor state (e.g. the
681
+ * route) rather than the query builder state, it is also available when
682
+ * the editor fails to initialize.
683
+ */
684
+ getSourceInfo(): LegendQuerySourceInfo | undefined {
685
+ return undefined;
686
+ }
687
+
688
+ /**
689
+ * Which surface opened the query builder, reported as `openedFrom` on
690
+ * `query-builder.opened`. Creator routes inherit this; only
691
+ * `ExistingQueryEditorStore` overrides it.
692
+ *
693
+ * Note this names the surface only — what is being queried is already carried
694
+ * by `getSourceInfo()` on the same payload.
695
+ */
696
+ getOpenedFrom(): QUERY_BUILDER_OPENED_FROM {
697
+ return QUERY_BUILDER_OPENED_FROM.QUERY_CREATOR;
698
+ }
699
+
700
+ /**
701
+ * Where the query was started from, reported when the query creator is
702
+ * initialized
703
+ */
704
+ getInitializeTelemetrySource(): InitializeTelemetrySource {
705
+ return {
706
+ // spread flat, matching how `sourceInfo` is reported on every other query
707
+ // telemetry event — see `QueryBuilderTelemetryContext`
708
+ ...this.getSourceInfo(),
709
+ restoredFromRecent: false,
710
+ };
711
+ }
712
+
713
+ logInitializeFailureMetrics(stopWatch: StopWatch, error: Error): void {
714
+ LegendQueryTelemetryHelper.logEvent_InitializeQueryCreatorFailed(
715
+ this.applicationStore.telemetryService,
716
+ {
717
+ ...this.getInitializeTelemetrySource(),
718
+ ...buildTelemetryErrorFields(error),
719
+ timings:
720
+ this.applicationStore.timeService.finalizeTimingsRecord(stopWatch),
721
+ },
722
+ );
723
+ }
724
+
657
725
  *searchExistingQueryName(searchText: string): GeneratorFn<void> {
658
726
  const isValidSearchString =
659
727
  searchText.length >= DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH;
@@ -1282,6 +1350,10 @@ export abstract class QueryEditorStore {
1282
1350
  | ((val: ResolvedDataSpaceEntityWithOrigin) => void)
1283
1351
  | undefined,
1284
1352
  productSelectorState?: DataProductSelectorState | undefined,
1353
+ sourceInfo?:
1354
+ | LegendQueryDataProductSourceInfo
1355
+ | LegendQueryDataProductSampleSourceInfo
1356
+ | undefined,
1285
1357
  ): Promise<LegendQueryDataProductQueryBuilderState> {
1286
1358
  // 3. Build minimal graph and get analysis result
1287
1359
  const dataProductAnalysisResult =
@@ -1325,12 +1397,6 @@ export abstract class QueryEditorStore {
1325
1397
  }
1326
1398
  // 6. Create query builder state
1327
1399
  const projectInfo = { groupId, artifactId, versionId };
1328
- const sourceInfo = {
1329
- groupId,
1330
- artifactId,
1331
- versionId,
1332
- dataProduct: dataProductPath,
1333
- };
1334
1400
  const queryBuilderState = new LegendQueryDataProductQueryBuilderState(
1335
1401
  this.applicationStore,
1336
1402
  this.graphManagerState,
@@ -1348,11 +1414,20 @@ export abstract class QueryEditorStore {
1348
1414
  new DataProductSelectorState(
1349
1415
  this.depotServerClient,
1350
1416
  this.applicationStore,
1417
+ this.lakehouseState?.contractServerClient,
1351
1418
  ),
1352
1419
  onLegacyDataSpaceChange,
1353
1420
  undefined,
1354
1421
  this.applicationStore.config.options.queryBuilderConfig,
1355
- sourceInfo,
1422
+ sourceInfo ?? {
1423
+ sourceType: LegendQuerySourceType.DATA_PRODUCT,
1424
+ groupId,
1425
+ artifactId,
1426
+ versionId,
1427
+ dataProduct: dataProductPath,
1428
+ accessType: dataProductAccessType,
1429
+ accessId,
1430
+ },
1356
1431
  );
1357
1432
 
1358
1433
  if (
@@ -1449,13 +1524,19 @@ export class MappingQueryCreatorStore extends QueryEditorStore {
1449
1524
  };
1450
1525
  }
1451
1526
 
1452
- async initializeQueryBuilderState(): Promise<QueryBuilderState> {
1453
- const projectInfo = this.getProjectInfo();
1454
- const sourceInfo = {
1455
- groupId: projectInfo.groupId,
1456
- artifactId: projectInfo.artifactId,
1457
- versionId: projectInfo.versionId,
1527
+ override getSourceInfo(): LegendQueryMappingSourceInfo {
1528
+ return {
1529
+ sourceType: LegendQuerySourceType.MAPPING,
1530
+ groupId: this.groupId,
1531
+ artifactId: this.artifactId,
1532
+ versionId: this.versionId,
1533
+ mapping: this.mappingPath,
1534
+ runtime: this.runtimePath,
1458
1535
  };
1536
+ }
1537
+
1538
+ async initializeQueryBuilderState(): Promise<QueryBuilderState> {
1539
+ const sourceInfo = this.getSourceInfo();
1459
1540
  const queryBuilderState = new MappingQueryBuilderState(
1460
1541
  this.applicationStore,
1461
1542
  this.graphManagerState,
@@ -1574,6 +1655,16 @@ export class ServiceQueryCreatorStore extends QueryEditorStore {
1574
1655
  };
1575
1656
  }
1576
1657
 
1658
+ override getSourceInfo(): LegendQueryServiceSourceInfo {
1659
+ return {
1660
+ sourceType: LegendQuerySourceType.SERVICE,
1661
+ groupId: this.groupId,
1662
+ artifactId: this.artifactId,
1663
+ versionId: this.versionId,
1664
+ service: this.servicePath,
1665
+ };
1666
+ }
1667
+
1577
1668
  async initializeQueryBuilderState(): Promise<QueryBuilderState> {
1578
1669
  const service = this.graphManagerState.graph.getService(this.servicePath);
1579
1670
  assertType(
@@ -1582,13 +1673,7 @@ export class ServiceQueryCreatorStore extends QueryEditorStore {
1582
1673
  `Can't process service execution: only Pure execution is supported`,
1583
1674
  );
1584
1675
 
1585
- const projectInfo = this.getProjectInfo();
1586
- const sourceInfo = {
1587
- groupId: projectInfo.groupId,
1588
- artifactId: projectInfo.artifactId,
1589
- versionId: projectInfo.versionId,
1590
- service: service.path,
1591
- };
1676
+ const sourceInfo = this.getSourceInfo();
1592
1677
  const queryBuilderState = new ServiceQueryBuilderState(
1593
1678
  this.applicationStore,
1594
1679
  this.graphManagerState,
@@ -1799,13 +1884,7 @@ export class ExistingQueryUpdateState {
1799
1884
  LegendQueryTelemetryHelper.logEvent_UpdateQuerySucceeded(
1800
1885
  this.editorStore.applicationStore.telemetryService,
1801
1886
  {
1802
- query: {
1803
- id: query.id,
1804
- name: query.name,
1805
- groupId: query.groupId,
1806
- artifactId: query.artifactId,
1807
- versionId: query.versionId,
1808
- },
1887
+ ...buildQueryIdentity(query),
1809
1888
  ...queryBuilderState.getExtraTelemetryMetadata(),
1810
1889
  },
1811
1890
  );
@@ -1819,6 +1898,10 @@ export class ExistingQueryUpdateState {
1819
1898
  error,
1820
1899
  );
1821
1900
  this.editorStore.applicationStore.notificationService.notifyError(error);
1901
+ LegendQueryTelemetryHelper.logEvent_UpdateQueryFailed(
1902
+ this.editorStore.applicationStore.telemetryService,
1903
+ buildQueryLifecycleFailureData(this.editorStore.id, error),
1904
+ );
1822
1905
  } finally {
1823
1906
  this.updateQueryState.complete();
1824
1907
  }
@@ -1848,13 +1931,7 @@ export class ExistingQueryUpdateState {
1848
1931
  LegendQueryTelemetryHelper.logEvent_UpdateQuerySucceeded(
1849
1932
  this.editorStore.applicationStore.telemetryService,
1850
1933
  {
1851
- query: {
1852
- id: updatedQuery.id,
1853
- name: updatedQuery.name,
1854
- groupId: updatedQuery.groupId,
1855
- artifactId: updatedQuery.artifactId,
1856
- versionId: updatedQuery.versionId,
1857
- },
1934
+ ...buildQueryIdentity(updatedQuery),
1858
1935
  ...extraTelemetryMetadata,
1859
1936
  },
1860
1937
  );
@@ -1865,6 +1942,10 @@ export class ExistingQueryUpdateState {
1865
1942
  error,
1866
1943
  );
1867
1944
  this.editorStore.applicationStore.notificationService.notifyError(error);
1945
+ LegendQueryTelemetryHelper.logEvent_UpdateQueryFailed(
1946
+ this.editorStore.applicationStore.telemetryService,
1947
+ buildQueryLifecycleFailureData(queryId, error),
1948
+ );
1868
1949
  } finally {
1869
1950
  this.updateQueryState.complete();
1870
1951
  }
@@ -2002,17 +2083,19 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2002
2083
  this.applicationStore.telemetryService,
2003
2084
  {
2004
2085
  graph: graphBuilderReportData,
2005
- query: {
2006
- id: currentQuery.id,
2007
- name: currentQuery.name,
2008
- groupId: currentQuery.groupId,
2009
- artifactId: currentQuery.artifactId,
2010
- versionId: currentQuery.versionId,
2011
- },
2086
+ ...buildQueryIdentity(currentQuery),
2012
2087
  },
2013
2088
  );
2014
2089
  }
2015
2090
 
2091
+ override getOpenedFrom(): QUERY_BUILDER_OPENED_FROM {
2092
+ return QUERY_BUILDER_OPENED_FROM.QUERY_SAVED;
2093
+ }
2094
+
2095
+ override logInitializeFailureMetrics(): void {
2096
+ // Do nothing: an existing query is not a query creator
2097
+ }
2098
+
2016
2099
  setLightQuery(val: LightQuery): void {
2017
2100
  this._lightQuery = val;
2018
2101
  }
@@ -2162,12 +2245,14 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2162
2245
  runtime,
2163
2246
  );
2164
2247
  if (matchingExecutionContext) {
2165
- const sourceInfo = {
2248
+ const sourceInfo: LegendQueryDataSpaceSourceInfo = {
2249
+ sourceType: LegendQuerySourceType.DATA_SPACE,
2166
2250
  groupId: queryInfo.groupId,
2167
2251
  artifactId: queryInfo.artifactId,
2168
2252
  versionId: queryInfo.versionId,
2169
2253
  queryId: queryInfo.id,
2170
2254
  dataSpace: dataSpace.path,
2255
+ executionContext: exec.executionKey,
2171
2256
  };
2172
2257
  const visitedDataSpaces =
2173
2258
  LegendQueryUserDataHelper.getRecentlyVisitedDataSpaces(
@@ -2264,6 +2349,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2264
2349
  new DataProductSelectorState(
2265
2350
  this.depotServerClient,
2266
2351
  this.applicationStore,
2352
+ this.lakehouseState?.contractServerClient,
2267
2353
  ),
2268
2354
  () => {
2269
2355
  this.applicationStore.notificationService.notifyWarning(
@@ -2318,11 +2404,14 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2318
2404
  }
2319
2405
  } else if (exec instanceof QueryExplicitExecutionContextInfo) {
2320
2406
  const projectInfo = this.getProjectInfo();
2321
- const sourceInfo = {
2407
+ const sourceInfo: LegendQueryMappingSourceInfo = {
2408
+ sourceType: LegendQuerySourceType.MAPPING,
2322
2409
  groupId: projectInfo.groupId,
2323
2410
  artifactId: projectInfo.artifactId,
2324
2411
  versionId: projectInfo.versionId,
2325
2412
  queryId: queryInfo.id,
2413
+ mapping: exec.mapping,
2414
+ runtime: exec.runtime,
2326
2415
  };
2327
2416
  const classQueryBuilderState = new ClassQueryBuilderState(
2328
2417
  this.applicationStore,
@@ -2387,6 +2476,18 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2387
2476
  'Switching data products is not supported from the existing query editor. Please open a new query instead.',
2388
2477
  );
2389
2478
  },
2479
+ undefined,
2480
+ undefined,
2481
+ {
2482
+ sourceType: LegendQuerySourceType.DATA_PRODUCT,
2483
+ groupId: queryInfo.groupId,
2484
+ artifactId: queryInfo.artifactId,
2485
+ versionId: queryInfo.versionId,
2486
+ queryId: queryInfo.id,
2487
+ dataProduct: exec.dataProductPath,
2488
+ accessType,
2489
+ accessId: executionContextId,
2490
+ },
2390
2491
  );
2391
2492
  return queryBuilderState;
2392
2493
  } else if (exec instanceof QueryIngestExecutionContextInfo) {
@@ -2445,11 +2546,14 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2445
2546
  projectInfo,
2446
2547
  this.applicationStore.config.options.queryBuilderConfig,
2447
2548
  {
2549
+ sourceType: LegendQuerySourceType.INGEST,
2448
2550
  groupId: projectInfo.groupId,
2449
2551
  artifactId: projectInfo.artifactId,
2450
2552
  versionId: projectInfo.versionId,
2451
2553
  queryId: queryInfo.id,
2452
- },
2554
+ ingestDefinitionPath: exec.ingestDefinitionPath,
2555
+ dataSet: exec.dataSet,
2556
+ } satisfies LegendQueryIngestSourceInfo,
2453
2557
  );
2454
2558
  await ingestQueryBuilderState.changeAccessorOwner(ingestDefinition);
2455
2559
  await ingestQueryBuilderState.changeAccessor({
@@ -2537,26 +2641,14 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2537
2641
  this.applicationStore.telemetryService,
2538
2642
  {
2539
2643
  ...initailizeQueryStateReport,
2540
- query: {
2541
- id: query.id,
2542
- name: query.name,
2543
- groupId: query.groupId,
2544
- artifactId: query.artifactId,
2545
- versionId: query.versionId,
2546
- },
2644
+ ...buildQueryIdentity(query),
2547
2645
  },
2548
2646
  );
2549
2647
  LegendQueryTelemetryHelper.logEvent_ViewQuerySucceeded(
2550
2648
  this.applicationStore.telemetryService,
2551
2649
  {
2552
2650
  ...report,
2553
- query: {
2554
- id: query.id,
2555
- name: query.name,
2556
- groupId: query.groupId,
2557
- artifactId: query.artifactId,
2558
- versionId: query.versionId,
2559
- },
2651
+ ...buildQueryIdentity(query),
2560
2652
  },
2561
2653
  );
2562
2654
  return queryBuilderState;
@@ -25,8 +25,8 @@ import type { LegendQueryApplicationStore } from './LegendQueryBaseStore.js';
25
25
  import { EXTERNAL_APPLICATION_NAVIGATION__generateStudioProductionizeQueryUrl } from '../__lib__/LegendQueryNavigation.js';
26
26
  import { BaseQuerySetupStore } from './QuerySetupStore.js';
27
27
  import { LegendQueryUserDataHelper } from '../__lib__/LegendQueryUserDataHelper.js';
28
+ import { buildQueryLoaderLifecycleTelemetryHandlers } from '../__lib__/LegendQueryLifecycleTelemetry.js';
28
29
  import { quantifyList } from '@finos/legend-shared';
29
- import { LegendQueryTelemetryHelper } from '../__lib__/LegendQueryTelemetryHelper.js';
30
30
 
31
31
  export class QueryProductionizerSetupStore extends BaseQuerySetupStore {
32
32
  readonly queryLoaderState: QueryLoaderState;
@@ -61,25 +61,13 @@ export class QueryProductionizerSetupStore extends BaseQuerySetupStore {
61
61
  'recently viewed queries',
62
62
  )}`
63
63
  : `No recently viewed queries`,
64
- onQueryDeleted: (queryId): void =>
65
- LegendQueryUserDataHelper.removeRecentlyViewedQuery(
66
- this.applicationStore.userDataService,
67
- queryId,
68
- ),
69
- onQueryRenamed: (query): void => {
70
- LegendQueryTelemetryHelper.logEvent_RenameQuerySucceeded(
71
- applicationStore.telemetryService,
72
- {
73
- query: {
74
- id: query.id,
75
- name: query.name,
76
- groupId: query.groupId,
77
- artifactId: query.artifactId,
78
- versionId: query.versionId,
79
- },
80
- },
81
- );
82
- },
64
+ ...buildQueryLoaderLifecycleTelemetryHandlers(this.applicationStore, {
65
+ onQueryDeleted: (queryId): void =>
66
+ LegendQueryUserDataHelper.removeRecentlyViewedQuery(
67
+ this.applicationStore.userDataService,
68
+ queryId,
69
+ ),
70
+ }),
83
71
  handleFetchDefaultQueriesFailure: (): void =>
84
72
  LegendQueryUserDataHelper.removeRecentlyViewedQueries(
85
73
  this.applicationStore.userDataService,
@@ -81,6 +81,8 @@ export abstract class BaseQuerySetupStore {
81
81
  baseUrl: this.applicationStore.config.engineServerUrl,
82
82
  queryBaseUrl: this.applicationStore.config.engineQueryServerUrl,
83
83
  enableCompression: true,
84
+ useCookieAuthOnly:
85
+ this.applicationStore.config.engineUseCookieAuthOnly,
84
86
  },
85
87
  },
86
88
  {
@@ -23,6 +23,10 @@ import { generateDataProductSampleQueryRoute } from '../../__lib__/LegendQueryNa
23
23
  import { DataProductSelectorState } from '../data-space/DataProductSelectorState.js';
24
24
  import { createQueryDataProductTaggedValue } from '../../components/data-product/QueryDataProductUtil.js';
25
25
  import { BaseTemplateQueryCreatorStore } from '../BaseTemplateQueryCreatorStore.js';
26
+ import {
27
+ type LegendQueryDataProductSampleSourceInfo,
28
+ LegendQuerySourceType,
29
+ } from '../../__lib__/LegendQuerySourceInfo.js';
26
30
 
27
31
  export class DataProductSampleQueryCreatorStore extends BaseTemplateQueryCreatorStore {
28
32
  readonly dataProductPath: string;
@@ -77,6 +81,17 @@ export class DataProductSampleQueryCreatorStore extends BaseTemplateQueryCreator
77
81
  return [createQueryDataProductTaggedValue(this.dataProductPath)];
78
82
  }
79
83
 
84
+ override getSourceInfo(): LegendQueryDataProductSampleSourceInfo {
85
+ return {
86
+ sourceType: LegendQuerySourceType.DATA_PRODUCT_SAMPLE,
87
+ groupId: this.groupId,
88
+ artifactId: this.artifactId,
89
+ versionId: this.versionId,
90
+ dataProduct: this.dataProductPath,
91
+ sampleQueryId: this.templateQueryId,
92
+ };
93
+ }
94
+
80
95
  async initializeQueryBuilderState(): Promise<QueryBuilderState> {
81
96
  const artifact = await this.fetchDataProductArtifact(
82
97
  this.groupId,
@@ -120,7 +135,9 @@ export class DataProductSampleQueryCreatorStore extends BaseTemplateQueryCreator
120
135
  new DataProductSelectorState(
121
136
  this.depotServerClient,
122
137
  this.applicationStore,
138
+ this.lakehouseState?.contractServerClient,
123
139
  ),
140
+ this.getSourceInfo(),
124
141
  );
125
142
 
126
143
  const query = await this.graphManagerState.graphManager.pureCodeToLambda(