Skip to content

Instantly share code, notes, and snippets.

@yoadsn
Last active September 3, 2018 17:29
Show Gist options
  • Select an option

  • Save yoadsn/2e035e67ada1b80cde874f8918520b9f to your computer and use it in GitHub Desktop.

Select an option

Save yoadsn/2e035e67ada1b80cde874f8918520b9f to your computer and use it in GitHub Desktop.
AppInsights - Bot Type Processor
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