{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition","partial"]},"type":"markdown"},"seo":{"title":"Treasure Data Android SDK クイックスタート","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"android-sdk-クイックスタート","__idx":0},"children":["Android SDK クイックスタート"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data Android および Android TV SDK を使用することで、Treasure Data サービスを標準的な Android アプリや Android TV アプリに統合できます。これは、Android および Android TV アプリケーションのイベントを Treasure Data に簡単にインポートする方法です。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件と要件","__idx":1},"children":["前提条件と要件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Android 開発の基礎知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Android Pie 以降。自動トラッキングは API 28(Android 9.0)以降で動作する Android デバイスのみをサポートします"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Data の基礎知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-android-sdk/releases"},"children":["Android SDK Releases"]},"へのアクセス"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["GDPR への準拠の確認"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"バージョン-100-への移行","__idx":2},"children":["バージョン 1.0.0 への移行"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バージョン 1.0.0 には、以前のバージョンとの後方互換性がない大きな変更があります。バージョン 0.6.0 以前からアップグレードする場合は、以下の手順を実行しないとコードが正しく動作しません:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["API エンドポイントが Ingestion エンドポイントに変更されました。デフォルト値は [ https://us01.records.in.treasuredata.com ] です。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["initializeApiEndpoint(String apiEndpoint)"]}," API は使用できなくなりました。代わりに ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["initializeSharedInstance(Context context, String apiKey, String apiEndpoint)"]}," を使用してください。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uuid"]}," は予約されたカラム名になりました。イベントの ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uuid"]}," キーに値を追加しようとしても、データベースにカラムが表示されません。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_ip"]}," フィールドを追加することによるクライアント ID の自動トラッキングはサポートされなくなりました。代わりに、新しい ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#auto-tracking-device-ip"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoTrackingIP"]}]}," および ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#auto-tracking-device-ip"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableAutoTrackingIP"]}]}," API を使用してください。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"インストール","__idx":3},"children":["インストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の動画は Android SDK のインストール方法を示しています。"]},{"$$mdtype":"Tag","name":"iframe","attributes":{"width":"560","height":"315","src":"https://www.youtube.com/embed/nVwTMABEouI","title":"YouTube video player","frameBorder":"0","allow":"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture","allowFullScreen":""},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ライブラリのインストール","__idx":4},"children":["ライブラリのインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data ライブラリをプロジェクトに追加します。Gradle、Maven、および Jar ファイルを使用する例を以下に示します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","data-title":"Gradle","header":{"title":"Gradle","controls":{"copy":{}}},"source":"// build.gradle に以下を追加\ndependencies {\n    implementation 'com.treasuredata:td-android-sdk:1.0.0'\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","data-title":"Maven","header":{"title":"Maven","controls":{"copy":{}}},"source":"// pom.xml に以下を追加\n  <dependency>\n    <groupId>com.treasuredata</groupId>\n    <artifactId>td-android-sdk</artifactId>\n    <version>1.0.0</version>\n  </dependency>\n","lang":"xml"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"text","data-title":"Jar File","header":{"title":"Jar File","controls":{"copy":{}}},"source":"1) 最新の td-android-sdk-x.x.x-shaded.jar パッケージを以下からダウンロード\n    https://central.sonatype.com/search?q=g:com.treasuredata%20%20a:td-android-sdk&smo=true\n2) .jar を YOUR_ANDROID_PROJECT/libs フォルダに追加\n","lang":"text"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この SDK には",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-android-sdk/tree/master/example"},"children":["サンプル Android アプリケーションプロジェクト"]},"があります。pom.xml が良い参考になります。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"必要な-android-パーミッションの有効化","__idx":5},"children":["必要な Android パーミッションの有効化"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["まだ存在しない場合は、AndroidManifest.xml ファイルに ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INTERNET"]}," パーミッションを追加します。以下のエントリは ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<manifest> .. </manifest>"]}," タグの間に記述する必要があります。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","header":{"controls":{"copy":{}}},"source":"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n  package=\"com.treasuredata.android.demo\"\n  android:versionCode=\"1\"\n  android:versionName=\"1.0\" >\n  ...\n\n  <!-- 必要なパーミッション -->\n  <uses-permission android:name=\"android.permission.INTERNET\"/>\n</manifest>\n","lang":"xml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["詳細は ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-android-sdk/blob/master/example/src/main/AndroidManifest.xml"},"children":["Android Manifest の例"]},"をご覧ください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"gdpr---個人情報のトラッキング","__idx":6},"children":["GDPR - 個人情報のトラッキング"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"注意"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["会社のデータプライバシー責任者および法務顧問とデータ収集ポリシーを確認し、どのような個人情報を収集すべきかを判断する必要があります。個人のトラッキングを有効にする場合は、個人ユーザーのトラッキングへのオプトインを追跡するために、同意管理システムも統合することをお勧めします。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["さまざまな領域、特に EU の GDPR におけるデータプライバシー規制に準拠するため、Treasure Data Android SDK は個人を特定できる特定のイベントメタデータをデフォルトでは収集しません。具体的には、以下の情報はデフォルトでは収集されません:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]}," - クライアントの識別子で、このデバイス上のこのアプリケーションのこのインストールに固有です。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]}," は、個々のユーザーを追跡し、ユーザーセッション内およびセッション間でデータを分析し、追跡された行動を実在の個人と関連付けるなどを行う場合に必要です。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ユーザーの同意を得た後、個人データの収集を有効にできます。例:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"td.enableAutoAppendUniqId();\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["テスト時には、収集している情報を確認し、意図した個人情報のみが含まれ、それ以上のものが含まれていないことを確認してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developer.android.com/reference/java/util/UUID"},"children":["Android SDK の UUID"]}," について詳しく学んでください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"基本的な使用方法","__idx":7},"children":["基本的な使用方法"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ライブラリの初期化","__idx":8},"children":["ライブラリの初期化"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["効率的な API 呼び出しのために、Application サブクラスの ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onCreate()"]}," メソッドで ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData"]}," 共有インスタンスを初期化することを強くお勧めします。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"public class ExampleApp extends Application {\n\n  @Override\n  public void onCreate() {\n\n    // Treasure Data Android SDK の初期化\n    TreasureData.initializeEncryptionKey(\"RANDOM_STRING_TO_ENCRYPT_DATA\");\n    TreasureData.disableLogging();\n    TreasureData.initializeSharedInstance(this, \"YOUR_API_KEY\", \"API_ENDPOINT\");\n    TreasureData.sharedInstance.setDefaultDatabase(\"your_application_name\");\n    TreasureData.sharedInstance.setDefaultTable(\"your_event_name\");\n    TreasureData.sharedInstance.enableAutoAppendUniqId();\n    TreasureData.sharedInstance.enableAutoAppendModelInformation();\n    TreasureData.sharedInstance.enableAutoAppendAppInformation();\n    TreasureData.sharedInstance.enableAutoAppendLocaleInformation();\n  }\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR_API_KEY"]}," は、実際の apikey 文字列に置き換える必要があります。API キーは、Treasure コンソール のプロファイルから取得できます。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/my-settings/getting-your-api-keys"},"children":["Write-only API key"]}," の使用が推奨されます。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["その後、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.sharedInstance()"]}," メソッドを使用して、どこからでも共有インスタンスを使用できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"public class ExampleActivity extends Activity {\n\n  public void onDataLoadSomethingFinished(long elapsedTime) {\n    Map<String, Object> event = new HashMap<String, Object>();\n    event.put(\"data_type\", \"something\");\n    event.put(\"elapsed_time\", elapsedTime);\n    TreasureData.sharedInstance().addEvent(\"events\", event);\n  }\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ローカルバッファへのイベントの追加","__idx":9},"children":["ローカルバッファへのイベントの追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ローカルバッファにイベントを追加するには、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEvent"]}," または ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEventWithCallback"]}," API を呼び出します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","data-title":"シンプル","header":{"title":"シンプル","controls":{"copy":{}}},"source":"View v = findViewById(R.id.button);\n v.setOnClickListener(new OnClickListener() {\n   @Override\n   public void onClick(View v) {\n\n     final Map event = new HashMap<String, Object>();\n     event.put(\"id\", v.getId());\n     event.put(\"left\", v.getLeft());\n     event.put(\"right\", v.getRight());\n     event.put(\"top\", v.getTop());\n     event.put(\"bottom\", v.getBottom());\n\n     td.addEvent(\"testdb\", \"demotbl\", event);\n  }\n});\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","data-title":"コールバック付き","header":{"title":"コールバック付き","controls":{"copy":{}}},"source":"View v = findViewById(R.id.button);\n v.setOnClickListener(new OnClickListener() {\n   @Override\n   public void onClick(View v) {\n\n     final Map event = new HashMap<String, Object>();\n     event.put(\"id\", v.getId());\n     event.put(\"left\", v.getLeft());\n     event.put(\"right\", v.getRight());\n     event.put(\"top\", v.getTop());\n     event.put(\"bottom\", v.getBottom());\n\n     td.addEventWithCallback(\"testdb\", \"demotbl\", event, new TDCallback() {\n       @Override\n       public void onSuccess() {\n         Log.i(\"ExampleApp\", \"success!\");\n       }\n\n       @Override\n       public void onError(String errorCode, Exception e) {\n         Log.w(\"ExampleApp\", \"errorCode: \" + errorCode + \", detail: \" + e.toString());\n       }\n     });\n  }\n});\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["イベントをインポートするデータベースとテーブルを指定します。データベースとテーブルの合計長は 256 文字未満である必要があります。各テーブルは最大 10000 イベントをキャッシュします。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["さらに、イベント内のキーの長さは 256 文字を超えてはならず、イベント内の値の長さは 10000 文字を超えてはなりません。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"バッファされたイベントのアップロード","__idx":10},"children":["バッファされたイベントのアップロード"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バッファされたイベントを Treasure Data にアップロードするには、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uploadEvents"]}," または ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uploadEventsWithCallback"]}," API を使用します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリケーションのニーズによって、バッファされたイベントをいつ、どのくらいの頻度でアップロードするかが決まります。以下をお勧めします:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["現在の画面が閉じているとき、またはバックグラウンドに移動するとき"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリケーションを閉じるとき"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","data-title":"シンプル","header":{"title":"シンプル","controls":{"copy":{}}},"source":"findViewById(R.id.upload).setOnTouchListener(new OnTouchListener() {\n   @Override\n   public boolean onTouch(View view, MotionEvent motionEvent) {\n\n     // この API を呼び出して、いつでもバッファされたイベントをアップロードできます。\n     td.uploadEvents();\n\n     return false;\n  }\n});\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","data-title":"コールバック付き","header":{"title":"コールバック付き","controls":{"copy":{}}},"source":"findViewById(R.id.upload).setOnTouchListener(new OnTouchListener() {\n   @Override\n   public boolean onTouch(View view, MotionEvent motionEvent) {\n\n     // この API を呼び出して、いつでもバッファされたイベントをアップロードできます。\n     td.uploadEventsWithCallback(new TDCallback() {\n       @Override\n       public void onSuccess() {\n         Log.i(\"ExampleApp\", \"success!\");\n       }\n\n       @Override\n       public void onError(String errorCode, Exception e) {\n         Log.w(\"ExampleApp\", \"errorCode: \" + errorCode + \", detail: \" + e.toString());\n       }\n     });\n\n     return false;\n  }\n});\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バッファされたイベントをいつ、どのくらいの頻度でアップロードするかは、アプリケーションの特性によって異なります。しかし、少なくとも以下のタイミングでアップロードすることをお勧めします。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["現在の画面が閉じているとき、またはバックグラウンドに移動するとき"," ","アプリケーションを閉じるとき"," ","送信されたイベントは、Treasure Data ストレージにインポートされる前に数分間バッファされます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"高度な使用方法","__idx":11},"children":["高度な使用方法"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["基本を理解したところで、使用できるいくつかの高度なメソッドとプラクティスを紹介します。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"アップロードの再試行と重複排除","__idx":12},"children":["アップロードの再試行と重複排除"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SDK は、これらの機能を組み合わせた 1 つのスタイルでイベントをインポートします:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["この SDK は、一意のキーを追加してバッファされたイベントを保持し、イベントがサーバー側にアップロードされ保存されたことを確認するまで、アップロードを再試行します(少なくとも 1 回)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["サーバー側は、デフォルトで過去 1 時間以内のすべてのイベントの一意のキーを記憶し、重複インポートを防ぐことができます。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["重複排除は、同じ識別子を持つレコードが同じデータセット内で、最大で過去 1 時間以内または過去 4096 レコード以内のいずれか早い方で見られた場合に、重複レコードを識別するベストエフォートシステムです。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デフォルト値","__idx":13},"children":["デフォルト値"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["テーブル、データベース、または任意のテーブルやデータベースに追加されたイベントに対して、キーの値を自動的に設定したい場合は、デフォルト値を設定します。同じキーに複数のデフォルト値が設定されている場合、新しく追加されたイベントには、以下の順序でデフォルト値が適用され、上書きされます:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["すべてのテーブルとデータベースを対象とするデフォルト値が最初に適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["データベース内のすべてのテーブルを対象とするデフォルト値が適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["イベントが追加されるテーブルを対象とするデフォルト値が適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["イベントが追加されるテーブルとデータベースを対象とするデフォルト値が適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["最後に、イベントがキーの値を持っている場合、その値がすべてのデフォルト値を上書きします。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"デフォルト値の設定","__idx":14},"children":["デフォルト値の設定"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"TreasureData.sharedInstance().setDefaultValue(null, null, \"key\", \"Value\"); // すべてのデータベースとテーブルを対象\nTreasureData.sharedInstance().setDefaultValue(\"database_name\", null, \"key\", \"Value\"); // データベース \"database_name\" のすべてのテーブルを対象\nTreasureData.sharedInstance().setDefaultValue(null, \"table_name\", \"key\", \"Value\"); // \"table_name\" という名前のすべてのテーブルを対象\nTreasureData.sharedInstance().setDefaultValue(\"database_name\", \"table_name\", \"key\", \"Value\"); // データベース \"database_name\" のテーブル \"table_name\" を対象\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"デフォルト値の取得","__idx":15},"children":["デフォルト値の取得"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"String defaultValue = (String) TreasureData.sharedInstance().getDefaultValue(\"database_name\", \"table_name\", \"key\"); // データベース \"database_name\" とテーブル \"table_name\" を対象とするキーのデフォルト値を取得\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"デフォルト値の削除","__idx":16},"children":["デフォルト値の削除"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"TreasureData.sharedInstance().removeDefaultValue(\"database_name\", \"table_name\", \"key\"); // データベース \"database_name\" とテーブル \"table_name\" を対象とするデフォルト値のみを削除\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"セッションの開始と終了","__idx":17},"children":["セッションの開始と終了"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startSession"]}," メソッドを呼び出すと、SDK はセッション ID を生成し、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endSession"]}," が呼び出されるまで保持します。セッション ID は列名 \"td_session_id\" として出力されます。また、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startSession"]}," と ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endSession"]}," メソッドは {",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"td_session_event\":\"start\""]}," または ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"end\""]},"} を含むイベントを追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"@Override\nprotected void onStart(Bundle savedInstanceState) {\n                :\n        TreasureData.sharedInstance().startSession(\"demotbl\");\n                :\n}\n\n@Override\nprotected void onStop() {\n                :\n        TreasureData.sharedInstance().endSession(\"demotbl\");\n        TreasureData.sharedInstance().uploadEvents();\n        // 出力 =>>\n        // [{\"td_session_id\":\"cad88260-67b4-0242-1329-2650772a66b1\",\n        // \"td_session_event\":\"start\", \"time\":1418880000},\n        //\n        // {\"td_session_id\":\"cad88260-67b4-0242-1329-2650772a66b1\",\n        // \"td_session_event\":\"end\", \"time\":1418880123}\n        // ]\n            :\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のケースを処理したい場合は、グローバルセッショントラッキングのために ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.startSession"]}," と ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.endSession"]}," のクラスメソッドのペアを使用してください:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ユーザーがアプリケーションを開き、セッショントラッキングを開始します。例えば、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["session#0"]}," です。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ユーザーがホーム画面に移動し、Activity を破棄します"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ユーザーがデフォルトの 10 秒以内にアプリケーションを再度開き、セッショントラッキングを再開します。しかし、この新しいセッションを ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["session#0"]}," と同じセッションとして扱いたい場合です。"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"@Override\nprotected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n                :\n        TreasureData.setSessionTimeoutMilli(30 * 1000); // デフォルトは 10 秒\n}\n\n@Override\nprotected void onStart() {\n                :\nTreasureData.startSession(this);\n        :\n}\n\n@Override\nprotected void onStop() {\n:\nTreasureData.endSession(this);\nTreasureData.sharedInstance().uploadEvents();\n:\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.getSessionId"]}," を使用して現在のセッション ID を取得できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"@Override\nprotected void onStart() {\n                :\n        TreasureData.startSession(this);\n        Log.i(TAG, \"onStart(): Session ID=\" + TreasureData.getSessionId(this));\n                :\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"アプリライフサイクルイベントの自動トラッキング","__idx":18},"children":["アプリライフサイクルイベントの自動トラッキング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリライフサイクルイベントのトラッキングはオプションであり、デフォルトでは有効になっていません。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAppLifecycleEvent()"]}," を使用してアプリライフサイクルイベントを自動的にトラッキングできます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリライフサイクルイベントには、アプリケーションのインストール、アプリケーションのオープン、アプリケーションのアップデートが含まれます。以下のように個別のコアイベントを無効にできます:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリケーションインストールの無効化: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableAppInstalledEvent()"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリケーションオープンの無効化: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableAppOpenEvent()"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリケーションアップデートの無効化: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableAppUpdatedEvent()"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"アプリ内課金イベントの自動トラッキング","__idx":19},"children":["アプリ内課金イベントの自動トラッキング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリ内課金イベントのトラッキングはオプションであり、デフォルトでは有効になっていません。アプリ内課金イベントを自動的にトラッキングするには、次のコードを追加してください: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.enableInAppPurchaseEvent()"]},"。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の列が出力されます:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"列名"},"children":["列名"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"説明"},"children":["説明"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_android_event"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TD_ANDROID_IN_APP_PURCHASE"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["productId (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_order_id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["orderId (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_price"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["price (SKU detail)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_quantity"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_price_amount_micros"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["price_amount_micros (SKU detail)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_currency"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["price_currency_code (SKU detail)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_purchase_time"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["purchaseTime (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_purchase_token"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["purchaseToken (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_purchase_state"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["purchaseState (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_purchase_developer_payload"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["developerPayload (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_type"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["type (SKU detail)、ワンタイム製品の場合は inapp、サブスクリプションの場合は subs"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_title"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["title (SKU detail)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_description"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["description (SKU detail)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_package_name"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["packageName (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_subs_auto_renewing"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["autoRenewing (Purchase)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_subs_status"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["サブスクリプションの自動検出 (New"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_subs_period"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["subscriptionPeriod (SKU detail for subscription)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_free_trial_period"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["freeTrialPeriod (SKU detail for subscription)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_intro_price_period"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["introductoryPricePeriod (SKU detail for subscription)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_intro_price_cycless"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["introductoryPriceCycles (SKU detail for subscription)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_intro_price_amount_micros"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["introductoryPriceAmountMicro (SKU detail for subscription)"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この SDK は、Google Play Billing Library と AIDL を使用したアプリ内課金の両方を使用する Android アプリケーションのアプリ内課金イベントをトラッキングできます。アプリケーションが AIDL API を使用したアプリ内課金で開発されている場合、SDK が使用する AIDL クラスを保持するために、以下の ProGuard ルールをプロジェクトに追加する必要があります。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"-keep class com.android.vending.billing.** { *; }\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"オプトアウト","__idx":20},"children":["オプトアウト"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリを販売する国(例: EU)によっては、アプリ内でユーザーがデータトラッキングをオプトアウトできる機能を提供する必要がある場合があります。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリケーションライフサイクルイベントの自動トラッキングをオフにする(アプリケーションライフサイクルイベントトラッキングが有効な場合): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableAppLifecycleEvent()"]},"。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリ内課金イベントの自動トラッキングをオフにする(アプリ内課金イベントが有効な場合): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableInAppPurchaseEvent()"]},"。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["カスタムイベント(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEvent"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEventWithCallback"]}," でトラッキングしているイベント)をオフにする: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableCustomEvent"]},"。再度オンにする: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableCustomEvent"]},"。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isAppLifecycleEventEnabled()"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isInAppPurchaseEventEnabled()"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isCustomEventEnabled()"]}," を使用して、イベントトラッキングの状態を照会できます。これらの状態はデバイスの再起動やアプリの更新をまたいで効果があるため、アプリケーション中に一度呼び出すだけで済みます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"エラーコード","__idx":21},"children":["エラーコード"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEventWithCallback"]}," や ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uploadEventWithCallback"]}," のようなコールバック付き関数を使用する場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["errorCode"]}," 引数を持つ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TDCallback.onError"]}," メソッドのコールバックを取得できます。この引数はエラーの原因タイプを知るのに役立ちます。以下のエラーコードがあります。"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"エラーコード"},"children":["エラーコード"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"説明"},"children":["説明"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["init_error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["初期化に失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invalid_param"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["API に渡されたパラメータが無効でした。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invalid_event"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["イベントが無効でした。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data_conversion"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["データの JSON への変換または JSON からの変換に失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["storage_error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ストレージ内のデータの読み取り/書き込みに失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["network_error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ネットワークの問題によりサーバーとの通信に失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["server_response"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["サーバーがエラーレスポンスを返しました。"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"追加設定","__idx":22},"children":["追加設定"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"エンドポイント","__idx":23},"children":["エンドポイント"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["API エンドポイント(デフォルト: [ https://us01.records.in.treasuredata.com ] )は変更できます。例えば:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"td = new TreasureData(this, \"your_api_key\", \"https://specifying-another-endpoint.com\");\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"暗号化キー","__idx":24},"children":["暗号化キー"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.initializeEncryptionKey"]}," で暗号化キーを設定した場合、SDK は ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#addEvent"]}," または ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.addEventWithCallback"]}," が呼び出されたときにイベントデータを暗号化して保存します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"    TreasureData.initializeEncryptionKey(\"hello world\");\n        :\n    td.addEventWithCallback(...)\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デフォルトデータベース","__idx":25},"children":["デフォルトデータベース"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  TreasureData.sharedInstance().setDefaultDatabase(\"default_db\");\n    :\n  TreasureData.sharedInstance().addEvent(\"demotbl\", …);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントレコードへのローカルタイムスタンプの自動追加","__idx":26},"children":["各イベントレコードへのローカルタイムスタンプの自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このオプションはデフォルトで有効になっています。ローカルタイムスタンプがイベントの ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]}," キーに自動的に追加されます。イベントに ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]}," キーを追加せずに ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableAutoAppendLocalTimestamp"]}," を実行すると、サーバーがサーバー側のタイムスタンプを ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]}," 列に追加します。カスタム列でローカル時刻を自動トラッキングすることもできます。その場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]}," 列にはサーバー側のタイムスタンプが含まれます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"    // ローカル時刻を `time` 列として使用\n    TreasureData.sharedInstance().enableAutoAppendLocalTimestamp();\n\n    // ローカル時刻をカスタマイズされた列名として追加\n    TreasureData.sharedInstance().enableAutoAppendLocalTimestamp(\"custom_time\");\n\n    // ローカル時刻の自動追加を無効化\n    TreasureData.sharedInstance().disableAutoAppendLocalTimestamp();\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのデバイスの-uuid-の自動追加","__idx":27},"children":["各イベントへのデバイスの UUID の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#enableAutoAppendUniqId()"]}," を呼び出すと、デバイスの UUID が各イベントに自動的に追加されます。この値はアプリケーションがアンインストールされるまで変更されません。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  td.enableAutoAppendUniqId();\n    :\n  td.addEvent(...);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["値は列名 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]}," として出力されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#resetUniqId()"]}," を使用して UUID をリセットし、古い UUID で ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["forget_device_uuid"]}," イベントを送信できます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントレコードへの-uuid-の自動追加","__idx":28},"children":["各イベントレコードへの UUID の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoAppendRecordUUID"]}," を呼び出すと、UUID が各イベントレコードに自動的に追加されます。各イベントは異なる UUID を持ちます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  td.enableAutoAppendRecordUUID();\n  // 列名をカスタマイズしたい場合は、API に渡してください\n  // td.enableAutoAppendRecordUUID(\"my_record_uuid\");\n    :\n  td.addEvent(...);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルトでは、値は列名 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["record_uuid"]}," として出力されます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントレコードへの広告-id-の自動追加","__idx":29},"children":["各イベントレコードへの広告 ID の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoAppendAdvertisingIdentifier"]}," を呼び出すと、広告 ID が各イベントレコードに自動的に追加されます。この機能を動作させるには、Google Play Service Ads (Gradle ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["com.google.android.gms:play-services-ads"]},") を依存関係としてインストールする必要があります。また、ユーザーがデバイスで広告トラッキングの制限機能をオンにしていない必要があります。そうでない場合、Treasure Data は広告 ID をレコードに添付できません。"," ","広告 ID の取得は非同期であるため、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoAppendAdvertisingIdentifier"]}," メソッドが呼び出された後、広告 ID が利用可能になるまでに時間がかかる場合があります。ただし、Treasure Data は広告 ID をキャッシュするため、広告 ID の取得タスクの完了を待つことなく、次のイベントに追加できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"td.enableAutoAppendAdvertisingIdentifier();\n// 列名をカスタマイズしたい場合は、API に渡してください\n// td.enableAutoAppendAdvertisingIdentifier(\"my_advertising_id_column\");\n:\ntd.addEvent(...);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルトでは、値は列名 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_maid"]}," として出力されます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのデバイスモデル情報の自動追加","__idx":30},"children":["各イベントへのデバイスモデル情報の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#enableAutoAppendModelInformation"]}," を呼び出すと、デバイスモデル情報が各イベントに自動的に追加されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  td.enableAutoAppendModelInformation();\n    :\n  td.addEvent(...);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の列名と値が出力されます:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_board"]}," : android.os.Build#BOARD"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_brand"]}," : android.os.Build#BRAND"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_device"]}," : android.os.Build#DEVICE"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_display"]}," : android.os.Build#DISPLAY"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_model"]}," : android.os.Build#MODEL"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_os_ver"]}," : android.os.Build.VERSION#SDK_INT"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_os_type"]}," : \"Android\""]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのアプリケーションパッケージバージョン情報の自動追加","__idx":31},"children":["各イベントへのアプリケーションパッケージバージョン情報の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#enableAutoAppendAppInformation"]}," を呼び出すと、アプリケーションパッケージバージョン情報が各イベントに自動的に追加されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  td.enableAutoAppendAppInformation();\n    :\n  td.addEvent(...);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の列名と値が出力されます:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_app_ver"]}," : android.content.pm.PackageInfo.versionName (Context.getPackageManager().getPackageInfo() から)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_app_ver_num"]}," : android.content.pm.PackageInfo.versionCode (Context.getPackageManager().getPackageInfo() から)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのロケール設定情報の自動追加","__idx":32},"children":["各イベントへのロケール設定情報の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#enableAutoAppendLocaleInformation"]}," を呼び出すと、ロケール設定情報が各イベントに自動的に追加されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  td.enableAutoAppendLocaleInformation();\n    :\n  td.addEvent(...);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の列名と値が出力されます:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_locale_country"]}," : java.util.Locale.getCountry() (Context.getResources().getConfiguration().locale から)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_locale_lang"]}," : java.util.Locale.getLanguage() (Context.getResources().getConfiguration().locale から)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デバイス-ip-の自動トラッキング","__idx":33},"children":["デバイス IP の自動トラッキング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoTrackingIP"]}," を呼び出すと、デバイス IP が ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_ip"]}," 列に各イベントに自動的に追加されます。トラッキングされる IP アドレスは、イベントを追加したときではなく、Treasure Data にイベントをアップロードしたときのものであることに注意してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"TreasureData.sharedInstance().enableAutoTrackingIP();\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["IP の自動トラッキングを無効にするには:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"TreasureData.sharedInstance().disableAutoTrackingIP();\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"profiles-api","__idx":34},"children":["Profiles API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/products/customer-data-platform/audience-studio/profiles"},"children":["Profiles API"]}," を使用してプロファイルを検索する方法の例を以下に示します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"// CDP エンドポイントを以下のいずれかに設定してください:\n//   https://cdp.in.treasuredata.com        (US)\n//   https://cdp-tokyo.in.treasuredata.com  (Tokyo)\n//   https://cdp-eu01.in.treasuredata.com   (EU)\n//   https://cdp-ap02.in.treasuredata.com   (Seoul)\n//   https://cdp-ap03.in.treasuredata.com   (Tokyo)\nTreasureData.sharedInstance().setCDPEndpoint(\"<your_cdp_endpoint>\");\n\nTreasureData.sharedInstance().fetchUserSegments(Arrays.asList(\"<your_profile_api_tokens>\"),\n                                                Collections.singletonMap(\"<your_key_column>\", \"<value>\"),\n                                                new FetchUserSegmentsCallback() {\n                                                    @Override\n                                                    public void onSuccess(List<Profile> profiles) {\n                                                        System.out.println(profiles);\n                                                    }\n                                                    @Override\n                                                    public void onError(Exception e) {\n                                                        System.err.println(e);\n                                                    }\n                                                });\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デバッグログの有効化と無効化","__idx":35},"children":["デバッグログの有効化と無効化"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  TreasureData.enableLogging();\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"  TreasureData.disableLogging();\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"android-バージョンのサポート","__idx":36},"children":["Android バージョンのサポート"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["サポートされている Android バージョンのリストについては、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-android-sdk/tree/master?tab=readme-ov-file#android-version-support"},"children":["GitHub リポジトリ"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"参考資料","__idx":37},"children":["参考資料"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["追加情報については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-android-sdk"},"children":["Android SDK GitHub リポジトリ"]},"を参照してください。"]}]},"headings":[{"value":"Android SDK クイックスタート","id":"android-sdk-クイックスタート","depth":1},{"value":"前提条件と要件","id":"前提条件と要件","depth":2},{"value":"バージョン 1.0.0 への移行","id":"バージョン-100-への移行","depth":2},{"value":"インストール","id":"インストール","depth":2},{"value":"ライブラリのインストール","id":"ライブラリのインストール","depth":3},{"value":"必要な Android パーミッションの有効化","id":"必要な-android-パーミッションの有効化","depth":3},{"value":"GDPR - 個人情報のトラッキング","id":"gdpr---個人情報のトラッキング","depth":2},{"value":"基本的な使用方法","id":"基本的な使用方法","depth":2},{"value":"ライブラリの初期化","id":"ライブラリの初期化","depth":3},{"value":"ローカルバッファへのイベントの追加","id":"ローカルバッファへのイベントの追加","depth":3},{"value":"バッファされたイベントのアップロード","id":"バッファされたイベントのアップロード","depth":3},{"value":"高度な使用方法","id":"高度な使用方法","depth":2},{"value":"アップロードの再試行と重複排除","id":"アップロードの再試行と重複排除","depth":3},{"value":"デフォルト値","id":"デフォルト値","depth":3},{"value":"デフォルト値の設定","id":"デフォルト値の設定","depth":4},{"value":"デフォルト値の取得","id":"デフォルト値の取得","depth":4},{"value":"デフォルト値の削除","id":"デフォルト値の削除","depth":4},{"value":"セッションの開始と終了","id":"セッションの開始と終了","depth":3},{"value":"アプリライフサイクルイベントの自動トラッキング","id":"アプリライフサイクルイベントの自動トラッキング","depth":3},{"value":"アプリ内課金イベントの自動トラッキング","id":"アプリ内課金イベントの自動トラッキング","depth":3},{"value":"オプトアウト","id":"オプトアウト","depth":3},{"value":"エラーコード","id":"エラーコード","depth":2},{"value":"追加設定","id":"追加設定","depth":2},{"value":"エンドポイント","id":"エンドポイント","depth":3},{"value":"暗号化キー","id":"暗号化キー","depth":3},{"value":"デフォルトデータベース","id":"デフォルトデータベース","depth":3},{"value":"各イベントレコードへのローカルタイムスタンプの自動追加","id":"各イベントレコードへのローカルタイムスタンプの自動追加","depth":3},{"value":"各イベントへのデバイスの UUID の自動追加","id":"各イベントへのデバイスの-uuid-の自動追加","depth":3},{"value":"各イベントレコードへの UUID の自動追加","id":"各イベントレコードへの-uuid-の自動追加","depth":3},{"value":"各イベントレコードへの広告 ID の自動追加","id":"各イベントレコードへの広告-id-の自動追加","depth":3},{"value":"各イベントへのデバイスモデル情報の自動追加","id":"各イベントへのデバイスモデル情報の自動追加","depth":3},{"value":"各イベントへのアプリケーションパッケージバージョン情報の自動追加","id":"各イベントへのアプリケーションパッケージバージョン情報の自動追加","depth":3},{"value":"各イベントへのロケール設定情報の自動追加","id":"各イベントへのロケール設定情報の自動追加","depth":3},{"value":"デバイス IP の自動トラッキング","id":"デバイス-ip-の自動トラッキング","depth":3},{"value":"Profiles API","id":"profiles-api","depth":3},{"value":"デバッグログの有効化と無効化","id":"デバッグログの有効化と無効化","depth":3},{"value":"Android バージョンのサポート","id":"android-バージョンのサポート","depth":2},{"value":"参考資料","id":"参考資料","depth":2}],"frontmatter":{"seo":{"title":"Treasure Data Android SDK クイックスタート"}},"lastModified":"2026-05-14T07:27:55.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/products/customer-data-platform/integration-hub/streaming/mobile/android","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}