flagsmith-nodejs 2.0.0-beta.1 → 2.0.0-beta.2

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.
Files changed (49) hide show
  1. package/build/flagsmith-engine/environments/models.d.ts +2 -2
  2. package/build/flagsmith-engine/environments/models.js +6 -6
  3. package/build/flagsmith-engine/features/models.d.ts +2 -2
  4. package/build/flagsmith-engine/features/models.js +7 -7
  5. package/build/flagsmith-engine/identities/models.d.ts +1 -1
  6. package/build/flagsmith-engine/identities/models.js +5 -5
  7. package/build/flagsmith-engine/identities/util.js +1 -1
  8. package/build/flagsmith-engine/index.d.ts +1 -1
  9. package/build/flagsmith-engine/index.js +18 -17
  10. package/build/flagsmith-engine/organisations/models.d.ts +1 -1
  11. package/build/flagsmith-engine/organisations/models.js +4 -4
  12. package/build/flagsmith-engine/projects/models.d.ts +1 -1
  13. package/build/flagsmith-engine/projects/models.js +2 -3
  14. package/build/flagsmith-engine/segments/evaluators.js +2 -2
  15. package/build/flagsmith-engine/utils/errors.d.ts +2 -0
  16. package/build/flagsmith-engine/utils/errors.js +6 -0
  17. package/build/flagsmith-engine/utils/hashing/index.d.ts +8 -0
  18. package/build/flagsmith-engine/utils/hashing/index.js +9 -11
  19. package/build/index.d.ts +1 -2
  20. package/build/index.js +5 -1
  21. package/build/sdk/analytics.js +0 -21
  22. package/build/sdk/index.d.ts +1 -2
  23. package/build/sdk/index.js +3 -9
  24. package/build/sdk/polling_manager.d.ts +1 -1
  25. package/build/sdk/utils.d.ts +1 -1
  26. package/build/sdk/utils.js +1 -1
  27. package/example/package-lock.json +1070 -2
  28. package/example/package.json +1 -0
  29. package/example/server/api/index.js +9 -7
  30. package/flagsmith-engine/environments/models.ts +8 -8
  31. package/flagsmith-engine/features/models.ts +7 -7
  32. package/flagsmith-engine/identities/models.ts +8 -8
  33. package/flagsmith-engine/identities/util.ts +1 -1
  34. package/flagsmith-engine/index.ts +20 -19
  35. package/flagsmith-engine/organisations/models.ts +6 -6
  36. package/flagsmith-engine/projects/models.ts +2 -3
  37. package/flagsmith-engine/segments/evaluators.ts +2 -2
  38. package/flagsmith-engine/utils/errors.ts +1 -0
  39. package/flagsmith-engine/utils/hashing/index.ts +9 -14
  40. package/index.ts +4 -1
  41. package/package.json +9 -8
  42. package/sdk/analytics.ts +0 -28
  43. package/sdk/index.ts +9 -21
  44. package/sdk/models.ts +3 -1
  45. package/sdk/polling_manager.ts +4 -4
  46. package/sdk/utils.ts +1 -1
  47. package/tests/sdk/flagsmith.test.ts +1 -1
  48. package/tests/sdk/polling.test.ts +1 -1
  49. package/tests/sdk/utils.ts +1 -1
@@ -9,7 +9,7 @@ export declare class EnvironmentAPIKeyModel {
9
9
  clientApiKey: string;
10
10
  expiresAt?: number;
11
11
  active: boolean;
12
- constructor(id: number, key: string, created_at: number, name: string, client_api_key: string, expires_at?: number);
12
+ constructor(id: number, key: string, createdAt: number, name: string, clientApiKey: string, expiresAt?: number);
13
13
  isValid(): boolean;
14
14
  }
