ወደ ዋናው ይዘት ዝለል

የደንበኛ ቤተ-መጻሕፍት

የማዕቀፍ አስማሚዎች

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 ምናባዊ ማሽንን ዒላማ ያደርጋል፣ ወደ አውታረ መረቡም በ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,
);