You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.9 KiB

  1. // 'use strict';
  2. // import * as os from 'os';
  3. // import { env, version, workspace } from 'vscode';
  4. // import { configuration } from './configuration';
  5. // import { Logger } from './logger';
  6. // import { Strings } from './system';
  7. // let _reporter: TelemetryReporter | undefined;
  8. // export class Telemetry {
  9. // static configure(key: string) {
  10. // if (!configuration.get<boolean>(configuration.name('advanced')('telemetry')('enabled').value) ||
  11. // !workspace.getConfiguration('telemetry').get<boolean>('enableTelemetry', true)) {
  12. // return;
  13. // }
  14. // const start = process.hrtime();
  15. // _reporter = new TelemetryReporter(key);
  16. // Logger.log(`Telemetry.configure ${GlyphChars.Dot} ${Strings.getDurationMilliseconds(start)} ms`);
  17. // }
  18. // static setContext(context?: { [key: string]: string }) {
  19. // if (_reporter === undefined) return;
  20. // _reporter.setContext(context);
  21. // }
  22. // static trackEvent(name: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number; }) {
  23. // if (_reporter === undefined) return;
  24. // _reporter.trackEvent(name, properties, measurements);
  25. // }
  26. // static trackException(ex: Error) {
  27. // if (_reporter === undefined) return;
  28. // _reporter.trackException(ex);
  29. // }
  30. // }
  31. // export class TelemetryReporter {
  32. // private appInsights: ApplicationInsights;
  33. // private _client: Client;
  34. // private _context: { [key: string]: string };
  35. // constructor(key: string) {
  36. // const diagChannelState = process.env['APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL'];
  37. // (process.env['APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL'] as any) = true;
  38. // this.appInsights = require('applicationinsights') as ApplicationInsights;
  39. // process.env['APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL'] = diagChannelState;
  40. // if (this.appInsights.client) {
  41. // this._client = this.appInsights.getClient(key);
  42. // // no other way to enable offline mode
  43. // this._client.channel.setOfflineMode(true);
  44. // }
  45. // else {
  46. // this._client = this.appInsights.setup(key)
  47. // .setAutoCollectRequests(false)
  48. // .setAutoCollectPerformance(false)
  49. // .setAutoCollectExceptions(false)
  50. // .setAutoCollectDependencies(false)
  51. // .setAutoCollectConsole(false)
  52. // .setAutoDependencyCorrelation(false)
  53. // .setOfflineMode(true)
  54. // .start()
  55. // .client;
  56. // }
  57. // this.setContext();
  58. // this.stripPII(this._client);
  59. // }
  60. // setContext(context?: { [key: string]: string }) {
  61. // if (!this._context) {
  62. // this._context = Object.create(null);
  63. // // Add vscode properties
  64. // this._context['code.language'] = env.language;
  65. // this._context['code.version'] = version;
  66. // this._context[this._client.context.keys.sessionId] = env.sessionId;
  67. // // Add os properties
  68. // this._context['os.platform'] = os.platform();
  69. // this._context['os.version'] = os.release();
  70. // }
  71. // if (context) {
  72. // Object.assign(this._context, context);
  73. // }
  74. // Object.assign(this._client.commonProperties, this._context);
  75. // }
  76. // trackEvent(name: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number; }) {
  77. // this._client.trackEvent(name, properties, measurements);
  78. // }
  79. // trackException(ex: Error) {
  80. // this._client.trackException(ex);
  81. // }
  82. // private stripPII(client: Client) {
  83. // if (client && client.context && client.context.keys && client.context.tags) {
  84. // const machineNameKey = client.context.keys.deviceMachineName;
  85. // client.context.tags[machineNameKey] = '';
  86. // }
  87. // }
  88. // }