> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/enabling-adaptive-content/feature-flags.md).

# 機能フラグ

{% hint style="warning" %}
アダプティブコンテンツをフィーチャーフラグと併用するには、アプリケーションにコードを追加する必要があります。

現在、GitBook ヘルパーは React ベースのセットアップのみをサポートしています。
{% endhint %}

GitBook は、次のような一般的な機能フラグサービスプロバイダー向けにヘルパー関数と統合機能を提供しています。 [**LaunchDarkly**](#launchdarkly) 、 [**Reflag**](#reflag).

これにより、ユーザーがドキュメントを読む際に、製品内でどの機能フラグにアクセスできるかを読み取れるようになります。これは、特定のグループの人だけが利用できる機能のドキュメントを表示する必要がある場合に便利です。

### LaunchDarkly

LaunchDarkly では、次のものを通じて機能フラグへのアクセスをクレームとして送信できます。 [`launchdarkly-react-client-sdk`](https://launchdarkly.com/docs/sdk/client-side/react/react-web) および GitBook の [`@gitbook/adaptive`](broken://spaces/zq8ynchcecIscc4uulgN) パッケージ。

すでに製品で LaunchDarkly の機能フラグを使用している場合は、このパッケージがすでに設定されている可能性が高いです。

これらの機能フラグをクレームとして GitBook に渡すには、次の手順に従ってください。

{% stepper %}
{% step %}
**LaunchDarkly 統合をインストールする**

まず、 [LaunchDarkly 統合をインストールして](https://app.gitbook.com/integrations/launchdarkly) GitBook サイトに組み込みます。
{% endstep %}

{% step %}
**プロジェクトとアクセスキーを設定する**

次の [LaunchDarkly の設定](https://app.launchdarkly.com/settings) から、プロジェクトキーとサービスアクセス トークンを統合設定に追加します。
{% endstep %}

{% step %}
**GitBook ヘルパーをアプリケーションにインストールして追加する**

LaunchDarkly 統合を設定したら、アプリケーションに GitBook の adaptive content ヘルパーをインストールする必要があります。

```bash
npm install @gitbook/adaptive
```

{% endstep %}

{% step %}
**アプリケーションを設定する**

次の `withLaunchDarkly` ヘルパーを LaunchDarkly React SDK と組み合わせて使用し、コンテキストを GitBook に渡す必要があります。

<pre class="language-javascript"><code class="lang-javascript">import { render } from 'react-dom';
<strong>import { withLaunchDarkly } from '@gitbook/adaptive';
</strong><strong>import { asyncWithLDProvider, useLDClient } from 'launchdarkly-react-client-sdk';
</strong>import MyApplication from './MyApplication';

function PassFeatureFlagsToGitBookSite() {
<strong>    const ldClient = useLDClient();
</strong>    React.useEffect(() => {
        if (!ldClient) {
            return;
        }
<strong>        return withLaunchDarkly(ldClient);
</strong>    }, [ldClient]);
    return null;
}
(async () => {
    const LDProvider = await asyncWithLDProvider({
        clientSideID: 'client-side-id-123abc',
        context: {
            kind: 'user',
            key: 'user-key-123abc',
            name: 'Sandy Smith',
            email: 'sandy@example.com'
        },
        options: { /* ... */ }
    });
    render(
        &#x3C;LDProvider>
            &#x3C;PassFeatureFlagsToGitBookSite />
            &#x3C;MyApplication />
        &#x3C;/LDProvider>,
        document.getElementById('reactDiv'),
    );
})();
</code></pre>

{% endstep %}

{% step %}
**ビジター スキーマを確認する**

A [visitor schema](/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/enabling-adaptive-content.md#set-your-visitor-schema) は、公開サイトでクレームを読み取れるようにするために必要です。LaunchDarkly 統合をインストールして設定すると、ビジター スキーマは自動的に設定されます。
{% endstep %}

{% step %}
**コンテンツをパーソナライズする**

ビジター スキーマを設定したら、ユーザーがアクセスできる機能フラグを使って、サイトを訪れるユーザー向けにドキュメント体験を調整する準備が整います。

LaunchDarkly で利用可能な任意の機能フラグの値は、ビジター スキーマの一部として次の下に公開されます。 `visitor.claims.unsigned.launchdarkly` オブジェクト。署名なしクレームの詳細を読む [こちら](/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/enabling-adaptive-content.md#set-an-unsigned-claim).

次へ移動します [コンテンツの調整](/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/adapting-your-content.md) ユーザー向けにドキュメントをさらにパーソナライズする方法について詳しく学べます。
{% endstep %}
{% endstepper %}

### Reflag

Reflag では、次のものを通じて機能フラグへのアクセスをクレームとして送信できます。 [`@reflag/react-sdk`](https://www.npmjs.com/package/@reflag/react-sdk) および GitBook の [`@gitbook/adaptive`](https://github.com/GitbookIO/integrations/tree/main/packages/adaptive) パッケージ。

すでに製品で Reflag の機能フラグを使用している場合は、このパッケージがすでに設定されている可能性が高いです。

これらの機能フラグをクレームとして GitBook に渡すには、次の手順に従ってください。

{% stepper %}
{% step %}
**Reflag 統合をインストールする**

まず、 [Reflag 統合をインストールする](https://app.gitbook.com/integrations/bucket) GitBook サイトに組み込みます。
{% endstep %}

{% step %}
**シークレットキーを設定する**

次の [Reflag の設定](https://app.reflag.com/envs/current/settings/app-environments) から、プロジェクトキーとサービスアクセス トークンを統合設定に追加します。
{% endstep %}

{% step %}
**GitBook ヘルパーをアプリケーションにインストールする**

Reflag 統合を設定したら、アプリケーションに GitBook の adaptive content ヘルパーをインストールする必要があります。

```bash
npm install @gitbook/adaptive
```

{% endstep %}

{% step %}
**アプリケーションを設定する**

次の `withReflag` ヘルパーを Reflag React SDK と組み合わせて使用し、コンテキストを GitBook に渡す必要があります。

<pre class="language-javascript"><code class="lang-javascript"><strong>import { withReflag } from '@gitbook/adaptive';
</strong><strong>import { ReflagProvider, useClient } from '@reflag/react-sdk';
</strong>import MyApplication from './MyApplication';

function PassFeatureFlagsToGitBookSite() {
<strong>    const client = useClient();
</strong>    React.useEffect(() => {
        if (!client) {
            return;
        }
<strong>        return withReflag(client);
</strong>    }, [client]);
    return null;
}
export function Application() {
    const currentUser = useLoggedInUser();
    const appConfig = useAppConfig();
    return (
        &#x3C;ReflagProvider
            publishableKey={appConfig.reflagCom.publishableKey}
            user={{
                id: currentUser.uid,
                email: currentUser.email ?? undefined,
                name: currentUser.displayName ?? '',
            }}
            company={{
                id: currentUser.company.id,
            }}
        >
            &#x3C;PassFeatureFlagsToGitBookSite />
            &#x3C;MyApplication />
        &#x3C;/ReflagProvider>
    );
}
</code></pre>

{% endstep %}

{% step %}
**ビジター スキーマを確認する**

A [visitor schema](/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/enabling-adaptive-content.md#set-your-visitor-schema) は、公開サイトでクレームを読み取れるようにするために必要です。Reflag 統合をインストールして設定すると、ビジター スキーマは自動的に設定されます。
{% endstep %}

{% step %}
**コンテンツをパーソナライズする**

ビジター スキーマを設定したら、ユーザーがアクセスできる機能フラグを使って、サイトを訪れるユーザー向けにドキュメント体験を調整する準備が整います。

Reflag で利用可能な任意の機能フラグの値は、ビジター スキーマの一部として次の下に公開されます。 `visitor.claims.unsigned.reflag` オブジェクト。署名なしクレームの詳細を読む [こちら](/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/enabling-adaptive-content.md#set-an-unsigned-claim).

次へ移動します [コンテンツの調整](/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/adapting-your-content.md) ユーザー向けにドキュメントをさらにパーソナライズする方法について詳しく学べます。
{% endstep %}
{% endstepper %}

{% hint style="info" %}
機能フラグの値はクライアント側で評価されるため、機密データやセキュリティ上重要なデータを渡すためにこの方法を使用しないでください。
{% endhint %}


---

# 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, and the optional `goal` query parameter:

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/gong-kai/adaptive-content/enabling-adaptive-content/feature-flags.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
