Skip to content

Commit

Permalink
Add IDType to GCIR (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
sroyal-statsig authored Oct 9, 2024
1 parent 7c9a175 commit 7230be8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type InitializeResponse = {
allocated_experiment_name?: string;
explicit_parameters?: string[];
undelegated_secondary_exposures?: Record<string, string>[];
id_type?: string;
};

export type ClientInitializeResponse = {
Expand Down Expand Up @@ -329,6 +330,7 @@ export default class Evaluator {
res.secondary_exposures,
options?.hash,
),
id_type: spec.idType,
};
});

Expand All @@ -348,6 +350,7 @@ export default class Evaluator {
}),
);
const format = this._specToInitializeResponse(spec, res, options?.hash);
format.id_type = spec.idType ?? null;
if (spec.entity !== 'dynamic_config' && spec.entity !== 'autotune') {
format.is_user_in_experiment = this._isUserAllocatedToExperiment(
user,
Expand Down
9 changes: 9 additions & 0 deletions src/__tests__/data/initialize_response.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
{
"feature_gates": {
"KfJ1sBBfnL8SwCIxTAyfnj6DiWIyR7uSqimZADQi4Jg=": {
"id_type": "userID",
"name": "KfJ1sBBfnL8SwCIxTAyfnj6DiWIyR7uSqimZADQi4Jg=",
"rule_id": "",
"secondary_exposures": [],
"value": false
},
"OqAaBJ4fpvUSJVicA+jDgotK2OKGJmKxbu+Icyq30P4=": {
"id_type": "userID",
"name": "OqAaBJ4fpvUSJVicA+jDgotK2OKGJmKxbu+Icyq30P4=",
"rule_id": "2DWuOvXQZWKvoaNm27dqcs",
"secondary_exposures": [],
"value": true
},
"rGc+6rvo48V4j1sXkvsGHeSfJfY7kMp1OHfQnw+3XbI=": {
"id_type": "userID",
"name": "rGc+6rvo48V4j1sXkvsGHeSfJfY7kMp1OHfQnw+3XbI=",
"value": true,
"rule_id": "2DWuOvXQZWKvoaNm27dqcs",
"secondary_exposures": []
},
"srhBjpz3NFHATrntxEsdHManNXJQZawtJUkQ3s0XT3Q=": {
"id_type": "userID",
"name": "srhBjpz3NFHATrntxEsdHManNXJQZawtJUkQ3s0XT3Q=",
"value": true,
"rule_id": "3jdTW54SQWbbxFFZJe7wYZ",
Expand All @@ -35,11 +39,13 @@
},
"rule_id": "4lInPNRUnjUzaWNkEWLFA9",
"group": "4lInPNRUnjUzaWNkEWLFA9",
"id_type": "userID",
"is_device_based": false,
"secondary_exposures": []
},
"S52jGlsKiXpNsVbAbe/hcTxLnaHOVT+rNsVP/ibJitY=": {
"group": "prestart",
"id_type": "userID",
"is_device_based": false,
"name": "S52jGlsKiXpNsVbAbe/hcTxLnaHOVT+rNsVP/ibJitY=",
"rule_id": "prestart",
Expand All @@ -54,13 +60,15 @@
"rule_id": "5yQbPMfmKQdiRV35hS3B2l",
"group": "5yQbPMfmKQdiRV35hS3B2l",
"group_name": "Control",
"id_type": "userID",
"is_device_based": false,
"secondary_exposures": [],
"is_experiment_active": true,
"is_user_in_experiment": true
},
"BYdogc4bXxkqfoDOnfjlh1Ij+5QKjNp0rACKdwBL+vc=": {
"group": "",
"id_type": null,
"is_device_based": false,
"is_experiment_active": false,
"is_user_in_experiment": false,
Expand All @@ -74,6 +82,7 @@
"value": {},
"rule_id": "prestart",
"group": "prestart",
"id_type": "userID",
"secondary_exposures": [],
"is_device_based": false,
"is_experiment_active": false,
Expand Down

0 comments on commit 7230be8

Please sign in to comment.