From f560af7039f01a26788fd0cf4304e7aec0185159 Mon Sep 17 00:00:00 2001 From: Vinicius de Lacerda Date: Thu, 6 Jun 2024 13:16:36 +0200 Subject: [PATCH] Code review --- packages/lib/package.json | 5 +- .../src/integrations/__fixtures__/dataFile.ts | 122 +++++++++++++----- 2 files changed, 93 insertions(+), 34 deletions(-) diff --git a/packages/lib/package.json b/packages/lib/package.json index 6448337..5299962 100755 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -2,9 +2,8 @@ "name": "opticks", "version": "4.3.0", "description": "FindHotel Toggle Flag JavaScript SDK", - "main": "dist/optimizely.js", - "module": "dist/optimizely.mjs", - "types": "dist/optimizely.d.ts", + "main": "src/optimizely.ts", + "types": "src/types.ts", "files": [ "dist" ], diff --git a/packages/lib/src/integrations/__fixtures__/dataFile.ts b/packages/lib/src/integrations/__fixtures__/dataFile.ts index 292932f..7313f92 100755 --- a/packages/lib/src/integrations/__fixtures__/dataFile.ts +++ b/packages/lib/src/integrations/__fixtures__/dataFile.ts @@ -1,10 +1,98 @@ export default { accountId: '12345', - anonymizeIP: false, - botFiltering: false, projectId: '23456', revision: '6', + attributes: [ + {id: 'trafficSource', key: 'trafficSource'}, + {id: 'hasDefaultDates', key: 'hasDefaultDates'}, + {id: 'deviceType', key: 'deviceType'} + ], + audiences: [ + { + id: 'foo-default-dates', + name: 'Foo Traffic', + conditions: + '[ "and", { "name": "trafficSource", "value": "foo", "type": "custom_attribute" }, { "name": "hasDefaultDates", "value": true, "type": "custom_attribute" }, ["not", { "name": "deviceType", "value": "mobile", "type": "custom_attribute" } ] ]' + } + ], version: '4', + events: [], + integrations: [], + anonymizeIP: false, + botFiltering: false, + typedAudiences: [], + variables: [], + environmentKey: 'production', + sdkKey: '12345', + featureFlags: [ + { + experimentIds: ['foo'], + id: 'foo', + rolloutId: 'rollout-1234', + key: 'foo', + variables: [] + }, + { + experimentIds: ['bar'], + id: 'bar', + rolloutId: 'rollout-456', + key: 'bar', + variables: [] + } + ], + rollouts: [ + { + id: 'rollout-1234', + experiments: [ + { + id: '12345', + key: 'foo-exp', + status: 'Running', + layerId: '1234', + variations: [ + { + id: '12345', + key: 'on', + featureEnabled: true, + variables: [] + } + ], + trafficAllocation: [ + { + entityId: '12345', + endOfRange: 5000 + } + ], + forcedVariations: {}, + audienceIds: [], + audienceConditions: [] + }, + { + id: 'default-foo', + key: 'default-foo', + status: 'Running', + layerId: 'default-foo', + variations: [ + { + id: '624542', + key: 'off', + featureEnabled: false, + variables: [] + } + ], + trafficAllocation: [ + { + entityId: '624542', + endOfRange: 10000 + } + ], + forcedVariations: {}, + audienceIds: [], + audienceConditions: [] + } + ] + } + ], experiments: [ { id: 'foo', @@ -67,33 +155,5 @@ export default { forcedVariations: [] } ], - featureFlags: [ - { - experimentIds: ['foo'], - id: 'foo', - key: 'foo' - }, - { - experimentIds: ['bar'], - id: 'bar', - key: 'bar' - } - ], - events: [], - audiences: [ - { - id: 'foo-default-dates', - name: 'Foo Traffic', - conditions: - '[ "and", { "name": "trafficSource", "value": "foo", "type": "custom_attribute" }, { "name": "hasDefaultDates", "value": true, "type": "custom_attribute" }, ["not", { "name": "deviceType", "value": "mobile", "type": "custom_attribute" } ] ]' - } - ], - attributes: [ - {id: 'trafficSource', key: 'trafficSource'}, - {id: 'hasDefaultDates', key: 'hasDefaultDates'}, - {id: 'deviceType', key: 'deviceType'} - ], - groups: [], - rollouts: [], - variables: [] + groups: [] }