15
15
  export declare class EnvironmentModel {
@@ -21,5 +21,5 @@ export declare class EnvironmentModel {
21
21
  segment_config?: IntegrationModel;
22
22
  mixpanel_config?: IntegrationModel;
23
23
  heap_config?: IntegrationModel;
24
- constructor(id: number, api_key: string, project: ProjectModel);
24
+ constructor(id: number, apiKey: string, project: ProjectModel);
25
25
  }
@@ -9,13 +9,13 @@ class EnvironmentAPIKeyModel {
9
9
  clientApiKey;
10
10
  expiresAt;
11
11
  active = true;
12
- constructor(id, key, created_at, name, client_api_key, expires_at) {
12
+ constructor(id, key, createdAt, name, clientApiKey, expiresAt) {
13
13
  this.id = id;
14
14
  this.key = key;
15
- this.createdAt = created_at;
15
+ this.createdAt = createdAt;
16
16
  this.name = name;
17
- this.clientApiKey = client_api_key;
18
- this.expiresAt = expires_at;
17
+ this.clientApiKey = clientApiKey;
18
+ this.expiresAt = expiresAt;
19
19
  }
20
20
  isValid() {
21
21
  return !!this.active && (!this.expiresAt || this.expiresAt > Date.now());
@@ -31,9 +31,9 @@ class EnvironmentModel {
31
31
  segment_config;
32
32
  mixpanel_config;
33
33
  heap_config;
34
- constructor(id, api_key, project) {
34
+ constructor(id, apiKey, project) {
35
35
  this.id = id;
36
- this.apiKey = api_key;
36
+ this.apiKey = apiKey;
37
37
  this.project = project;
38
38
  }
39
39
  }
@@ -22,9 +22,9 @@ export declare class FeatureStateModel {
22
22
  enabled: boolean;
23
23
  djangoID: number;
24
24
  featurestateUUID: string;
25
- _value: any;
25
+ private value;
26
26
  multivariateFeatureStateValues: MultivariateFeatureStateValueModel[];
27
- constructor(feature: FeatureModel, enabled: boolean, djangoID: number, value?: any, featurestate_uuid?: string);
27
+ constructor(feature: FeatureModel, enabled: boolean, djangoID: number, value?: any, featurestateUuid?: string);
28
28
  setValue(value: any): void;
29
29
  getValue(identityId?: number | string): any;
30
30
  get_feature_state_value(): any;
@@ -44,23 +44,23 @@ class FeatureStateModel {
44
44
  enabled;
45
45
  djangoID;
46
46
  featurestateUUID = (0, uuid_1.v4)();
47
- _value;
47
+ value;
48
48
  multivariateFeatureStateValues = [];
49
- constructor(feature, enabled, djangoID, value, featurestate_uuid = (0, uuid_1.v4)()) {
49
+ constructor(feature, enabled, djangoID, value, featurestateUuid = (0, uuid_1.v4)()) {
50
50
  this.feature = feature;
51
51
  this.enabled = enabled;
52
52
  this.djangoID = djangoID;
53
- this._value = value;
54
- this.featurestateUUID = featurestate_uuid;
53
+ this.value = value;
54
+ this.featurestateUUID = featurestateUuid;
55
55
  }
56
56
  setValue(value) {
57
- this._value = value;
57
+ this.value = value;
58
58
  }
59
59
  getValue(identityId) {
60
60
  if (!!identityId && this.multivariateFeatureStateValues.length > 0) {
61
61
  return this.getMultivariateValue(identityId);
62
62
  }
63
- return this._value;
63
+ return this.value;
64
64
  }
65
65
  get_feature_state_value() {
66
66
  return this.getValue();
@@ -79,7 +79,7 @@ class FeatureStateModel {
79
79
  }
80
80
  startPercentage = limit;
81
81
  }
82
- return this._value;
82
+ return this.value;
83
83
  }
84
84
  }
85
85
  exports.FeatureStateModel = FeatureStateModel;
@@ -8,7 +8,7 @@ export declare class IdentityModel {
8
8
  identityTraits: TraitModel[];
9
9
  identityUuid: string;
10
10
  djangoID: number | undefined;
11
- constructor(created_date: string, identity_traits: TraitModel[], identity_features: IdentityFeaturesList, environment_api_key: string, identifier: string, identity_uuid?: string);
11
+ constructor(created_date: string, identityTraits: TraitModel[], identityFeatures: IdentityFeaturesList, environmentApiKey: string, identifier: string, identityUuid?: string);
12
12
  get compositeKey(): string;
13
13
  static generateCompositeKey(env_key: string, identifier: string): string;
14
14
  update_traits(traits: TraitModel[]): void;
@@ -11,12 +11,12 @@ class IdentityModel {
11
11
  identityTraits;
12
12
  identityUuid;
13
13
  djangoID;
14
- constructor(created_date, identity_traits, identity_features, environment_api_key, identifier, identity_uuid) {
15
- this.identityUuid = identity_uuid || uuidv4();
14
+ constructor(created_date, identityTraits, identityFeatures, environmentApiKey, identifier, identityUuid) {
15
+ this.identityUuid = identityUuid || uuidv4();
16
16
  this.createdDate = Date.parse(created_date) || Date.now();
17
- this.identityTraits = identity_traits;
18
- this.identityFeatures = new collections_1.IdentityFeaturesList(...identity_features);
19
- this.environmentApiKey = environment_api_key;
17
+ this.identityTraits = identityTraits;
18
+ this.identityFeatures = new collections_1.IdentityFeaturesList(...identityFeatures);
19
+ this.environmentApiKey = environmentApiKey;
20
20
  this.identifier = identifier;
21
21
  }
22
22
  get compositeKey() {
@@ -16,7 +16,7 @@ function buildIdentityModel(identityJSON) {
16
16
  const model = new models_1.IdentityModel(identityJSON.created_date, identityJSON.identity_traits
17
17
  ? identityJSON.identity_traits.map((trait) => buildTraitModel(trait))
18
18
  : [], featureList, identityJSON.environment_api_key, identityJSON.identifier, identityJSON.identity_uuid);
19
- model.djangoID = identityJSON['django_id'];
19
+ model.djangoID = identityJSON.django_id;
20
20
  return model;
21
21
  }
22
22
  exports.buildIdentityModel = buildIdentityModel;
@@ -2,7 +2,7 @@ import { EnvironmentModel } from './environments/models';
2
2
  import { FeatureStateModel } from './features/models';
3
3
  import { IdentityModel } from './identities/models';
4
4
  import { TraitModel } from './identities/traits/models';
5
- export declare function getIdentityFeatureState(environment: EnvironmentModel, identity: IdentityModel, feature_name: string, override_traits?: TraitModel[]): FeatureStateModel;
5
+ export declare function getIdentityFeatureState(environment: EnvironmentModel, identity: IdentityModel, featureName: string, overrideTraits?: TraitModel[]): FeatureStateModel;
6
6
  export declare function getIdentityFeatureStates(environment: EnvironmentModel, identity: IdentityModel, overrideTraits?: TraitModel[]): FeatureStateModel[];
7
7
  export declare function getEnvironmentFeatureState(environment: EnvironmentModel, featureName: string): FeatureStateModel;
8
8
  export declare function getEnvironmentFeatureStates(environment: EnvironmentModel): FeatureStateModel[];
@@ -2,45 +2,46 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEnvironmentFeatureStates = exports.getEnvironmentFeatureState = exports.getIdentityFeatureStates = exports.getIdentityFeatureState = void 0;
4
4
  const evaluators_1 = require("./segments/evaluators");
5
- function getIdentityFeatureStatesDict(environment, identity, override_traits) {
5
+ const errors_1 = require("./utils/errors");
6
+ function getIdentityFeatureStatesDict(environment, identity, overrideTraits) {
6
7
  // Get feature states from the environment
7
- const feature_states = {};
8
+ const featureStates = {};
8
9
  for (const fs of environment.featureStates) {
9
- feature_states[fs.feature.id] = fs;
10
+ featureStates[fs.feature.id] = fs;
10
11
  }
11
12
  // Override with any feature states defined by matching segments
12
- const identity_segments = (0, evaluators_1.getIdentitySegments)(environment, identity, override_traits);
13
- for (const matching_segment of identity_segments) {
14
- for (const feature_state of matching_segment.featureStates) {
13
+ const identitySegments = (0, evaluators_1.getIdentitySegments)(environment, identity, overrideTraits);
14
+ for (const matchingSegment of identitySegments) {
15
+ for (const featureState of matchingSegment.featureStates) {
15
16
  // note that feature states are stored on the segment in descending priority
16
17
  // order so we only care that the last one is added
17
18
  // TODO: can we optimise this?
18
- feature_states[feature_state.feature.id] = feature_state;
19
+ featureStates[featureState.feature.id] = featureState;
19
20
  }
20
21
  }
21
22
  // Override with any feature states defined directly the identity
22
23
  for (const fs of identity.identityFeatures || []) {
23
- if (feature_states[fs.feature.id]) {
24
- feature_states[fs.feature.id] = fs;
24
+ if (featureStates[fs.feature.id]) {
25
+ featureStates[fs.feature.id] = fs;
25
26
  }
26
27
  }
27
- return feature_states;
28
+ return featureStates;
28
29
  }
29
- function getIdentityFeatureState(environment, identity, feature_name, override_traits) {
30
- const featureStates = getIdentityFeatureStatesDict(environment, identity, override_traits);
31
- const matchingFeature = Object.values(featureStates).filter(f => f.feature.name === feature_name);
30
+ function getIdentityFeatureState(environment, identity, featureName, overrideTraits) {
31
+ const featureStates = getIdentityFeatureStatesDict(environment, identity, overrideTraits);
32
+ const matchingFeature = Object.values(featureStates).filter(f => f.feature.name === featureName);
32
33
  if (matchingFeature.length === 0) {
33
- throw new Error('Feature State Not Found');
34
+ throw new errors_1.FeatureStateNotFound('Feature State Not Found');
34
35
  }
35
36
  return matchingFeature[0];
36
37
  }
37
38
  exports.getIdentityFeatureState = getIdentityFeatureState;
38
39
  function getIdentityFeatureStates(environment, identity, overrideTraits) {
39
- const feature_states = Object.values(getIdentityFeatureStatesDict(environment, identity, overrideTraits));
40
+ const featureStates = Object.values(getIdentityFeatureStatesDict(environment, identity, overrideTraits));
40
41
  if (environment.project.hideDisabledFlags) {
41
- return feature_states.filter(fs => !!fs.enabled);
42
+ return featureStates.filter(fs => !!fs.enabled);
42
43
  }
43
- return feature_states;
44
+ return featureStates;
44
45
  }
45
46
  exports.getIdentityFeatureStates = getIdentityFeatureStates;
46
47
  function getEnvironmentFeatureState(environment, featureName) {
@@ -4,6 +4,6 @@ export declare class OrganisationModel {
4
4
  featureAnalytics: boolean;
5
5
  stopServingFlags: boolean;
6
6
  persistTraitData: boolean;
7
- constructor(id: number, name: string, feature_analytics: boolean, stop_serving_flags: boolean, persist_trait_data: boolean);
7
+ constructor(id: number, name: string, featureAnalytics: boolean, stopServingFlags: boolean, persistTraitData: boolean);
8
8
  get unique_slug(): string;
9
9
  }
@@ -7,12 +7,12 @@ class OrganisationModel {
7
7
  featureAnalytics;
8
8
  stopServingFlags;
9
9
  persistTraitData;
10
- constructor(id, name, feature_analytics, stop_serving_flags, persist_trait_data) {
10
+ constructor(id, name, featureAnalytics, stopServingFlags, persistTraitData) {
11
11
  this.id = id;
12
12
  this.name = name;
13
- this.featureAnalytics = feature_analytics;
14
- this.stopServingFlags = stop_serving_flags;
15
- this.persistTraitData = persist_trait_data;
13
+ this.featureAnalytics = featureAnalytics;
14
+ this.stopServingFlags = stopServingFlags;
15
+ this.persistTraitData = persistTraitData;
16
16
  }
17
17
  get unique_slug() {
18
18
  return this.id.toString() + '-' + this.name;
@@ -6,5 +6,5 @@ export declare class ProjectModel {
6
6
  organisation: OrganisationModel;
7
7
  hideDisabledFlags: boolean;
8
8
  segments: SegmentModel[];
9
- constructor(id: number, name: string, hide_disabled_flags: boolean, organization: OrganisationModel);
9
+ constructor(id: number, name: string, hideDisabledFlags: boolean, organization: OrganisationModel);
10
10
  }
@@ -6,12 +6,11 @@ class ProjectModel {
6
6
  name;
7
7
  organisation;
8
8
  hideDisabledFlags;
9
- // FIXME
10
9
  segments = [];
11
- constructor(id, name, hide_disabled_flags, organization) {
10
+ constructor(id, name, hideDisabledFlags, organization) {
12
11
  this.id = id;
13
12
  this.name = name;
14
- this.hideDisabledFlags = hide_disabled_flags;
13
+ this.hideDisabledFlags = hideDisabledFlags;
15
14
  this.organisation = organization;
16
15
  }
17
16
  }
@@ -19,11 +19,11 @@ function traitsMatchSegmentRule(identityTraits, rule, segmentId, identityId) {
19
19
  return (matchesConditions &&
20
20
  rule.rules.filter(rule => traitsMatchSegmentRule(identityTraits, rule, segmentId, identityId)).length === rule.rules.length);
21
21
  }
22
- function traitsMatchSegmentCondition(identity_traits, condition, segmentId, identityId) {
22
+ function traitsMatchSegmentCondition(identityTraits, condition, segmentId, identityId) {
23
23
  if (condition.operator == constants_1.PERCENTAGE_SPLIT) {
24
24
  return (0, hashing_1.getHashedPercentateForObjIds)([segmentId, identityId]) <= parseFloat(condition.value);
25
25
  }
26
- const traits = identity_traits.filter(t => t.traitKey === condition.property_);
26
+ const traits = identityTraits.filter(t => t.traitKey === condition.property_);
27
27
  const trait = traits.length > 0 ? traits[0] : undefined;
28
28
  return trait ? condition.matchesTraitValue(trait.traitValue) : false;
29
29
  }
@@ -0,0 +1,2 @@
1
+ export declare class FeatureStateNotFound extends Error {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeatureStateNotFound = void 0;
4
+ class FeatureStateNotFound extends Error {
5
+ }
6
+ exports.FeatureStateNotFound = FeatureStateNotFound;
@@ -1 +1,9 @@
1
+ /**
2
+ * Given a list of object ids, get a floating point number between 0 and 1 based on
3
+ * the hash of those ids. This should give the same value every time for any list of ids.
4
+ *
5
+ * @param {Array<any>} objectIds list of object ids to calculate the has for
6
+ * @param {} iterations=1 num times to include each id in the generated string to hash
7
+ * @returns number number between 0 (inclusive) and 100 (exclusive)
8
+ */
1
9
  export declare function getHashedPercentateForObjIds(objectIds: Array<any>, iterations?: number): number;
@@ -6,18 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getHashedPercentateForObjIds = void 0;
7
7
  const md5_1 = __importDefault(require("md5"));
8
8
  const big_integer_1 = __importDefault(require("big-integer"));
9
- // def get_hashed_percentage_for_object_ids(
10
- // object_ids: typing.Iterable[typing.Any], iterations: int = 1
11
- // ) -> float:
12
- // """
13
- // Given a list of object ids, get a floating point number between 0 and 1 based on
14
- // the hash of those ids. This should give the same value every time for any
15
- // list of ids.
16
- // :param object_ids: list of object ids to calculate the has for
17
- // :param iterations: num times to include each id in the generated string to hash
18
- // :return: (float) number between 0 (inclusive) and 100 (exclusive)
19
- // """
20
9
  const makeRepeated = (arr, repeats) => Array.from({ length: repeats }, () => arr).flat();
10
+ // https://stackoverflow.com/questions/12532871/how-to-convert-a-very-large-hex-number-to-decimal-in-javascript
21
11
  function h2d(s) {
22
12
  function add(x, y) {
23
13
  var c = 0, r = [];
@@ -43,6 +33,14 @@ function h2d(s) {
43
33
  });
44
34
  return dec;
45
35
  }
36
+ /**
37
+ * Given a list of object ids, get a floating point number between 0 and 1 based on
38
+ * the hash of those ids. This should give the same value every time for any list of ids.
39
+ *
40
+ * @param {Array<any>} objectIds list of object ids to calculate the has for
41
+ * @param {} iterations=1 num times to include each id in the generated string to hash
42
+ * @returns number number between 0 (inclusive) and 100 (exclusive)
43
+ */
46
44
  function getHashedPercentateForObjIds(objectIds, iterations = 1) {
47
45
  let to_hash = makeRepeated(objectIds, iterations).join(',');
48
46
  const hashedValue = (0, md5_1.default)(to_hash);
package/build/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import Flagsmith from './sdk';
2
- export default Flagsmith;
1
+ export { Flagsmith } from './sdk';
package/build/index.js CHANGED
@@ -3,5 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Flagsmith = void 0;
6
7
  const sdk_1 = __importDefault(require("./sdk"));
7
- exports.default = sdk_1.default;
8
+ var sdk_2 = require("./sdk");
9
+ Object.defineProperty(exports, "Flagsmith", { enumerable: true, get: function () { return sdk_2.Flagsmith; } });
10
+ // export default Flagsmith;
11
+ module.exports = sdk_1.default;
@@ -9,27 +9,6 @@ const ANALYTICS_ENDPOINT = 'analytics/flags/';
9
9
  // Used to control how often we send data(in seconds)
10
10
  const ANALYTICS_TIMER = 10;
11
11
  const delay = (ms) => new Promise(resolve => setTimeout(() => resolve(undefined), ms));
12
- const retryFetch = (url, fetchOptions = {}, retries = 3, retryDelay = 1000, timeout) => {
13
- return new Promise((resolve, reject) => {
14
- // check for timeout
15
- if (timeout)
16
- setTimeout(() => reject('error: timeout'), timeout);
17
- const wrapper = (n) => {
18
- (0, node_fetch_1.default)(url, fetchOptions)
19
- .then(res => resolve(res))
20
- .catch(async (err) => {
21
- if (n > 0) {
22
- await delay(retryDelay);
23
- wrapper(--n);
24
- }
25
- else {
26
- reject(err);
27
- }
28
- });
29
- };
30
- wrapper(retries);
31
- });
32
- };
33
12
  class AnalyticsProcessor {
34
13
  analyticsEndpoint;
35
14
  environmentKey;
@@ -17,7 +17,7 @@ export declare class Flagsmith {
17
17
  identitiesUrl: string;
18
18
  environmentUrl: string;
19
19
  environmentDataPollingManager?: EnvironmentDataPollingManager;
20
- environment?: EnvironmentModel;
20
+ environment: EnvironmentModel;
21
21
  private analyticsProcessor?;
22
22
  /**
23
23
  * A Flagsmith client.
@@ -94,6 +94,5 @@ export declare class Flagsmith {
94
94
  private getEnvironmentFlagsFromApi;
95
95
  private getIdentityFlagsFromApi;
96
96
  private buildIdentityModel;
97
- stop(): void;
98
97
  }
99
98
  export default Flagsmith;
@@ -120,7 +120,7 @@ class Flagsmith {
120
120
  this.environment = await this.getEnvironmentFromApi();
121
121
  }
122
122
  async getJSONResponse(url, method, body) {
123
- const headers = {};
123
+ const headers = { 'Content-Type': 'application/json' };
124
124
  if (this.environmentKey) {
125
125
  headers['X-Environment-Key'] = this.environmentKey;
126
126
  }
@@ -145,9 +145,6 @@ class Flagsmith {
145
145
  return (0, util_1.buildEnvironmentModel)(environment_data);
146
146
  }
147
147
  getEnvironmentFlagsFromDocument() {
148
- if (!this.environment) {
149
- throw new errors_1.FlagsmithClientError('Unable to build identity model when no local environment present.');
150
- }
151
148
  return models_3.Flags.fromFeatureStateModels({
152
149
  featureStates: (0, flagsmith_engine_1.getEnvironmentFeatureStates)(this.environment),
153
150
  analyticsProcessor: this.analyticsProcessor,
@@ -155,10 +152,7 @@ class Flagsmith {
155
152
  });
156
153
  }
157
154
  getIdentityFlagsFromDocument(identifier, traits) {
158
- if (!this.environment) {
159
- throw new errors_1.FlagsmithClientError('Unable to build identity model when no local environment present.');
160
- }
161
- const identityModel = this.buildIdentityModel(identifier, Object.keys(traits).map((key) => ({
155
+ const identityModel = this.buildIdentityModel(identifier, Object.keys(traits).map(key => ({
162
156
  key,
163
157
  value: traits[key]
164
158
  })));
@@ -215,7 +209,7 @@ class Flagsmith {
215
209
  const traitModels = traits.map(trait => new models_2.TraitModel(trait.key, trait.value));
216
210
  return new models_1.IdentityModel('0', traitModels, [], this.environment.apiKey, identifier);
217
211
  }
218
- stop() { }
219
212
  }
220
213
  exports.Flagsmith = Flagsmith;
221
214
  exports.default = Flagsmith;
215
+ // export = Flagsmith;
@@ -1,4 +1,4 @@
1
- import { Flagsmith } from '.';
1
+ import Flagsmith from '.';
2
2
  export declare class EnvironmentDataPollingManager {
3
3
  private interval?;
4
4
  private main;
@@ -4,7 +4,7 @@ export declare function generateIdentitiesData(identifier: string, traits?: {
4
4
  }): {
5
5
  identifier: string;
6
6
  traits: {
7
- trait_key: any;
7
+ trait_key: string;
8
8
  trait_value: any;
9
9
  }[];
10
10
  };
@@ -9,7 +9,7 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
9
9
  if (typeof node_fetch_1.default.default !== 'undefined')
10
10
  node_fetch_1.default = node_fetch_1.default.default;
11
11
  function generateIdentitiesData(identifier, traits) {
12
- const traitsGenerated = Object.values(traits || {}).map(trait => ({
12
+ const traitsGenerated = Object.entries(traits || {}).map(trait => ({
13
13
  trait_key: trait[0],
14
14
  trait_value: trait[1]
15
15
  }));