This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(telemetry): added server init & app routes telemetry views (and …
…events)
- Loading branch information
1 parent
fba29e8
commit f8286b1
Showing
5 changed files
with
64 additions
and
33 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,37 @@ | ||
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( { | ||
app_key: '6b79ee267ff23c4b99108591c5b33f0ba8ed5e4b', | ||
url: 'https://telemetry.speckle.works', | ||
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 { | ||
logger.info( 'Failed to initialise route based telemetry.' ) | ||
} | ||
} ) | ||
} catch { | ||
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
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