Skip to content

Commit

Permalink
add source to gallery query telemetry event
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Apr 25, 2022
1 parent 6f26fa1 commit fef2fb9
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ interface IQueryState {
readonly flags: Flags;
readonly criteria: ICriterium[];
readonly assetTypes: string[];
readonly source?: string;
}

const DefaultQueryState: IQueryState = {
Expand All @@ -246,6 +247,7 @@ type GalleryServiceQueryClassification = {
readonly statusCode?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
readonly errorCode?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
readonly count?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
readonly source?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
};

type QueryTelemetryData = {
Expand All @@ -254,6 +256,7 @@ type QueryTelemetryData = {
readonly sortBy: string;
readonly sortOrder: string;
readonly pageNumber: string;
readonly source?: string;
};

type GalleryServiceQueryEvent = QueryTelemetryData & {
Expand Down Expand Up @@ -322,6 +325,10 @@ class Query {
return new Query({ ...this.state, assetTypes });
}

withSource(source: string): Query {
return new Query({ ...this.state, source });
}

get raw(): any {
const { criteria, pageNumber, pageSize, sortBy, sortOrder, flags, assetTypes } = this.state;
const filters = [{ criteria, pageNumber, pageSize, sortBy, sortOrder }];
Expand All @@ -339,7 +346,8 @@ class Query {
flags: this.state.flags,
sortBy: String(this.sortBy),
sortOrder: String(this.sortOrder),
pageNumber: String(this.pageNumber)
pageNumber: String(this.pageNumber),
source: this.state.source
};
}
}
Expand Down Expand Up @@ -600,6 +608,9 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
if (options.queryAllVersions || isQueryForReleaseVersionFromPreReleaseVersion /* Inlcude all versions if every requested extension is for release version and has pre-release version */) {
query = query.withFlags(query.flags, Flags.IncludeVersions);
}
if (options.source) {
query = query.withSource(options.source);
}

const { extensions } = await this.queryGalleryExtensions(query, { targetPlatform: options.targetPlatform ?? CURRENT_TARGET_PLATFORM, includePreRelease: includePreReleases, versions, compatible: !!options.compatible }, token);
if (options.source) {
Expand Down Expand Up @@ -717,6 +728,10 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
query = query.withSortOrder(options.sortOrder);
}

if (options.source) {
query = query.withSource(options.source);
}

const runQuery = async (query: Query, token: CancellationToken) => {
const { extensions, total } = await this.queryGalleryExtensions(query, { targetPlatform: CURRENT_TARGET_PLATFORM, compatible: false, includePreRelease: !!options.includePreRelease }, token);
extensions.forEach((e, index) => setTelemetry(e, ((query.pageNumber - 1) * query.pageSize) + index, options.source));
Expand Down

0 comments on commit fef2fb9

Please sign in to comment.