chore update user agent payload
This commit is contained in:
@@ -225,14 +225,18 @@ class WakaTimeCore {
|
|||||||
*/
|
*/
|
||||||
preparePayload(heartbeat: SendHeartbeat, type: string): Record<string, unknown> {
|
preparePayload(heartbeat: SendHeartbeat, type: string): Record<string, unknown> {
|
||||||
let browserName = 'chrome';
|
let browserName = 'chrome';
|
||||||
|
let userAgent;
|
||||||
if (navigator.userAgent.includes('Firefox')) {
|
if (navigator.userAgent.includes('Firefox')) {
|
||||||
browserName = 'firefox';
|
browserName = 'firefox';
|
||||||
|
userAgent = navigator.userAgent.match(/Firefox\/\S+/g)![0];
|
||||||
|
} else {
|
||||||
|
userAgent = navigator.userAgent.match(/Chrome\/\S+/g)![0];
|
||||||
}
|
}
|
||||||
const payload: Record<string, unknown> = {
|
const payload: Record<string, unknown> = {
|
||||||
entity: heartbeat.url,
|
entity: heartbeat.url,
|
||||||
time: moment().format('X'),
|
time: moment().format('X'),
|
||||||
type: type,
|
type: type,
|
||||||
user_agent: `${navigator.userAgent} ${browserName}-wakatime/${config.version}`,
|
user_agent: `${userAgent} ${browserName}-wakatime/${config.version}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (heartbeat.project) {
|
if (heartbeat.project) {
|
||||||
|
|||||||
Reference in New Issue
Block a user