@runbandit/sdk 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -3
- package/dist/index.js +819 -747
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -366,7 +366,6 @@ interface CompanySnapshot {
|
|
|
366
366
|
experiments: Record<string, SnapshotExperiment>;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
declare function generateId(): string;
|
|
370
369
|
declare function validateTreatmentWeights(treatments: Treatment[]): boolean;
|
|
371
370
|
declare function normalizeTreatmentWeights(treatments: Treatment[]): Treatment[];
|
|
372
371
|
declare function calculateConfidenceInterval(successes: number, trials: number, confidence?: number): {
|
|
@@ -493,6 +492,9 @@ interface RenderedDocument {
|
|
|
493
492
|
}
|
|
494
493
|
declare function renderEmailDocument(document: EmailDocument, slots: Record<string, string>): RenderedDocument;
|
|
495
494
|
|
|
495
|
+
declare function normalizeConversionPath(input: string | undefined): string | undefined;
|
|
496
|
+
declare function matchesConversionPath(pattern: string, pathname: string): boolean;
|
|
497
|
+
|
|
496
498
|
interface BanditsClientConfig {
|
|
497
499
|
apiUrl: string;
|
|
498
500
|
apiKey: string;
|
|
@@ -513,9 +515,10 @@ declare class BanditsClient {
|
|
|
513
515
|
private config;
|
|
514
516
|
private namedEventQueue;
|
|
515
517
|
private sessionId;
|
|
518
|
+
readonly visitorId: string;
|
|
516
519
|
private flushTimer?;
|
|
517
520
|
constructor(config: BanditsClientConfig);
|
|
518
|
-
getAssignment(experimentId: string, userId
|
|
521
|
+
getAssignment(experimentId: string, userId?: string, context?: ContextualFeatures): Promise<Assignment>;
|
|
519
522
|
trackNamedEvent(event: {
|
|
520
523
|
name: string;
|
|
521
524
|
category?: string;
|
|
@@ -530,6 +533,8 @@ declare class BanditsClient {
|
|
|
530
533
|
identify(anonymousId: string, identifiedUserId: string, mergeReason?: 'user_signup' | 'email_verification' | 'social_login' | 'account_recovery' | 'manual'): Promise<void>;
|
|
531
534
|
label(userId: string, labels: Record<string, string | boolean>): Promise<void>;
|
|
532
535
|
trackFunnelReward(funnelId: string, userId: string, value: number): Promise<void>;
|
|
536
|
+
convert(funnelId: string, value?: number): Promise<void>;
|
|
537
|
+
convertOn(funnelId: string, pathPattern: string, value?: number): Promise<boolean>;
|
|
533
538
|
getBundle(bundleId: string, userId: string, context?: ContextualFeatures): Promise<BundleAssignmentResponse>;
|
|
534
539
|
trackBundleReward(bundleId: string, userId: string, value: number): Promise<void>;
|
|
535
540
|
private generateId;
|
|
@@ -583,13 +588,16 @@ declare class SnapshotClient {
|
|
|
583
588
|
|
|
584
589
|
declare const SESSION_ID_KEY = "bandits_session_id";
|
|
585
590
|
declare const SESSION_CREATED_AT_KEY = "bandits_session_created_at";
|
|
591
|
+
declare const VISITOR_ID_KEY = "bandits_visitor_id";
|
|
586
592
|
declare const DEFAULT_SESSION_TTL_MS = 86400000;
|
|
593
|
+
declare function generateId(): string;
|
|
587
594
|
interface SessionOptions {
|
|
588
595
|
storage?: Storage | null;
|
|
589
596
|
now?: () => number;
|
|
590
597
|
ttlMs?: number;
|
|
591
598
|
}
|
|
592
599
|
declare function getOrCreateSessionId(options?: SessionOptions): string;
|
|
600
|
+
declare function getOrCreateVisitorId(storage: Storage | null | undefined): string;
|
|
593
601
|
|
|
594
602
|
interface RewriteOptions {
|
|
595
603
|
linkTable: string[];
|
|
@@ -632,4 +640,4 @@ declare function reportPlanImpressions(plan: EmailPlan, recipientIds: string[],
|
|
|
632
640
|
alreadyRecorded: boolean;
|
|
633
641
|
}>;
|
|
634
642
|
|
|
635
|
-
export { type APIResponse, type Account, type AlgorithmResult, type ApiKey, type Assignment, type AssignmentRequest, BanditAlgorithm, BanditsClient as BanditClient, type BanditConfig, type BanditResult, BanditsClient, type BanditsClientConfig, type Bound, type Bundle, type BundleAssignmentRequest, type BundleAssignmentResponse, type BundleMode, type BundleSlotAssignment, type ButtonBlock, CONTENT_TYPE_BY_KIND, type Company, type CompanySnapshot, ContentType, type ContextualFeatures, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateExperimentRequest, DEFAULT_HALF_LIFE_MS, DEFAULT_SESSION_TTL_MS, DEFAULT_WINDOW_MS, type DividerBlock, EMAIL_TOKEN_PARAM, type EmailBlock, type EmailDocument, type EmailPlan, type EmailTokenPayload, type Experiment, type ExperimentStats, ExperimentStatus, type ForgettingConfig, ForgettingMode, type Funnel, type FunnelRewardRequest, FunnelStatus, type HeadingBlock, type IdentifyMergeReason, type IdentifyUserRequest, type IdentifyUserResponse, type ImageBlock, type ImageContent, MAX_ORDERING_ITEMS, MIN_ORDERING_ITEMS, type OfferContent, PLACEMENTS, PLACEMENTS_BY_KIND, type Placement, type PlanArm, type PlanRenderResult, type PlanSlot, Posterior, type RenderEmailOptions, type RenderedDocument, type RenderedEmail, type ResolvedIdentity, type RewriteOptions, type RewriteResult, SESSION_CREATED_AT_KEY, SESSION_ID_KEY, STATIONARY, STOREFRONT_KINDS, type Session, type SessionOptions, type SigningKey, type SlotBinding, SnapshotClient, type SnapshotClientConfig, type SnapshotExperiment, type SnapshotTreatment, type SpacerBlock, type StorefrontKind, type SyncAssignment, type TextBlock, type TrackNamedEventRequest, type Treatment, type TreatmentContent, type TreatmentMetadata, type TreatmentStats, type User, type VariantConfig, type VerifiedToken, appendEmailToken, buildSubdomainUrl, calculateConfidenceInterval, extractDocumentSlots, extractEmailLinks, extractSlotNames, extractSubdomain, generateId, generateSubdomain, getContentTypeCategory, getOrCreateSessionId, hashRecipient, impressionManifest, isPlacement, isShopifyCdnUrl, isSlotBinding, isValidEmail, isValidSubdomain, kindOfPlacement, mintEmailToken, normalizeAlgorithm, normalizePosterior, normalizeTreatmentWeights, parseTreatmentContent, pickArm, pickTreatment, renderEmail, renderEmailDocument, renderFromPlan, reportPlanImpressions, resolveForgetting, rewriteEmailLinks, sampleCombination, sanitizeMetadata, serializeTreatmentConfig, shouldRefreshPlan, uniformFor, validateTreatmentWeights, verifyEmailToken };
|
|
643
|
+
export { type APIResponse, type Account, type AlgorithmResult, type ApiKey, type Assignment, type AssignmentRequest, BanditAlgorithm, BanditsClient as BanditClient, type BanditConfig, type BanditResult, BanditsClient, type BanditsClientConfig, type Bound, type Bundle, type BundleAssignmentRequest, type BundleAssignmentResponse, type BundleMode, type BundleSlotAssignment, type ButtonBlock, CONTENT_TYPE_BY_KIND, type Company, type CompanySnapshot, ContentType, type ContextualFeatures, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateExperimentRequest, DEFAULT_HALF_LIFE_MS, DEFAULT_SESSION_TTL_MS, DEFAULT_WINDOW_MS, type DividerBlock, EMAIL_TOKEN_PARAM, type EmailBlock, type EmailDocument, type EmailPlan, type EmailTokenPayload, type Experiment, type ExperimentStats, ExperimentStatus, type ForgettingConfig, ForgettingMode, type Funnel, type FunnelRewardRequest, FunnelStatus, type HeadingBlock, type IdentifyMergeReason, type IdentifyUserRequest, type IdentifyUserResponse, type ImageBlock, type ImageContent, MAX_ORDERING_ITEMS, MIN_ORDERING_ITEMS, type OfferContent, PLACEMENTS, PLACEMENTS_BY_KIND, type Placement, type PlanArm, type PlanRenderResult, type PlanSlot, Posterior, type RenderEmailOptions, type RenderedDocument, type RenderedEmail, type ResolvedIdentity, type RewriteOptions, type RewriteResult, SESSION_CREATED_AT_KEY, SESSION_ID_KEY, STATIONARY, STOREFRONT_KINDS, type Session, type SessionOptions, type SigningKey, type SlotBinding, SnapshotClient, type SnapshotClientConfig, type SnapshotExperiment, type SnapshotTreatment, type SpacerBlock, type StorefrontKind, type SyncAssignment, type TextBlock, type TrackNamedEventRequest, type Treatment, type TreatmentContent, type TreatmentMetadata, type TreatmentStats, type User, VISITOR_ID_KEY, type VariantConfig, type VerifiedToken, appendEmailToken, buildSubdomainUrl, calculateConfidenceInterval, extractDocumentSlots, extractEmailLinks, extractSlotNames, extractSubdomain, generateId, generateSubdomain, getContentTypeCategory, getOrCreateSessionId, getOrCreateVisitorId, hashRecipient, impressionManifest, isPlacement, isShopifyCdnUrl, isSlotBinding, isValidEmail, isValidSubdomain, kindOfPlacement, matchesConversionPath, mintEmailToken, normalizeAlgorithm, normalizeConversionPath, normalizePosterior, normalizeTreatmentWeights, parseTreatmentContent, pickArm, pickTreatment, renderEmail, renderEmailDocument, renderFromPlan, reportPlanImpressions, resolveForgetting, rewriteEmailLinks, sampleCombination, sanitizeMetadata, serializeTreatmentConfig, shouldRefreshPlan, uniformFor, validateTreatmentWeights, verifyEmailToken };
|