<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>dwt&#039;s life - fingerprintjs</title>
<link>https://dwt.life/tag/fingerprintjs/</link>
<atom:link href="https://dwt.life/feed/tag/fingerprintjs/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description></description>
<lastBuildDate>Sat, 29 Jan 2022 00:31:21 +0800</lastBuildDate>
<pubDate>Sat, 29 Jan 2022 00:31:21 +0800</pubDate>
<item>
<title>fingerprintjs pro接入指南</title>
<link>https://dwt.life/archives/186/</link>
<guid>https://dwt.life/archives/186/</guid>
<pubDate>Sat, 29 Jan 2022 00:31:21 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[接入npm install @fingerprintjs/fingerprintjs-pro或&lt;script&gt;  // Initialize the agent at applica...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<h1>接入</h1><p><code>npm install @fingerprintjs/fingerprintjs-pro</code><br>或</p><pre><code>&lt;script&gt;
  // Initialize the agent at application startup.
  const fpPromise = new Promise((resolve, reject) =&gt; {
    const script = document.createElement(&#039;script&#039;)
    script.onload = resolve
    script.onerror = () =&gt; reject(&#039;Failed to load the script&#039;)
    script.async = true
    script.src = &#039;https://cdn.jsdelivr.net/npm/&#039;
      + &#039;@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js&#039;
    document.head.appendChild(script)
  })
    .then(() =&gt; FingerprintJS.load({
      // Get a token at https://dashboard.fingerprintjs.com
      // Wait a couple of seconds before a result appears
      token: &#039;sample_docs_token&#039;,
      // region: &#039;eu&#039;,
      // endpoint: &#039;https://fp.your.com&#039;,
    }))

  // Get the visitor identifier when you need it.
  fpPromise
    .then(fp =&gt; fp.get(
      /* { linkedId: &#039;your-linked-id&#039;, tag: { yourTag: 123456 } } */
    ))
    .then(result =&gt; {
      const visitorId = result.visitorId
      console.log(&#039;Your visitorId:&#039;, visitorId)
    })
    .catch(error =&gt; console.error(error))
&lt;/script&gt;</code></pre><p>npm接入代码：</p><pre><code>import FingerprintJS from &#039;@fingerprintjs/fingerprintjs-pro&#039;

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

// Get the visitor identifier when you need it.
fpPromise
  .then(fp =&gt; fp.get())
  .then(result =&gt; console.log(result.visitorId))</code></pre><h1>服务端</h1><p><img src="https://pic.8oh.com.cn/cos/2022/01/29/427f23fc7d344_1643386768.png" alt="177.png" title="177.png"><br>检查用户visitorId:<br><a href="https://api.fpjs.io/visitors/someVisitorID?token=token">https://api.fpjs.io/visitors/someVisitorID?token=token</a><br>其中，</p><ul><li><a href="https://eu.api.fpjs.io">https://eu.api.fpjs.io</a> for EU</li><li><a href="https://ap.api.fpjs.io">https://ap.api.fpjs.io</a> for Asia (Mumbai)</li></ul><h1>用户标注</h1><p>使用tag和link-id区分，tag分组，link-id细分uid</p><pre><code>import FingerprintJS from &#039;@fingerprintjs/fingerprintjs-pro&#039;

// Initialize an agent at application startup.
const fpPromise = FingerprintJS.load({ token: &#039;token&#039; })

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

  // Get the visitor identifier when you need it.
  fpPromise
    .then(fp =&gt; fp.get({ linkedId: &#039;your-linked-id&#039;, tag: { yourTag: 123456 }})
    .then(result =&gt; console.log(result.visitorId));
&lt;/script&gt;</code></pre><h1>自定义数据上报域名</h1><p>有时候adblock可能会屏蔽fp的域名，我们可以在后台自定义域名（需要申请ssl）<br><img src="https://pic.8oh.com.cn/cos/2022/01/29/473b444a02da7_1643387272.png" alt="178.png" title="178.png"><br>按要求先解析cname过去，然后耐心等待SSL签发，检测很快就会通过。<br><img src="https://pic.8oh.com.cn/cos/2022/01/29/4da1dca88b7ca_1643387367.png" alt="179.png" title="179.png"><br>出来两个亚马逊BGP的IP，并告诉我们如何指定endpoint：</p><pre><code class="lang-js">FingerprintJS.load({token: &#039;&#039;, endpoint: &#039;https://endpoint&#039;})</code></pre><p>暂时更新这么多， fingerprintjspro的dashboard bug真不少，之前注册接入域名的时候卡住了，提交不了。后续从激活链接点入的就可以了，不过界面做的还倒是不错。</p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/186/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/tag/fingerprintjs/</wfw:commentRss>
</item>
</channel>
</rss>