<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Anonymization on Tarragon</title><link>https://tarrragon.github.io/blog/tags/anonymization/</link><description>Recent content in Anonymization on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Fri, 19 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/tags/anonymization/index.xml" rel="self" type="application/rss+xml"/><item><title>去識別化策略</title><link>https://tarrragon.github.io/blog/monitoring/07-security-privacy/anonymization-strategy/</link><pubDate>Fri, 19 Jun 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/monitoring/07-security-privacy/anonymization-strategy/</guid><description>&lt;p>去識別化是把監控資料中可以關聯到特定個人的欄位，轉換成無法回溯到個人但仍保留分析價值的形式。去識別化和 &lt;a href="https://tarrragon.github.io/blog/monitoring/knowledge-cards/redaction/" data-link-title="Redaction" data-link-desc="說明在事件資料離開 client 之前把敏感欄位的值替換成遮罩或移除的機制">redaction&lt;/a> 的差別在於：redaction 完全移除資訊（&lt;code>[REDACTED]&lt;/code>），去識別化保留結構化的資訊但移除可識別性。&lt;/p>
&lt;h2 id="ip-截斷">IP 截斷&lt;/h2>
&lt;p>IP 位址是最常見的個人識別欄位。完整的 IPv4 位址（&lt;code>192.168.1.50&lt;/code>）可以定位到特定的網路和裝置；截斷後的 IP（&lt;code>192.168.1.0&lt;/code>）保留網段資訊但無法定位到特定裝置。&lt;/p>
&lt;h3 id="截斷策略">截斷策略&lt;/h3>
&lt;p>&lt;strong>IPv4 末八位清零&lt;/strong>：&lt;code>192.168.1.50&lt;/code> → &lt;code>192.168.1.0&lt;/code>。保留 /24 網段資訊，足以判斷「使用者在哪個網段」但無法定位到特定裝置。Google Analytics 採用這個策略。&lt;/p>
&lt;p>&lt;strong>IPv4 末十六位清零&lt;/strong>：&lt;code>192.168.1.50&lt;/code> → &lt;code>192.168.0.0&lt;/code>。更強的去識別化，但地理定位精度降低到城市級。&lt;/p>
&lt;p>&lt;strong>IPv6&lt;/strong>：截斷更多位元。IPv6 的後 80 位通常包含 MAC 位址衍生的 interface ID — 截斷到 /48 前綴保留 ISP 資訊，移除裝置識別。&lt;/p>
&lt;h3 id="實作位置">實作位置&lt;/h3>
&lt;p>IP 截斷應在 collector 收到事件後、寫入儲存前執行。SDK 端不做 IP 截斷 — SDK 通常不知道自己的外部 IP（知道的是 NAT 後的內部 IP），外部 IP 是 collector 從 HTTP request 的 source IP 取得的。&lt;/p>
&lt;h2 id="user-agent-簡化">User Agent 簡化&lt;/h2>
&lt;p>User agent 字串包含瀏覽器版本、OS 版本、裝置型號 — 組合起來可能形成唯一的 fingerprint。簡化 user agent 保留有用的分類資訊（「iOS 17 上的 Safari」），移除可用於 fingerprinting 的細節（「iPhone 15 Pro Max, Build/22A3354」）。&lt;/p>
&lt;h3 id="簡化規則">簡化規則&lt;/h3>
&lt;p>保留：平台（iOS / Android / Windows / macOS）、主要版本號（iOS 17、Android 14）、瀏覽器類型（Safari / Chrome / Firefox）。&lt;/p>
&lt;p>移除：minor version、build number、裝置型號、CPU 架構、語言設定。&lt;/p>





