Skip to content

Commit

Permalink
Add $useragent when user agent is available
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvuerings committed Jan 6, 2024
1 parent de5c37d commit 8d8f4a8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/__tests__/posthog-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ describe('posthog core', () => {
const event = given.subject()
expect(hook).toHaveBeenCalledWith('$event')
expect(event.properties['$browser_type']).toEqual('bot')
expect(event.properties['$useragent']).toContain('Googlebot')

// eslint-disable-next-line no-import-assign
globals['userAgent'] = originalUseragent
Expand Down
1 change: 1 addition & 0 deletions src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ export class PostHog {
properties['$browser_type'] = _isBlockedUA(userAgent, this.config.custom_blocked_useragents)
? 'bot'
: 'browser'
properties['$useragent'] = userAgent
}

// note: extend writes to the first object, so lets make sure we
Expand Down

0 comments on commit 8d8f4a8

Please sign in to comment.