Ruka hadi maudhui makuu

SDK ya Dart

Mteja kwa programu za Flutter na Dart: Dart safi, bila utegemezi wa wakati wa utekelezaji, na matukio, bendera na kikasha vilevile vinavyobebwa na wateja wengine.

Ilipochapishwa

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

Sakinisha

Bash
dart pub add prodantix_sdk

Mfano

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();
Mteja huyu hukumbuka ni nani anayemtumia, hivyo identify huweka kitambulisho mara moja na kila wito unaofuata unamhusu mtu huyo. Ita reset unapotoka.

Bendera za mbali na za ndani

Ukaguzi wa mbali huuliza seva na ndio wenye mamlaka. Ukaguzi wa ndani hutathmini picha iliyohifadhiwa ya sheria ndani ya mchakato wenyewe, bila safari ya kwenda na kurudi kwa kila wito, na hicho ndicho njia yenye shughuli nyingi inahitaji.

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>'])) {
  // ...
}

Unapoendeshwa

Unalenga simu na mashine pepe ya Dart, na hufikia mtandao kupitia dart:io. Katika jukwaa lingine lolote, pitisha Transport na Requester wako mwenyewe; hakuna kingine kinachobadilika kuhusu mteja.

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,
);