mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
add basic debugger analytics
This commit is contained in:
@@ -8,10 +8,11 @@ const timeLabels = new Map();
|
||||
let session_start = Date.now();
|
||||
|
||||
/**
|
||||
* @param {string} t
|
||||
* @param {string} u
|
||||
* @param {string} s
|
||||
* @param {{name:string,version:string}} package_json
|
||||
* @param {string} [t]
|
||||
* @param {string} [u]
|
||||
* @param {string} [s]
|
||||
* @param {{name:string,version:string}} [package_json]
|
||||
* @param {*} [props]
|
||||
*/
|
||||
function init(t = '0cca95950055c6553804a46ce7e3df18', u, s, package_json, props) {
|
||||
if (mp) {
|
||||
@@ -20,10 +21,15 @@ function init(t = '0cca95950055c6553804a46ce7e3df18', u, s, package_json, props)
|
||||
try {
|
||||
mp = require('mixpanel').init(t);
|
||||
}
|
||||
catch {}
|
||||
catch {
|
||||
return;
|
||||
}
|
||||
uid = u;
|
||||
sid = s;
|
||||
|
||||
if (!props) {
|
||||
return;
|
||||
}
|
||||
const os = require('os');
|
||||
event(`${package_json.name}-start`, {
|
||||
extension: package_json.name,
|
||||
@@ -56,7 +62,7 @@ function event(eventName, properties) {
|
||||
...properties,
|
||||
});
|
||||
} else {
|
||||
mp.track(eventName);
|
||||
mp.track(eventName, properties);
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ class APKFileInfo {
|
||||
*/
|
||||
file_data = null;
|
||||
|
||||
/**
|
||||
* The size of the APK file (in bytes)
|
||||
*/
|
||||
file_size = 0;
|
||||
|
||||
/**
|
||||
* last modified time of the APK file (in ms)
|
||||
*/
|
||||
@@ -67,6 +72,7 @@ class APKFileInfo {
|
||||
// read the APK file contents
|
||||
try {
|
||||
result.file_data = await readFile(args.apkFile);
|
||||
result.file_size = result.file_data.length;
|
||||
} catch(err) {
|
||||
throw new Error(`APK read error. ${err.message}`);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const {
|
||||
// node and external modules
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const uuidv4 = require('uuid').v4;
|
||||
|
||||
// our stuff
|
||||
const { ADBClient } = require('./adbclient');
|
||||
@@ -20,6 +21,7 @@ const { checkADBStarted, getAndroidSourcesFolder } = require('./utils/android');
|
||||
const { D, initLogToClient, onMessagePrint } = require('./utils/print');
|
||||
const { hasValidSourceFileExtension } = require('./utils/source-file');
|
||||
const { VariableManager } = require('./variable-manager');
|
||||
const analytics = require('../langserver/analytics');
|
||||
|
||||
class AndroidDebugSession extends DebugSession {
|
||||
|
||||
@@ -107,6 +109,10 @@ class AndroidDebugSession extends DebugSession {
|
||||
*/
|
||||
this.debug_mode = null;
|
||||
|
||||
this.session_id = uuidv4();
|
||||
this.session_start = new Date();
|
||||
analytics.init();
|
||||
|
||||
// this debugger uses one-based lines and columns
|
||||
this.setDebuggerLinesStartAt1(true);
|
||||
this.setDebuggerColumnsStartAt1(true);
|
||||
@@ -417,6 +423,14 @@ class AndroidDebugSession extends DebugSession {
|
||||
this.LOG(`Debugger attached`);
|
||||
await this.dbgr.resume();
|
||||
|
||||
analytics.event('debug-started', {
|
||||
dbg_session_id: this.session_id,
|
||||
dbg_start: this.session_start.toLocaleTimeString(),
|
||||
dbg_tz: this.session_start.getTimezoneOffset(),
|
||||
dbg_kind: 'attach',
|
||||
dbg_device_api: this.device_api_level,
|
||||
dbg_emulator: /^emulator/.test(this._device.serial),
|
||||
})
|
||||
} catch(e) {
|
||||
//this.performDisconnect();
|
||||
// exceptions use message, adbclient uses msg
|
||||
@@ -558,6 +572,17 @@ class AndroidDebugSession extends DebugSession {
|
||||
this.sendResponse(response);
|
||||
await this.dbgr.resume();
|
||||
|
||||
analytics.event('debug-started', {
|
||||
dbg_session_id: this.session_id,
|
||||
dbg_start: this.session_start.toLocaleTimeString(),
|
||||
dbg_tz: this.session_start.getTimezoneOffset(),
|
||||
dbg_kind: 'debug',
|
||||
dbg_device_api: this.device_api_level,
|
||||
dbg_emulator: /^emulator/.test(this._device.serial),
|
||||
dbg_apk_size: this.apk_file_info.file_size,
|
||||
dbg_pkg_name: this.apk_file_info.manifest.package || '',
|
||||
})
|
||||
|
||||
this.LOG('Application started');
|
||||
} catch(e) {
|
||||
// exceptions use message, adbclient uses msg
|
||||
@@ -748,6 +773,10 @@ class AndroidDebugSession extends DebugSession {
|
||||
async disconnectRequest(response) {
|
||||
D('disconnectRequest');
|
||||
this._isDisconnecting = true;
|
||||
analytics.event('debug-end', {
|
||||
dbg_session_id: this.session_id,
|
||||
dbg_elapsed: Math.trunc((Date.now() - this.session_start.getTime())/1e3),
|
||||
});
|
||||
if (this.debuggerAttached) {
|
||||
try {
|
||||
if (this.debug_mode === 'launch') {
|
||||
|
||||
Reference in New Issue
Block a user