> For the complete documentation index, see [llms.txt](https://docs.nubrick.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nubrick.app/experiment_edior/delivery_logic.md).

# 配信ロジックについて

## 1. アプリ内埋め込み (Embeddable Experiment)

{% hint style="info" icon="lightbulb-exclamation-on" %}
アプリのネイティブレイアウト内に特定のUIを動的に挿入するコンポーネントです
{% endhint %}

#### 表示タイミング

* Viewの初期化時
  * 実装された `NubrickEmbedding` ウィジェット（Flutter等）やViewがレンダリングされるタイミングで評価・表示されます
* 暗黙的なトリガー
  * 特定のイベント発火を待つのではなく、その「場所（ID）」に到達したことが表示のトリガーとなります

#### トリガーの仕組み

* 埋め込みID (Embedding ID): コード内に埋め込まれた固有のIDをキーとして、管理画面上の設定と紐付けます
* トリガー設定の不要性: オーバーレイと異なり、明示的なイベント（アプリ起動等）の設定は不要です。特定の画面表示＝表示タイミングとなります

#### 配信プロセスの詳細

1. Context Resolution
   * SDKが保持している現在の `User Properties`（`setProperties`で注入された値）を読み込みます
2. Targeting Evaluation
   * 管理画面で定義された対象ユーザー条件とプロパティを照合します
   * 注意：埋め込みの場合、条件指定は `set_properties` による属性ベースのみとなります。
3. Conflict Resolution (優先度判定)
   * 同一の埋め込みIDに対して、条件を満たす複数のエクスペリメントが存在する場合、設定された 「優先度（Priority）」が最も高いもの を1つ選出します
4. Resource Fetch & Render
   * 選出されたエクスペリメントの構成JSONを取得し、ネイティブUIとして描写します

## 2. オーバーレイ表示 (In-App Messaging / Product Tour)

{% hint style="info" icon="lightbulb-exclamation-on" %}
特定のユーザーアクションや状態変化に応じて、オーバーレイで表示されるコンポーネントです
{% endhint %}

#### 表示タイミング

* イベントドリブン
  * アプリ起動、バックグラウンド復帰、または `NubrickDispatcher` によって明示的に送信されたカスタムイベント（例：`purchase_completed`）の発生直後に評価されます

#### トリガーの仕組み

* イベントトリガー
  * デフォルトイベント：アプリ起動、初回起動、バックグラウンド復帰
  * カスタムイベント：SDKを通じて任意に定義・発火させたイベント、SDKのAPIを経由して発火させたイベント
* 頻度制御 (Frequency Control)
  * 「毎回」「1回のみ」「1日1回」「n日に1回」といった表示回数制限を、端末内のローカルDB（履歴データ）を用いて判定します

#### 配信プロセスの詳細

1. Event Capture
   * `NubrickDispatcher` がイベントを検知し、当該イベントに紐づく全ての Modal/Tour の構成（Config）をロードします
2. Multilayer Filtering
   * 属性フィルタ: `setProperties` の値がターゲットセグメントに合致するか判定
   * スケジュールフィルタ: 現在のデバイス時刻が、配信期間（開始・終了）およびカスタムスケジュール（曜日・時間帯）内か判定
   * 頻度フィルタ: 過去のインプレッションログに基づき、頻度設定を逸脱していないか判定
3. Priority Evaluation
   * フィルタを通過した候補が複数ある場合、優先度が最も高いもの を選出します（Flutterの場合、ツールチップも同様のロジックで評価されます）
4. Execution
   * 条件に合致したJSONファイルを取得し、最前面のレイヤーに表示を実行します


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nubrick.app/experiment_edior/delivery_logic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
