@datadog/flagging-core 0.2.0 → 0.3.0
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.
- package/LICENSE +1 -1
- package/cjs/configuration/flagEvaluationAggregator.d.ts +15 -0
- package/cjs/configuration/flagEvaluationAggregator.d.ts.map +1 -0
- package/cjs/configuration/flagEvaluationAggregator.js +82 -0
- package/cjs/configuration/flagEvaluationAggregator.js.map +1 -0
- package/cjs/configuration/flagEvaluationEvent.d.ts +18 -0
- package/cjs/configuration/flagEvaluationEvent.d.ts.map +1 -0
- package/cjs/configuration/flagEvaluationEvent.js +38 -0
- package/cjs/configuration/flagEvaluationEvent.js.map +1 -0
- package/cjs/configuration/flagEvaluationEvent.types.d.ts +55 -0
- package/cjs/configuration/flagEvaluationEvent.types.d.ts.map +1 -0
- package/cjs/configuration/flagEvaluationEvent.types.js +3 -0
- package/cjs/configuration/flagEvaluationEvent.types.js.map +1 -0
- package/cjs/configuration/index.d.ts +3 -0
- package/cjs/configuration/index.d.ts.map +1 -1
- package/cjs/configuration/index.js +3 -0
- package/cjs/configuration/index.js.map +1 -1
- package/esm/configuration/flagEvaluationAggregator.d.ts +15 -0
- package/esm/configuration/flagEvaluationAggregator.d.ts.map +1 -0
- package/esm/configuration/flagEvaluationAggregator.js +78 -0
- package/esm/configuration/flagEvaluationAggregator.js.map +1 -0
- package/esm/configuration/flagEvaluationEvent.d.ts +18 -0
- package/esm/configuration/flagEvaluationEvent.d.ts.map +1 -0
- package/esm/configuration/flagEvaluationEvent.js +35 -0
- package/esm/configuration/flagEvaluationEvent.js.map +1 -0
- package/esm/configuration/flagEvaluationEvent.types.d.ts +55 -0
- package/esm/configuration/flagEvaluationEvent.types.d.ts.map +1 -0
- package/esm/configuration/flagEvaluationEvent.types.js +2 -0
- package/esm/configuration/flagEvaluationEvent.types.js.map +1 -0
- package/esm/configuration/index.d.ts +3 -0
- package/esm/configuration/index.d.ts.map +1 -1
- package/esm/configuration/index.js +3 -0
- package/esm/configuration/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2025 Datadog, Inc.
|
|
189
|
+
Copyright 2025-present Datadog, Inc.
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EvaluationContext, EvaluationDetails, FlagValue } from '@openfeature/core';
|
|
2
|
+
import type { FlagEvaluationEvent } from './flagEvaluationEvent.types';
|
|
3
|
+
export declare class FlagEvaluationAggregator {
|
|
4
|
+
private aggregatedData;
|
|
5
|
+
private intervalId?;
|
|
6
|
+
private readonly flushInterval;
|
|
7
|
+
private readonly onFlush;
|
|
8
|
+
constructor(flushInterval: number, onFlush: (events: FlagEvaluationEvent[]) => void);
|
|
9
|
+
start(): void;
|
|
10
|
+
stop(): void;
|
|
11
|
+
addEvaluation<T extends FlagValue>(context: EvaluationContext, details: EvaluationDetails<T>, error?: string): void;
|
|
12
|
+
flush(): void;
|
|
13
|
+
private createAggregationKeyString;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=flagEvaluationAggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationAggregator.d.ts","sourceRoot":"","sources":["../../src/configuration/flagEvaluationAggregator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA0B,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGhH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAgBtE,qBAAa,wBAAwB;IACnC,OAAO,CAAC,cAAc,CAAmD;IACzE,OAAO,CAAC,UAAU,CAAC,CAAgB;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAQ;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;gBAErD,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,IAAI;IAKnF,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAQZ,aAAa,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAiCnH,KAAK,IAAI,IAAI;IAYb,OAAO,CAAC,0BAA0B;CAsBnC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlagEvaluationAggregator = void 0;
|
|
4
|
+
const obfuscation_1 = require("../obfuscation");
|
|
5
|
+
const flagEvaluationEvent_1 = require("./flagEvaluationEvent");
|
|
6
|
+
class FlagEvaluationAggregator {
|
|
7
|
+
constructor(flushInterval, onFlush) {
|
|
8
|
+
this.aggregatedData = new Map();
|
|
9
|
+
this.flushInterval = flushInterval;
|
|
10
|
+
this.onFlush = onFlush;
|
|
11
|
+
}
|
|
12
|
+
start() {
|
|
13
|
+
this.intervalId = setInterval(() => {
|
|
14
|
+
this.flush();
|
|
15
|
+
}, this.flushInterval);
|
|
16
|
+
}
|
|
17
|
+
stop() {
|
|
18
|
+
if (this.intervalId) {
|
|
19
|
+
clearInterval(this.intervalId);
|
|
20
|
+
this.intervalId = undefined;
|
|
21
|
+
}
|
|
22
|
+
this.flush();
|
|
23
|
+
}
|
|
24
|
+
addEvaluation(context, details, error) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
const keyString = this.createAggregationKeyString(context, details, error);
|
|
27
|
+
const timestamp = Date.now();
|
|
28
|
+
const existingData = this.aggregatedData.get(keyString);
|
|
29
|
+
if (existingData) {
|
|
30
|
+
existingData.count++;
|
|
31
|
+
existingData.lastEvaluation = timestamp;
|
|
32
|
+
if (error) {
|
|
33
|
+
existingData.error = error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const runtimeDefaultUsed = details.reason === 'DEFAULT' || details.reason === 'ERROR';
|
|
38
|
+
const allocationKey = (_a = details.flagMetadata) === null || _a === void 0 ? void 0 : _a.allocationKey;
|
|
39
|
+
const targetingRuleKey = (_b = details.flagMetadata) === null || _b === void 0 ? void 0 : _b.targetingRuleKey;
|
|
40
|
+
const { targetingKey, ...targetingContext } = context;
|
|
41
|
+
this.aggregatedData.set(keyString, {
|
|
42
|
+
flagKey: details.flagKey,
|
|
43
|
+
variantKey: details.variant,
|
|
44
|
+
allocationKey,
|
|
45
|
+
targetingRuleKey,
|
|
46
|
+
targetingKey,
|
|
47
|
+
targetingContext,
|
|
48
|
+
count: 1,
|
|
49
|
+
firstEvaluation: timestamp,
|
|
50
|
+
lastEvaluation: timestamp,
|
|
51
|
+
runtimeDefaultUsed,
|
|
52
|
+
error,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
flush() {
|
|
57
|
+
if (this.aggregatedData.size === 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const events = Array.from(this.aggregatedData.values()).map((data) => (0, flagEvaluationEvent_1.createFlagEvaluationEvent)(data, data.firstEvaluation));
|
|
61
|
+
this.aggregatedData.clear();
|
|
62
|
+
this.onFlush(events);
|
|
63
|
+
}
|
|
64
|
+
createAggregationKeyString(context, details, error) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const allocationKey = (_a = details.flagMetadata) === null || _a === void 0 ? void 0 : _a.allocationKey;
|
|
67
|
+
const targetingRuleKey = (_b = details.flagMetadata) === null || _b === void 0 ? void 0 : _b.targetingRuleKey;
|
|
68
|
+
const { targetingKey, ...targetingContext } = context;
|
|
69
|
+
// Hash the deterministic object representation
|
|
70
|
+
return (0, obfuscation_1.getMD5Hash)(JSON.stringify({
|
|
71
|
+
flagKey: details.flagKey,
|
|
72
|
+
variant: details.variant || '',
|
|
73
|
+
allocationKey: allocationKey || '',
|
|
74
|
+
targetingRuleKey: targetingRuleKey || '',
|
|
75
|
+
targetingKey: targetingKey || '',
|
|
76
|
+
targetingContext,
|
|
77
|
+
error: error || '',
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.FlagEvaluationAggregator = FlagEvaluationAggregator;
|
|
82
|
+
//# sourceMappingURL=flagEvaluationAggregator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationAggregator.js","sourceRoot":"","sources":["../../src/configuration/flagEvaluationAggregator.ts"],"names":[],"mappings":";;;AACA,gDAA2C;AAC3C,+DAAiE;AAiBjE,MAAa,wBAAwB;IAMnC,YAAY,aAAqB,EAAE,OAAgD;QAL3E,mBAAc,GAAG,IAAI,GAAG,EAAyC,CAAA;QAMvE,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YACjC,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IACxB,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC7B,CAAC;QACD,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;IAED,aAAa,CAAsB,OAA0B,EAAE,OAA6B,EAAE,KAAc;;QAC1G,MAAM,SAAS,GAAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;QAC1E,MA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AC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CACtD,CAAA;QACD,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACtB,CAAC;IAEO,0BAA0B,CAChC,OAA0B,EAC1B,OAA6B,EAC7B,KAAc;;QAEd,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,0CAAE,aAAuB,CAAA;QACnE,MAAM,gBAAgB,GAAG,MAAA,OAAO,CAAC,YAAY,0CAAE,gBAA0B,CAAA;QACzE,MAAM,EAAE,YAAY,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAA;QAErD,+CAA+C;QAC/C,OAAO,IAAA,wBAAU,EACf,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,aAAa,EAAE,aAAa,IAAI,EAAE;YAClC,gBAAgB,EAAE,gBAAgB,IAAI,EAAE;YACxC,YAAY,EAAE,YAAY,IAAI,EAAE;YAChC,gBAAgB;YAChB,KAAK,EAAE,KAAK,IAAI,EAAE;SACnB,CAAC,CACH,CAAA;IACH,CAAC;CACF;AA5FD,4DA4FC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EvaluationContextValue } from '@openfeature/core';
|
|
2
|
+
import type { FlagEvaluationEvent } from './flagEvaluationEvent.types';
|
|
3
|
+
interface FlagEvaluationAggregationData {
|
|
4
|
+
flagKey: string;
|
|
5
|
+
variantKey?: string;
|
|
6
|
+
allocationKey?: string;
|
|
7
|
+
targetingRuleKey?: string;
|
|
8
|
+
targetingKey?: string;
|
|
9
|
+
targetingContext?: Record<string, EvaluationContextValue>;
|
|
10
|
+
count: number;
|
|
11
|
+
firstEvaluation: number;
|
|
12
|
+
lastEvaluation: number;
|
|
13
|
+
runtimeDefaultUsed: boolean;
|
|
14
|
+
error?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function createFlagEvaluationEvent(data: FlagEvaluationAggregationData, timestamp: number): FlagEvaluationEvent;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=flagEvaluationEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationEvent.d.ts","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEtE,UAAU,6BAA6B;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;IACzD,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,CAwCrH"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFlagEvaluationEvent = createFlagEvaluationEvent;
|
|
4
|
+
function createFlagEvaluationEvent(data, timestamp) {
|
|
5
|
+
const event = {
|
|
6
|
+
flag: {
|
|
7
|
+
key: data.flagKey,
|
|
8
|
+
},
|
|
9
|
+
first_evaluation: data.firstEvaluation,
|
|
10
|
+
last_evaluation: data.lastEvaluation,
|
|
11
|
+
evaluation_count: data.count,
|
|
12
|
+
runtime_default_used: data.runtimeDefaultUsed,
|
|
13
|
+
timestamp,
|
|
14
|
+
};
|
|
15
|
+
if (data.targetingKey) {
|
|
16
|
+
event.targeting_key = data.targetingKey;
|
|
17
|
+
}
|
|
18
|
+
if (data.error) {
|
|
19
|
+
event.error = { message: data.error };
|
|
20
|
+
}
|
|
21
|
+
if (data.variantKey) {
|
|
22
|
+
event.variant = { key: data.variantKey };
|
|
23
|
+
}
|
|
24
|
+
if (data.allocationKey) {
|
|
25
|
+
event.allocation = { key: data.allocationKey };
|
|
26
|
+
}
|
|
27
|
+
if (data.targetingRuleKey) {
|
|
28
|
+
event.targeting_rule = { key: data.targetingRuleKey };
|
|
29
|
+
}
|
|
30
|
+
// Add context data if targeting context exists
|
|
31
|
+
if (data.targetingContext && Object.keys(data.targetingContext).length > 0) {
|
|
32
|
+
event.context = {
|
|
33
|
+
evaluation: data.targetingContext,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return event;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=flagEvaluationEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationEvent.js","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.ts"],"names":[],"mappings":";;AAiBA,8DAwCC;AAxCD,SAAgB,yBAAyB,CAAC,IAAmC,EAAE,SAAiB;IAC9F,MAAM,KAAK,GAAwB;QACjC,IAAI,EAAE;YACJ,GAAG,EAAE,IAAI,CAAC,OAAO;SAClB;QACD,gBAAgB,EAAE,IAAI,CAAC,eAAe;QACtC,eAAe,EAAE,IAAI,CAAC,cAAc;QACpC,gBAAgB,EAAE,IAAI,CAAC,KAAK;QAC5B,oBAAoB,EAAE,IAAI,CAAC,kBAAkB;QAC7C,SAAS;KACV,CAAA;IAED,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAA;IACzC,CAAC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,KAAK,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,CAAA;IACvC,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,KAAK,CAAC,OAAO,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAA;IAC1C,CAAC;IAED,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,KAAK,CAAC,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,CAAA;IAChD,CAAC;IAED,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,KAAK,CAAC,cAAc,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACvD,CAAC;IAED,+CAA+C;IAC/C,IAAI,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3E,KAAK,CAAC,OAAO,GAAG;YACd,UAAU,EAAE,IAAI,CAAC,gBAAgB;SAClC,CAAA;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { EvaluationContextValue } from '@openfeature/core';
|
|
2
|
+
export interface FlagEvaluationEvent {
|
|
3
|
+
flag: {
|
|
4
|
+
key: string;
|
|
5
|
+
};
|
|
6
|
+
first_evaluation: number;
|
|
7
|
+
last_evaluation: number;
|
|
8
|
+
evaluation_count: number;
|
|
9
|
+
runtime_default_used: boolean;
|
|
10
|
+
timestamp: number;
|
|
11
|
+
targeting_key?: string;
|
|
12
|
+
error?: {
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
variant?: {
|
|
16
|
+
key: string;
|
|
17
|
+
};
|
|
18
|
+
allocation?: {
|
|
19
|
+
key: string;
|
|
20
|
+
};
|
|
21
|
+
targeting_rule?: {
|
|
22
|
+
key: string;
|
|
23
|
+
};
|
|
24
|
+
context?: {
|
|
25
|
+
evaluation?: Record<string, EvaluationContextValue>;
|
|
26
|
+
dd?: {
|
|
27
|
+
service?: string;
|
|
28
|
+
rum?: {
|
|
29
|
+
application?: {
|
|
30
|
+
id?: string;
|
|
31
|
+
};
|
|
32
|
+
view?: {
|
|
33
|
+
url?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface FlagEvaluationAggregationKey {
|
|
40
|
+
flagKey: string;
|
|
41
|
+
variantKey?: string;
|
|
42
|
+
allocationKey?: string;
|
|
43
|
+
targetingRuleKey?: string;
|
|
44
|
+
targetingKey?: string;
|
|
45
|
+
targetingContext?: Record<string, EvaluationContextValue>;
|
|
46
|
+
}
|
|
47
|
+
export interface FlagEvaluationAggregationData {
|
|
48
|
+
key: FlagEvaluationAggregationKey;
|
|
49
|
+
count: number;
|
|
50
|
+
firstEvaluation: number;
|
|
51
|
+
lastEvaluation: number;
|
|
52
|
+
runtimeDefaultUsed: boolean;
|
|
53
|
+
error?: string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=flagEvaluationEvent.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationEvent.types.d.ts","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE/D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,oBAAoB,EAAE,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
+
{"version":3,"file":"flagEvaluationEvent.types.js","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './configuration';
|
|
2
2
|
export * from './exposureEvent';
|
|
3
3
|
export * from './exposureEvent.types';
|
|
4
|
+
export * from './flagEvaluationAggregator';
|
|
5
|
+
export * from './flagEvaluationEvent';
|
|
6
|
+
export * from './flagEvaluationEvent.types';
|
|
4
7
|
export * from './wire';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,QAAQ,CAAA"}
|
|
@@ -17,5 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./configuration"), exports);
|
|
18
18
|
__exportStar(require("./exposureEvent"), exports);
|
|
19
19
|
__exportStar(require("./exposureEvent.types"), exports);
|
|
20
|
+
__exportStar(require("./flagEvaluationAggregator"), exports);
|
|
21
|
+
__exportStar(require("./flagEvaluationEvent"), exports);
|
|
22
|
+
__exportStar(require("./flagEvaluationEvent.types"), exports);
|
|
20
23
|
__exportStar(require("./wire"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,kDAA+B;AAC/B,wDAAqC;AACrC,yCAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,kDAA+B;AAC/B,wDAAqC;AACrC,6DAA0C;AAC1C,wDAAqC;AACrC,8DAA2C;AAC3C,yCAAsB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EvaluationContext, EvaluationDetails, FlagValue } from '@openfeature/core';
|
|
2
|
+
import type { FlagEvaluationEvent } from './flagEvaluationEvent.types';
|
|
3
|
+
export declare class FlagEvaluationAggregator {
|
|
4
|
+
private aggregatedData;
|
|
5
|
+
private intervalId?;
|
|
6
|
+
private readonly flushInterval;
|
|
7
|
+
private readonly onFlush;
|
|
8
|
+
constructor(flushInterval: number, onFlush: (events: FlagEvaluationEvent[]) => void);
|
|
9
|
+
start(): void;
|
|
10
|
+
stop(): void;
|
|
11
|
+
addEvaluation<T extends FlagValue>(context: EvaluationContext, details: EvaluationDetails<T>, error?: string): void;
|
|
12
|
+
flush(): void;
|
|
13
|
+
private createAggregationKeyString;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=flagEvaluationAggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationAggregator.d.ts","sourceRoot":"","sources":["../../src/configuration/flagEvaluationAggregator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA0B,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGhH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAgBtE,qBAAa,wBAAwB;IACnC,OAAO,CAAC,cAAc,CAAmD;IACzE,OAAO,CAAC,UAAU,CAAC,CAAgB;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAQ;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;gBAErD,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,IAAI;IAKnF,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAQZ,aAAa,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAiCnH,KAAK,IAAI,IAAI;IAYb,OAAO,CAAC,0BAA0B;CAsBnC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getMD5Hash } from '../obfuscation';
|
|
2
|
+
import { createFlagEvaluationEvent } from './flagEvaluationEvent';
|
|
3
|
+
export class FlagEvaluationAggregator {
|
|
4
|
+
constructor(flushInterval, onFlush) {
|
|
5
|
+
this.aggregatedData = new Map();
|
|
6
|
+
this.flushInterval = flushInterval;
|
|
7
|
+
this.onFlush = onFlush;
|
|
8
|
+
}
|
|
9
|
+
start() {
|
|
10
|
+
this.intervalId = setInterval(() => {
|
|
11
|
+
this.flush();
|
|
12
|
+
}, this.flushInterval);
|
|
13
|
+
}
|
|
14
|
+
stop() {
|
|
15
|
+
if (this.intervalId) {
|
|
16
|
+
clearInterval(this.intervalId);
|
|
17
|
+
this.intervalId = undefined;
|
|
18
|
+
}
|
|
19
|
+
this.flush();
|
|
20
|
+
}
|
|
21
|
+
addEvaluation(context, details, error) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const keyString = this.createAggregationKeyString(context, details, error);
|
|
24
|
+
const timestamp = Date.now();
|
|
25
|
+
const existingData = this.aggregatedData.get(keyString);
|
|
26
|
+
if (existingData) {
|
|
27
|
+
existingData.count++;
|
|
28
|
+
existingData.lastEvaluation = timestamp;
|
|
29
|
+
if (error) {
|
|
30
|
+
existingData.error = error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const runtimeDefaultUsed = details.reason === 'DEFAULT' || details.reason === 'ERROR';
|
|
35
|
+
const allocationKey = (_a = details.flagMetadata) === null || _a === void 0 ? void 0 : _a.allocationKey;
|
|
36
|
+
const targetingRuleKey = (_b = details.flagMetadata) === null || _b === void 0 ? void 0 : _b.targetingRuleKey;
|
|
37
|
+
const { targetingKey, ...targetingContext } = context;
|
|
38
|
+
this.aggregatedData.set(keyString, {
|
|
39
|
+
flagKey: details.flagKey,
|
|
40
|
+
variantKey: details.variant,
|
|
41
|
+
allocationKey,
|
|
42
|
+
targetingRuleKey,
|
|
43
|
+
targetingKey,
|
|
44
|
+
targetingContext,
|
|
45
|
+
count: 1,
|
|
46
|
+
firstEvaluation: timestamp,
|
|
47
|
+
lastEvaluation: timestamp,
|
|
48
|
+
runtimeDefaultUsed,
|
|
49
|
+
error,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
flush() {
|
|
54
|
+
if (this.aggregatedData.size === 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const events = Array.from(this.aggregatedData.values()).map((data) => createFlagEvaluationEvent(data, data.firstEvaluation));
|
|
58
|
+
this.aggregatedData.clear();
|
|
59
|
+
this.onFlush(events);
|
|
60
|
+
}
|
|
61
|
+
createAggregationKeyString(context, details, error) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const allocationKey = (_a = details.flagMetadata) === null || _a === void 0 ? void 0 : _a.allocationKey;
|
|
64
|
+
const targetingRuleKey = (_b = details.flagMetadata) === null || _b === void 0 ? void 0 : _b.targetingRuleKey;
|
|
65
|
+
const { targetingKey, ...targetingContext } = context;
|
|
66
|
+
// Hash the deterministic object representation
|
|
67
|
+
return getMD5Hash(JSON.stringify({
|
|
68
|
+
flagKey: details.flagKey,
|
|
69
|
+
variant: details.variant || '',
|
|
70
|
+
allocationKey: allocationKey || '',
|
|
71
|
+
targetingRuleKey: targetingRuleKey || '',
|
|
72
|
+
targetingKey: targetingKey || '',
|
|
73
|
+
targetingContext,
|
|
74
|
+
error: error || '',
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=flagEvaluationAggregator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationAggregator.js","sourceRoot":"","sources":["../../src/configuration/flagEvaluationAggregator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AAiBjE,MAAM,OAAO,wBAAwB;IAMnC,YAAY,aAAqB,EAAE,OAAgD;QAL3E,mBAAc,GAAG,IAAI,GAAG,EAAyC,CAAA;QAMvE,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YACjC,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IACxB,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC7B,CAAC;QACD,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;IAED,aAAa,CAAsB,OAA0B,EAAE,OAA6B,EAAE,KAAc;;QAC1G,MAAM,SAAS,GAAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;QAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAE5B,MAAM,YAAY,GAAG,I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C,KAAK,EAAE,CAAA;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACtB,CAAC;IAEO,0BAA0B,CAChC,OAA0B,EAC1B,OAA6B,EAC7B,KAAc;;QAEd,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,0CAAE,aAAuB,CAAA;QACnE,MAAM,gBAAgB,GAAG,MAAA,OAAO,CAAC,YAAY,0CAAE,gBAA0B,CAAA;QACzE,MAAM,EAAE,YAAY,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAA;QAErD,+CAA+C;QAC/C,OAAO,UAAU,CACf,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,aAAa,EAAE,aAAa,IAAI,EAAE;YAClC,gBAAgB,EAAE,gBAAgB,IAAI,EAAE;YACxC,YAAY,EAAE,YAAY,IAAI,EAAE;YAChC,gBAAgB;YAChB,KAAK,EAAE,KAAK,IAAI,EAAE;SACnB,CAAC,CACH,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EvaluationContextValue } from '@openfeature/core';
|
|
2
|
+
import type { FlagEvaluationEvent } from './flagEvaluationEvent.types';
|
|
3
|
+
interface FlagEvaluationAggregationData {
|
|
4
|
+
flagKey: string;
|
|
5
|
+
variantKey?: string;
|
|
6
|
+
allocationKey?: string;
|
|
7
|
+
targetingRuleKey?: string;
|
|
8
|
+
targetingKey?: string;
|
|
9
|
+
targetingContext?: Record<string, EvaluationContextValue>;
|
|
10
|
+
count: number;
|
|
11
|
+
firstEvaluation: number;
|
|
12
|
+
lastEvaluation: number;
|
|
13
|
+
runtimeDefaultUsed: boolean;
|
|
14
|
+
error?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function createFlagEvaluationEvent(data: FlagEvaluationAggregationData, timestamp: number): FlagEvaluationEvent;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=flagEvaluationEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationEvent.d.ts","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEtE,UAAU,6BAA6B;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;IACzD,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,CAwCrH"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function createFlagEvaluationEvent(data, timestamp) {
|
|
2
|
+
const event = {
|
|
3
|
+
flag: {
|
|
4
|
+
key: data.flagKey,
|
|
5
|
+
},
|
|
6
|
+
first_evaluation: data.firstEvaluation,
|
|
7
|
+
last_evaluation: data.lastEvaluation,
|
|
8
|
+
evaluation_count: data.count,
|
|
9
|
+
runtime_default_used: data.runtimeDefaultUsed,
|
|
10
|
+
timestamp,
|
|
11
|
+
};
|
|
12
|
+
if (data.targetingKey) {
|
|
13
|
+
event.targeting_key = data.targetingKey;
|
|
14
|
+
}
|
|
15
|
+
if (data.error) {
|
|
16
|
+
event.error = { message: data.error };
|
|
17
|
+
}
|
|
18
|
+
if (data.variantKey) {
|
|
19
|
+
event.variant = { key: data.variantKey };
|
|
20
|
+
}
|
|
21
|
+
if (data.allocationKey) {
|
|
22
|
+
event.allocation = { key: data.allocationKey };
|
|
23
|
+
}
|
|
24
|
+
if (data.targetingRuleKey) {
|
|
25
|
+
event.targeting_rule = { key: data.targetingRuleKey };
|
|
26
|
+
}
|
|
27
|
+
// Add context data if targeting context exists
|
|
28
|
+
if (data.targetingContext && Object.keys(data.targetingContext).length > 0) {
|
|
29
|
+
event.context = {
|
|
30
|
+
evaluation: data.targetingContext,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return event;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=flagEvaluationEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationEvent.js","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,yBAAyB,CAAC,IAAmC,EAAE,SAAiB;IAC9F,MAAM,KAAK,GAAwB;QACjC,IAAI,EAAE;YACJ,GAAG,EAAE,IAAI,CAAC,OAAO;SAClB;QACD,gBAAgB,EAAE,IAAI,CAAC,eAAe;QACtC,eAAe,EAAE,IAAI,CAAC,cAAc;QACpC,gBAAgB,EAAE,IAAI,CAAC,KAAK;QAC5B,oBAAoB,EAAE,IAAI,CAAC,kBAAkB;QAC7C,SAAS;KACV,CAAA;IAED,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAA;IACzC,CAAC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,KAAK,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,CAAA;IACvC,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,KAAK,CAAC,OAAO,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAA;IAC1C,CAAC;IAED,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,KAAK,CAAC,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,CAAA;IAChD,CAAC;IAED,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,KAAK,CAAC,cAAc,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACvD,CAAC;IAED,+CAA+C;IAC/C,IAAI,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3E,KAAK,CAAC,OAAO,GAAG;YACd,UAAU,EAAE,IAAI,CAAC,gBAAgB;SAClC,CAAA;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { EvaluationContextValue } from '@openfeature/core';
|
|
2
|
+
export interface FlagEvaluationEvent {
|
|
3
|
+
flag: {
|
|
4
|
+
key: string;
|
|
5
|
+
};
|
|
6
|
+
first_evaluation: number;
|
|
7
|
+
last_evaluation: number;
|
|
8
|
+
evaluation_count: number;
|
|
9
|
+
runtime_default_used: boolean;
|
|
10
|
+
timestamp: number;
|
|
11
|
+
targeting_key?: string;
|
|
12
|
+
error?: {
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
variant?: {
|
|
16
|
+
key: string;
|
|
17
|
+
};
|
|
18
|
+
allocation?: {
|
|
19
|
+
key: string;
|
|
20
|
+
};
|
|
21
|
+
targeting_rule?: {
|
|
22
|
+
key: string;
|
|
23
|
+
};
|
|
24
|
+
context?: {
|
|
25
|
+
evaluation?: Record<string, EvaluationContextValue>;
|
|
26
|
+
dd?: {
|
|
27
|
+
service?: string;
|
|
28
|
+
rum?: {
|
|
29
|
+
application?: {
|
|
30
|
+
id?: string;
|
|
31
|
+
};
|
|
32
|
+
view?: {
|
|
33
|
+
url?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface FlagEvaluationAggregationKey {
|
|
40
|
+
flagKey: string;
|
|
41
|
+
variantKey?: string;
|
|
42
|
+
allocationKey?: string;
|
|
43
|
+
targetingRuleKey?: string;
|
|
44
|
+
targetingKey?: string;
|
|
45
|
+
targetingContext?: Record<string, EvaluationContextValue>;
|
|
46
|
+
}
|
|
47
|
+
export interface FlagEvaluationAggregationData {
|
|
48
|
+
key: FlagEvaluationAggregationKey;
|
|
49
|
+
count: number;
|
|
50
|
+
firstEvaluation: number;
|
|
51
|
+
lastEvaluation: number;
|
|
52
|
+
runtimeDefaultUsed: boolean;
|
|
53
|
+
error?: string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=flagEvaluationEvent.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationEvent.types.d.ts","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE/D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,OAAO,CAAC,EAAE;QACR,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,UAAU,CAAC,EAAE;QACX,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,cAAc,CAAC,EAAE;QACf,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;QACnD,EAAE,CAAC,EAAE;YACH,OAAO,CAAC,EAAE,MAAM,CAAA;YAChB,GAAG,CAAC,EAAE;gBACJ,WAAW,CAAC,EAAE;oBACZ,EAAE,CAAC,EAAE,MAAM,CAAA;iBACZ,CAAA;gBACD,IAAI,CAAC,EAAE;oBACL,GAAG,CAAC,EAAE,MAAM,CAAA;iBACb,CAAA;aACF,CAAA;SACF,CAAA;KACF,CAAA;CACF;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;CAC1D;AAED,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,4BAA4B,CAAA;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvaluationEvent.types.js","sourceRoot":"","sources":["../../src/configuration/flagEvaluationEvent.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './configuration';
|
|
2
2
|
export * from './exposureEvent';
|
|
3
3
|
export * from './exposureEvent.types';
|
|
4
|
+
export * from './flagEvaluationAggregator';
|
|
5
|
+
export * from './flagEvaluationEvent';
|
|
6
|
+
export * from './flagEvaluationEvent.types';
|
|
4
7
|
export * from './wire';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,QAAQ,CAAA"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './configuration';
|
|
2
2
|
export * from './exposureEvent';
|
|
3
3
|
export * from './exposureEvent.types';
|
|
4
|
+
export * from './flagEvaluationAggregator';
|
|
5
|
+
export * from './flagEvaluationEvent';
|
|
6
|
+
export * from './flagEvaluationEvent.types';
|
|
4
7
|
export * from './wire';
|
|
5
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,QAAQ,CAAA"}
|