in src/chromeDebugAdapter.ts [231:320]
protected doAttach(port: number, targetUrl?: string, address?: string, timeout?: number, websocketUrl?: string, extraCRDPChannelPort?: number): Promise<void> {
return super.doAttach(port, targetUrl, address, timeout, websocketUrl, extraCRDPChannelPort).then(async () => {
// Don't return this promise, a failure shouldn't fail attach
this.globalEvaluate({ expression: 'navigator.userAgent', silent: true })
.then(
evalResponse => logger.log('Target userAgent: ' + evalResponse.result.value),
err => logger.log('Getting userAgent failed: ' + err.message))
.then(() => {
const configDisableNetworkCache = (<ICommonRequestArgs>this._launchAttachArgs).disableNetworkCache;
const cacheDisabled = typeof configDisableNetworkCache === 'boolean' ?
configDisableNetworkCache :
true;
this.chrome.Network.setCacheDisabled({ cacheDisabled }).catch(() => {
// Ignore failure
});
});
const versionInformationPromise = this.chrome.Browser.getVersion().then(
response => {
const properties = {
'Versions.Target.CRDPVersion': response.protocolVersion,
'Versions.Target.Revision': response.revision,
'Versions.Target.UserAgent': response.userAgent,
'Versions.Target.V8': response.jsVersion
};
const parts = (response.product || '').split('/');
if (parts.length === 2) { // Currently response.product looks like "Chrome/65.0.3325.162" so we split the project and the actual version number
properties['Versions.Target.Project'] = parts[0];
properties['Versions.Target.Version'] = parts[1];
} else { // If for any reason that changes, we submit the entire product as-is
properties['Versions.Target.Product'] = response.product;
}
return properties;
},
err => {
logger.log('Getting userAgent failed: ' + err.message);
const properties = { 'Versions.Target.NoUserAgentReason': 'Error while retriving target user agent' } as telemetry.IExecutionResultTelemetryProperties;
coreUtils.fillErrorDetails(properties, err);
return properties;
});
// Send the versions information as it's own event so we can easily backfill other events in the user session if needed
/* __GDPR__FRAGMENT__
"VersionInformation" : {
"Versions.Target.CRDPVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.Revision" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.UserAgent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.V8" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.V<NUMBER>" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.Project" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.Version" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.Product" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"Versions.Target.NoUserAgentReason" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"${include}": [ "${IExecutionResultTelemetryProperties}" ]
}
*/
/* __GDPR__
"target-version" : {
"${include}": [ "${DebugCommonProperties}" ]
}
*/
versionInformationPromise.then(versionInformation => telemetry.telemetry.reportEvent('target-version', versionInformation));
try {
if (this._breakOnLoadHelper) {
// This is what -core is doing. We only actually care to see if this fails, to see if we need to apply the workaround
const browserVersion = (await this._chromeConnection.version).browser;
if (!browserVersion.isAtLeastVersion(0, 1)) { // If this is true it means it's unknown version
logger.log(`/json/version failed, attempting workaround to get the version`);
// If the original way failed, we try to use versionInformationPromise to get this information
const versionInformation = await versionInformationPromise;
const alternativeBrowserVersion = Version.parse(versionInformation['Versions.Target.Version']);
this._breakOnLoadHelper.setBrowserVersion(alternativeBrowserVersion);
}
}
} catch (exception) {
// If something fails we report telemetry and we ignore it
telemetry.telemetry.reportEvent('break-on-load-target-version-workaround-failed', exception);
}
/* __GDPR__FRAGMENT__
"DebugCommonProperties" : {
"${include}": [ "${VersionInformation}" ]
}
*/
telemetry.telemetry.addCustomGlobalProperty(versionInformationPromise);
});
}