安装 SDK
为你的运行环境选择对应的 SDK。每一个都把事件发送到同一个采集端点,并依据同一套规则在本地评估功能开关,因此无论你选哪一个,用户都会落入同一批次。
这些代码片段中的密钥来自控制台: 获取 API 密钥
At a glance
- Packages
@prodantix/sdk(web),prodantix_sdk(Dart),prodantix_sdk_flutter(Flutter),prodantix-sdk(Python)- Ingest host
https://eu.api.prodantix.com- Flags host
https://api.prodantix.com- Credentials
- Public project key in the client, access token for GraphQL
- Verify
- Read the event back from the
eventsquery
浏览器与 Node
Bash
bun add @prodantix/sdk
# React 应用还需要这个适配器:
bun add @prodantix/reactJavaScript
import { createWebClient } from '@prodantix/sdk/web';
const prodantix = createWebClient({
apiKey: PRODANTIX_PUBLIC_KEY,
host: 'https://eu.api.prodantix.com',
flagsHost: 'https://api.prodantix.com',
});
prodantix.capture('order.completed', { properties: { amount: 4200 } });JavaScript
import { ProdantixProvider, useProdantix } from '@prodantix/react';
<ProdantixProvider options={{ apiKey: PRODANTIX_PUBLIC_KEY, host: 'https://eu.api.prodantix.com' }}>
<App />
</ProdantixProvider>
const prodantix = useProdantix();
prodantix?.capture('order.completed');Flutter 与 Dart
Bash
flutter pub add prodantix_sdk_flutter
# Dart 服务端或命令行,不带 Flutter 层:
dart pub add prodantix_sdkPython 服务端
Bash
pip install prodantix-sdk项目密钥是公开的:它只标识项目,并不授予访问其数据的权限,因此可以随客户端代码一起发布。但具备写入权限的服务端密钥绝不可发布。
确认事件已到达
Ingestion answers 202 as soon as the batch is accepted. To see the event itself, read it back from the events query, or watch it arrive on the realtime project room.
Bash
curl "https://api.prodantix.com/graphql" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query":"{ events(projectId: \"p_1\", limit: 5) { name receivedAt } }"}'