From e07556d3bd8184d032321e11996c66e51125dc11 Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Tue, 13 Dec 2022 13:55:50 -0700 Subject: [PATCH 1/2] fix: always send deploy event and fix telemetry for mdapi deploy --- src/client/index.ts | 2 ++ src/client/metadataApiDeploy.ts | 34 ++++++++++++++++++++++----------- src/client/types.ts | 11 +++++++++++ src/index.ts | 2 ++ 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/client/index.ts b/src/client/index.ts index 8063b27e47..9c10133cd7 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -46,4 +46,6 @@ export { PackageOption, PackageOptions, RetrieveOptions, + DeployVersionData, + RetrieveVersionData, } from './types'; diff --git a/src/client/metadataApiDeploy.ts b/src/client/metadataApiDeploy.ts index cac8816386..efae522930 100644 --- a/src/client/metadataApiDeploy.ts +++ b/src/client/metadataApiDeploy.ts @@ -5,6 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { basename, dirname, extname, join, posix, sep } from 'path'; +import { format } from 'util'; import { isString } from '@salesforce/ts-types'; import { create as createArchive } from 'archiver'; import * as fs from 'graceful-fs'; @@ -353,14 +354,13 @@ export class MetadataApiDeploy extends MetadataTransfer { const lifecycle = Lifecycle.getInstance(); try { + const connection = await this.getConnection(); + const apiVersion = connection.getApiVersion(); // Creates an array of unique metadata types that were deployed, uses Set to avoid duplicates. - const listOfMetadataTypesDeployed = Array.from(new Set(this.options.components.map((c) => c.type.name))); + let listOfMetadataTypesDeployed: string[]; + if (this.options.components) { + listOfMetadataTypesDeployed = Array.from(new Set(this.options.components.map((c) => c.type.name))); + } else { + // mdapi deploys don't have a ComponentSet, so using the result + const types = new Set(); + const successes = ensureArray(result.details?.componentSuccesses); + const failures = ensureArray(result.details?.componentFailures); + [...successes, ...failures].forEach((c) => c.componentType && types.add(c.componentType)); + listOfMetadataTypesDeployed = Array.from(types); + } void lifecycle.emitTelemetry({ eventName: 'metadata_api_deploy_result', library: 'SDR', status: result.status, - apiVersion: this.options.apiVersion, - sourceApiVersion: this.options.components?.sourceApiVersion, + apiVersion, + sourceApiVersion: this.components?.sourceApiVersion, createdDate: result.createdDate, startDate: result.startDate, completedDate: result.completedDate, diff --git a/src/client/types.ts b/src/client/types.ts index e7f5729028..2ec0e405cd 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -356,3 +356,14 @@ export interface ListMetadataQuery { type: string; folder?: string; } + +export interface DeployVersionData { + apiVersion: string; + manifestVersion: string | undefined; + webService: 'SOAP' | 'REST'; +} + +export interface RetrieveVersionData { + apiVersion: string; + manifestVersion: string; +} diff --git a/src/index.ts b/src/index.ts index 57a459bdff..4e60c016fa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,6 +41,8 @@ export { PackageOption, PackageOptions, RetrieveOptions, + DeployVersionData, + RetrieveVersionData, } from './client'; export { MetadataConverter, From aa1d6a7ab00986502b4aa376f73f639e4cdba2b1 Mon Sep 17 00:00:00 2001 From: svc-cli-bot Date: Tue, 13 Dec 2022 21:10:11 +0000 Subject: [PATCH 2/2] test: record perf --- .../eda.json | 8 ++++---- .../lotsOfClasses.json | 8 ++++---- .../lotsOfClassesOneDir.json | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/eda.json b/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/eda.json index f5bf769341..f0c6c1cdc3 100644 --- a/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/eda.json +++ b/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/eda.json @@ -1,18 +1,18 @@ [ { "name": "componentSetCreate", - "duration": 206.5693120000069 + "duration": 207.28292900000815 }, { "name": "sourceToMdapi", - "duration": 4943.071838999982 + "duration": 5269.58986800001 }, { "name": "sourceToZip", - "duration": 4826.46210199999 + "duration": 5145.71405000001 }, { "name": "mdapiToSource", - "duration": 3256.713862000004 + "duration": 3490.6539969999867 } ] \ No newline at end of file diff --git a/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClasses.json b/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClasses.json index 9710429e94..a28e9dde9c 100644 --- a/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClasses.json +++ b/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClasses.json @@ -1,18 +1,18 @@ [ { "name": "componentSetCreate", - "duration": 384.5527920000022 + "duration": 402.4377370000002 }, { "name": "sourceToMdapi", - "duration": 6970.504320000007 + "duration": 7953.675813999987 }, { "name": "sourceToZip", - "duration": 6130.4723740000045 + "duration": 6505.835978999996 }, { "name": "mdapiToSource", - "duration": 4920.01653100003 + "duration": 4109.450435000006 } ] \ No newline at end of file diff --git a/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClassesOneDir.json b/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClassesOneDir.json index 2294111997..132951c09b 100644 --- a/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClassesOneDir.json +++ b/test/nuts/perfResults/x64-linux-2xIntel-Xeon-Platinum-8370C-CPU-2-80GHz/lotsOfClassesOneDir.json @@ -1,18 +1,18 @@ [ { "name": "componentSetCreate", - "duration": 681.8188979999977 + "duration": 681.3880480000225 }, { "name": "sourceToMdapi", - "duration": 10472.678083999956 + "duration": 10064.488008000015 }, { "name": "sourceToZip", - "duration": 8984.845709999965 + "duration": 9558.054119999986 }, { "name": "mdapiToSource", - "duration": 10057.14215899998 + "duration": 7265.466457000002 } ] \ No newline at end of file