Skip to content

Commit 3afaa34

Browse files
committed
[FSSDK-11925] fix type in event.experimentIds field in projectConfig
1 parent a204cb7 commit 3afaa34

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

lib/core/optimizely_config/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export class OptimizelyConfig {
6262
public events: OptimizelyEvent[];
6363
private datafile: string;
6464

65-
6665
constructor(configObj: ProjectConfig, datafile: string, logger?: LoggerFacade) {
6766
this.sdkKey = configObj.sdkKey ?? '';
6867
this.environmentKey = configObj.environmentKey ?? '';

lib/core/project_config/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ interface Event {
5050
key: string;
5151
id: string;
5252
experimentsIds: string[];
53+
54+
// the field is named experimentIds in the datafile, but this type previously defined it as experimentsIds.
55+
// keeping both to avoid breaking changes, removed experimentsIds in v6.
56+
experimentIds: string[]; // fix typo in property name (https://github.com/optimizely/javascript-sdk/issues/991)
5357
}
5458

5559
interface VariableUsageMap {
@@ -142,6 +146,12 @@ export const createProjectConfig = function(datafileObj?: JSON, datafileStr: str
142146

143147
projectConfig.__datafileStr = datafileStr === null ? JSON.stringify(datafileObj) : datafileStr;
144148

149+
// Copy experimentIds to experimentsIds in each event to fix typo in property name
150+
// https://github.com/optimizely/javascript-sdk/issues/991
151+
projectConfig.events.forEach(event => {
152+
event.experimentsIds = event.experimentIds;
153+
});
154+
145155
/*
146156
* Conditions of audiences in projectConfig.typedAudiences are not
147157
* expected to be string-encoded as they are here in projectConfig.audiences.

lib/shared_types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2020-2024, Optimizely
2+
* Copyright 2020-2025, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -469,6 +469,10 @@ export type OptimizelyEvent = {
469469
id: string;
470470
key: string;
471471
experimentsIds: string[];
472+
473+
// the field is named experimentIds in the datafile, but this type previously defined it as experimentsIds.
474+
// keeping both to avoid breaking changes, removed experimentsIds in v6.
475+
experimentIds: string[]; // fix typo in property name (https://github.com/optimizely/javascript-sdk/issues/991)
472476
};
473477

474478
export interface OptimizelyFeature {

0 commit comments

Comments
 (0)