Last active
September 3, 2018 17:29
-
-
Save yoadsn/2e035e67ada1b80cde874f8918520b9f to your computer and use it in GitHub Desktop.
AppInsights - Bot Type Processor
This file contains hidden or 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
| const appendUserAgent = (envelope, context) => { | |
| if (envelope.data.baseType === 'RequestData') { | |
| // headers are available on the context - but are not reported | |
| const ua = context['http.ServerRequest'].headers['user-agent']; | |
| if (ua) { | |
| // Extract the bot type (google only in that case) | |
| const botType = getGoogleBotType(ua); | |
| if (botType) { | |
| // The reporting would not include the bot type data point with the request. | |
| envelope.data.baseData.properties['bot-type'] = botType; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment