@seekora-ai/search-sdk 0.2.12 → 0.2.13
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/client.d.ts +26 -0
- package/dist/client.js +24 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -78,6 +78,14 @@ export interface SeekoraClientConfig {
|
|
|
78
78
|
* @default 0
|
|
79
79
|
*/
|
|
80
80
|
impressionTrackingDelay?: number;
|
|
81
|
+
/**
|
|
82
|
+
* A/B test experiment ID to include in all analytics events
|
|
83
|
+
*/
|
|
84
|
+
abTestId?: string;
|
|
85
|
+
/**
|
|
86
|
+
* A/B test variant to include in all analytics events
|
|
87
|
+
*/
|
|
88
|
+
abVariant?: string;
|
|
81
89
|
/**
|
|
82
90
|
* Enable event deduplication (industry standard: Segment, Amplitude pattern)
|
|
83
91
|
* When enabled, generates insert_id for backend deduplication
|
|
@@ -147,6 +155,10 @@ export interface ExtendedEventPayload extends DataTypesEventPayload {
|
|
|
147
155
|
insert_id?: string;
|
|
148
156
|
/** Conversion type for conversion events (add_to_cart, wishlist, purchase, etc.) */
|
|
149
157
|
conversion_type?: string;
|
|
158
|
+
/** A/B test experiment ID */
|
|
159
|
+
ab_test_id?: string;
|
|
160
|
+
/** A/B test variant */
|
|
161
|
+
ab_variant?: string;
|
|
150
162
|
}
|
|
151
163
|
export interface SearchOptions {
|
|
152
164
|
q: string;
|
|
@@ -330,6 +342,8 @@ export declare class SeekoraClient {
|
|
|
330
342
|
private clientConfig;
|
|
331
343
|
private enableDeduplication;
|
|
332
344
|
private deduplicationWindow;
|
|
345
|
+
private abTestId?;
|
|
346
|
+
private abVariant?;
|
|
333
347
|
constructor(config?: SeekoraClientConfig);
|
|
334
348
|
/**
|
|
335
349
|
* Search for documents
|
|
@@ -743,6 +757,18 @@ export declare class SeekoraClient {
|
|
|
743
757
|
anonId: string;
|
|
744
758
|
sessionId: string;
|
|
745
759
|
};
|
|
760
|
+
/**
|
|
761
|
+
* Set A/B test experiment ID and variant for all subsequent analytics events.
|
|
762
|
+
* Call this when experiment assignments are fetched.
|
|
763
|
+
*/
|
|
764
|
+
setAbTest(abTestId?: string, abVariant?: string): void;
|
|
765
|
+
/**
|
|
766
|
+
* Get current A/B test fields
|
|
767
|
+
*/
|
|
768
|
+
getAbTest(): {
|
|
769
|
+
abTestId?: string;
|
|
770
|
+
abVariant?: string;
|
|
771
|
+
};
|
|
746
772
|
/**
|
|
747
773
|
* Get the event queue instance (if enabled)
|
|
748
774
|
*/
|
package/dist/client.js
CHANGED
|
@@ -42,6 +42,8 @@ class SeekoraClient {
|
|
|
42
42
|
this.anonId = config.anonId || (0, utils_1.getOrCreateAnonId)();
|
|
43
43
|
this.sessionId = config.sessionId || (0, utils_1.getOrCreateSessionId)();
|
|
44
44
|
this.autoTrackSearch = config.autoTrackSearch || false;
|
|
45
|
+
this.abTestId = config.abTestId;
|
|
46
|
+
this.abVariant = config.abVariant;
|
|
45
47
|
// Initialize context collection
|
|
46
48
|
this.enableContextCollection = config.enableContextCollection !== false; // Default to true
|
|
47
49
|
this.contextCollector = new context_collector_1.ContextCollector(config.contextCollector);
|
|
@@ -1235,6 +1237,13 @@ class SeekoraClient {
|
|
|
1235
1237
|
payload.is_tablet = ctx.is_tablet ? 1 : 0;
|
|
1236
1238
|
payload.is_touch_device = ctx.is_touch_device;
|
|
1237
1239
|
}
|
|
1240
|
+
// Inject A/B test fields from client config (event-level values take precedence)
|
|
1241
|
+
if (this.abTestId && !payload.ab_test_id) {
|
|
1242
|
+
payload.ab_test_id = this.abTestId;
|
|
1243
|
+
}
|
|
1244
|
+
if (this.abVariant && !payload.ab_variant) {
|
|
1245
|
+
payload.ab_variant = this.abVariant;
|
|
1246
|
+
}
|
|
1238
1247
|
// Generate insert_id for deduplication (industry standard: Segment/Amplitude pattern)
|
|
1239
1248
|
// Always enable for purchase events (revenue must be accurate)
|
|
1240
1249
|
// Optional for other events based on config
|
|
@@ -1631,6 +1640,21 @@ class SeekoraClient {
|
|
|
1631
1640
|
sessionId: this.sessionId,
|
|
1632
1641
|
};
|
|
1633
1642
|
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Set A/B test experiment ID and variant for all subsequent analytics events.
|
|
1645
|
+
* Call this when experiment assignments are fetched.
|
|
1646
|
+
*/
|
|
1647
|
+
setAbTest(abTestId, abVariant) {
|
|
1648
|
+
this.abTestId = abTestId;
|
|
1649
|
+
this.abVariant = abVariant;
|
|
1650
|
+
this.logger.verbose('A/B test fields updated', { abTestId, abVariant });
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Get current A/B test fields
|
|
1654
|
+
*/
|
|
1655
|
+
getAbTest() {
|
|
1656
|
+
return { abTestId: this.abTestId, abVariant: this.abVariant };
|
|
1657
|
+
}
|
|
1634
1658
|
/**
|
|
1635
1659
|
* Get the event queue instance (if enabled)
|
|
1636
1660
|
*/
|