मुख्य सामग्री पर जाएँ

क्लाइंट लाइब्रेरी

फ़्रेमवर्क अडैप्टर

Dart SDK

Flutter और Dart ऐप्स के लिए क्लाइंट: शुद्ध Dart, कोई रनटाइम निर्भरता नहीं, और वही इवेंट, फ़्लैग तथा इनबॉक्स जो बाकी क्लाइंट रखते हैं।

कहाँ प्रकाशित है

prodantix_sdk on pub.dev. Pure Dart, with no runtime dependencies.

इंस्टॉल

Bash
dart pub add prodantix_sdk

उदाहरण

Dart
import 'package:prodantix_sdk/prodantix_sdk.dart';

const projectKey = String.fromEnvironment('PRODANTIX_PUBLIC_KEY');

final client = ProdantixClient(
  apiKey: projectKey,
  host: 'https://eu.api.prodantix.com',
);

client.identify('user-123');
client.capture('order.completed', properties: {'total': 42});

final inbox = await client.getInbox();
await client.shutdown();
यह क्लाइंट याद रखता है कि उसे कौन इस्तेमाल कर रहा है, इसलिए identify उपयोगकर्ता की आईडी एक बार सेट करता है और उसके बाद की हर कॉल उसी व्यक्ति के बारे में होती है। साइन आउट पर reset कॉल करें।

रिमोट और लोकल फ़्लैग

रिमोट जाँच सर्वर से पूछती है और वही निर्णायक है। लोकल जाँच नियमों के कैश किए गए स्नैपशॉट का मूल्यांकन प्रोसेस के भीतर ही करती है, हर कॉल पर राउंड ट्रिप के बिना, और हॉट पाथ को यही चाहिए।

Dart
// Remote: asks the server, and is the authoritative answer.
if (await client.isFeatureEnabled('new-checkout')) {
  // ...
}

// Local: evaluated in process from a cached snapshot, no round trip per call.
if (await client.isFeatureEnabledLocal('new-checkout', properties: {'plan': 'pro'})) {
  // ...
}

// Every per-flag read records one $feature_flag_called exposure.
final variant = await client.getVariant('new-checkout');
if (variant?['key'] == 'treatment') {
  // ...
}

// A flag targeting a cohort reads this user's memberships from the store;
// pass them yourself to skip the lookup.
if (await client.isFeatureEnabledLocal('members', cohorts: ['<cohort id>'])) {
  // ...
}

यह कहाँ चलता है

यह मोबाइल और Dart VM को लक्ष्य करता है, और नेटवर्क तक dart:io के ज़रिये पहुँचता है। किसी भी अन्य प्लेटफ़ॉर्म पर अपना Transport और Requester दें; क्लाइंट में और कुछ नहीं बदलता।

Dart
final client = ProdantixClient(
  apiKey: projectKey,
  host: 'https://eu.api.prodantix.com',
  transport: MyTransport(),
  requester: myRequester,
  // Hold a Socket.IO subscription to flag changes and refetch the snapshot on
  // push, instead of waiting for the 30s poll.
  streamFlags: true,
);