Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 49x 49x 49x 49x 49x 374x 374x 184x 184x 190x 190x 190x 105x 105x 190x 190x 190x 190x 190x 610x 610x 610x 190x 190x 190x 190x 190x 49x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 60x 32x 2x | import Flag from './flag'
export default class Router {
constructor(gatingInfo) {
this.gatingInfo = gatingInfo
this.gatingInfoMap = this._getGatingInfoMap(this.gatingInfo)
}
_getGatingInfoMap(gatingInfo) {
const map = {}
const flags = gatingInfo.flags
for (let i = 0; i < flags.length; i++) {
const flag = Object.assign({}, flags[i])
if (flag.flagType === 'uncategorized' || flag.flagStatus === 'archived') {
map[flag.codename] = new Flag(flag)
continue
}
const overrides = flag.overrides
const overridesMap = {}
for (let j = 0; j < overrides.length; j++) {
const override = overrides[j]
overridesMap[`${override.entityType}_${override.entityId}`] = override
}
flag.overrides = overridesMap
const treatments = flag.treatments
const treatmentsMap = {}
let offTreatment = null
for (let k = 0; k < treatments.length; k++) {
const treatment = treatments[k]
treatmentsMap[treatment.treatmentId] = treatment
if (treatment.isOffTreatment) {
offTreatment = treatment
}
}
flag.treatments = treatments
flag.treatmentsMap = treatmentsMap
flag.offTreatment = offTreatment
map[flag.codename] = new Flag(flag)
}
return map
}
getIngestionMaxItem() {
const sdkInfo = this.gatingInfo.sdkInfo
Eif (sdkInfo) {
return sdkInfo.SDK_INGESTION_MAX_ITEMS
}
return null
}
getBrowserIngestionMaxItems() {
const sdkInfo = this.gatingInfo.sdkInfo
Eif (sdkInfo) {
return sdkInfo.SDK_BROWSER_INGESTION_MAX_ITEMS
}
return null
}
getIngestionInterval() {
const sdkInfo = this.gatingInfo.sdkInfo
Eif (sdkInfo) {
return sdkInfo.SDK_INGESTION_INTERVAL * 1000
}
return null
}
getBrowserIngestionInterval() {
const sdkInfo = this.gatingInfo.sdkInfo
Eif (sdkInfo) {
return sdkInfo.SDK_BROWSER_INGESTION_INTERVAL * 1000
}
return null
}
getShouldIngestObjects() {
const sdkInfo = this.gatingInfo.sdkInfo
Iif (sdkInfo && typeof sdkInfo.SDK_SHOULD_INGEST_OBJECTS === 'boolean') {
return sdkInfo.SDK_SHOULD_INGEST_OBJECTS
}
return null
}
getShouldIngestStats() {
const sdkInfo = this.gatingInfo.sdkInfo
Iif (sdkInfo && typeof sdkInfo.SDK_SHOULD_INGEST_STATS === 'boolean') {
return sdkInfo.SDK_SHOULD_INGEST_STATS
}
return null
}
getShouldIngestExposures() {
const sdkInfo = this.gatingInfo.sdkInfo
Iif (sdkInfo && typeof sdkInfo.SDK_SHOULD_INGEST_EXPOSURES === 'boolean') {
return sdkInfo.SDK_SHOULD_INGEST_EXPOSURES
}
return null
}
getShouldIngestFlags() {
const sdkInfo = this.gatingInfo.sdkInfo
Iif (sdkInfo && typeof sdkInfo.SDK_SHOULD_INGEST_FLAGS === 'boolean') {
return sdkInfo.SDK_SHOULD_INGEST_FLAGS
}
return null
}
getFlag(flagName) {
return this.gatingInfoMap[flagName] || new Flag(flagName)
}
getEnv() {
return this.gatingInfo.env
}
isLocallyConfigured() {
return this.getEnv().envKey === null
}
}
|