实现
<html>
<head>
<script src="https://ds.viewpkg.com/device-scan-2-0-1.js"></script>
</head>
<script>
var deviceScan = new vPkg.DeviceScan('web_token', 'session_id')
deviceScan.setSandbox()
deviceScan.setGeoLocation(true)
deviceScan.info('event_type', 'event_id')
.then((res) => console.log(res))
.catch((error) => console.log(error))
</script>
</html>
库通过调用属于 DeviceScan 类的 .info() 函数来执行用户分析,该类包含在我们的 vPkg 库中,如上例所示。变量 'web_token'、'session_id'、'event_type'(可选)和 'event_id'(可选)应替换为各自的真实值。成功时,库将返回一个表示收集成功的字符串;失败时,将返回一个表示错误类型的字符串。