-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include raw user agent in event properties (#868)
* fix: include raw user agent in event properties * remove old js tests
- Loading branch information
1 parent
bf81856
commit 97029d9
Showing
3 changed files
with
33 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { _info } from '../../utils/event-utils' | ||
import * as globals from '../../utils/globals' | ||
|
||
jest.mock('../../utils/globals') | ||
|
||
describe(`event-utils`, () => { | ||
it('should have $host and $pathname in properties', () => { | ||
const properties = _info.properties() | ||
expect(properties['$current_url']).toBeDefined() | ||
expect(properties['$host']).toBeDefined() | ||
expect(properties['$pathname']).toBeDefined() | ||
}) | ||
|
||
it('should have user agent in properties', () => { | ||
// TS doesn't like it but we can assign userAgent | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
globals['userAgent'] = 'blah' | ||
const properties = _info.properties() | ||
expect(properties['$raw_user_agent']).toBe('blah') | ||
}) | ||
|
||
it('should truncate very long user agents in properties', () => { | ||
// TS doesn't like it but we can assign userAgent | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
globals['userAgent'] = 'a'.repeat(1001) | ||
const properties = _info.properties() | ||
expect(properties['$raw_user_agent'].length).toBe(1000) | ||
expect(properties['$raw_user_agent'].substring(995)).toBe('aa...') | ||
}) | ||
}) |
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