@configdirector/nuxt-sdk 1.14.3 → 1.15.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/dist/module.d.mts +13 -0
- package/dist/module.json +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClient.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClient.d.ts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClientHooks.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClientHooks.d.ts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorContext.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorContext.d.ts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorContext.mjs +8 -2
- package/dist/runtime/app/composables/useConfigDirectorValue.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorValue.d.ts +1 -1
- package/dist/runtime/{native-values-BjAsU5SD.d.mts → native-values-DQVM1FGD.d.mts} +13 -0
- package/dist/runtime/nitro/offline-values.d.mts +1 -1
- package/dist/runtime/nitro/offline-values.d.ts +1 -1
- package/dist/runtime/nitro/plugin.d.mts +2 -2
- package/dist/runtime/nitro/plugin.d.ts +2 -2
- package/dist/runtime/nitro/plugin.mjs +30 -18
- package/dist/runtime/plugin.client.mjs +96 -23
- package/dist/runtime/plugin.server.mjs +11 -3
- package/dist/runtime/server/composables/useConfigDirectorServerClient.d.mts +1 -1
- package/dist/runtime/server/composables/useConfigDirectorServerClient.d.ts +1 -1
- package/dist/runtime/server/composables/useConfigDirectorServerHooks.d.mts +1 -1
- package/dist/runtime/server/composables/useConfigDirectorServerHooks.d.ts +1 -1
- package/dist/runtime/{types-BeMbqkgk.d.mts → types-CXuEYplq.d.mts} +1 -1
- package/dist/runtime/{types-BOsBpju5.d.mts → types-CqVeH32Z.d.mts} +1 -1
- package/dist/testing.d.mts +15 -2
- package/dist/testing.mjs +51 -5
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -81,6 +81,10 @@ type ConfigDirectorContext = {
|
|
|
81
81
|
* or the site's data is cleared. However, keep in mind that this value is used for segmenting
|
|
82
82
|
* contexts in percentage rollouts, and changes to the {@link id} could result in the context
|
|
83
83
|
* being assigned to a different percentile.
|
|
84
|
+
*
|
|
85
|
+
* An identifier has at most 256 characters. A client SDK ignores a context with a longer one as
|
|
86
|
+
* a whole: it logs an error and evaluates as if no context had been provided. A server SDK still
|
|
87
|
+
* evaluates such a context, and ConfigDirector does not add it to the environment's contexts.
|
|
84
88
|
*/
|
|
85
89
|
id?: string;
|
|
86
90
|
/**
|
|
@@ -98,11 +102,20 @@ type ConfigDirectorContext = {
|
|
|
98
102
|
/**
|
|
99
103
|
* The context's display name. This will be shown in the ConfigDirector dashboard and may be
|
|
100
104
|
* used for targeting rules.
|
|
105
|
+
*
|
|
106
|
+
* A name has at most 256 characters. A client SDK ignores a context with a longer one as a
|
|
107
|
+
* whole: it logs an error and evaluates as if no context had been provided. A server SDK still
|
|
108
|
+
* evaluates such a context, and ConfigDirector does not add it to the environment's contexts.
|
|
101
109
|
*/
|
|
102
110
|
name?: string;
|
|
103
111
|
/**
|
|
104
112
|
* Any arbitrary traits for the context. They will be shown in the ConfigDirector dashboard
|
|
105
113
|
* and may be used for targeting rules.
|
|
114
|
+
*
|
|
115
|
+
* Traits take at most 64 KB once written as JSON. A client SDK ignores a context with larger
|
|
116
|
+
* traits as a whole: it logs an error and evaluates as if no context had been provided. A server
|
|
117
|
+
* SDK still evaluates such a context, and ConfigDirector does not add it to the environment's
|
|
118
|
+
* contexts.
|
|
106
119
|
*/
|
|
107
120
|
traits?: {
|
|
108
121
|
[key: string]: unknown;
|
package/dist/module.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-CqVeH32Z.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/app/composables/useConfigDirectorClientHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorClientHooks: (hooks: ClientHooks) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-CqVeH32Z.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/app/composables/useConfigDirectorClientHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorClientHooks: (hooks: ClientHooks) => void;
|
|
@@ -41,12 +41,13 @@ const getEffectiveTimeout = (option) => {
|
|
|
41
41
|
const useConfigDirectorContext = () => {
|
|
42
42
|
const state = useState("configdirector-context");
|
|
43
43
|
const { client } = useConfigDirectorClient();
|
|
44
|
-
const { $configDirectorClientStartup } = useNuxtApp();
|
|
44
|
+
const { $configDirectorClientStartup, $configDirectorClientContextUpdate } = useNuxtApp();
|
|
45
45
|
const startup = $configDirectorClientStartup;
|
|
46
|
+
const updateClientContext = $configDirectorClientContextUpdate;
|
|
46
47
|
const handContextToClient = (rawContext) => {
|
|
47
48
|
switch (decideContextUpdateAction(client, rawContext, startup.waitsForFirstContext)) {
|
|
48
49
|
case "startClient": return startup.start(rawContext);
|
|
49
|
-
case "updateContext": return
|
|
50
|
+
case "updateContext": return updateClientContext(rawContext);
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
const updateContext = async (context, options) => {
|
|
@@ -57,12 +58,17 @@ const useConfigDirectorContext = () => {
|
|
|
57
58
|
if (oldContext != newContext) {
|
|
58
59
|
const timeout = getEffectiveTimeout(options?.timeoutMilliseconds);
|
|
59
60
|
let timer;
|
|
61
|
+
const showContextHeldByClient = () => {
|
|
62
|
+
state.value = client.context;
|
|
63
|
+
};
|
|
64
|
+
client.on("connectionError", showContextHeldByClient);
|
|
60
65
|
try {
|
|
61
66
|
await Promise.race([handContextToClient(rawContext), new Promise((resolve) => {
|
|
62
67
|
timer = setTimeout(() => resolve(), timeout);
|
|
63
68
|
})]);
|
|
64
69
|
} finally {
|
|
65
70
|
clearTimeout(timer);
|
|
71
|
+
client.off("connectionError", showContextHeldByClient);
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
};
|
|
@@ -93,6 +93,10 @@ type ConfigDirectorContext = {
|
|
|
93
93
|
* or the site's data is cleared. However, keep in mind that this value is used for segmenting
|
|
94
94
|
* contexts in percentage rollouts, and changes to the {@link id} could result in the context
|
|
95
95
|
* being assigned to a different percentile.
|
|
96
|
+
*
|
|
97
|
+
* An identifier has at most 256 characters. A client SDK ignores a context with a longer one as
|
|
98
|
+
* a whole: it logs an error and evaluates as if no context had been provided. A server SDK still
|
|
99
|
+
* evaluates such a context, and ConfigDirector does not add it to the environment's contexts.
|
|
96
100
|
*/
|
|
97
101
|
id?: string;
|
|
98
102
|
/**
|
|
@@ -110,11 +114,20 @@ type ConfigDirectorContext = {
|
|
|
110
114
|
/**
|
|
111
115
|
* The context's display name. This will be shown in the ConfigDirector dashboard and may be
|
|
112
116
|
* used for targeting rules.
|
|
117
|
+
*
|
|
118
|
+
* A name has at most 256 characters. A client SDK ignores a context with a longer one as a
|
|
119
|
+
* whole: it logs an error and evaluates as if no context had been provided. A server SDK still
|
|
120
|
+
* evaluates such a context, and ConfigDirector does not add it to the environment's contexts.
|
|
113
121
|
*/
|
|
114
122
|
name?: string;
|
|
115
123
|
/**
|
|
116
124
|
* Any arbitrary traits for the context. They will be shown in the ConfigDirector dashboard
|
|
117
125
|
* and may be used for targeting rules.
|
|
126
|
+
*
|
|
127
|
+
* Traits take at most 64 KB once written as JSON. A client SDK ignores a context with larger
|
|
128
|
+
* traits as a whole: it logs an error and evaluates as if no context had been provided. A server
|
|
129
|
+
* SDK still evaluates such a context, and ConfigDirector does not add it to the environment's
|
|
130
|
+
* contexts.
|
|
118
131
|
*/
|
|
119
132
|
traits?: {
|
|
120
133
|
[key: string]: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ConnectionMode } from "../native-values-
|
|
2
|
-
import { n as ConfigDirectorClient } from "../types-
|
|
1
|
+
import { o as ConnectionMode } from "../native-values-DQVM1FGD.mjs";
|
|
2
|
+
import { n as ConfigDirectorClient } from "../types-CXuEYplq.mjs";
|
|
3
3
|
import * as _$nitropack from "nitropack";
|
|
4
4
|
|
|
5
5
|
//#region src/runtime/nitro/plugin.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ConnectionMode } from "../native-values-
|
|
2
|
-
import { n as ConfigDirectorClient } from "../types-
|
|
1
|
+
import { o as ConnectionMode } from "../native-values-DQVM1FGD.mjs";
|
|
2
|
+
import { n as ConfigDirectorClient } from "../types-CXuEYplq.mjs";
|
|
3
3
|
import * as _$nitropack from "nitropack";
|
|
4
4
|
|
|
5
5
|
//#region src/runtime/nitro/plugin.d.ts
|
|
@@ -7722,18 +7722,25 @@ const resolvePollingInterval = (configuredSeconds, defaults) => {
|
|
|
7722
7722
|
var InvalidContextSubmissions = class {
|
|
7723
7723
|
countsByKindSample = /* @__PURE__ */ new Map();
|
|
7724
7724
|
countBeyondSampleLimit = 0;
|
|
7725
|
+
countsBySizeLimit = /* @__PURE__ */ new Map();
|
|
7725
7726
|
startTime;
|
|
7726
|
-
|
|
7727
|
+
recordInvalidKind(kindSample) {
|
|
7727
7728
|
this.startTime ??= /* @__PURE__ */ new Date();
|
|
7728
|
-
return this.
|
|
7729
|
+
return this.addInvalidKind(kindSample, 1);
|
|
7730
|
+
}
|
|
7731
|
+
recordOverSizeLimit(reason) {
|
|
7732
|
+
this.startTime ??= /* @__PURE__ */ new Date();
|
|
7733
|
+
this.addOverSizeLimit(reason, 1);
|
|
7729
7734
|
}
|
|
7730
7735
|
absorb(entries) {
|
|
7731
7736
|
for (const entry of entries) {
|
|
7732
7737
|
if (this.startTime === void 0 || entry.startTime < this.startTime) this.startTime = entry.startTime;
|
|
7733
|
-
|
|
7738
|
+
const { event } = entry;
|
|
7739
|
+
if (event.reason === "invalid-context-kind") this.addInvalidKind(event.kindSample, entry.count);
|
|
7740
|
+
else this.addOverSizeLimit(event.reason, entry.count);
|
|
7734
7741
|
}
|
|
7735
7742
|
}
|
|
7736
|
-
|
|
7743
|
+
addInvalidKind(kindSample, count) {
|
|
7737
7744
|
if (kindSample !== void 0) {
|
|
7738
7745
|
const knownCount = this.countsByKindSample.get(kindSample);
|
|
7739
7746
|
if (knownCount !== void 0) {
|
|
@@ -7749,26 +7756,31 @@ var InvalidContextSubmissions = class {
|
|
|
7749
7756
|
this.countBeyondSampleLimit += count;
|
|
7750
7757
|
return firstBeyondSampleLimit ? "first-beyond-sample-limit" : "beyond-sample-limit";
|
|
7751
7758
|
}
|
|
7759
|
+
addOverSizeLimit(reason, count) {
|
|
7760
|
+
this.countsBySizeLimit.set(reason, (this.countsBySizeLimit.get(reason) ?? 0) + count);
|
|
7761
|
+
}
|
|
7752
7762
|
takeSnapshot() {
|
|
7753
7763
|
const endTime = /* @__PURE__ */ new Date();
|
|
7754
7764
|
const startTime = this.startTime ?? endTime;
|
|
7755
|
-
const entryOf = (count,
|
|
7765
|
+
const entryOf = (count, event) => ({
|
|
7756
7766
|
startTime,
|
|
7757
7767
|
endTime,
|
|
7758
7768
|
count,
|
|
7759
|
-
event
|
|
7760
|
-
reason: "invalid-context-kind",
|
|
7761
|
-
kindSample
|
|
7762
|
-
}
|
|
7769
|
+
event
|
|
7763
7770
|
});
|
|
7764
|
-
const sampledEntries = Array.from(this.countsByKindSample, ([kindSample, count]) => entryOf(count,
|
|
7765
|
-
|
|
7771
|
+
const sampledEntries = Array.from(this.countsByKindSample, ([kindSample, count]) => entryOf(count, {
|
|
7772
|
+
reason: "invalid-context-kind",
|
|
7773
|
+
kindSample
|
|
7774
|
+
}));
|
|
7775
|
+
const invalidKindEntries = this.countBeyondSampleLimit > 0 ? [...sampledEntries, entryOf(this.countBeyondSampleLimit, { reason: "invalid-context-kind" })] : sampledEntries;
|
|
7776
|
+
const sizeLimitEntries = Array.from(this.countsBySizeLimit, ([reason, count]) => entryOf(count, { reason }));
|
|
7766
7777
|
this.clear();
|
|
7767
|
-
return
|
|
7778
|
+
return [...invalidKindEntries, ...sizeLimitEntries];
|
|
7768
7779
|
}
|
|
7769
7780
|
clear() {
|
|
7770
7781
|
this.countsByKindSample.clear();
|
|
7771
7782
|
this.countBeyondSampleLimit = 0;
|
|
7783
|
+
this.countsBySizeLimit.clear();
|
|
7772
7784
|
this.startTime = void 0;
|
|
7773
7785
|
}
|
|
7774
7786
|
};
|
|
@@ -8249,8 +8261,8 @@ var ServerTelemetryEventCollector = class extends TelemetryEventCollector {
|
|
|
8249
8261
|
};
|
|
8250
8262
|
this.evaluationEventQueue.push(this.sanitizeEvaluatedConfigEvent(event));
|
|
8251
8263
|
}
|
|
8252
|
-
|
|
8253
|
-
return this.invalidContextSubmissions.
|
|
8264
|
+
recordInvalidContextKind(kindSample) {
|
|
8265
|
+
return this.invalidContextSubmissions.recordInvalidKind(kindSample);
|
|
8254
8266
|
}
|
|
8255
8267
|
sanitizeEvaluatedConfigEvent(event) {
|
|
8256
8268
|
return {
|
|
@@ -8304,7 +8316,7 @@ var ServerTelemetryEventCollector = class extends TelemetryEventCollector {
|
|
|
8304
8316
|
const discardingTelemetryClient = {
|
|
8305
8317
|
start: () => {},
|
|
8306
8318
|
evaluatedConfig: () => {},
|
|
8307
|
-
|
|
8319
|
+
recordInvalidContextKind: () => "new-kind-sample",
|
|
8308
8320
|
trackedEvent: () => {},
|
|
8309
8321
|
close: async () => {}
|
|
8310
8322
|
};
|
|
@@ -8337,7 +8349,7 @@ const liveTimeoutWarningDetails = {
|
|
|
8337
8349
|
streaming: "The client will continue to retry since there were no fatal errors detected. Configs will return the default value until the connection succeeds.",
|
|
8338
8350
|
polling: "Since the client was configured without streaming, configs may not update and always return the default value."
|
|
8339
8351
|
};
|
|
8340
|
-
const
|
|
8352
|
+
const logInvalidContextKind = {
|
|
8341
8353
|
"new-kind-sample": (logger, kindSample) => logger.error(`[ConfigDirectorClient] Ignored a context with the invalid kind '${kindSample}' and evaluated as if no context was supplied. A context kind has 1 to 64 characters, using only lowercase letters, digits, '-' and '_'.`),
|
|
8342
8354
|
"known-kind-sample": () => {},
|
|
8343
8355
|
"first-beyond-sample-limit": (logger) => logger.error(`[ConfigDirectorClient] Ignored a context with another invalid kind and evaluated as if no context was supplied. 20 different invalid kinds were logged recently, so further invalid kinds are not logged individually.`),
|
|
@@ -8631,7 +8643,7 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
8631
8643
|
switch (admission.outcome) {
|
|
8632
8644
|
case "admitted": return admission.context;
|
|
8633
8645
|
case "ignored":
|
|
8634
|
-
|
|
8646
|
+
logInvalidContextKind[this.usageEventCollector.recordInvalidContextKind(admission.kindSample)](this.logger, admission.kindSample);
|
|
8635
8647
|
return;
|
|
8636
8648
|
}
|
|
8637
8649
|
}
|
|
@@ -8712,7 +8724,7 @@ var plugin_default = defineNitroPlugin((nitroApp) => {
|
|
|
8712
8724
|
logger.debug("Initializing ConfigDirector Nitro plugin");
|
|
8713
8725
|
const client = new DefaultConfigDirectorClient(serverSdkKey || void 0, {
|
|
8714
8726
|
sdkName: "nuxt-sdk",
|
|
8715
|
-
sdkVersion: "1.
|
|
8727
|
+
sdkVersion: "1.15.0"
|
|
8716
8728
|
}, {
|
|
8717
8729
|
logger,
|
|
8718
8730
|
metadata: {
|
|
@@ -919,7 +919,8 @@ const createDefaultLogger$1 = (level, messageDecorator) => {
|
|
|
919
919
|
const discardingTelemetryClient = {
|
|
920
920
|
updateContext: async () => {},
|
|
921
921
|
evaluatedConfig: () => {},
|
|
922
|
-
|
|
922
|
+
recordInvalidContextKind: () => {},
|
|
923
|
+
recordContextOverSizeLimit: () => {},
|
|
923
924
|
trackedEvent: () => {},
|
|
924
925
|
close: async () => {}
|
|
925
926
|
};
|
|
@@ -1305,6 +1306,42 @@ const utf8ByteLength = (text) => {
|
|
|
1305
1306
|
return bytes;
|
|
1306
1307
|
};
|
|
1307
1308
|
//#endregion
|
|
1309
|
+
//#region ../js-client-core/src/context-admission.ts
|
|
1310
|
+
const IDENTIFIER_MAXIMUM_CHARACTERS = 256;
|
|
1311
|
+
const NAME_MAXIMUM_CHARACTERS$1 = 256;
|
|
1312
|
+
const TRAITS_MAXIMUM_JSON_BYTES = 65536;
|
|
1313
|
+
const hasMoreCharactersThan = (maximumCharacters, text) => typeof text === "string" && Array.from(text).length > maximumCharacters;
|
|
1314
|
+
const hasMoreJsonBytesThan = (maximumBytes, traits) => {
|
|
1315
|
+
let json;
|
|
1316
|
+
try {
|
|
1317
|
+
json = JSON.stringify(traits);
|
|
1318
|
+
} catch {
|
|
1319
|
+
return false;
|
|
1320
|
+
}
|
|
1321
|
+
return json !== void 0 && utf8ByteLength(json) > maximumBytes;
|
|
1322
|
+
};
|
|
1323
|
+
const firstSizeLimitPassedBy = (context) => {
|
|
1324
|
+
if (hasMoreCharactersThan(IDENTIFIER_MAXIMUM_CHARACTERS, context?.id)) return "identifier-too-long";
|
|
1325
|
+
if (hasMoreCharactersThan(NAME_MAXIMUM_CHARACTERS$1, context?.name)) return "name-too-long";
|
|
1326
|
+
if (hasMoreJsonBytesThan(TRAITS_MAXIMUM_JSON_BYTES, context?.traits)) return "traits-too-large";
|
|
1327
|
+
};
|
|
1328
|
+
const admitClientContext = (context) => {
|
|
1329
|
+
const kindAdmission = admitContext(context);
|
|
1330
|
+
if (kindAdmission.outcome === "ignored") return {
|
|
1331
|
+
outcome: "invalid kind",
|
|
1332
|
+
kindSample: kindAdmission.kindSample
|
|
1333
|
+
};
|
|
1334
|
+
const passedSizeLimit = firstSizeLimitPassedBy(context);
|
|
1335
|
+
if (passedSizeLimit !== void 0) return {
|
|
1336
|
+
outcome: "over a size limit",
|
|
1337
|
+
reason: passedSizeLimit
|
|
1338
|
+
};
|
|
1339
|
+
return {
|
|
1340
|
+
outcome: "admitted",
|
|
1341
|
+
context
|
|
1342
|
+
};
|
|
1343
|
+
};
|
|
1344
|
+
//#endregion
|
|
1308
1345
|
//#region ../shared/src/telemetry/reported-context.ts
|
|
1309
1346
|
const USER_CONTEXT_KIND = "user";
|
|
1310
1347
|
const reportedContextOf = (context) => {
|
|
@@ -1561,6 +1598,11 @@ var CachedValuesStore = class {
|
|
|
1561
1598
|
//#endregion
|
|
1562
1599
|
//#region ../js-client-core/src/DefaultConfigDirectorClient.ts
|
|
1563
1600
|
const MAX_EXPONENTIAL_DELAY = 9;
|
|
1601
|
+
const CONTEXT_SIZE_LIMIT_EXPLANATIONS = {
|
|
1602
|
+
"identifier-too-long": "its id is longer than 256 characters",
|
|
1603
|
+
"name-too-long": "its name is longer than 256 characters",
|
|
1604
|
+
"traits-too-large": "its traits are over 64 KB of JSON"
|
|
1605
|
+
};
|
|
1564
1606
|
const createReadyOrClosedSignal = () => {
|
|
1565
1607
|
let raise;
|
|
1566
1608
|
return {
|
|
@@ -1798,12 +1840,16 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1798
1840
|
await this.connectToTransport(this.admittedContextFor(context, submission), submission);
|
|
1799
1841
|
}
|
|
1800
1842
|
admittedContextFor(suppliedContext, submission) {
|
|
1801
|
-
const admission =
|
|
1843
|
+
const admission = admitClientContext(suppliedContext);
|
|
1802
1844
|
switch (admission.outcome) {
|
|
1803
1845
|
case "admitted": return admission.context;
|
|
1804
|
-
case "
|
|
1846
|
+
case "invalid kind":
|
|
1805
1847
|
this.logger.error(`[ConfigDirectorClient] Ignored the context supplied for ${submission} because its kind '${admission.kindSample}' is invalid; continuing as if no context was supplied. A context kind has 1 to 64 characters, using only lowercase letters, digits, '-' and '_'.`);
|
|
1806
|
-
this.telemetryClient.
|
|
1848
|
+
this.telemetryClient.recordInvalidContextKind(admission.kindSample);
|
|
1849
|
+
return;
|
|
1850
|
+
case "over a size limit":
|
|
1851
|
+
this.logger.error(`[ConfigDirectorClient] Ignored the context supplied for ${submission} because ${CONTEXT_SIZE_LIMIT_EXPLANATIONS[admission.reason]}; continuing as if no context was supplied.`);
|
|
1852
|
+
this.telemetryClient.recordContextOverSizeLimit(admission.reason);
|
|
1807
1853
|
return;
|
|
1808
1854
|
}
|
|
1809
1855
|
}
|
|
@@ -2093,18 +2139,25 @@ var TrackedEventQueue = class {
|
|
|
2093
2139
|
var InvalidContextSubmissions = class {
|
|
2094
2140
|
countsByKindSample = /* @__PURE__ */ new Map();
|
|
2095
2141
|
countBeyondSampleLimit = 0;
|
|
2142
|
+
countsBySizeLimit = /* @__PURE__ */ new Map();
|
|
2096
2143
|
startTime;
|
|
2097
|
-
|
|
2144
|
+
recordInvalidKind(kindSample) {
|
|
2098
2145
|
this.startTime ??= /* @__PURE__ */ new Date();
|
|
2099
|
-
return this.
|
|
2146
|
+
return this.addInvalidKind(kindSample, 1);
|
|
2147
|
+
}
|
|
2148
|
+
recordOverSizeLimit(reason) {
|
|
2149
|
+
this.startTime ??= /* @__PURE__ */ new Date();
|
|
2150
|
+
this.addOverSizeLimit(reason, 1);
|
|
2100
2151
|
}
|
|
2101
2152
|
absorb(entries) {
|
|
2102
2153
|
for (const entry of entries) {
|
|
2103
2154
|
if (this.startTime === void 0 || entry.startTime < this.startTime) this.startTime = entry.startTime;
|
|
2104
|
-
|
|
2155
|
+
const { event } = entry;
|
|
2156
|
+
if (event.reason === "invalid-context-kind") this.addInvalidKind(event.kindSample, entry.count);
|
|
2157
|
+
else this.addOverSizeLimit(event.reason, entry.count);
|
|
2105
2158
|
}
|
|
2106
2159
|
}
|
|
2107
|
-
|
|
2160
|
+
addInvalidKind(kindSample, count) {
|
|
2108
2161
|
if (kindSample !== void 0) {
|
|
2109
2162
|
const knownCount = this.countsByKindSample.get(kindSample);
|
|
2110
2163
|
if (knownCount !== void 0) {
|
|
@@ -2120,26 +2173,31 @@ var InvalidContextSubmissions = class {
|
|
|
2120
2173
|
this.countBeyondSampleLimit += count;
|
|
2121
2174
|
return firstBeyondSampleLimit ? "first-beyond-sample-limit" : "beyond-sample-limit";
|
|
2122
2175
|
}
|
|
2176
|
+
addOverSizeLimit(reason, count) {
|
|
2177
|
+
this.countsBySizeLimit.set(reason, (this.countsBySizeLimit.get(reason) ?? 0) + count);
|
|
2178
|
+
}
|
|
2123
2179
|
takeSnapshot() {
|
|
2124
2180
|
const endTime = /* @__PURE__ */ new Date();
|
|
2125
2181
|
const startTime = this.startTime ?? endTime;
|
|
2126
|
-
const entryOf = (count,
|
|
2182
|
+
const entryOf = (count, event) => ({
|
|
2127
2183
|
startTime,
|
|
2128
2184
|
endTime,
|
|
2129
2185
|
count,
|
|
2130
|
-
event
|
|
2131
|
-
reason: "invalid-context-kind",
|
|
2132
|
-
kindSample
|
|
2133
|
-
}
|
|
2186
|
+
event
|
|
2134
2187
|
});
|
|
2135
|
-
const sampledEntries = Array.from(this.countsByKindSample, ([kindSample, count]) => entryOf(count,
|
|
2136
|
-
|
|
2188
|
+
const sampledEntries = Array.from(this.countsByKindSample, ([kindSample, count]) => entryOf(count, {
|
|
2189
|
+
reason: "invalid-context-kind",
|
|
2190
|
+
kindSample
|
|
2191
|
+
}));
|
|
2192
|
+
const invalidKindEntries = this.countBeyondSampleLimit > 0 ? [...sampledEntries, entryOf(this.countBeyondSampleLimit, { reason: "invalid-context-kind" })] : sampledEntries;
|
|
2193
|
+
const sizeLimitEntries = Array.from(this.countsBySizeLimit, ([reason, count]) => entryOf(count, { reason }));
|
|
2137
2194
|
this.clear();
|
|
2138
|
-
return
|
|
2195
|
+
return [...invalidKindEntries, ...sizeLimitEntries];
|
|
2139
2196
|
}
|
|
2140
2197
|
clear() {
|
|
2141
2198
|
this.countsByKindSample.clear();
|
|
2142
2199
|
this.countBeyondSampleLimit = 0;
|
|
2200
|
+
this.countsBySizeLimit.clear();
|
|
2143
2201
|
this.startTime = void 0;
|
|
2144
2202
|
}
|
|
2145
2203
|
};
|
|
@@ -2188,7 +2246,7 @@ var WebWorkerTelemetryClient = class {
|
|
|
2188
2246
|
return;
|
|
2189
2247
|
}
|
|
2190
2248
|
try {
|
|
2191
|
-
return new Worker(URL.createObjectURL(new Blob(["(function(){let e=async(e,t)=>e.valueId?{valueId:e.valueId}:e.value?e.value.length<=500&&e.type!=`json`?{value:e.value}:{valueId:await t(e.value)}:e,t=e=>{let t=Object.keys(e);if(t.length==0)return!0;for(let n of t)if((e[n]?.length??0)>0)return!1;return!0},n=e=>{if(!e)return!0;let t=Object.keys(e);if(t.length==0)return!0;for(let n of t)if((e[n]??0)>0)return!1;return!0},r=async(e,t,n,r)=>{let i=new AbortController,a=setTimeout(()=>{r.debug(`[fetchWithTimeout] Reached timeout, aborting request`),i.abort()},e);try{let e=await fetch(typeof t==`string`||t instanceof Request?t:t.toString(),{...n,signal:i.signal});return clearTimeout(a),e}catch(e){throw r.warn(`[fetchWithTimeout] Fetch error: `,e),clearTimeout(a),e}},i=e=>e?.name===`NotAllowedError`?!0:e instanceof TypeError,a=e=>e>=55296&&e<=56319,o=e=>e>=56320&&e<=57343,s=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t+=1:r<=2047?t+=2:a(r)&&n+1<e.length&&o(e.charCodeAt(n+1))?(t+=4,n++):t+=3}return t};var c=class{constructor(e){this.executeRequests=!0,this.sdkKey=e.sdkKey,this.logger=e.logger,this.sdkIdentity=e.sdkIdentity,this.metaContext=e.metaContext,this.url=e.urlFactory(`client/telemetry/v1`,e.baseUrl),this.clientSession=e.clientSession}async report({context:e,discreteEvents:t,aggregatedEvents:n,droppedEvents:r}){if(!this.executeRequests)return{success:!1,fatalError:!0};let{instanceId:i}=await this.clientSession,a={clientSdkKey:this.sdkKey,instanceId:i,metaContext:{sdkName:this.sdkIdentity.sdkName,sdkVersion:this.sdkIdentity.sdkVersion,appName:this.metaContext.appName,appVersion:this.metaContext.appVersion},context:e,discreteEvents:t,aggregatedEvents:n,droppedEvents:r};if(this.isReportEmpty(a))return{success:!0,fatalError:!1};let o=await this.sendReport(a);return o.fatalError&&(this.executeRequests=!1),o}isReportEmpty(e){return t(e.discreteEvents)&&t(e.aggregatedEvents)&&n(e.droppedEvents)}async sendReport(e){try{let t=JSON.stringify(e),n=await r(5e3,this.url,{method:`POST`,body:t,keepalive:s(t)<=32768},this.logger),i=this.isStatusFatal(n.status);return i?this.logger.warn(`[EventReporter] Received a fatal status response (${n.status}) from the telemetry endpoint. No more telemetry data will be sent.`):n.status===413&&this.logger.warn(`[EventReporter] The telemetry endpoint responded with status ${n.status}. The events in this report were discarded.`),{success:n.ok,fatalError:i}}catch(e){let t=i(e);return this.logger.warn(`[EventReporter] Error attempting to send telemetry data: ${e}`,{error:e}),{success:!1,fatalError:t}}}isStatusFatal(e){return!!e&&e>=400&&e<500&&e!=429&&e!=413}},l=class{aggregate(e){if(e.events.length==0)return[];let t=new Map;for(let n of e.events){let e=JSON.stringify(n),r=t.get(e)?.count||0;t.set(e,{event:n,count:r+1})}return Array.from(t).map(([,t])=>({startTime:e.startTime,endTime:e.endTime,count:t.count,event:t.event}))}},u=class{constructor(e){this._events=[],this._droppedEventCount=0,this.limit=e??1e3}get events(){return this._events}get reachedLimit(){return this._events.length>=this.limit}get droppedEventCount(){return this._droppedEventCount}push(...e){this.startTime||=new Date;let t=Math.max(0,e.length-this.limit),n=e.slice(t,e.length);if(this._droppedEventCount+=t,this._events.length+n.length>this.limit){let e=this._events.length+n.length-this.limit;this._events.splice(0,e),this._droppedEventCount+=e}return this._events.push(...n)}takeSnapshot(){let e=new Date,t=this.startTime??e,n=this._events.splice(0),r=this._droppedEventCount;return this.startTime=void 0,this._droppedEventCount=0,{startTime:t,endTime:e,events:n,droppedCount:r}}clear(){this._events=[],this.startTime=void 0,this._droppedEventCount=0}};let d={\"name-outside-the-character-limit\":`[ConfigDirectorClient] A tracked event was not reported because its name does not have 1 to 150 characters.`,\"value-not-a-finite-number\":`[ConfigDirectorClient] A tracked event was reported without its value because the value is not a finite number.`,\"details-not-reportable\":`[ConfigDirectorClient] A tracked event was reported without its details because they are not an object, have more than 20 top-level keys, are larger than 1024 bytes as JSON, or cannot be written as JSON.`,\"batch-already-full\":`[ConfigDirectorClient] A tracked event was not reported because 1000 tracked events are already waiting for the next telemetry batch.`},f=(e,t)=>{for(let n of t)e.warn(`${d[n]} Further tracked events like it are not logged until the next telemetry batch is sent.`)};var p=class{constructor(){this.entries=[],this.warningsRaisedThisBatch=new Set}add(e){return this.warningsOfKeeping(e).filter(e=>this.isFirstThisBatch(e))}absorb(e){this.entries.push(...e)}takeBatch(){let e=this.entries;return this.clear(),e}clear(){this.entries=[],this.warningsRaisedThisBatch.clear()}warningsOfKeeping(e){switch(e.outcome){case`dropped`:return e.warnings;case`admitted`:return this.entries.length>=1e3?[`batch-already-full`]:(this.entries.push(e.entry),e.warnings)}}isFirstThisBatch(e){return this.warningsRaisedThisBatch.has(e)?!1:(this.warningsRaisedThisBatch.add(e),!0)}},m=class{constructor(e){this.aggregator=new l,this.trackedEventQueue=new p,this.collectEvents=!0,this.started=!1,this.logger=e.logger,this.evaluationEventQueue=new u(e.evaluationQueueLimit??1e3),this.flushIntervalDelay=e.flushIntervalDelay??3e4,this.initialFlushIntervalDelay=e.initialFlushIntervalDelay??5e3}start(){this.started||!this.collectEvents||(this.started=!0,this.flushTimeout=setTimeout(()=>this.flushAndScheduleNext(),this.initialFlushIntervalDelay))}trackedEvent(e){this.collectEvents&&f(this.logger,this.trackedEventQueue.add(e))}async flushAndScheduleNext(){if(!this.collectEvents)return;let e;try{e=await this.flush()}catch(t){this.logger.warn(`[TelemetryEventCollector] Error flushing telemetry events: `,t),e={success:!1,fatalError:!1}}e.fatalError?(this.collectEvents=!1,this.close(),this.logger.warn(`[TelemetryEventCollector] Received a fatal error from telemetry collection. No longer collecting events.`)):this.collectEvents&&(this.cancelScheduledFlush(),this.flushTimeout=setTimeout(()=>this.flushAndScheduleNext(),this.flushIntervalDelay))}cancelScheduledFlush(){clearTimeout(this.flushTimeout)}async close(){this.collectEvents=!1,clearTimeout(this.flushTimeout);try{await this.flush()}catch(e){this.logger.warn(`[TelemetryEventCollector] Error flushing telemetry events during close: `,e)}this.evaluationEventQueue.clear(),this.trackedEventQueue.clear()}dispose(){this.close()}},h=class{constructor(e){this.valueIdGenerator=e,this.valueIdGenerator=e}async process(t){let n=await Promise.all(t.events.map(async t=>({...t,defaultValue:await e(t.defaultValue,this.valueIdGenerator),evaluatedValue:await e(t.evaluatedValue,this.valueIdGenerator)})));return{...t,events:n}}},g=class{constructor(){this.countsByKindSample=new Map,this.countBeyondSampleLimit=0}record(e){return this.startTime??=new Date,this.add(e,1)}absorb(e){for(let t of e)(this.startTime===void 0||t.startTime<this.startTime)&&(this.startTime=t.startTime),this.add(t.event.kindSample,t.count)}add(e,t){if(e!==void 0){let n=this.countsByKindSample.get(e);if(n!==void 0)return this.countsByKindSample.set(e,n+t),`known-kind-sample`;if(this.countsByKindSample.size<20)return this.countsByKindSample.set(e,t),`new-kind-sample`}let n=this.countBeyondSampleLimit===0;return this.countBeyondSampleLimit+=t,n?`first-beyond-sample-limit`:`beyond-sample-limit`}takeSnapshot(){let e=new Date,t=this.startTime??e,n=(n,r)=>({startTime:t,endTime:e,count:n,event:{reason:`invalid-context-kind`,kindSample:r}}),r=Array.from(this.countsByKindSample,([e,t])=>n(t,e)),i=this.countBeyondSampleLimit>0?[...r,n(this.countBeyondSampleLimit)]:r;return this.clear(),i}clear(){this.countsByKindSample.clear(),this.countBeyondSampleLimit=0,this.startTime=void 0}},_=class extends m{constructor(e){super(e),this.invalidContextSubmissions=new g,this.reporter=new c(e),this.evaluationEventSnapshotPreprocessor=new h(e.valueIdGenerator)}async updateContext(e){this.cancelScheduledFlush(),await this.flush(),this._context=e,await this.flushAndScheduleNext()}evaluatedConfig(e){this.collectEvents&&this.evaluationEventQueue.push(e)}recordInvalidContext(e){this.invalidContextSubmissions.record(e)}absorbInvalidContextSubmissions(e){this.invalidContextSubmissions.absorb(e)}absorbTrackedEventEntries(e){this.trackedEventQueue.absorb(e)}async forceFlush(){this.cancelScheduledFlush(),await this.flushAndScheduleNext()}async flush(){if(!this.reporter)return{success:!1,fatalError:!1};let e=await this.evaluationEventSnapshotPreprocessor.process(this.evaluationEventQueue.takeSnapshot());return await this.reporter?.report({context:this._context,discreteEvents:{trackedEvents:this.trackedEventQueue.takeBatch()},aggregatedEvents:{evaluatedConfig:this.aggregator.aggregate(e),invalidContext:this.invalidContextSubmissions.takeSnapshot()},droppedEvents:{evaluatedConfig:e.droppedCount}})}};let v=(e,t)=>new URL(e,t?.toString()),y=(e,t)=>{let n=BigInt(0),r=BigInt(62),i=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``),a=BigInt(`0x`+i),o=``;for(;a>n;)o=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`[Number(a%r)]+o,a/=r;return o.padStart(t,`0`)},b=Math.ceil(128/Math.log2(62)),x=new TextEncoder,S=async e=>{if(typeof crypto>`u`||crypto.subtle==null)return;let t=await crypto.subtle.digest(`SHA-256`,x.encode(e?.toString()??``));return y(new Uint8Array(t,0,16),b)},C,w,T=new Promise(e=>{w=e}),E=(e,t,...n)=>({type:`Log`,payload:{level:e,message:t,args:n}}),D=e=>{try{self.postMessage(e)}catch{self.postMessage(E(e.payload.level,e.payload.message))}},O={debug:function(e,...t){D(E(`debug`,e,t))},info:function(e,...t){D(E(`info`,e,t))},warn:function(e,...t){D(E(`warn`,e,t))},error:function(e,...t){D(E(`error`,e,t))}};addEventListener(`message`,e=>{let t=e.data;if(t.type!=`Initialize`&&!C){O.info(`[TelemetryWorker] Ignoring ${t.type} because no collector is configured`);return}switch(O.debug(`[TelemetryWorker] Received '${t.type}' event:`,t),t.type){case`Initialize`:if(C){O.warn(`[TelemetryWorker] Received a duplicate Initialize event, ignoring it`);break}C=new _({...t.payload,baseUrl:v(t.payload.baseUrl),urlFactory:v,valueIdGenerator:S,logger:O,clientSession:T}),C.start();break;case`ClientSession`:w(t.payload);break;case`EvaluatedConfigEvent`:C?.evaluatedConfig(t.payload);break;case`InvalidContextSubmissions`:C?.absorbInvalidContextSubmissions(t.payload.entries);break;case`TrackedEvent`:C?.trackedEvent(t.payload);break;case`TrackedEventEntries`:C?.absorbTrackedEventEntries(t.payload.entries);break;case`UpdateContext`:C?.updateContext(t.payload.context);break;case`Flush`:C?.forceFlush();break;case`Close`:(C?.close()??Promise.resolve()).then(()=>{self.postMessage({type:`Closed`}),self.close()});break}})})();"], { type: "application/javascript" })));
|
|
2249
|
+
return new Worker(URL.createObjectURL(new Blob(["(function(){let e=async(e,t)=>e.valueId?{valueId:e.valueId}:e.value?e.value.length<=500&&e.type!=`json`?{value:e.value}:{valueId:await t(e.value)}:e,t=e=>{let t=Object.keys(e);if(t.length==0)return!0;for(let n of t)if((e[n]?.length??0)>0)return!1;return!0},n=e=>{if(!e)return!0;let t=Object.keys(e);if(t.length==0)return!0;for(let n of t)if((e[n]??0)>0)return!1;return!0},r=async(e,t,n,r)=>{let i=new AbortController,a=setTimeout(()=>{r.debug(`[fetchWithTimeout] Reached timeout, aborting request`),i.abort()},e);try{let e=await fetch(typeof t==`string`||t instanceof Request?t:t.toString(),{...n,signal:i.signal});return clearTimeout(a),e}catch(e){throw r.warn(`[fetchWithTimeout] Fetch error: `,e),clearTimeout(a),e}},i=e=>e?.name===`NotAllowedError`?!0:e instanceof TypeError,a=e=>e>=55296&&e<=56319,o=e=>e>=56320&&e<=57343,s=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t+=1:r<=2047?t+=2:a(r)&&n+1<e.length&&o(e.charCodeAt(n+1))?(t+=4,n++):t+=3}return t};var c=class{constructor(e){this.executeRequests=!0,this.sdkKey=e.sdkKey,this.logger=e.logger,this.sdkIdentity=e.sdkIdentity,this.metaContext=e.metaContext,this.url=e.urlFactory(`client/telemetry/v1`,e.baseUrl),this.clientSession=e.clientSession}async report({context:e,discreteEvents:t,aggregatedEvents:n,droppedEvents:r}){if(!this.executeRequests)return{success:!1,fatalError:!0};let{instanceId:i}=await this.clientSession,a={clientSdkKey:this.sdkKey,instanceId:i,metaContext:{sdkName:this.sdkIdentity.sdkName,sdkVersion:this.sdkIdentity.sdkVersion,appName:this.metaContext.appName,appVersion:this.metaContext.appVersion},context:e,discreteEvents:t,aggregatedEvents:n,droppedEvents:r};if(this.isReportEmpty(a))return{success:!0,fatalError:!1};let o=await this.sendReport(a);return o.fatalError&&(this.executeRequests=!1),o}isReportEmpty(e){return t(e.discreteEvents)&&t(e.aggregatedEvents)&&n(e.droppedEvents)}async sendReport(e){try{let t=JSON.stringify(e),n=await r(5e3,this.url,{method:`POST`,body:t,keepalive:s(t)<=32768},this.logger),i=this.isStatusFatal(n.status);return i?this.logger.warn(`[EventReporter] Received a fatal status response (${n.status}) from the telemetry endpoint. No more telemetry data will be sent.`):n.status===413&&this.logger.warn(`[EventReporter] The telemetry endpoint responded with status ${n.status}. The events in this report were discarded.`),{success:n.ok,fatalError:i}}catch(e){let t=i(e);return this.logger.warn(`[EventReporter] Error attempting to send telemetry data: ${e}`,{error:e}),{success:!1,fatalError:t}}}isStatusFatal(e){return!!e&&e>=400&&e<500&&e!=429&&e!=413}},l=class{aggregate(e){if(e.events.length==0)return[];let t=new Map;for(let n of e.events){let e=JSON.stringify(n),r=t.get(e)?.count||0;t.set(e,{event:n,count:r+1})}return Array.from(t).map(([,t])=>({startTime:e.startTime,endTime:e.endTime,count:t.count,event:t.event}))}},u=class{constructor(e){this._events=[],this._droppedEventCount=0,this.limit=e??1e3}get events(){return this._events}get reachedLimit(){return this._events.length>=this.limit}get droppedEventCount(){return this._droppedEventCount}push(...e){this.startTime||=new Date;let t=Math.max(0,e.length-this.limit),n=e.slice(t,e.length);if(this._droppedEventCount+=t,this._events.length+n.length>this.limit){let e=this._events.length+n.length-this.limit;this._events.splice(0,e),this._droppedEventCount+=e}return this._events.push(...n)}takeSnapshot(){let e=new Date,t=this.startTime??e,n=this._events.splice(0),r=this._droppedEventCount;return this.startTime=void 0,this._droppedEventCount=0,{startTime:t,endTime:e,events:n,droppedCount:r}}clear(){this._events=[],this.startTime=void 0,this._droppedEventCount=0}};let d={\"name-outside-the-character-limit\":`[ConfigDirectorClient] A tracked event was not reported because its name does not have 1 to 150 characters.`,\"value-not-a-finite-number\":`[ConfigDirectorClient] A tracked event was reported without its value because the value is not a finite number.`,\"details-not-reportable\":`[ConfigDirectorClient] A tracked event was reported without its details because they are not an object, have more than 20 top-level keys, are larger than 1024 bytes as JSON, or cannot be written as JSON.`,\"batch-already-full\":`[ConfigDirectorClient] A tracked event was not reported because 1000 tracked events are already waiting for the next telemetry batch.`},f=(e,t)=>{for(let n of t)e.warn(`${d[n]} Further tracked events like it are not logged until the next telemetry batch is sent.`)};var p=class{constructor(){this.entries=[],this.warningsRaisedThisBatch=new Set}add(e){return this.warningsOfKeeping(e).filter(e=>this.isFirstThisBatch(e))}absorb(e){this.entries.push(...e)}takeBatch(){let e=this.entries;return this.clear(),e}clear(){this.entries=[],this.warningsRaisedThisBatch.clear()}warningsOfKeeping(e){switch(e.outcome){case`dropped`:return e.warnings;case`admitted`:return this.entries.length>=1e3?[`batch-already-full`]:(this.entries.push(e.entry),e.warnings)}}isFirstThisBatch(e){return this.warningsRaisedThisBatch.has(e)?!1:(this.warningsRaisedThisBatch.add(e),!0)}},m=class{constructor(e){this.aggregator=new l,this.trackedEventQueue=new p,this.collectEvents=!0,this.started=!1,this.logger=e.logger,this.evaluationEventQueue=new u(e.evaluationQueueLimit??1e3),this.flushIntervalDelay=e.flushIntervalDelay??3e4,this.initialFlushIntervalDelay=e.initialFlushIntervalDelay??5e3}start(){this.started||!this.collectEvents||(this.started=!0,this.flushTimeout=setTimeout(()=>this.flushAndScheduleNext(),this.initialFlushIntervalDelay))}trackedEvent(e){this.collectEvents&&f(this.logger,this.trackedEventQueue.add(e))}async flushAndScheduleNext(){if(!this.collectEvents)return;let e;try{e=await this.flush()}catch(t){this.logger.warn(`[TelemetryEventCollector] Error flushing telemetry events: `,t),e={success:!1,fatalError:!1}}e.fatalError?(this.collectEvents=!1,this.close(),this.logger.warn(`[TelemetryEventCollector] Received a fatal error from telemetry collection. No longer collecting events.`)):this.collectEvents&&(this.cancelScheduledFlush(),this.flushTimeout=setTimeout(()=>this.flushAndScheduleNext(),this.flushIntervalDelay))}cancelScheduledFlush(){clearTimeout(this.flushTimeout)}async close(){this.collectEvents=!1,clearTimeout(this.flushTimeout);try{await this.flush()}catch(e){this.logger.warn(`[TelemetryEventCollector] Error flushing telemetry events during close: `,e)}this.evaluationEventQueue.clear(),this.trackedEventQueue.clear()}dispose(){this.close()}},h=class{constructor(e){this.valueIdGenerator=e,this.valueIdGenerator=e}async process(t){let n=await Promise.all(t.events.map(async t=>({...t,defaultValue:await e(t.defaultValue,this.valueIdGenerator),evaluatedValue:await e(t.evaluatedValue,this.valueIdGenerator)})));return{...t,events:n}}},g=class{constructor(){this.countsByKindSample=new Map,this.countBeyondSampleLimit=0,this.countsBySizeLimit=new Map}recordInvalidKind(e){return this.startTime??=new Date,this.addInvalidKind(e,1)}recordOverSizeLimit(e){this.startTime??=new Date,this.addOverSizeLimit(e,1)}absorb(e){for(let t of e){(this.startTime===void 0||t.startTime<this.startTime)&&(this.startTime=t.startTime);let{event:e}=t;e.reason===`invalid-context-kind`?this.addInvalidKind(e.kindSample,t.count):this.addOverSizeLimit(e.reason,t.count)}}addInvalidKind(e,t){if(e!==void 0){let n=this.countsByKindSample.get(e);if(n!==void 0)return this.countsByKindSample.set(e,n+t),`known-kind-sample`;if(this.countsByKindSample.size<20)return this.countsByKindSample.set(e,t),`new-kind-sample`}let n=this.countBeyondSampleLimit===0;return this.countBeyondSampleLimit+=t,n?`first-beyond-sample-limit`:`beyond-sample-limit`}addOverSizeLimit(e,t){this.countsBySizeLimit.set(e,(this.countsBySizeLimit.get(e)??0)+t)}takeSnapshot(){let e=new Date,t=this.startTime??e,n=(n,r)=>({startTime:t,endTime:e,count:n,event:r}),r=Array.from(this.countsByKindSample,([e,t])=>n(t,{reason:`invalid-context-kind`,kindSample:e})),i=this.countBeyondSampleLimit>0?[...r,n(this.countBeyondSampleLimit,{reason:`invalid-context-kind`})]:r,a=Array.from(this.countsBySizeLimit,([e,t])=>n(t,{reason:e}));return this.clear(),[...i,...a]}clear(){this.countsByKindSample.clear(),this.countBeyondSampleLimit=0,this.countsBySizeLimit.clear(),this.startTime=void 0}},_=class extends m{constructor(e){super(e),this.invalidContextSubmissions=new g,this.reporter=new c(e),this.evaluationEventSnapshotPreprocessor=new h(e.valueIdGenerator)}async updateContext(e){this.cancelScheduledFlush(),await this.flush(),this._context=e,await this.flushAndScheduleNext()}evaluatedConfig(e){this.collectEvents&&this.evaluationEventQueue.push(e)}recordInvalidContextKind(e){this.invalidContextSubmissions.recordInvalidKind(e)}recordContextOverSizeLimit(e){this.invalidContextSubmissions.recordOverSizeLimit(e)}absorbInvalidContextSubmissions(e){this.invalidContextSubmissions.absorb(e)}absorbTrackedEventEntries(e){this.trackedEventQueue.absorb(e)}async forceFlush(){this.cancelScheduledFlush(),await this.flushAndScheduleNext()}async flush(){if(!this.reporter)return{success:!1,fatalError:!1};let e=await this.evaluationEventSnapshotPreprocessor.process(this.evaluationEventQueue.takeSnapshot());return await this.reporter?.report({context:this._context,discreteEvents:{trackedEvents:this.trackedEventQueue.takeBatch()},aggregatedEvents:{evaluatedConfig:this.aggregator.aggregate(e),invalidContext:this.invalidContextSubmissions.takeSnapshot()},droppedEvents:{evaluatedConfig:e.droppedCount}})}};let v=(e,t)=>new URL(e,t?.toString()),y=(e,t)=>{let n=BigInt(0),r=BigInt(62),i=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``),a=BigInt(`0x`+i),o=``;for(;a>n;)o=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`[Number(a%r)]+o,a/=r;return o.padStart(t,`0`)},b=Math.ceil(128/Math.log2(62)),x=new TextEncoder,S=async e=>{if(typeof crypto>`u`||crypto.subtle==null)return;let t=await crypto.subtle.digest(`SHA-256`,x.encode(e?.toString()??``));return y(new Uint8Array(t,0,16),b)},C,w,T=new Promise(e=>{w=e}),E=(e,t,...n)=>({type:`Log`,payload:{level:e,message:t,args:n}}),D=e=>{try{self.postMessage(e)}catch{self.postMessage(E(e.payload.level,e.payload.message))}},O={debug:function(e,...t){D(E(`debug`,e,t))},info:function(e,...t){D(E(`info`,e,t))},warn:function(e,...t){D(E(`warn`,e,t))},error:function(e,...t){D(E(`error`,e,t))}};addEventListener(`message`,e=>{let t=e.data;if(t.type!=`Initialize`&&!C){O.info(`[TelemetryWorker] Ignoring ${t.type} because no collector is configured`);return}switch(O.debug(`[TelemetryWorker] Received '${t.type}' event:`,t),t.type){case`Initialize`:if(C){O.warn(`[TelemetryWorker] Received a duplicate Initialize event, ignoring it`);break}C=new _({...t.payload,baseUrl:v(t.payload.baseUrl),urlFactory:v,valueIdGenerator:S,logger:O,clientSession:T}),C.start();break;case`ClientSession`:w(t.payload);break;case`EvaluatedConfigEvent`:C?.evaluatedConfig(t.payload);break;case`InvalidContextSubmissions`:C?.absorbInvalidContextSubmissions(t.payload.entries);break;case`TrackedEvent`:C?.trackedEvent(t.payload);break;case`TrackedEventEntries`:C?.absorbTrackedEventEntries(t.payload.entries);break;case`UpdateContext`:C?.updateContext(t.payload.context);break;case`Flush`:C?.forceFlush();break;case`Close`:(C?.close()??Promise.resolve()).then(()=>{self.postMessage({type:`Closed`}),self.close()});break}})})();"], { type: "application/javascript" })));
|
|
2192
2250
|
} catch (error) {
|
|
2193
2251
|
this.turnOff("[WebWorkerTelemetryClient] Telemetry is off because the telemetry Web Worker could not be created: ", error);
|
|
2194
2252
|
return;
|
|
@@ -2270,8 +2328,12 @@ var WebWorkerTelemetryClient = class {
|
|
|
2270
2328
|
if (this.pendingEvaluations.length >= this.pendingEvaluationLimit) this.pendingEvaluations.shift();
|
|
2271
2329
|
this.pendingEvaluations.push(evaluatedConfigMessage);
|
|
2272
2330
|
}
|
|
2273
|
-
|
|
2274
|
-
this.pendingInvalidContextSubmissions.
|
|
2331
|
+
recordInvalidContextKind(kindSample) {
|
|
2332
|
+
this.pendingInvalidContextSubmissions.recordInvalidKind(kindSample);
|
|
2333
|
+
this.forwardInvalidContextSubmissions(this.worker);
|
|
2334
|
+
}
|
|
2335
|
+
recordContextOverSizeLimit(reason) {
|
|
2336
|
+
this.pendingInvalidContextSubmissions.recordOverSizeLimit(reason);
|
|
2275
2337
|
this.forwardInvalidContextSubmissions(this.worker);
|
|
2276
2338
|
}
|
|
2277
2339
|
trackedEvent(admission) {
|
|
@@ -2499,12 +2561,13 @@ const getEffectiveTimeout = (option) => {
|
|
|
2499
2561
|
const useConfigDirectorContext = () => {
|
|
2500
2562
|
const state = useState("configdirector-context");
|
|
2501
2563
|
const { client } = useConfigDirectorClient();
|
|
2502
|
-
const { $configDirectorClientStartup } = useNuxtApp();
|
|
2564
|
+
const { $configDirectorClientStartup, $configDirectorClientContextUpdate } = useNuxtApp();
|
|
2503
2565
|
const startup = $configDirectorClientStartup;
|
|
2566
|
+
const updateClientContext = $configDirectorClientContextUpdate;
|
|
2504
2567
|
const handContextToClient = (rawContext) => {
|
|
2505
2568
|
switch (decideContextUpdateAction(client, rawContext, startup.waitsForFirstContext)) {
|
|
2506
2569
|
case "startClient": return startup.start(rawContext);
|
|
2507
|
-
case "updateContext": return
|
|
2570
|
+
case "updateContext": return updateClientContext(rawContext);
|
|
2508
2571
|
}
|
|
2509
2572
|
};
|
|
2510
2573
|
const updateContext = async (context, options) => {
|
|
@@ -2515,12 +2578,17 @@ const useConfigDirectorContext = () => {
|
|
|
2515
2578
|
if (oldContext != newContext) {
|
|
2516
2579
|
const timeout = getEffectiveTimeout(options?.timeoutMilliseconds);
|
|
2517
2580
|
let timer;
|
|
2581
|
+
const showContextHeldByClient = () => {
|
|
2582
|
+
state.value = client.context;
|
|
2583
|
+
};
|
|
2584
|
+
client.on("connectionError", showContextHeldByClient);
|
|
2518
2585
|
try {
|
|
2519
2586
|
await Promise.race([handContextToClient(rawContext), new Promise((resolve) => {
|
|
2520
2587
|
timer = setTimeout(() => resolve(), timeout);
|
|
2521
2588
|
})]);
|
|
2522
2589
|
} finally {
|
|
2523
2590
|
clearTimeout(timer);
|
|
2591
|
+
client.off("connectionError", showContextHeldByClient);
|
|
2524
2592
|
}
|
|
2525
2593
|
}
|
|
2526
2594
|
};
|
|
@@ -2565,6 +2633,10 @@ var plugin_client_default = defineNuxtPlugin(async (nuxtApp) => {
|
|
|
2565
2633
|
settleReadyStatus();
|
|
2566
2634
|
}
|
|
2567
2635
|
};
|
|
2636
|
+
const updateContext = async (context) => {
|
|
2637
|
+
await client.updateContext(context);
|
|
2638
|
+
settleReadyStatus();
|
|
2639
|
+
};
|
|
2568
2640
|
nuxtApp.hooks.hook("app:created", async () => {
|
|
2569
2641
|
const { context } = useConfigDirectorContext();
|
|
2570
2642
|
const rawContext = toRaw(context.value);
|
|
@@ -2587,7 +2659,8 @@ var plugin_client_default = defineNuxtPlugin(async (nuxtApp) => {
|
|
|
2587
2659
|
return { provide: {
|
|
2588
2660
|
configDirectorClient: client,
|
|
2589
2661
|
configDirectorClientReadyStatus: readonly(readyStatus),
|
|
2590
|
-
configDirectorClientStartup: startup
|
|
2662
|
+
configDirectorClientStartup: startup,
|
|
2663
|
+
configDirectorClientContextUpdate: updateContext
|
|
2591
2664
|
} };
|
|
2592
2665
|
});
|
|
2593
2666
|
const buildClient = async (configdirector, logger) => {
|
|
@@ -2600,7 +2673,7 @@ const buildClient = async (configdirector, logger) => {
|
|
|
2600
2673
|
return {
|
|
2601
2674
|
client: createBrowserClient(configdirector?.clientSdkKey || void 0, {
|
|
2602
2675
|
sdkName: "nuxt-sdk",
|
|
2603
|
-
sdkVersion: "1.
|
|
2676
|
+
sdkVersion: "1.15.0"
|
|
2604
2677
|
}, {
|
|
2605
2678
|
metadata: {
|
|
2606
2679
|
appName: configdirector?.appName,
|
|
@@ -97,12 +97,13 @@ const getEffectiveTimeout = (option) => {
|
|
|
97
97
|
const useConfigDirectorContext = () => {
|
|
98
98
|
const state = useState("configdirector-context");
|
|
99
99
|
const { client } = useConfigDirectorClient();
|
|
100
|
-
const { $configDirectorClientStartup } = useNuxtApp();
|
|
100
|
+
const { $configDirectorClientStartup, $configDirectorClientContextUpdate } = useNuxtApp();
|
|
101
101
|
const startup = $configDirectorClientStartup;
|
|
102
|
+
const updateClientContext = $configDirectorClientContextUpdate;
|
|
102
103
|
const handContextToClient = (rawContext) => {
|
|
103
104
|
switch (decideContextUpdateAction(client, rawContext, startup.waitsForFirstContext)) {
|
|
104
105
|
case "startClient": return startup.start(rawContext);
|
|
105
|
-
case "updateContext": return
|
|
106
|
+
case "updateContext": return updateClientContext(rawContext);
|
|
106
107
|
}
|
|
107
108
|
};
|
|
108
109
|
const updateContext = async (context, options) => {
|
|
@@ -113,12 +114,17 @@ const useConfigDirectorContext = () => {
|
|
|
113
114
|
if (oldContext != newContext) {
|
|
114
115
|
const timeout = getEffectiveTimeout(options?.timeoutMilliseconds);
|
|
115
116
|
let timer;
|
|
117
|
+
const showContextHeldByClient = () => {
|
|
118
|
+
state.value = client.context;
|
|
119
|
+
};
|
|
120
|
+
client.on("connectionError", showContextHeldByClient);
|
|
116
121
|
try {
|
|
117
122
|
await Promise.race([handContextToClient(rawContext), new Promise((resolve) => {
|
|
118
123
|
timer = setTimeout(() => resolve(), timeout);
|
|
119
124
|
})]);
|
|
120
125
|
} finally {
|
|
121
126
|
clearTimeout(timer);
|
|
127
|
+
client.off("connectionError", showContextHeldByClient);
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
};
|
|
@@ -141,6 +147,7 @@ var plugin_server_default = defineNuxtPlugin((nuxtApp) => {
|
|
|
141
147
|
waitsForFirstContext: false,
|
|
142
148
|
start: (context) => client.initialize(context)
|
|
143
149
|
};
|
|
150
|
+
const updateContext = (context) => client.updateContext(context);
|
|
144
151
|
nuxtApp.hooks.hook("app:created", async () => {
|
|
145
152
|
logger.debug("Updating ConfigDirector context for SSR evaluation");
|
|
146
153
|
const { context } = useConfigDirectorContext();
|
|
@@ -149,7 +156,8 @@ var plugin_server_default = defineNuxtPlugin((nuxtApp) => {
|
|
|
149
156
|
return { provide: {
|
|
150
157
|
configDirectorClient: client,
|
|
151
158
|
configDirectorClientReadyStatus: readonly(readyStatus),
|
|
152
|
-
configDirectorClientStartup: startup
|
|
159
|
+
configDirectorClientStartup: startup,
|
|
160
|
+
configDirectorClientContextUpdate: updateContext
|
|
153
161
|
} };
|
|
154
162
|
});
|
|
155
163
|
var SsrClient = class {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ConfigDirectorClient } from "../../types-
|
|
1
|
+
import { n as ConfigDirectorClient } from "../../types-CXuEYplq.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerClient.d.ts
|
|
4
4
|
declare const useConfigDirectorServerClient: () => ConfigDirectorClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ConfigDirectorClient } from "../../types-
|
|
1
|
+
import { n as ConfigDirectorClient } from "../../types-CXuEYplq.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerClient.d.ts
|
|
4
4
|
declare const useConfigDirectorServerClient: () => ConfigDirectorClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-CXuEYplq.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorServerHooks: (hooks: ClientHooks) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-CXuEYplq.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorServerHooks: (hooks: ClientHooks) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ConfigValueType, i as ConfigState, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-
|
|
1
|
+
import { a as ConfigValueType, i as ConfigState, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-DQVM1FGD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../js-server-sdk/src/types.d.ts
|
|
4
4
|
type ClientEvents = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ConfigValueType, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-
|
|
1
|
+
import { a as ConfigValueType, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-DQVM1FGD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../js-client-core/src/Emitter.d.ts
|
|
4
4
|
type EventType = string | symbol;
|
package/dist/testing.d.mts
CHANGED
|
@@ -103,6 +103,10 @@ type ConfigDirectorContext = {
|
|
|
103
103
|
* or the site's data is cleared. However, keep in mind that this value is used for segmenting
|
|
104
104
|
* contexts in percentage rollouts, and changes to the {@link id} could result in the context
|
|
105
105
|
* being assigned to a different percentile.
|
|
106
|
+
*
|
|
107
|
+
* An identifier has at most 256 characters. A client SDK ignores a context with a longer one as
|
|
108
|
+
* a whole: it logs an error and evaluates as if no context had been provided. A server SDK still
|
|
109
|
+
* evaluates such a context, and ConfigDirector does not add it to the environment's contexts.
|
|
106
110
|
*/
|
|
107
111
|
id?: string;
|
|
108
112
|
/**
|
|
@@ -120,11 +124,20 @@ type ConfigDirectorContext = {
|
|
|
120
124
|
/**
|
|
121
125
|
* The context's display name. This will be shown in the ConfigDirector dashboard and may be
|
|
122
126
|
* used for targeting rules.
|
|
127
|
+
*
|
|
128
|
+
* A name has at most 256 characters. A client SDK ignores a context with a longer one as a
|
|
129
|
+
* whole: it logs an error and evaluates as if no context had been provided. A server SDK still
|
|
130
|
+
* evaluates such a context, and ConfigDirector does not add it to the environment's contexts.
|
|
123
131
|
*/
|
|
124
132
|
name?: string;
|
|
125
133
|
/**
|
|
126
134
|
* Any arbitrary traits for the context. They will be shown in the ConfigDirector dashboard
|
|
127
135
|
* and may be used for targeting rules.
|
|
136
|
+
*
|
|
137
|
+
* Traits take at most 64 KB once written as JSON. A client SDK ignores a context with larger
|
|
138
|
+
* traits as a whole: it logs an error and evaluates as if no context had been provided. A server
|
|
139
|
+
* SDK still evaluates such a context, and ConfigDirector does not add it to the environment's
|
|
140
|
+
* contexts.
|
|
128
141
|
*/
|
|
129
142
|
traits?: {
|
|
130
143
|
[key: string]: unknown;
|
|
@@ -397,8 +410,8 @@ interface TestClient {
|
|
|
397
410
|
failContextUpdate(): void;
|
|
398
411
|
/**
|
|
399
412
|
* The context of every `initialize` and `updateContext` call, in call order. `initialize` without
|
|
400
|
-
* a context records an empty context, and so does a call whose context has an invalid kind
|
|
401
|
-
* the client connects without it. Resumes are not recorded.
|
|
413
|
+
* a context records an empty context, and so does a call whose context has an invalid kind or is
|
|
414
|
+
* over the context size limits, since the client connects without it. Resumes are not recorded.
|
|
402
415
|
*/
|
|
403
416
|
readonly contextUpdates: ConfigDirectorContext[];
|
|
404
417
|
/**
|
package/dist/testing.mjs
CHANGED
|
@@ -916,7 +916,8 @@ const createDefaultLogger = (level, messageDecorator) => {
|
|
|
916
916
|
const discardingTelemetryClient = {
|
|
917
917
|
updateContext: async () => {},
|
|
918
918
|
evaluatedConfig: () => {},
|
|
919
|
-
|
|
919
|
+
recordInvalidContextKind: () => {},
|
|
920
|
+
recordContextOverSizeLimit: () => {},
|
|
920
921
|
trackedEvent: () => {},
|
|
921
922
|
close: async () => {}
|
|
922
923
|
};
|
|
@@ -1298,6 +1299,42 @@ const utf8ByteLength = (text) => {
|
|
|
1298
1299
|
return bytes;
|
|
1299
1300
|
};
|
|
1300
1301
|
//#endregion
|
|
1302
|
+
//#region ../js-client-core/src/context-admission.ts
|
|
1303
|
+
const IDENTIFIER_MAXIMUM_CHARACTERS = 256;
|
|
1304
|
+
const NAME_MAXIMUM_CHARACTERS$1 = 256;
|
|
1305
|
+
const TRAITS_MAXIMUM_JSON_BYTES = 65536;
|
|
1306
|
+
const hasMoreCharactersThan = (maximumCharacters, text) => typeof text === "string" && Array.from(text).length > maximumCharacters;
|
|
1307
|
+
const hasMoreJsonBytesThan = (maximumBytes, traits) => {
|
|
1308
|
+
let json;
|
|
1309
|
+
try {
|
|
1310
|
+
json = JSON.stringify(traits);
|
|
1311
|
+
} catch {
|
|
1312
|
+
return false;
|
|
1313
|
+
}
|
|
1314
|
+
return json !== void 0 && utf8ByteLength(json) > maximumBytes;
|
|
1315
|
+
};
|
|
1316
|
+
const firstSizeLimitPassedBy = (context) => {
|
|
1317
|
+
if (hasMoreCharactersThan(IDENTIFIER_MAXIMUM_CHARACTERS, context?.id)) return "identifier-too-long";
|
|
1318
|
+
if (hasMoreCharactersThan(NAME_MAXIMUM_CHARACTERS$1, context?.name)) return "name-too-long";
|
|
1319
|
+
if (hasMoreJsonBytesThan(TRAITS_MAXIMUM_JSON_BYTES, context?.traits)) return "traits-too-large";
|
|
1320
|
+
};
|
|
1321
|
+
const admitClientContext = (context) => {
|
|
1322
|
+
const kindAdmission = admitContext(context);
|
|
1323
|
+
if (kindAdmission.outcome === "ignored") return {
|
|
1324
|
+
outcome: "invalid kind",
|
|
1325
|
+
kindSample: kindAdmission.kindSample
|
|
1326
|
+
};
|
|
1327
|
+
const passedSizeLimit = firstSizeLimitPassedBy(context);
|
|
1328
|
+
if (passedSizeLimit !== void 0) return {
|
|
1329
|
+
outcome: "over a size limit",
|
|
1330
|
+
reason: passedSizeLimit
|
|
1331
|
+
};
|
|
1332
|
+
return {
|
|
1333
|
+
outcome: "admitted",
|
|
1334
|
+
context
|
|
1335
|
+
};
|
|
1336
|
+
};
|
|
1337
|
+
//#endregion
|
|
1301
1338
|
//#region ../shared/src/telemetry/reported-context.ts
|
|
1302
1339
|
const USER_CONTEXT_KIND = "user";
|
|
1303
1340
|
const reportedContextOf = (context) => {
|
|
@@ -1549,6 +1586,11 @@ var CachedValuesStore = class {
|
|
|
1549
1586
|
//#endregion
|
|
1550
1587
|
//#region ../js-client-core/src/DefaultConfigDirectorClient.ts
|
|
1551
1588
|
const MAX_EXPONENTIAL_DELAY = 9;
|
|
1589
|
+
const CONTEXT_SIZE_LIMIT_EXPLANATIONS = {
|
|
1590
|
+
"identifier-too-long": "its id is longer than 256 characters",
|
|
1591
|
+
"name-too-long": "its name is longer than 256 characters",
|
|
1592
|
+
"traits-too-large": "its traits are over 64 KB of JSON"
|
|
1593
|
+
};
|
|
1552
1594
|
const createReadyOrClosedSignal = () => {
|
|
1553
1595
|
let raise;
|
|
1554
1596
|
return {
|
|
@@ -1786,12 +1828,16 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1786
1828
|
await this.connectToTransport(this.admittedContextFor(context, submission), submission);
|
|
1787
1829
|
}
|
|
1788
1830
|
admittedContextFor(suppliedContext, submission) {
|
|
1789
|
-
const admission =
|
|
1831
|
+
const admission = admitClientContext(suppliedContext);
|
|
1790
1832
|
switch (admission.outcome) {
|
|
1791
1833
|
case "admitted": return admission.context;
|
|
1792
|
-
case "
|
|
1834
|
+
case "invalid kind":
|
|
1793
1835
|
this.logger.error(`[ConfigDirectorClient] Ignored the context supplied for ${submission} because its kind '${admission.kindSample}' is invalid; continuing as if no context was supplied. A context kind has 1 to 64 characters, using only lowercase letters, digits, '-' and '_'.`);
|
|
1794
|
-
this.telemetryClient.
|
|
1836
|
+
this.telemetryClient.recordInvalidContextKind(admission.kindSample);
|
|
1837
|
+
return;
|
|
1838
|
+
case "over a size limit":
|
|
1839
|
+
this.logger.error(`[ConfigDirectorClient] Ignored the context supplied for ${submission} because ${CONTEXT_SIZE_LIMIT_EXPLANATIONS[admission.reason]}; continuing as if no context was supplied.`);
|
|
1840
|
+
this.telemetryClient.recordContextOverSizeLimit(admission.reason);
|
|
1795
1841
|
return;
|
|
1796
1842
|
}
|
|
1797
1843
|
}
|
|
@@ -2338,7 +2384,7 @@ const installTestClient = (testClient) => {
|
|
|
2338
2384
|
const createTestClient = (options) => {
|
|
2339
2385
|
return createTestClient$1({
|
|
2340
2386
|
sdkName: "nuxt-sdk",
|
|
2341
|
-
sdkVersion: "1.
|
|
2387
|
+
sdkVersion: "1.15.0"
|
|
2342
2388
|
}, options);
|
|
2343
2389
|
};
|
|
2344
2390
|
//#endregion
|
package/package.json
CHANGED