-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: send userAgent instead of deviceInfo (#48)
- Loading branch information
1 parent
c21cf8c
commit 26c27d0
Showing
9 changed files
with
8 additions
and
190 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
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 |
---|---|---|
@@ -1,33 +1,14 @@ | ||
import { IDeviceInfo, IPromise } from '@qiwi/substrate' | ||
import platform from 'platform' | ||
import { IPromise } from '@qiwi/substrate' | ||
|
||
import { IPipe, IPipeOutput, ITransmittable } from '../interfaces' | ||
import { clone, isMobile, set } from '../utils' | ||
import { clone, set } from '../utils' | ||
|
||
export const type = 'device-info' | ||
|
||
export const getDeviceInfo = (userAgent?: string): IDeviceInfo => { | ||
const parsedData = userAgent ? platform.parse(userAgent) : platform | ||
const { name, version, layout, product, manufacturer, os } = parsedData | ||
return { | ||
browser: { | ||
name, | ||
version, | ||
layout, | ||
}, | ||
isMobile: isMobile(userAgent || window.navigator.userAgent), | ||
model: { | ||
name: product, | ||
manufacturer, | ||
}, | ||
os, | ||
} | ||
} | ||
|
||
export const createDeviceInfoPipe = (): IPipe => ({ | ||
type, | ||
execute({ data }: ITransmittable): IPromise<IPipeOutput> { | ||
const output = set(clone(data), 'meta.deviceInfo', getDeviceInfo()) | ||
const output = set(clone(data), 'meta.userAgent', window.navigator.userAgent) | ||
return Promise.resolve([null, output]) | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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