forked from speckleworks/SpeckleServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request speckleworks#162 from speckleworks/Dimitrie/dev/te…
…lemetry Dimitrie/dev/telemetry
- Loading branch information
Showing
7 changed files
with
133 additions
and
14 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
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,42 @@ | ||
const countly = require( 'countly-sdk-nodejs' ) | ||
const myMachineId = require( 'node-machine-id' ).machineIdSync( ) | ||
|
||
const logger = require( '../../config/logger' ) | ||
|
||
// This module lets us know which routes are hit on a server, thus aggregating | ||
// the "hot" endpoints. | ||
|
||
module.exports = ( app ) => { | ||
|
||
if ( process.env.TELEMETRY === 'false' ) | ||
return | ||
|
||
try { | ||
countly.init( { | ||
// eslint-disable-next-line camelcase | ||
app_key: '6b79ee267ff23c4b99108591c5b33f0ba8ed5e4b', | ||
url: 'https://telemetry.speckle.works', | ||
// eslint-disable-next-line camelcase | ||
device_id: myMachineId, | ||
debug: false | ||
} ) | ||
|
||
countly.user_details( { | ||
'username': myMachineId | ||
} ) | ||
|
||
app.use( ( req, res, next ) => { | ||
|
||
next( ) // let's not block things, in case telemetry server is down. | ||
|
||
try { | ||
countly.track_view( `${req.method} "${req.route.path}"` ) | ||
} catch ( err ) { | ||
logger.info( 'Failed to initialise route based telemetry.' ) | ||
} | ||
|
||
} ) | ||
} catch ( err ) { | ||
logger.info( 'Failed to initialise route based telemetry.' ) | ||
} | ||
} |
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,55 @@ | ||
const countly = require( 'countly-sdk-nodejs' ) | ||
const machineIdSync = require( 'node-machine-id' ).machineIdSync | ||
const { exec } = require( 'child_process' ) | ||
|
||
const logger = require( '../../config/logger' ) | ||
|
||
// This module lets us know the version of the running server, and how many times | ||
// it's initialised. | ||
module.exports = ( ) => { | ||
|
||
if ( process.env.TELEMETRY === 'false' ) | ||
return | ||
|
||
let myMachineId = machineIdSync( ) | ||
let tagVersion = 'unknown' | ||
|
||
try { | ||
exec( 'git describe --tags', ( err, stdout ) => { | ||
tagVersion = stdout.split( '-' )[ 0 ] | ||
logger.info( `Version: ${tagVersion}` ) | ||
|
||
countly.init( { | ||
// eslint-disable-next-line camelcase | ||
app_key: '6b79ee267ff23c4b99108591c5b33f0ba8ed5e4b', | ||
url: 'https://telemetry.speckle.works', | ||
// eslint-disable-next-line camelcase | ||
device_id: myMachineId, | ||
// eslint-disable-next-line camelcase | ||
app_version: tagVersion, | ||
debug: false | ||
} ) | ||
|
||
countly.user_details( { | ||
'username': myMachineId | ||
} ) | ||
|
||
countly.add_event( { | ||
"key": "server-deployment", | ||
"segmentation": { | ||
"machineId": myMachineId, | ||
"version": tagVersion | ||
} | ||
} ) | ||
|
||
// one view to track version | ||
countly.track_view( `SERVER DEPLOYMENT versioned at ${tagVersion}` ) | ||
|
||
// one view to track generic usage, regardless of version | ||
countly.track_view( `SERVER DEPLOYMENT generic` ) | ||
|
||
} ) | ||
} catch ( err ) { | ||
logger.error( err ) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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