&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="ln">1&lt;/span>&lt;span class="cl">原始：Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">2&lt;/span>&lt;span class="cl">簡化：iOS/17 Safari&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="stack-trace-路徑清理">Stack Trace 路徑清理&lt;/h2>
&lt;p>Error 事件的 stack trace 包含檔案路徑。檔案路徑可能洩漏部署結構（&lt;code>/home/deploy_user/app/v2.3.1/src/...&lt;/code>）或開發者的個人資訊（&lt;code>/Users/alice/projects/...&lt;/code>）。&lt;/p>
&lt;h3 id="清理規則">清理規則&lt;/h3>
&lt;p>&lt;strong>移除使用者目錄前綴&lt;/strong>：&lt;code>/Users/alice/projects/app/src/main.dart:42&lt;/code> → &lt;code>src/main.dart:42&lt;/code>。保留 source file 相對路徑和行號，移除使用者名稱。&lt;/p>
&lt;p>&lt;strong>移除部署路徑前綴&lt;/strong>：&lt;code>/opt/deploy/releases/20260619/app/lib/...&lt;/code> → &lt;code>lib/...&lt;/code>。保留程式碼結構，移除部署細節。&lt;/p>
&lt;p>&lt;strong>統一 path separator&lt;/strong>：Windows 路徑（&lt;code>C:\Users\...&lt;/code>）和 Unix 路徑（&lt;code>/home/...&lt;/code>）統一處理。&lt;/p>
&lt;p>清理規則用正則表達式匹配常見的路徑前綴模式，替換為空字串。自訂的部署路徑格式需要在 collector 設定中額外註冊。&lt;/p>
&lt;h2 id="session-uuid">Session UUID&lt;/h2>
&lt;p>Session ID 用於關聯同一次使用中的多個事件。UUID v4（隨機產生）作為 session ID，沒有可預測性、沒有順序性、無法回推使用者身份。&lt;/p>
&lt;h3 id="session-id-的生命週期">Session ID 的生命週期&lt;/h3>
&lt;p>SDK 在初始化時產生一個 UUID v4 作為 session ID，所有事件附帶這個 ID。App 重新啟動時產生新的 session ID — 前後兩次使用的事件無法關聯。&lt;/p>
&lt;p>這個設計讓分析粒度限制在「一次使用」而非「一個使用者」。如果需要跨 session 關聯（例如計算 DAU），需要另一個 persistent ID — 但 persistent ID 本身就是可識別資訊，需要使用者同意。&lt;/p>
&lt;h3 id="避免使用可識別的-id">避免使用可識別的 ID&lt;/h3>
&lt;p>裝置 ID（IDFA / GAID）、安裝 ID、使用者帳號 — 這些可以關聯到特定個人，不適合作為監控系統的 session ID。使用 UUID v4 確保 session ID 的唯一性來自隨機性而非身份。&lt;/p>
&lt;p>去識別化是資料保護的一環，另一環是在資料離開 client 之前就處理 — &lt;a href="https://tarrragon.github.io/blog/monitoring/07-security-privacy/sdk-redaction-api/" data-link-title="SDK Redaction API 設計" data-link-desc="預設 redaction rule 過濾已知敏感欄位、自訂 pattern 擴展應用特有的 secret 格式 — redaction 在 SDK 端執行，敏感資料不離開 client">SDK Redaction API 設計&lt;/a>從 SDK 端攔截敏感欄位。法規層面的具體要求見 &lt;a href="https://tarrragon.github.io/blog/monitoring/07-security-privacy/gdpr-minimization/" data-link-title="GDPR 最小化原則的工程落地" data-link-desc="資料最小化、目的限制、儲存限制 — GDPR 三個核心原則在監控系統的工程實作方式">GDPR 最小化原則的工程落地&lt;/a>。去識別化完成後的資料才能用於&lt;a href="https://tarrragon.github.io/blog/monitoring/08-business-analytics/" data-link-title="模組八：行為資料的商業利用" data-link-desc="Funnel / Cohort / Attribution / A/B test / 推薦系統 / RFM — 從 debug 工具到商業資產的翻轉">行為分析&lt;/a> — 這是商業利用的入場條件。&lt;/p></description><content:encoded><![CDATA[<p>去識別化是把監控資料中可以關聯到特定個人的欄位，轉換成無法回溯到個人但仍保留分析價值的形式。去識別化和 <a href="/blog/monitoring/knowledge-cards/redaction/" data-link-title="Redaction" data-link-desc="說明在事件資料離開 client 之前把敏感欄位的值替換成遮罩或移除的機制">redaction</a> 的差別在於：redaction 完全移除資訊（<code>[REDACTED]</code>），去識別化保留結構化的資訊但移除可識別性。</p>
<h2 id="ip-截斷">IP 截斷</h2>
<p>IP 位址是最常見的個人識別欄位。完整的 IPv4 位址（<code>192.168.1.50</code>）可以定位到特定的網路和裝置；截斷後的 IP（<code>192.168.1.0</code>）保留網段資訊但無法定位到特定裝置。</p>
<h3 id="截斷策略">截斷策略</h3>
<p><strong>IPv4 末八位清零</strong>：<code>192.168.1.50</code> → <code>192.168.1.0</code>。保留 /24 網段資訊，足以判斷「使用者在哪個網段」但無法定位到特定裝置。Google Analytics 採用這個策略。</p>
<p><strong>IPv4 末十六位清零</strong>：<code>192.168.1.50</code> → <code>192.168.0.0</code>。更強的去識別化，但地理定位精度降低到城市級。</p>
<p><strong>IPv6</strong>：截斷更多位元。IPv6 的後 80 位通常包含 MAC 位址衍生的 interface ID — 截斷到 /48 前綴保留 ISP 資訊，移除裝置識別。</p>
<h3 id="實作位置">實作位置</h3>
<p>IP 截斷應在 collector 收到事件後、寫入儲存前執行。SDK 端不做 IP 截斷 — SDK 通常不知道自己的外部 IP（知道的是 NAT 後的內部 IP），外部 IP 是 collector 從 HTTP request 的 source IP 取得的。</p>
<h2 id="user-agent-簡化">User Agent 簡化</h2>
<p>User agent 字串包含瀏覽器版本、OS 版本、裝置型號 — 組合起來可能形成唯一的 fingerprint。簡化 user agent 保留有用的分類資訊（「iOS 17 上的 Safari」），移除可用於 fingerprinting 的細節（「iPhone 15 Pro Max, Build/22A3354」）。</p>
<h3 id="簡化規則">簡化規則</h3>
<p>保留：平台（iOS / Android / Windows / macOS）、主要版本號（iOS 17、Android 14）、瀏覽器類型（Safari / Chrome / Firefox）。</p>
<p>移除：minor version、build number、裝置型號、CPU 架構、語言設定。</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="ln">1</span><span class="cl">原始：Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X)
</span></span><span class="line"><span class="ln">2</span><span class="cl">簡化：iOS/17 Safari</span></span></code></pre></div><h2 id="stack-trace-路徑清理">Stack Trace 路徑清理</h2>
<p>Error 事件的 stack trace 包含檔案路徑。檔案路徑可能洩漏部署結構（<code>/home/deploy_user/app/v2.3.1/src/...</code>）或開發者的個人資訊（<code>/Users/alice/projects/...</code>）。</p>
<h3 id="清理規則">清理規則</h3>
<p><strong>移除使用者目錄前綴</strong>：<code>/Users/alice/projects/app/src/main.dart:42</code> → <code>src/main.dart:42</code>。保留 source file 相對路徑和行號，移除使用者名稱。</p>
<p><strong>移除部署路徑前綴</strong>：<code>/opt/deploy/releases/20260619/app/lib/...</code> → <code>lib/...</code>。保留程式碼結構，移除部署細節。</p>
<p><strong>統一 path separator</strong>：Windows 路徑（<code>C:\Users\...</code>）和 Unix 路徑（<code>/home/...</code>）統一處理。</p>
<p>清理規則用正則表達式匹配常見的路徑前綴模式，替換為空字串。自訂的部署路徑格式需要在 collector 設定中額外註冊。</p>
<h2 id="session-uuid">Session UUID</h2>
<p>Session ID 用於關聯同一次使用中的多個事件。UUID v4（隨機產生）作為 session ID，沒有可預測性、沒有順序性、無法回推使用者身份。</p>
<h3 id="session-id-的生命週期">Session ID 的生命週期</h3>
<p>SDK 在初始化時產生一個 UUID v4 作為 session ID，所有事件附帶這個 ID。App 重新啟動時產生新的 session ID — 前後兩次使用的事件無法關聯。</p>
<p>這個設計讓分析粒度限制在「一次使用」而非「一個使用者」。如果需要跨 session 關聯（例如計算 DAU），需要另一個 persistent ID — 但 persistent ID 本身就是可識別資訊，需要使用者同意。</p>
<h3 id="避免使用可識別的-id">避免使用可識別的 ID</h3>
<p>裝置 ID（IDFA / GAID）、安裝 ID、使用者帳號 — 這些可以關聯到特定個人，不適合作為監控系統的 session ID。使用 UUID v4 確保 session ID 的唯一性來自隨機性而非身份。</p>
<p>去識別化是資料保護的一環，另一環是在資料離開 client 之前就處理 — <a href="/blog/monitoring/07-security-privacy/sdk-redaction-api/" data-link-title="SDK Redaction API 設計" data-link-desc="預設 redaction rule 過濾已知敏感欄位、自訂 pattern 擴展應用特有的 secret 格式 — redaction 在 SDK 端執行，敏感資料不離開 client">SDK Redaction API 設計</a>從 SDK 端攔截敏感欄位。法規層面的具體要求見 <a href="/blog/monitoring/07-security-privacy/gdpr-minimization/" data-link-title="GDPR 最小化原則的工程落地" data-link-desc="資料最小化、目的限制、儲存限制 — GDPR 三個核心原則在監控系統的工程實作方式">GDPR 最小化原則的工程落地</a>。去識別化完成後的資料才能用於<a href="/blog/monitoring/08-business-analytics/" data-link-title="模組八：行為資料的商業利用" data-link-desc="Funnel / Cohort / Attribution / A/B test / 推薦系統 / RFM — 從 debug 工具到商業資產的翻轉">行為分析</a> — 這是商業利用的入場條件。</p>
]]></content:encoded></item></channel></rss>