superposition-provider 0.92.0 → 0.93.0
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/experimentation-client.d.ts +4 -3
- package/dist/index.esm.js +93 -68
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +93 -68
- package/dist/index.js.map +1 -1
- package/dist/native-lib/libsuperposition_core-aarch64-apple-darwin.dylib +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-apple-darwin.dylib +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-pc-windows-msvc.dll +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-unknown-linux-gnu.so +0 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { GroupType } from
|
|
2
|
-
import { SuperpositionOptions, ExperimentationOptions } from
|
|
1
|
+
import { GroupType, Bucket, VariantType } from "superposition-sdk";
|
|
2
|
+
import { SuperpositionOptions, ExperimentationOptions } from "./types";
|
|
3
3
|
export interface Variant {
|
|
4
4
|
id: string;
|
|
5
|
-
variant_type:
|
|
5
|
+
variant_type: VariantType;
|
|
6
6
|
context_id?: string;
|
|
7
7
|
override_id?: string;
|
|
8
8
|
overrides: Record<string, string>;
|
|
@@ -19,6 +19,7 @@ export interface ExperimentGroup {
|
|
|
19
19
|
member_experiment_ids: string[];
|
|
20
20
|
traffic_percentage: number;
|
|
21
21
|
group_type: GroupType;
|
|
22
|
+
buckets: Bucket[];
|
|
22
23
|
}
|
|
23
24
|
export declare class ExperimentationClient {
|
|
24
25
|
private superpositionOptions;
|
package/dist/index.esm.js
CHANGED
|
@@ -9100,7 +9100,7 @@ function requireModels_0 () {
|
|
|
9100
9100
|
if (hasRequiredModels_0) return models_0;
|
|
9101
9101
|
hasRequiredModels_0 = 1;
|
|
9102
9102
|
Object.defineProperty(models_0, "__esModule", { value: true });
|
|
9103
|
-
models_0.Stage = models_0.FunctionExecutionRequest = models_0.ExperimentSortOn = models_0.ExperimentGroupSortOn = models_0.WorkspaceStatus = models_0.Version = models_0.HttpMethod = models_0.OrgStatus = models_0.FunctionTypes = models_0.ContextFilterSortOn = models_0.DimensionMatchStrategy = models_0.MergeStrategy = models_0.DimensionType = models_0.ExperimentStatusType = models_0.ExperimentType = models_0.ContextActionOut = models_0.ContextAction = models_0.ContextIdentifier = models_0.SortBy = models_0.VariantType = models_0.ResourceNotFound = models_0.InternalServerError = models_0.GroupType = void 0;
|
|
9103
|
+
models_0.Stage = models_0.FunctionExecutionRequest = models_0.ExperimentSortOn = models_0.ExperimentGroupSortOn = models_0.WorkspaceStatus = models_0.Version = models_0.HttpMethod = models_0.OrgStatus = models_0.FunctionTypes = models_0.ContextFilterSortOn = models_0.DimensionMatchStrategy = models_0.MergeStrategy = models_0.DimensionType = models_0.ExperimentStatusType = models_0.ExperimentType = models_0.ContextActionOut = models_0.ContextAction = models_0.ContextIdentifier = models_0.SortBy = models_0.AuditAction = models_0.VariantType = models_0.ResourceNotFound = models_0.InternalServerError = models_0.GroupType = void 0;
|
|
9104
9104
|
const SuperpositionServiceException_1 = requireSuperpositionServiceException();
|
|
9105
9105
|
models_0.GroupType = {
|
|
9106
9106
|
SYSTEM_GENERATED: "SYSTEM_GENERATED",
|
|
@@ -9136,9 +9136,14 @@ function requireModels_0 () {
|
|
|
9136
9136
|
CONTROL: "CONTROL",
|
|
9137
9137
|
EXPERIMENTAL: "EXPERIMENTAL",
|
|
9138
9138
|
};
|
|
9139
|
+
models_0.AuditAction = {
|
|
9140
|
+
DELETE: "DELETE",
|
|
9141
|
+
INSERT: "INSERT",
|
|
9142
|
+
UPDATE: "UPDATE",
|
|
9143
|
+
};
|
|
9139
9144
|
models_0.SortBy = {
|
|
9140
|
-
|
|
9141
|
-
|
|
9145
|
+
ASC: "asc",
|
|
9146
|
+
DESC: "desc",
|
|
9142
9147
|
};
|
|
9143
9148
|
var ContextIdentifier;
|
|
9144
9149
|
(function (ContextIdentifier) {
|
|
@@ -9206,22 +9211,22 @@ function requireModels_0 () {
|
|
|
9206
9211
|
REPLACE: "REPLACE",
|
|
9207
9212
|
};
|
|
9208
9213
|
models_0.DimensionMatchStrategy = {
|
|
9209
|
-
|
|
9210
|
-
|
|
9214
|
+
EXACT: "exact",
|
|
9215
|
+
SUBSET: "subset",
|
|
9211
9216
|
};
|
|
9212
9217
|
models_0.ContextFilterSortOn = {
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9218
|
+
CREATED_AT: "created_at",
|
|
9219
|
+
LAST_MODIFIED_AT: "last_modified_at",
|
|
9220
|
+
WEIGHT: "weight",
|
|
9216
9221
|
};
|
|
9217
9222
|
models_0.FunctionTypes = {
|
|
9218
|
-
|
|
9219
|
-
|
|
9223
|
+
AUTOCOMPLETE: "AUTOCOMPLETE",
|
|
9224
|
+
VALIDATION: "VALIDATION",
|
|
9220
9225
|
};
|
|
9221
9226
|
models_0.OrgStatus = {
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9227
|
+
ACTIVE: "Active",
|
|
9228
|
+
INACTIVE: "Inactive",
|
|
9229
|
+
PENDING_KYB: "PendingKyb",
|
|
9225
9230
|
};
|
|
9226
9231
|
models_0.HttpMethod = {
|
|
9227
9232
|
DELETE: "DELETE",
|
|
@@ -9239,13 +9244,13 @@ function requireModels_0 () {
|
|
|
9239
9244
|
ENABLED: "ENABLED",
|
|
9240
9245
|
};
|
|
9241
9246
|
models_0.ExperimentGroupSortOn = {
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9247
|
+
CREATED_AT: "created_at",
|
|
9248
|
+
LAST_MODIFIED_AT: "last_modified_at",
|
|
9249
|
+
NAME: "name",
|
|
9245
9250
|
};
|
|
9246
9251
|
models_0.ExperimentSortOn = {
|
|
9247
|
-
|
|
9248
|
-
|
|
9252
|
+
CREATED_AT: "created_at",
|
|
9253
|
+
LAST_MODIFIED_AT: "last_modified_at",
|
|
9249
9254
|
};
|
|
9250
9255
|
var FunctionExecutionRequest;
|
|
9251
9256
|
(function (FunctionExecutionRequest) {
|
|
@@ -9730,7 +9735,7 @@ function requireAws_restJson1 () {
|
|
|
9730
9735
|
});
|
|
9731
9736
|
b.bp("/config");
|
|
9732
9737
|
const query = (0, smithy_client_1.map)({
|
|
9733
|
-
[_p]: [, input[_p]],
|
|
9738
|
+
[_p]: [() => input.prefix !== void 0, () => ((input[_p] || []))],
|
|
9734
9739
|
[_v]: [, input[_v]],
|
|
9735
9740
|
});
|
|
9736
9741
|
let body;
|
|
@@ -9894,7 +9899,7 @@ function requireAws_restJson1 () {
|
|
|
9894
9899
|
});
|
|
9895
9900
|
b.bp("/config/resolve");
|
|
9896
9901
|
const query = (0, smithy_client_1.map)({
|
|
9897
|
-
[_p]: [, input[_p]],
|
|
9902
|
+
[_p]: [() => input.prefix !== void 0, () => ((input[_p] || []))],
|
|
9898
9903
|
[_v]: [, input[_v]],
|
|
9899
9904
|
[_sr]: [() => input.show_reasoning !== void 0, () => (input[_sr].toString())],
|
|
9900
9905
|
[_ci]: [, input[_ci]],
|
|
@@ -10017,8 +10022,8 @@ function requireAws_restJson1 () {
|
|
|
10017
10022
|
[_a]: [() => input.all !== void 0, () => (input[_a].toString())],
|
|
10018
10023
|
[_fd]: [() => input.from_date !== void 0, () => ((0, smithy_client_1.serializeDateTime)(input[_fd]).toString())],
|
|
10019
10024
|
[_td]: [() => input.to_date !== void 0, () => ((0, smithy_client_1.serializeDateTime)(input[_td]).toString())],
|
|
10020
|
-
[_ta]: [, input[_t]],
|
|
10021
|
-
[_ac]: [, input[_ac]],
|
|
10025
|
+
[_ta]: [() => input.tables !== void 0, () => ((input[_t] || []))],
|
|
10026
|
+
[_ac]: [() => input.action !== void 0, () => ((input[_ac] || []))],
|
|
10022
10027
|
[_u]: [, input[_u]],
|
|
10023
10028
|
[_sb]: [, input[_sb]],
|
|
10024
10029
|
});
|
|
@@ -10041,11 +10046,11 @@ function requireAws_restJson1 () {
|
|
|
10041
10046
|
[_c]: [() => input.count !== void 0, () => (input[_c].toString())],
|
|
10042
10047
|
[_pa]: [() => input.page !== void 0, () => (input[_pa].toString())],
|
|
10043
10048
|
[_a]: [() => input.all !== void 0, () => (input[_a].toString())],
|
|
10044
|
-
[_p]: [, input[_p]],
|
|
10049
|
+
[_p]: [() => input.prefix !== void 0, () => ((input[_p] || []))],
|
|
10045
10050
|
[_so]: [, input[_so]],
|
|
10046
10051
|
[_sb]: [, input[_sb]],
|
|
10047
|
-
[_cb]: [, input[_cb]],
|
|
10048
|
-
[_lmb]: [, input[_lmb]],
|
|
10052
|
+
[_cb]: [() => input.created_by !== void 0, () => ((input[_cb] || []))],
|
|
10053
|
+
[_lmb]: [() => input.last_modified_by !== void 0, () => ((input[_lmb] || []))],
|
|
10049
10054
|
[_pl]: [, input[_pl]],
|
|
10050
10055
|
[_dms]: [, input[_dms]],
|
|
10051
10056
|
});
|
|
@@ -10109,13 +10114,13 @@ function requireAws_restJson1 () {
|
|
|
10109
10114
|
[_c]: [() => input.count !== void 0, () => (input[_c].toString())],
|
|
10110
10115
|
[_pa]: [() => input.page !== void 0, () => (input[_pa].toString())],
|
|
10111
10116
|
[_a]: [() => input.all !== void 0, () => (input[_a].toString())],
|
|
10112
|
-
[_s]: [, input[_s]],
|
|
10117
|
+
[_s]: [() => input.status !== void 0, () => ((input[_s] || []))],
|
|
10113
10118
|
[_fd]: [() => input.from_date !== void 0, () => ((0, smithy_client_1.serializeDateTime)(input[_fd]).toString())],
|
|
10114
10119
|
[_td]: [() => input.to_date !== void 0, () => ((0, smithy_client_1.serializeDateTime)(input[_td]).toString())],
|
|
10115
10120
|
[_en]: [, input[_en]],
|
|
10116
|
-
[_ei]: [, input[_ei]],
|
|
10117
|
-
[_egi]: [, input[_egi]],
|
|
10118
|
-
[_cb]: [, input[_cb]],
|
|
10121
|
+
[_ei]: [() => input.experiment_ids !== void 0, () => ((input[_ei] || []))],
|
|
10122
|
+
[_egi]: [() => input.experiment_group_ids !== void 0, () => ((input[_egi] || []))],
|
|
10123
|
+
[_cb]: [() => input.created_by !== void 0, () => ((input[_cb] || []))],
|
|
10119
10124
|
[_so]: [, input[_so]],
|
|
10120
10125
|
[_sb]: [, input[_sb]],
|
|
10121
10126
|
[_geo]: [() => input.global_experiments_only !== void 0, () => (input[_geo].toString())],
|
|
@@ -10145,7 +10150,7 @@ function requireAws_restJson1 () {
|
|
|
10145
10150
|
[_lmb]: [, input[_lmb]],
|
|
10146
10151
|
[_so]: [, input[_so]],
|
|
10147
10152
|
[_sb]: [, input[_sb]],
|
|
10148
|
-
[_gt]: [, input[_gt]],
|
|
10153
|
+
[_gt]: [() => input.group_type !== void 0, () => ((input[_gt] || []))],
|
|
10149
10154
|
});
|
|
10150
10155
|
let body;
|
|
10151
10156
|
b.m("GET")
|
|
@@ -10166,6 +10171,7 @@ function requireAws_restJson1 () {
|
|
|
10166
10171
|
[_c]: [() => input.count !== void 0, () => (input[_c].toString())],
|
|
10167
10172
|
[_pa]: [() => input.page !== void 0, () => (input[_pa].toString())],
|
|
10168
10173
|
[_a]: [() => input.all !== void 0, () => (input[_a].toString())],
|
|
10174
|
+
[_ft]: [() => input.function_type !== void 0, () => ((input[_ft] || []))],
|
|
10169
10175
|
});
|
|
10170
10176
|
let body;
|
|
10171
10177
|
b.m("GET")
|
|
@@ -12917,6 +12923,7 @@ function requireAws_restJson1 () {
|
|
|
12917
12923
|
const _ei = "experiment_ids";
|
|
12918
12924
|
const _en = "experiment_name";
|
|
12919
12925
|
const _fd = "from_date";
|
|
12926
|
+
const _ft = "function_type";
|
|
12920
12927
|
const _geo = "global_experiments_only";
|
|
12921
12928
|
const _gt = "group_type";
|
|
12922
12929
|
const _lm = "last-modified";
|
|
@@ -15477,10 +15484,11 @@ class ExperimentationClient {
|
|
|
15477
15484
|
this.cachedExperiments = experiments;
|
|
15478
15485
|
this.cachedExperimentGroups = experimentgroups;
|
|
15479
15486
|
this.lastUpdated = new Date();
|
|
15480
|
-
console.log(
|
|
15487
|
+
console.log("Experiments and Experiment Groups fetched successfully.");
|
|
15481
15488
|
}
|
|
15482
15489
|
// Set up refresh strategy
|
|
15483
|
-
if (this.options.refreshStrategy &&
|
|
15490
|
+
if (this.options.refreshStrategy &&
|
|
15491
|
+
"interval" in this.options.refreshStrategy) {
|
|
15484
15492
|
const strategy = this.options.refreshStrategy;
|
|
15485
15493
|
this.startPolling(strategy.interval);
|
|
15486
15494
|
}
|
|
@@ -15494,11 +15502,11 @@ class ExperimentationClient {
|
|
|
15494
15502
|
this.cachedExperiments = experiments;
|
|
15495
15503
|
this.cachedExperimentGroups = experimentGroups;
|
|
15496
15504
|
this.lastUpdated = new Date();
|
|
15497
|
-
console.log(
|
|
15505
|
+
console.log("Experiments and Experiment Groups refreshed successfully.");
|
|
15498
15506
|
}
|
|
15499
15507
|
}
|
|
15500
15508
|
catch (error) {
|
|
15501
|
-
console.error(
|
|
15509
|
+
console.error("Polling error:", error);
|
|
15502
15510
|
}
|
|
15503
15511
|
}, interval);
|
|
15504
15512
|
}
|
|
@@ -15507,7 +15515,11 @@ class ExperimentationClient {
|
|
|
15507
15515
|
const commandInput = {
|
|
15508
15516
|
workspace_id: this.superpositionOptions.workspace_id,
|
|
15509
15517
|
org_id: this.superpositionOptions.org_id,
|
|
15510
|
-
all: true
|
|
15518
|
+
all: true,
|
|
15519
|
+
status: [
|
|
15520
|
+
superpositionSdk.ExperimentStatusType.CREATED,
|
|
15521
|
+
superpositionSdk.ExperimentStatusType.INPROGRESS,
|
|
15522
|
+
],
|
|
15511
15523
|
};
|
|
15512
15524
|
const command = new superpositionSdk.ListExperimentCommand(commandInput);
|
|
15513
15525
|
const response = await this.smithyClient.send(command);
|
|
@@ -15519,7 +15531,7 @@ class ExperimentationClient {
|
|
|
15519
15531
|
for (const exp of response.data) {
|
|
15520
15532
|
// Skip experiments without required fields
|
|
15521
15533
|
if (!exp.id) {
|
|
15522
|
-
console.warn(
|
|
15534
|
+
console.warn("Skipping experiment without ID");
|
|
15523
15535
|
continue;
|
|
15524
15536
|
}
|
|
15525
15537
|
const variants = [];
|
|
@@ -15531,7 +15543,8 @@ class ExperimentationClient {
|
|
|
15531
15543
|
continue;
|
|
15532
15544
|
}
|
|
15533
15545
|
const variantType = variant.variant_type;
|
|
15534
|
-
if (variantType !==
|
|
15546
|
+
if (variantType !== superpositionSdk.VariantType.CONTROL &&
|
|
15547
|
+
variantType !== superpositionSdk.VariantType.EXPERIMENTAL) {
|
|
15535
15548
|
console.warn(`Invalid variant type: ${variant.variant_type}`);
|
|
15536
15549
|
continue;
|
|
15537
15550
|
}
|
|
@@ -15540,7 +15553,7 @@ class ExperimentationClient {
|
|
|
15540
15553
|
variant_type: variantType,
|
|
15541
15554
|
context_id: variant.context_id,
|
|
15542
15555
|
override_id: variant.override_id,
|
|
15543
|
-
overrides: this.normalizeToStringRecord(variant.overrides)
|
|
15556
|
+
overrides: this.normalizeToStringRecord(variant.overrides),
|
|
15544
15557
|
});
|
|
15545
15558
|
}
|
|
15546
15559
|
}
|
|
@@ -15548,13 +15561,13 @@ class ExperimentationClient {
|
|
|
15548
15561
|
id: exp.id,
|
|
15549
15562
|
context: this.normalizeToStringRecord(exp.context),
|
|
15550
15563
|
variants: variants,
|
|
15551
|
-
traffic_percentage: exp.traffic_percentage || 100
|
|
15564
|
+
traffic_percentage: exp.traffic_percentage || 100,
|
|
15552
15565
|
});
|
|
15553
15566
|
}
|
|
15554
15567
|
return experiments;
|
|
15555
15568
|
}
|
|
15556
15569
|
catch (error) {
|
|
15557
|
-
console.error(
|
|
15570
|
+
console.error("Error fetching experiments from Superposition:", error);
|
|
15558
15571
|
return null;
|
|
15559
15572
|
}
|
|
15560
15573
|
}
|
|
@@ -15563,7 +15576,7 @@ class ExperimentationClient {
|
|
|
15563
15576
|
const commandInput = {
|
|
15564
15577
|
workspace_id: this.superpositionOptions.workspace_id,
|
|
15565
15578
|
org_id: this.superpositionOptions.org_id,
|
|
15566
|
-
all: true
|
|
15579
|
+
all: true,
|
|
15567
15580
|
};
|
|
15568
15581
|
const command = new superpositionSdk.ListExperimentGroupsCommand(commandInput);
|
|
15569
15582
|
const response = await this.smithyClient.send(command);
|
|
@@ -15575,7 +15588,7 @@ class ExperimentationClient {
|
|
|
15575
15588
|
for (const exp_group of response.data) {
|
|
15576
15589
|
// Skip experiment groups without required fields
|
|
15577
15590
|
if (!exp_group.id) {
|
|
15578
|
-
console.warn(
|
|
15591
|
+
console.warn("Skipping experiment group without ID");
|
|
15579
15592
|
continue;
|
|
15580
15593
|
}
|
|
15581
15594
|
experimentGroups.push({
|
|
@@ -15583,13 +15596,15 @@ class ExperimentationClient {
|
|
|
15583
15596
|
context: this.normalizeToStringRecord(exp_group.context),
|
|
15584
15597
|
traffic_percentage: exp_group.traffic_percentage || 100,
|
|
15585
15598
|
member_experiment_ids: exp_group.member_experiment_ids || [],
|
|
15586
|
-
group_type: exp_group.group_type ||
|
|
15599
|
+
group_type: exp_group.group_type ||
|
|
15600
|
+
superpositionSdk.GroupType.USER_CREATED,
|
|
15601
|
+
buckets: exp_group.buckets || [],
|
|
15587
15602
|
});
|
|
15588
15603
|
}
|
|
15589
15604
|
return experimentGroups;
|
|
15590
15605
|
}
|
|
15591
15606
|
catch (error) {
|
|
15592
|
-
console.error(
|
|
15607
|
+
console.error("Error fetching experiment groups from Superposition:", error);
|
|
15593
15608
|
return null;
|
|
15594
15609
|
}
|
|
15595
15610
|
}
|
|
@@ -15604,9 +15619,9 @@ class ExperimentationClient {
|
|
|
15604
15619
|
return result;
|
|
15605
15620
|
}
|
|
15606
15621
|
// If it's already a record/object
|
|
15607
|
-
if (typeof value ===
|
|
15622
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
15608
15623
|
for (const [key, val] of Object.entries(value)) {
|
|
15609
|
-
if (typeof val ===
|
|
15624
|
+
if (typeof val === "string") {
|
|
15610
15625
|
result[key] = val;
|
|
15611
15626
|
}
|
|
15612
15627
|
else if (val != null) {
|
|
@@ -15621,14 +15636,16 @@ class ExperimentationClient {
|
|
|
15621
15636
|
return result;
|
|
15622
15637
|
}
|
|
15623
15638
|
async getExperiments() {
|
|
15624
|
-
if (this.options.refreshStrategy &&
|
|
15639
|
+
if (this.options.refreshStrategy &&
|
|
15640
|
+
"ttl" in this.options.refreshStrategy) {
|
|
15625
15641
|
const strategy = this.options.refreshStrategy;
|
|
15626
15642
|
const now = new Date();
|
|
15627
15643
|
const shouldRefresh = !this.lastUpdated ||
|
|
15628
|
-
|
|
15644
|
+
now.getTime() - this.lastUpdated.getTime() >
|
|
15645
|
+
strategy.ttl * 1000;
|
|
15629
15646
|
if (shouldRefresh) {
|
|
15630
15647
|
try {
|
|
15631
|
-
console.log(
|
|
15648
|
+
console.log("TTL expired. Fetching experiments on-demand.");
|
|
15632
15649
|
const experiments = await this.fetchExperiments();
|
|
15633
15650
|
if (experiments) {
|
|
15634
15651
|
this.cachedExperiments = experiments;
|
|
@@ -15636,25 +15653,28 @@ class ExperimentationClient {
|
|
|
15636
15653
|
}
|
|
15637
15654
|
}
|
|
15638
15655
|
catch (error) {
|
|
15639
|
-
console.warn(
|
|
15640
|
-
if (!strategy.use_stale_on_error ||
|
|
15656
|
+
console.warn("On-demand fetch failed:", error);
|
|
15657
|
+
if (!strategy.use_stale_on_error ||
|
|
15658
|
+
!this.cachedExperiments) {
|
|
15641
15659
|
throw error;
|
|
15642
15660
|
}
|
|
15643
|
-
console.log(
|
|
15661
|
+
console.log("Using stale experiments due to error.");
|
|
15644
15662
|
}
|
|
15645
15663
|
}
|
|
15646
15664
|
}
|
|
15647
15665
|
return this.cachedExperiments || [];
|
|
15648
15666
|
}
|
|
15649
15667
|
async getExperimentGroups() {
|
|
15650
|
-
if (this.options.refreshStrategy &&
|
|
15668
|
+
if (this.options.refreshStrategy &&
|
|
15669
|
+
"ttl" in this.options.refreshStrategy) {
|
|
15651
15670
|
const strategy = this.options.refreshStrategy;
|
|
15652
15671
|
const now = new Date();
|
|
15653
15672
|
const shouldRefresh = !this.lastUpdated ||
|
|
15654
|
-
|
|
15673
|
+
now.getTime() - this.lastUpdated.getTime() >
|
|
15674
|
+
strategy.ttl * 1000;
|
|
15655
15675
|
if (shouldRefresh) {
|
|
15656
15676
|
try {
|
|
15657
|
-
console.log(
|
|
15677
|
+
console.log("TTL expired. Fetching experiment groups on-demand.");
|
|
15658
15678
|
const experimentGroups = await this.fetchExperimentGroups();
|
|
15659
15679
|
if (experimentGroups) {
|
|
15660
15680
|
this.cachedExperimentGroups = experimentGroups;
|
|
@@ -15662,11 +15682,12 @@ class ExperimentationClient {
|
|
|
15662
15682
|
}
|
|
15663
15683
|
}
|
|
15664
15684
|
catch (error) {
|
|
15665
|
-
console.warn(
|
|
15666
|
-
if (!strategy.use_stale_on_error ||
|
|
15685
|
+
console.warn("On-demand fetch failed:", error);
|
|
15686
|
+
if (!strategy.use_stale_on_error ||
|
|
15687
|
+
!this.cachedExperimentGroups) {
|
|
15667
15688
|
throw error;
|
|
15668
15689
|
}
|
|
15669
|
-
console.log(
|
|
15690
|
+
console.log("Using stale experiment groups due to error.");
|
|
15670
15691
|
}
|
|
15671
15692
|
}
|
|
15672
15693
|
}
|
|
@@ -15688,15 +15709,15 @@ class ExperimentationClient {
|
|
|
15688
15709
|
try {
|
|
15689
15710
|
if (this.pollingInterval) {
|
|
15690
15711
|
clearInterval(this.pollingInterval);
|
|
15691
|
-
console.log(
|
|
15712
|
+
console.log("Polling stopped successfully");
|
|
15692
15713
|
}
|
|
15693
15714
|
this.clearEvalCache();
|
|
15694
15715
|
this.cachedExperiments = null;
|
|
15695
15716
|
this.lastUpdated = null;
|
|
15696
|
-
console.log(
|
|
15717
|
+
console.log("ExperimentationClient closed successfully");
|
|
15697
15718
|
}
|
|
15698
15719
|
catch (error) {
|
|
15699
|
-
console.error(
|
|
15720
|
+
console.error("Error during ExperimentationClient cleanup:", error);
|
|
15700
15721
|
throw error;
|
|
15701
15722
|
}
|
|
15702
15723
|
}
|
|
@@ -15786,6 +15807,7 @@ class ConfigurationClient {
|
|
|
15786
15807
|
throw new Error(`Failed to fetch configuration: ${errorMessage}`);
|
|
15787
15808
|
}
|
|
15788
15809
|
}
|
|
15810
|
+
// TODO: defaultValue is taken but not used. Should it be used as a fallback?
|
|
15789
15811
|
async getAllConfigValue(defaultValue, context, targetingKey) {
|
|
15790
15812
|
try {
|
|
15791
15813
|
const configData = await this.fetchConfigData();
|
|
@@ -15793,9 +15815,10 @@ class ConfigurationClient {
|
|
|
15793
15815
|
let queryData = { ...context };
|
|
15794
15816
|
if (this.experimentationClient && targetingKey) {
|
|
15795
15817
|
const experiments = await this.experimentationClient.getExperiments();
|
|
15818
|
+
const experiment_groups = await this.experimentationClient.getExperimentGroups();
|
|
15796
15819
|
const identifier = this.experimentationOptions?.defaultIdentifier ||
|
|
15797
15820
|
(targetingKey ? targetingKey : "default");
|
|
15798
|
-
const variantIds = await this.getApplicableVariants(experiments, queryData, identifier);
|
|
15821
|
+
const variantIds = await this.getApplicableVariants(experiments, experiment_groups, this.currentConfigData?.dimensions || {}, queryData, identifier);
|
|
15799
15822
|
if (variantIds.length > 0) {
|
|
15800
15823
|
queryData.variantIds = variantIds;
|
|
15801
15824
|
}
|
|
@@ -15811,9 +15834,9 @@ class ConfigurationClient {
|
|
|
15811
15834
|
}
|
|
15812
15835
|
}
|
|
15813
15836
|
// Add method to get applicable variants
|
|
15814
|
-
async getApplicableVariants(experiments, queryData, identifier, filterPrefixes) {
|
|
15837
|
+
async getApplicableVariants(experiments, experiment_groups, dimensions, queryData, identifier, filterPrefixes) {
|
|
15815
15838
|
// This would use the native resolver's getApplicableVariants method
|
|
15816
|
-
return this.resolver.getApplicableVariants(experiments, queryData, identifier, filterPrefixes || []);
|
|
15839
|
+
return this.resolver.getApplicableVariants(experiments, experiment_groups, dimensions, queryData, identifier, filterPrefixes || []);
|
|
15817
15840
|
}
|
|
15818
15841
|
// Add method to close and cleanup
|
|
15819
15842
|
async close() {
|
|
@@ -16007,7 +16030,7 @@ class NativeResolver {
|
|
|
16007
16030
|
throw new Error(`Failed to parse reasoning evaluation result: ${parseError}`);
|
|
16008
16031
|
}
|
|
16009
16032
|
}
|
|
16010
|
-
getApplicableVariants(experiments, dimensions, userContext, identifier, filterPrefixes = []) {
|
|
16033
|
+
getApplicableVariants(experiments, experiment_groups, dimensions, userContext, identifier, filterPrefixes = []) {
|
|
16011
16034
|
if (!this.isAvailable) {
|
|
16012
16035
|
throw new Error("Native resolver is not available. Please ensure the native library is built and accessible.");
|
|
16013
16036
|
}
|
|
@@ -16018,15 +16041,17 @@ class NativeResolver {
|
|
|
16018
16041
|
throw new Error("userContext parameter is required");
|
|
16019
16042
|
}
|
|
16020
16043
|
const experimentsJson = JSON.stringify(experiments);
|
|
16044
|
+
const experimentGroupsJson = JSON.stringify(experiment_groups);
|
|
16021
16045
|
const userContextJson = JSON.stringify(userContext);
|
|
16022
16046
|
const dimensionsJson = JSON.stringify(dimensions);
|
|
16023
16047
|
const filterPrefixesJson = filterPrefixes.length > 0 ? JSON.stringify(filterPrefixes) : null;
|
|
16024
|
-
console.log("
|
|
16025
|
-
console.log(" experiments:", experiments);
|
|
16048
|
+
console.log("Calling FFI getApplicableVariants with parameters:");
|
|
16049
|
+
console.log(" experiments:", experiments.length);
|
|
16050
|
+
console.log(" experimentGroups:", experiment_groups.length);
|
|
16026
16051
|
console.log(" userContext:", userContext);
|
|
16027
16052
|
console.log(" identifier:", identifier);
|
|
16028
16053
|
console.log(" filterPrefixes:", filterPrefixes);
|
|
16029
|
-
const result = this.lib.core_get_applicable_variants(experimentsJson, dimensionsJson, userContextJson, identifier, filterPrefixesJson);
|
|
16054
|
+
const result = this.lib.core_get_applicable_variants(experimentsJson, experimentGroupsJson, dimensionsJson, userContextJson, identifier, filterPrefixesJson);
|
|
16030
16055
|
console.log("FFI getApplicableVariants call completed, result:", result);
|
|
16031
16056
|
if (!result) {
|
|
16032
16057
|
this.throwLastError("Failed to get applicable variants");
|