前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >fingerprintjs pro接入指南

fingerprintjs pro接入指南

作者头像
Laikee
发布2022-04-25 19:11:49
1.7K0
发布2022-04-25 19:11:49
举报
文章被收录于专栏:Laikee Tech Space

接入

npm install @fingerprintjs/fingerprintjs-pro

代码语言:javascript
复制
<script>
  // Initialize the agent at application startup.
  const fpPromise = new Promise((resolve, reject) => {
    const script = document.createElement('script')
    script.onload = resolve
    script.onerror = () => reject('Failed to load the script')
    script.async = true
    script.src = 'https://cdn.jsdelivr.net/npm/'
      + '@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js'
    document.head.appendChild(script)
  })
    .then(() => FingerprintJS.load({
      // Get a token at https://dashboard.fingerprintjs.com
      // Wait a couple of seconds before a result appears
      token: 'sample_docs_token',
      // region: 'eu',
      // endpoint: 'https://fp.your.com',
    }))

  // Get the visitor identifier when you need it.
  fpPromise
    .then(fp => fp.get(
      /* { linkedId: 'your-linked-id', tag: { yourTag: 123456 } } */
    ))
    .then(result => {
      const visitorId = result.visitorId
      console.log('Your visitorId:', visitorId)
    })
    .catch(error => console.error(error))
</script>

npm接入代码:

代码语言:javascript
复制
import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'

// Initialize an agent at application startup.
const fpPromise = FingerprintJS.load({
  token: 'sample_docs_token',
  region: 'eu' //ap eu 
})

// Get the visitor identifier when you need it.
fpPromise
  .then(fp => fp.get())
  .then(result => console.log(result.visitorId))

服务端

fingerprintjs pro接入指南
fingerprintjs pro接入指南

检查用户visitorId: https://api.fpjs.io/visitors/someVisitorID?token=token 其中,

用户标注

使用tag和link-id区分,tag分组,link-id细分uid

代码语言:javascript
复制
import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'

// Initialize an agent at application startup.
const fpPromise = FingerprintJS.load({ token: 'token' })

// Get the visitor identifier when you need it.
fpPromise
  .then(fp => fp.get({ linkedId: 'your-linked-id', tag: { yourTag: 123456 } }))
  .then(result => console.log(result.visitorId))
代码语言:javascript
复制
<script>
  // Initialize the agent at application startup.
  const fpPromise = new Promise((resolve, reject) => {
    const script = document.createElement('script');
    script.onload = resolve;
    script.onerror = reject;
    script.async = true;
    script.src = 'https://cdn.jsdelivr.net/npm/'
      + '@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js';
    document.head.appendChild(script);
  }).then(() =>
    FingerprintJS.load({ token: '' })
  );

  // Get the visitor identifier when you need it.
  fpPromise
    .then(fp => fp.get({ linkedId: 'your-linked-id', tag: { yourTag: 123456 }})
    .then(result => console.log(result.visitorId));
</script>

自定义数据上报域名

有时候adblock可能会屏蔽fp的域名,我们可以在后台自定义域名(需要申请ssl)

fingerprintjs pro接入指南
fingerprintjs pro接入指南

按要求先解析cname过去,然后耐心等待SSL签发,检测很快就会通过。

fingerprintjs pro接入指南
fingerprintjs pro接入指南

出来两个亚马逊BGP的IP,并告诉我们如何指定endpoint:

代码语言:javascript
复制
FingerprintJS.load({token: '', endpoint: 'https://endpoint'})

暂时更新这么多, fingerprintjspro的dashboard bug真不少,之前注册接入域名的时候卡住了,提交不了。后续从激活链接点入的就可以了,不过界面做的还倒是不错。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-01-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 接入
  • 服务端
  • 用户标注
  • 自定义数据上报域名
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档