Chuyển đến nội dung chính

Cài đặt một SDK

Chọn SDK phù hợp với môi trường chạy của bạn. Mỗi SDK đều gửi sự kiện tới cùng một endpoint thu nhận và đánh giá cờ tính năng cục bộ theo cùng bộ quy tắc, nên dù chọn cái nào người dùng cũng rơi vào cùng một đợt triển khai.

Khóa trong các đoạn mã này lấy từ bảng điều khiển: Lấy khóa API

At a glance

Packages
@prodantix/sdk (web), prodantix_sdk (Dart), prodantix_sdk_flutter (Flutter), prodantix-sdk (Python)
Credential
The public project key: Projects & keys
Endpoints
Hosts and contracts: REST

Trình duyệt và Node

Bash
bun add @prodantix/sdk

# Ứng dụng React cũng cần thêm bộ chuyển đổi:
bun add @prodantix/react
JavaScript
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 và Dart

Bash
flutter pub add prodantix_sdk_flutter

# Máy chủ Dart hoặc CLI, không có lớp Flutter:
dart pub add prodantix_sdk

Máy chủ Python

Bash
pip install prodantix-sdk

Khóa dự án của bạn là công khai: nó chỉ định danh dự án chứ không cấp quyền truy cập dữ liệu, nên có thể nằm trong mã phía client. Khóa máy chủ, vốn có quyền ghi, thì không bao giờ.

Tiếp theo đi đâu

Bắt đầu nhanh: capture a first event and read it back. Each package’s full surface is under Packages, and framework wiring (React, Vue, Svelte, Angular) under Frameworks.