-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added initial framework * Add handling for each message type * Fix getting current extension version * Return a new object for tracking params * Refactor to use VSCode API for telemetry * Add popup to ask for consent and update docs * Update to use better precompile directives * fix typo in README
- Loading branch information
1 parent
1c87bb1
commit 3b77ba1
Showing
11 changed files
with
278 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
skyline-vscode/src/version.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import * as esbuild from 'esbuild'; | ||
import ifdefPlugin from 'esbuild-ifdef'; | ||
|
||
let baseOptions = { | ||
entryPoints: ['./src/extension.js'], | ||
bundle: true, | ||
outfile: 'out/main.js', | ||
external: ['vscode'], | ||
format: 'cjs', | ||
platform: "node" | ||
}; | ||
|
||
let watchPlugin = [ | ||
ifdefPlugin({ | ||
variables: { | ||
DEBUG: true | ||
} | ||
}) | ||
]; | ||
|
||
let productionPlugin = [ | ||
ifdefPlugin({ | ||
variables: { | ||
DEBUG: false | ||
} | ||
}) | ||
]; | ||
|
||
let builds = { | ||
'base': { | ||
...baseOptions, | ||
sourcemap: true | ||
}, | ||
'debug': { | ||
...baseOptions, | ||
sourcemap: true, | ||
plugins: watchPlugin | ||
}, | ||
'production': { | ||
...baseOptions, | ||
minify: true, | ||
plugins: productionPlugin | ||
} | ||
}; | ||
|
||
try { | ||
|
||
|
||
await esbuild.build(builds[process.argv[2]]); | ||
} catch (error) { | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { SegmentInitializer } from "./SegmentInitializer"; | ||
import Analytics from "@segment/analytics-node"; | ||
import { filterObjectByKeyName } from "../utils"; | ||
export class AnalyticsManager { | ||
|
||
analytics: Analytics; | ||
hasIdentifiedUser: boolean; | ||
userId: string; | ||
|
||
constructor() { | ||
this.analytics = SegmentInitializer.initialize(); | ||
this.hasIdentifiedUser = false; | ||
this.userId = String(); | ||
} | ||
|
||
sendEventData = (eventName: string, data?: Record<string, any>) => { | ||
this.identifyUser(data); | ||
/// #if DEBUG | ||
console.log("Event!"); | ||
console.log({ | ||
userId: this.userId, | ||
event: eventName, | ||
timestamp: new Date(), | ||
properties: data | ||
}); | ||
/// #else | ||
this.analytics.track({ | ||
userId: this.userId, | ||
event: eventName, | ||
timestamp: new Date(), | ||
properties: data | ||
}); | ||
/// #endif | ||
}; | ||
|
||
sendErrorData = (error: Error, data?: Record<string, any>) => { | ||
this.identifyUser(data); | ||
/// #if DEBUG | ||
console.log("Error!"); | ||
console.log({ | ||
userId: this.userId, | ||
event: "Client Error", | ||
timestamp: new Date(), | ||
properties: {... data, ...error} | ||
}); | ||
/// #else | ||
this.analytics.track({ | ||
userId: this.userId, | ||
event: "Client Error", | ||
timestamp: new Date(), | ||
properties: {... data, ...error} | ||
}); | ||
/// #endif | ||
}; | ||
|
||
closeAndFlush = () => { | ||
this.analytics.closeAndFlush(); | ||
}; | ||
|
||
identifyUser(data?: Record<string, any>) { | ||
if (!this.hasIdentifiedUser && data) { | ||
this.userId = data["common.vscodemachineid"]; | ||
const commonTraits = filterObjectByKeyName(data, "common."); | ||
this.hasIdentifiedUser = true; | ||
/// #if DEBUG | ||
console.log("Identifying!"); | ||
console.log({ userId: this.userId, traits:commonTraits }); | ||
/// #else | ||
this.analytics.identify({ userId: this.userId, traits:commonTraits }); | ||
/// #endif | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Analytics, AnalyticsSettings } from '@segment/analytics-node' | ||
|
||
|
||
export namespace SegmentInitializer { | ||
export function initialize(): Analytics { | ||
// TODO: make sure the key is inside package.json and validate it | ||
let analyticsSettings: AnalyticsSettings = {writeKey: 'sOQXQfqVkpJxVqKbL0tbwkO6SFnpm5Ef', maxEventsInBatch: 10, flushInterval: 10000} | ||
let analytics: Analytics = new Analytics(analyticsSettings); | ||
return analytics; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Usage data being collected by CentML | ||
Only anonymous data is collected by CentML using VSCode's Telemetry API. All telemetry events are automatically sanitized to anonymize all paths (best effort) and references to the username. | ||
|
||
### Common data | ||
The common data sent in all telemetry requests may contain: | ||
- **Extension Name** `common.extname` - The extension name | ||
- **Extension Version** `common.extversion` - The extension version | ||
- **Machine Identifier** `common.vscodemachineid` - A common machine identifier generated by VS Code | ||
- **Session Identifier** `common.vscodesessionid` - A session identifier generated by VS Code | ||
- **VS Code Version** `common.vscodeversion` - The version of VS Code running the extension | ||
- **OS** `common.os` - The OS running VS Code | ||
- **Platform Version** `common.platformversion` - The version of the OS/Platform | ||
- **Product** `common.product` - What Vs code is hosted in, i.e. desktop, github.dev, codespaces. | ||
- **UI Kind** `common.uikind` - Web or Desktop indicating where VS Code is running | ||
- **Remote Name** `common.remotename` - A name to identify the type of remote connection. `other` indicates a remote connection not from the 3 main extensions (ssh, docker, wsl). | ||
- **Architecture** `common.nodeArch` - What architecture of node is running. i.e. arm or x86. On the web it will just say `web`. | ||
|
||
### Usage data | ||
The usage data sent contains the responses given by the DeepView.Profile | ||
|
||
### Error data | ||
The error data sent contains all error information thrown by the extension. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.