@launchdarkly/js-sdk-common 2.10.0 → 2.10.1-beta.1
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/{AttributeReference.d.ts → cjs/AttributeReference.d.ts} +2 -2
- package/dist/{AttributeReference.d.ts.map → cjs/AttributeReference.d.ts.map} +1 -1
- package/dist/{Context.d.ts → cjs/Context.d.ts} +13 -13
- package/dist/cjs/Context.d.ts.map +1 -0
- package/dist/cjs/ContextFilter.d.ts +11 -0
- package/dist/cjs/ContextFilter.d.ts.map +1 -0
- package/dist/{index.cjs → cjs/index.cjs} +286 -284
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{internal → cjs/internal}/diagnostics/DiagnosticsManager.d.ts +7 -7
- package/dist/{internal → cjs/internal}/diagnostics/DiagnosticsManager.d.ts.map +1 -1
- package/dist/{internal → cjs/internal}/evaluation/EventFactoryBase.d.ts +2 -2
- package/dist/{internal → cjs/internal}/evaluation/EventFactoryBase.d.ts.map +1 -1
- package/dist/{internal → cjs/internal}/events/ClientMessages.d.ts +1 -1
- package/dist/cjs/internal/events/EventProcessor.d.ts +44 -0
- package/dist/cjs/internal/events/EventProcessor.d.ts.map +1 -0
- package/dist/{internal → cjs/internal}/events/EventSender.d.ts +6 -6
- package/dist/{internal → cjs/internal}/events/EventSender.d.ts.map +1 -1
- package/dist/{internal → cjs/internal}/stream/StreamingProcessor.d.ts +14 -14
- package/dist/cjs/internal/stream/StreamingProcessor.d.ts.map +1 -0
- package/dist/{logging → cjs/logging}/BasicLogger.d.ts +7 -7
- package/dist/cjs/logging/BasicLogger.d.ts.map +1 -0
- package/dist/{logging → cjs/logging}/SafeLogger.d.ts +3 -3
- package/dist/{logging → cjs/logging}/SafeLogger.d.ts.map +1 -1
- package/dist/{options → cjs/options}/ServiceEndpoints.d.ts.map +1 -1
- package/dist/cjs/package.json +1 -0
- package/dist/{validators.d.ts → cjs/validators.d.ts} +2 -2
- package/dist/{validators.d.ts.map → cjs/validators.d.ts.map} +1 -1
- package/dist/esm/AttributeReference.d.ts +35 -0
- package/dist/esm/AttributeReference.d.ts.map +1 -0
- package/dist/esm/Context.d.ts +95 -0
- package/dist/esm/Context.d.ts.map +1 -0
- package/dist/esm/ContextFilter.d.ts +11 -0
- package/dist/esm/ContextFilter.d.ts.map +1 -0
- package/dist/esm/api/context/LDContext.d.ts +8 -0
- package/dist/esm/api/context/LDContext.d.ts.map +1 -0
- package/dist/esm/api/context/LDContextCommon.d.ts +29 -0
- package/dist/esm/api/context/LDContextCommon.d.ts.map +1 -0
- package/dist/esm/api/context/LDContextMeta.d.ts +52 -0
- package/dist/esm/api/context/LDContextMeta.d.ts.map +1 -0
- package/dist/esm/api/context/LDMultiKindContext.d.ts +46 -0
- package/dist/esm/api/context/LDMultiKindContext.d.ts.map +1 -0
- package/dist/esm/api/context/LDSingleKindContext.d.ts +24 -0
- package/dist/esm/api/context/LDSingleKindContext.d.ts.map +1 -0
- package/dist/esm/api/context/LDUser.d.ts +66 -0
- package/dist/esm/api/context/LDUser.d.ts.map +1 -0
- package/dist/esm/api/context/index.d.ts +7 -0
- package/dist/esm/api/context/index.d.ts.map +1 -0
- package/dist/esm/api/data/LDEvaluationDetail.d.ts +43 -0
- package/dist/esm/api/data/LDEvaluationDetail.d.ts.map +1 -0
- package/dist/esm/api/data/LDEvaluationReason.d.ts +57 -0
- package/dist/esm/api/data/LDEvaluationReason.d.ts.map +1 -0
- package/dist/esm/api/data/LDFlagSet.d.ts +8 -0
- package/dist/esm/api/data/LDFlagSet.d.ts.map +1 -0
- package/dist/esm/api/data/LDFlagValue.d.ts +7 -0
- package/dist/esm/api/data/LDFlagValue.d.ts.map +1 -0
- package/dist/esm/api/data/index.d.ts +5 -0
- package/dist/esm/api/data/index.d.ts.map +1 -0
- package/dist/esm/api/index.d.ts +7 -0
- package/dist/esm/api/index.d.ts.map +1 -0
- package/dist/esm/api/logging/BasicLoggerOptions.d.ts +43 -0
- package/dist/esm/api/logging/BasicLoggerOptions.d.ts.map +1 -0
- package/dist/esm/api/logging/LDLogLevel.d.ts +10 -0
- package/dist/esm/api/logging/LDLogLevel.d.ts.map +1 -0
- package/dist/esm/api/logging/LDLogger.d.ts +47 -0
- package/dist/esm/api/logging/LDLogger.d.ts.map +1 -0
- package/dist/esm/api/logging/index.d.ts +4 -0
- package/dist/esm/api/logging/index.d.ts.map +1 -0
- package/dist/esm/api/options/LDClientContext.d.ts +46 -0
- package/dist/esm/api/options/LDClientContext.d.ts.map +1 -0
- package/dist/esm/api/options/index.d.ts +3 -0
- package/dist/esm/api/options/index.d.ts.map +1 -0
- package/dist/esm/api/platform/AutoEnv.d.ts +50 -0
- package/dist/esm/api/platform/AutoEnv.d.ts.map +1 -0
- package/dist/esm/api/platform/Crypto.d.ts +45 -0
- package/dist/esm/api/platform/Crypto.d.ts.map +1 -0
- package/dist/esm/api/platform/Encoding.d.ts +4 -0
- package/dist/esm/api/platform/Encoding.d.ts.map +1 -0
- package/dist/esm/api/platform/EventSource.d.ts +31 -0
- package/dist/esm/api/platform/EventSource.d.ts.map +1 -0
- package/dist/esm/api/platform/Filesystem.d.ts +40 -0
- package/dist/esm/api/platform/Filesystem.d.ts.map +1 -0
- package/dist/esm/api/platform/Info.d.ts +80 -0
- package/dist/esm/api/platform/Info.d.ts.map +1 -0
- package/dist/esm/api/platform/Platform.d.ts +36 -0
- package/dist/esm/api/platform/Platform.d.ts.map +1 -0
- package/dist/esm/api/platform/Requests.d.ts +107 -0
- package/dist/esm/api/platform/Requests.d.ts.map +1 -0
- package/dist/esm/api/platform/Storage.d.ts +28 -0
- package/dist/esm/api/platform/Storage.d.ts.map +1 -0
- package/dist/esm/api/platform/index.d.ts +10 -0
- package/dist/esm/api/platform/index.d.ts.map +1 -0
- package/dist/esm/api/subsystem/LDContextDeduplicator.d.ts +24 -0
- package/dist/esm/api/subsystem/LDContextDeduplicator.d.ts.map +1 -0
- package/dist/esm/api/subsystem/LDEventProcessor.d.ts +7 -0
- package/dist/esm/api/subsystem/LDEventProcessor.d.ts.map +1 -0
- package/dist/esm/api/subsystem/LDEventSender.d.ts +18 -0
- package/dist/esm/api/subsystem/LDEventSender.d.ts.map +1 -0
- package/dist/esm/api/subsystem/LDStreamProcessor.d.ts +13 -0
- package/dist/esm/api/subsystem/LDStreamProcessor.d.ts.map +1 -0
- package/dist/esm/api/subsystem/index.d.ts +6 -0
- package/dist/esm/api/subsystem/index.d.ts.map +1 -0
- package/dist/esm/datasource/DataSourceErrorKinds.d.ts +7 -0
- package/dist/esm/datasource/DataSourceErrorKinds.d.ts.map +1 -0
- package/dist/esm/datasource/errors.d.ts +17 -0
- package/dist/esm/datasource/errors.d.ts.map +1 -0
- package/dist/esm/datasource/index.d.ts +4 -0
- package/dist/esm/datasource/index.d.ts.map +1 -0
- package/dist/esm/errors.d.ts +25 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/{index.mjs → esm/index.mjs} +286 -284
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/internal/context/index.d.ts +24 -0
- package/dist/esm/internal/context/index.d.ts.map +1 -0
- package/dist/esm/internal/diagnostics/DiagnosticsManager.d.ts +35 -0
- package/dist/esm/internal/diagnostics/DiagnosticsManager.d.ts.map +1 -0
- package/dist/esm/internal/diagnostics/index.d.ts +3 -0
- package/dist/esm/internal/diagnostics/index.d.ts.map +1 -0
- package/dist/esm/internal/diagnostics/types.d.ts +65 -0
- package/dist/esm/internal/diagnostics/types.d.ts.map +1 -0
- package/dist/esm/internal/evaluation/ErrorKinds.d.ts +12 -0
- package/dist/esm/internal/evaluation/ErrorKinds.d.ts.map +1 -0
- package/dist/esm/internal/evaluation/EventFactoryBase.d.ts +27 -0
- package/dist/esm/internal/evaluation/EventFactoryBase.d.ts.map +1 -0
- package/dist/esm/internal/evaluation/index.d.ts +4 -0
- package/dist/esm/internal/evaluation/index.d.ts.map +1 -0
- package/dist/esm/internal/events/ClientMessages.d.ts +8 -0
- package/dist/esm/internal/events/ClientMessages.d.ts.map +1 -0
- package/dist/esm/internal/events/EventProcessor.d.ts +44 -0
- package/dist/esm/internal/events/EventProcessor.d.ts.map +1 -0
- package/dist/esm/internal/events/EventSender.d.ts +14 -0
- package/dist/esm/internal/events/EventSender.d.ts.map +1 -0
- package/dist/esm/internal/events/EventSummarizer.d.ts +2 -0
- package/dist/esm/internal/events/EventSummarizer.d.ts.map +1 -0
- package/dist/esm/internal/events/InputClickEvent.d.ts +11 -0
- package/dist/esm/internal/events/InputClickEvent.d.ts.map +1 -0
- package/dist/esm/internal/events/InputCustomEvent.d.ts +13 -0
- package/dist/esm/internal/events/InputCustomEvent.d.ts.map +1 -0
- package/dist/esm/internal/events/InputEvalEvent.d.ts +22 -0
- package/dist/esm/internal/events/InputEvalEvent.d.ts.map +1 -0
- package/dist/esm/internal/events/InputEvent.d.ts +9 -0
- package/dist/esm/internal/events/InputEvent.d.ts.map +1 -0
- package/dist/esm/internal/events/InputEventBase.d.ts +8 -0
- package/dist/esm/internal/events/InputEventBase.d.ts.map +1 -0
- package/dist/esm/internal/events/InputIdentifyEvent.d.ts +9 -0
- package/dist/esm/internal/events/InputIdentifyEvent.d.ts.map +1 -0
- package/dist/esm/internal/events/InputMigrationEvent.d.ts +10 -0
- package/dist/esm/internal/events/InputMigrationEvent.d.ts.map +1 -0
- package/dist/esm/internal/events/InputPageViewEvent.d.ts +10 -0
- package/dist/esm/internal/events/InputPageViewEvent.d.ts.map +1 -0
- package/dist/esm/internal/events/LDInternalOptions.d.ts +25 -0
- package/dist/esm/internal/events/LDInternalOptions.d.ts.map +1 -0
- package/dist/esm/internal/events/LDInvalidSDKKeyError.d.ts +4 -0
- package/dist/esm/internal/events/LDInvalidSDKKeyError.d.ts.map +1 -0
- package/dist/esm/internal/events/NullEventProcessor.d.ts +7 -0
- package/dist/esm/internal/events/NullEventProcessor.d.ts.map +1 -0
- package/dist/esm/internal/events/SummaryCounter.d.ts +2 -0
- package/dist/esm/internal/events/SummaryCounter.d.ts.map +1 -0
- package/dist/esm/internal/events/guards.d.ts +9 -0
- package/dist/esm/internal/events/guards.d.ts.map +1 -0
- package/dist/esm/internal/events/index.d.ts +12 -0
- package/dist/esm/internal/events/index.d.ts.map +1 -0
- package/dist/esm/internal/events/sampling.d.ts +6 -0
- package/dist/esm/internal/events/sampling.d.ts.map +1 -0
- package/dist/esm/internal/index.d.ts +6 -0
- package/dist/esm/internal/index.d.ts.map +1 -0
- package/dist/esm/internal/stream/StreamingProcessor.d.ts +39 -0
- package/dist/esm/internal/stream/StreamingProcessor.d.ts.map +1 -0
- package/dist/esm/internal/stream/index.d.ts +5 -0
- package/dist/esm/internal/stream/index.d.ts.map +1 -0
- package/dist/esm/internal/stream/types.d.ts +3 -0
- package/dist/esm/internal/stream/types.d.ts.map +1 -0
- package/dist/esm/logging/BasicLogger.d.ts +33 -0
- package/dist/esm/logging/BasicLogger.d.ts.map +1 -0
- package/dist/esm/logging/SafeLogger.d.ts +28 -0
- package/dist/esm/logging/SafeLogger.d.ts.map +1 -0
- package/dist/esm/logging/createSafeLogger.d.ts +6 -0
- package/dist/esm/logging/createSafeLogger.d.ts.map +1 -0
- package/dist/esm/logging/format.d.ts +2 -0
- package/dist/esm/logging/format.d.ts.map +1 -0
- package/dist/esm/logging/index.d.ts +5 -0
- package/dist/esm/logging/index.d.ts.map +1 -0
- package/dist/esm/options/ApplicationTags.d.ts +17 -0
- package/dist/esm/options/ApplicationTags.d.ts.map +1 -0
- package/dist/esm/options/ClientContext.d.ts +43 -0
- package/dist/esm/options/ClientContext.d.ts.map +1 -0
- package/dist/esm/options/OptionMessages.d.ts +14 -0
- package/dist/esm/options/OptionMessages.d.ts.map +1 -0
- package/dist/esm/options/ServiceEndpoints.d.ts +58 -0
- package/dist/esm/options/ServiceEndpoints.d.ts.map +1 -0
- package/dist/esm/options/index.d.ts +6 -0
- package/dist/esm/options/index.d.ts.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/utils/VoidFunction.d.ts +2 -0
- package/dist/esm/utils/VoidFunction.d.ts.map +1 -0
- package/dist/esm/utils/cancelableTimedPromise.d.ts +20 -0
- package/dist/esm/utils/cancelableTimedPromise.d.ts.map +1 -0
- package/dist/esm/utils/clone.d.ts +2 -0
- package/dist/esm/utils/clone.d.ts.map +1 -0
- package/dist/esm/utils/date.d.ts +2 -0
- package/dist/esm/utils/date.d.ts.map +1 -0
- package/dist/esm/utils/debounce.d.ts +23 -0
- package/dist/esm/utils/debounce.d.ts.map +1 -0
- package/dist/esm/utils/deepCompact.d.ts +11 -0
- package/dist/esm/utils/deepCompact.d.ts.map +1 -0
- package/dist/esm/utils/fast-deep-equal/index.d.ts +2 -0
- package/dist/esm/utils/fast-deep-equal/index.d.ts.map +1 -0
- package/dist/esm/utils/http.d.ts +23 -0
- package/dist/esm/utils/http.d.ts.map +1 -0
- package/dist/esm/utils/index.d.ts +13 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/isEmptyObject.d.ts +3 -0
- package/dist/esm/utils/isEmptyObject.d.ts.map +1 -0
- package/dist/esm/utils/noop.d.ts +3 -0
- package/dist/esm/utils/noop.d.ts.map +1 -0
- package/dist/esm/utils/sleep.d.ts +3 -0
- package/dist/esm/utils/sleep.d.ts.map +1 -0
- package/dist/esm/utils/timedPromise.d.ts +9 -0
- package/dist/esm/utils/timedPromise.d.ts.map +1 -0
- package/dist/esm/validators.d.ts +98 -0
- package/dist/esm/validators.d.ts.map +1 -0
- package/package.json +15 -7
- package/dist/Context.d.ts.map +0 -1
- package/dist/ContextFilter.d.ts +0 -11
- package/dist/ContextFilter.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/internal/events/EventProcessor.d.ts +0 -44
- package/dist/internal/events/EventProcessor.d.ts.map +0 -1
- package/dist/internal/stream/StreamingProcessor.d.ts.map +0 -1
- package/dist/logging/BasicLogger.d.ts.map +0 -1
- /package/dist/{api → cjs/api}/context/LDContext.d.ts +0 -0
- /package/dist/{api → cjs/api}/context/LDContext.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/context/LDContextCommon.d.ts +0 -0
- /package/dist/{api → cjs/api}/context/LDContextCommon.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/context/LDContextMeta.d.ts +0 -0
- /package/dist/{api → cjs/api}/context/LDContextMeta.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/context/LDMultiKindContext.d.ts +0 -0
- /package/dist/{api → cjs/api}/context/LDMultiKindContext.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/context/LDSingleKindContext.d.ts +0 -0
- /package/dist/{api → cjs/api}/context/LDSingleKindContext.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/context/LDUser.d.ts +0 -0
- /package/dist/{api → cjs/api}/context/LDUser.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/context/index.d.ts +0 -0
- /package/dist/{api → cjs/api}/context/index.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/data/LDEvaluationDetail.d.ts +0 -0
- /package/dist/{api → cjs/api}/data/LDEvaluationDetail.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/data/LDEvaluationReason.d.ts +0 -0
- /package/dist/{api → cjs/api}/data/LDEvaluationReason.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/data/LDFlagSet.d.ts +0 -0
- /package/dist/{api → cjs/api}/data/LDFlagSet.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/data/LDFlagValue.d.ts +0 -0
- /package/dist/{api → cjs/api}/data/LDFlagValue.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/data/index.d.ts +0 -0
- /package/dist/{api → cjs/api}/data/index.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/index.d.ts +0 -0
- /package/dist/{api → cjs/api}/index.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/logging/BasicLoggerOptions.d.ts +0 -0
- /package/dist/{api → cjs/api}/logging/BasicLoggerOptions.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/logging/LDLogLevel.d.ts +0 -0
- /package/dist/{api → cjs/api}/logging/LDLogLevel.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/logging/LDLogger.d.ts +0 -0
- /package/dist/{api → cjs/api}/logging/LDLogger.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/logging/index.d.ts +0 -0
- /package/dist/{api → cjs/api}/logging/index.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/options/LDClientContext.d.ts +0 -0
- /package/dist/{api → cjs/api}/options/LDClientContext.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/options/index.d.ts +0 -0
- /package/dist/{api → cjs/api}/options/index.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/AutoEnv.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/AutoEnv.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/Crypto.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/Crypto.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/Encoding.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/Encoding.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/EventSource.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/EventSource.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/Filesystem.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/Filesystem.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/Info.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/Info.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/Platform.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/Platform.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/Requests.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/Requests.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/Storage.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/Storage.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/platform/index.d.ts +0 -0
- /package/dist/{api → cjs/api}/platform/index.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDContextDeduplicator.d.ts +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDContextDeduplicator.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDEventProcessor.d.ts +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDEventProcessor.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDEventSender.d.ts +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDEventSender.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDStreamProcessor.d.ts +0 -0
- /package/dist/{api → cjs/api}/subsystem/LDStreamProcessor.d.ts.map +0 -0
- /package/dist/{api → cjs/api}/subsystem/index.d.ts +0 -0
- /package/dist/{api → cjs/api}/subsystem/index.d.ts.map +0 -0
- /package/dist/{datasource → cjs/datasource}/DataSourceErrorKinds.d.ts +0 -0
- /package/dist/{datasource → cjs/datasource}/DataSourceErrorKinds.d.ts.map +0 -0
- /package/dist/{datasource → cjs/datasource}/errors.d.ts +0 -0
- /package/dist/{datasource → cjs/datasource}/errors.d.ts.map +0 -0
- /package/dist/{datasource → cjs/datasource}/index.d.ts +0 -0
- /package/dist/{datasource → cjs/datasource}/index.d.ts.map +0 -0
- /package/dist/{errors.d.ts → cjs/errors.d.ts} +0 -0
- /package/dist/{errors.d.ts.map → cjs/errors.d.ts.map} +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{index.d.ts.map → cjs/index.d.ts.map} +0 -0
- /package/dist/{internal → cjs/internal}/context/index.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/context/index.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/diagnostics/index.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/diagnostics/index.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/diagnostics/types.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/diagnostics/types.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/evaluation/ErrorKinds.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/evaluation/ErrorKinds.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/evaluation/index.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/evaluation/index.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/ClientMessages.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/EventSummarizer.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/EventSummarizer.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputClickEvent.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputClickEvent.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputCustomEvent.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputCustomEvent.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputEvalEvent.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputEvalEvent.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputEvent.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputEvent.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputEventBase.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputEventBase.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputIdentifyEvent.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputIdentifyEvent.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputMigrationEvent.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputMigrationEvent.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/InputPageViewEvent.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/InputPageViewEvent.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/LDInternalOptions.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/LDInternalOptions.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/LDInvalidSDKKeyError.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/LDInvalidSDKKeyError.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/NullEventProcessor.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/NullEventProcessor.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/SummaryCounter.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/SummaryCounter.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/guards.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/guards.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/index.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/index.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/events/sampling.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/events/sampling.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/index.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/index.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/stream/index.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/stream/index.d.ts.map +0 -0
- /package/dist/{internal → cjs/internal}/stream/types.d.ts +0 -0
- /package/dist/{internal → cjs/internal}/stream/types.d.ts.map +0 -0
- /package/dist/{logging → cjs/logging}/createSafeLogger.d.ts +0 -0
- /package/dist/{logging → cjs/logging}/createSafeLogger.d.ts.map +0 -0
- /package/dist/{logging → cjs/logging}/format.d.ts +0 -0
- /package/dist/{logging → cjs/logging}/format.d.ts.map +0 -0
- /package/dist/{logging → cjs/logging}/index.d.ts +0 -0
- /package/dist/{logging → cjs/logging}/index.d.ts.map +0 -0
- /package/dist/{options → cjs/options}/ApplicationTags.d.ts +0 -0
- /package/dist/{options → cjs/options}/ApplicationTags.d.ts.map +0 -0
- /package/dist/{options → cjs/options}/ClientContext.d.ts +0 -0
- /package/dist/{options → cjs/options}/ClientContext.d.ts.map +0 -0
- /package/dist/{options → cjs/options}/OptionMessages.d.ts +0 -0
- /package/dist/{options → cjs/options}/OptionMessages.d.ts.map +0 -0
- /package/dist/{options → cjs/options}/ServiceEndpoints.d.ts +0 -0
- /package/dist/{options → cjs/options}/index.d.ts +0 -0
- /package/dist/{options → cjs/options}/index.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/VoidFunction.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/VoidFunction.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/cancelableTimedPromise.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/cancelableTimedPromise.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/clone.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/clone.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/date.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/date.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/debounce.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/debounce.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/deepCompact.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/deepCompact.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/fast-deep-equal/index.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/fast-deep-equal/index.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/http.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/http.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/index.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/index.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/isEmptyObject.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/isEmptyObject.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/noop.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/noop.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/sleep.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/sleep.d.ts.map +0 -0
- /package/dist/{utils → cjs/utils}/timedPromise.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/timedPromise.d.ts.map +0 -0
|
@@ -46,23 +46,23 @@ class AttributeReference {
|
|
|
46
46
|
this.redactionName = refOrLiteral;
|
|
47
47
|
if (refOrLiteral === '' || refOrLiteral === '/' || !validate(refOrLiteral)) {
|
|
48
48
|
this.isValid = false;
|
|
49
|
-
this.
|
|
49
|
+
this._components = [];
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
if (isLiteral(refOrLiteral)) {
|
|
53
|
-
this.
|
|
53
|
+
this._components = [refOrLiteral];
|
|
54
54
|
}
|
|
55
55
|
else if (refOrLiteral.indexOf('/', 1) < 0) {
|
|
56
|
-
this.
|
|
56
|
+
this._components = [unescape(refOrLiteral.slice(1))];
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
this.
|
|
59
|
+
this._components = getComponents(refOrLiteral);
|
|
60
60
|
}
|
|
61
61
|
// The items inside of '_meta' are not intended to be addressable.
|
|
62
62
|
// Excluding it as a valid reference means that we can make it non-addressable
|
|
63
63
|
// without having to copy all the attributes out of the context object
|
|
64
64
|
// provided by the user.
|
|
65
|
-
if (this.
|
|
65
|
+
if (this._components[0] === '_meta') {
|
|
66
66
|
this.isValid = false;
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
@@ -71,14 +71,14 @@ class AttributeReference {
|
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
73
|
const literalVal = refOrLiteral;
|
|
74
|
-
this.
|
|
74
|
+
this._components = [literalVal];
|
|
75
75
|
this.isValid = literalVal !== '';
|
|
76
76
|
// Literals which start with '/' need escaped to prevent ambiguity.
|
|
77
77
|
this.redactionName = literalVal.startsWith('/') ? toRefString(literalVal) : literalVal;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
get(target) {
|
|
81
|
-
const { components, isValid } = this;
|
|
81
|
+
const { _components: components, isValid } = this;
|
|
82
82
|
if (!isValid) {
|
|
83
83
|
return undefined;
|
|
84
84
|
}
|
|
@@ -105,23 +105,23 @@ class AttributeReference {
|
|
|
105
105
|
return current;
|
|
106
106
|
}
|
|
107
107
|
getComponent(depth) {
|
|
108
|
-
return this.
|
|
108
|
+
return this._components[depth];
|
|
109
109
|
}
|
|
110
110
|
get depth() {
|
|
111
|
-
return this.
|
|
111
|
+
return this._components.length;
|
|
112
112
|
}
|
|
113
113
|
get isKind() {
|
|
114
|
-
return this.
|
|
114
|
+
return this._components.length === 1 && this._components[0] === 'kind';
|
|
115
115
|
}
|
|
116
116
|
compare(other) {
|
|
117
117
|
return (this.depth === other.depth &&
|
|
118
|
-
this.
|
|
118
|
+
this._components.every((value, index) => value === other.getComponent(index)));
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* For use as invalid references when deserializing Flag/Segment data.
|
|
123
123
|
*/
|
|
124
|
-
AttributeReference.
|
|
124
|
+
AttributeReference.InvalidReference = new AttributeReference('');
|
|
125
125
|
|
|
126
126
|
/* eslint-disable class-methods-use-this */
|
|
127
127
|
/* eslint-disable max-classes-per-file */
|
|
@@ -146,7 +146,7 @@ class FactoryOrInstance {
|
|
|
146
146
|
*/
|
|
147
147
|
class Type {
|
|
148
148
|
constructor(typeName, example) {
|
|
149
|
-
this.
|
|
149
|
+
this._typeName = typeName;
|
|
150
150
|
this.typeOf = typeof example;
|
|
151
151
|
}
|
|
152
152
|
is(u) {
|
|
@@ -156,7 +156,7 @@ class Type {
|
|
|
156
156
|
return typeof u === this.typeOf;
|
|
157
157
|
}
|
|
158
158
|
getType() {
|
|
159
|
-
return this.
|
|
159
|
+
return this._typeName;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
@@ -167,7 +167,7 @@ class Type {
|
|
|
167
167
|
*/
|
|
168
168
|
class TypeArray {
|
|
169
169
|
constructor(typeName, example) {
|
|
170
|
-
this.
|
|
170
|
+
this._typeName = typeName;
|
|
171
171
|
this.typeOf = typeof example;
|
|
172
172
|
}
|
|
173
173
|
is(u) {
|
|
@@ -180,7 +180,7 @@ class TypeArray {
|
|
|
180
180
|
return false;
|
|
181
181
|
}
|
|
182
182
|
getType() {
|
|
183
|
-
return this.
|
|
183
|
+
return this._typeName;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
@@ -450,18 +450,18 @@ class Context {
|
|
|
450
450
|
* implementation details, so they cannot be free functions.
|
|
451
451
|
*/
|
|
452
452
|
constructor(valid, kind, message) {
|
|
453
|
-
this.
|
|
454
|
-
this.
|
|
455
|
-
this.
|
|
456
|
-
this.
|
|
453
|
+
this._isMulti = false;
|
|
454
|
+
this._isUser = false;
|
|
455
|
+
this._wasLegacy = false;
|
|
456
|
+
this._contexts = {};
|
|
457
457
|
this.kind = kind;
|
|
458
458
|
this.valid = valid;
|
|
459
459
|
this.message = message;
|
|
460
460
|
}
|
|
461
|
-
static
|
|
461
|
+
static _contextForError(kind, message) {
|
|
462
462
|
return new Context(false, kind, message);
|
|
463
463
|
}
|
|
464
|
-
static
|
|
464
|
+
static _getValueFromContext(reference, context) {
|
|
465
465
|
if (!context || !reference.isValid) {
|
|
466
466
|
return undefined;
|
|
467
467
|
}
|
|
@@ -470,23 +470,23 @@ class Context {
|
|
|
470
470
|
}
|
|
471
471
|
return reference.get(context);
|
|
472
472
|
}
|
|
473
|
-
|
|
474
|
-
if (this.
|
|
475
|
-
return this.
|
|
473
|
+
_contextForKind(kind) {
|
|
474
|
+
if (this._isMulti) {
|
|
475
|
+
return this._contexts[kind];
|
|
476
476
|
}
|
|
477
477
|
if (this.kind === kind) {
|
|
478
|
-
return this.
|
|
478
|
+
return this._context;
|
|
479
479
|
}
|
|
480
480
|
return undefined;
|
|
481
481
|
}
|
|
482
|
-
static
|
|
482
|
+
static _fromMultiKindContext(context) {
|
|
483
483
|
const kinds = Object.keys(context).filter((key) => key !== 'kind');
|
|
484
484
|
const kindsValid = kinds.every(validKind);
|
|
485
485
|
if (!kinds.length) {
|
|
486
|
-
return Context.
|
|
486
|
+
return Context._contextForError('multi', 'A multi-kind context must contain at least one kind');
|
|
487
487
|
}
|
|
488
488
|
if (!kindsValid) {
|
|
489
|
-
return Context.
|
|
489
|
+
return Context._contextForError('multi', 'Context contains invalid kinds');
|
|
490
490
|
}
|
|
491
491
|
const privateAttributes = {};
|
|
492
492
|
let contextsAreObjects = true;
|
|
@@ -503,59 +503,59 @@ class Context {
|
|
|
503
503
|
return acc;
|
|
504
504
|
}, {});
|
|
505
505
|
if (!contextsAreObjects) {
|
|
506
|
-
return Context.
|
|
506
|
+
return Context._contextForError('multi', 'Context contained contexts that were not objects');
|
|
507
507
|
}
|
|
508
508
|
if (!Object.values(contexts).every((part) => validKey(part.key))) {
|
|
509
|
-
return Context.
|
|
509
|
+
return Context._contextForError('multi', 'Context contained invalid keys');
|
|
510
510
|
}
|
|
511
511
|
// There was only a single kind in the multi-kind context.
|
|
512
512
|
// So we can just translate this to a single-kind context.
|
|
513
513
|
if (kinds.length === 1) {
|
|
514
514
|
const kind = kinds[0];
|
|
515
515
|
const created = new Context(true, kind);
|
|
516
|
-
created.
|
|
517
|
-
created.
|
|
518
|
-
created.
|
|
516
|
+
created._context = { ...contexts[kind], kind };
|
|
517
|
+
created._privateAttributeReferences = privateAttributes;
|
|
518
|
+
created._isUser = kind === 'user';
|
|
519
519
|
return created;
|
|
520
520
|
}
|
|
521
521
|
const created = new Context(true, context.kind);
|
|
522
|
-
created.
|
|
523
|
-
created.
|
|
524
|
-
created.
|
|
522
|
+
created._contexts = contexts;
|
|
523
|
+
created._privateAttributeReferences = privateAttributes;
|
|
524
|
+
created._isMulti = true;
|
|
525
525
|
return created;
|
|
526
526
|
}
|
|
527
|
-
static
|
|
527
|
+
static _fromSingleKindContext(context) {
|
|
528
528
|
const { key, kind } = context;
|
|
529
529
|
const kindValid = validKind(kind);
|
|
530
530
|
const keyValid = validKey(key);
|
|
531
531
|
if (!kindValid) {
|
|
532
|
-
return Context.
|
|
532
|
+
return Context._contextForError(kind ?? 'unknown', 'The kind was not valid for the context');
|
|
533
533
|
}
|
|
534
534
|
if (!keyValid) {
|
|
535
|
-
return Context.
|
|
535
|
+
return Context._contextForError(kind, 'The key for the context was not valid');
|
|
536
536
|
}
|
|
537
537
|
// The JSON interfaces uses dangling _.
|
|
538
538
|
// eslint-disable-next-line no-underscore-dangle
|
|
539
539
|
const privateAttributeReferences = processPrivateAttributes(context._meta?.privateAttributes);
|
|
540
540
|
const created = new Context(true, kind);
|
|
541
|
-
created.
|
|
542
|
-
created.
|
|
543
|
-
created.
|
|
541
|
+
created._isUser = kind === 'user';
|
|
542
|
+
created._context = context;
|
|
543
|
+
created._privateAttributeReferences = {
|
|
544
544
|
[kind]: privateAttributeReferences,
|
|
545
545
|
};
|
|
546
546
|
return created;
|
|
547
547
|
}
|
|
548
|
-
static
|
|
548
|
+
static _fromLegacyUser(context) {
|
|
549
549
|
const keyValid = context.key !== undefined && context.key !== null;
|
|
550
550
|
// For legacy users we allow empty keys.
|
|
551
551
|
if (!keyValid) {
|
|
552
|
-
return Context.
|
|
552
|
+
return Context._contextForError('user', 'The key for the context was not valid');
|
|
553
553
|
}
|
|
554
554
|
const created = new Context(true, 'user');
|
|
555
|
-
created.
|
|
556
|
-
created.
|
|
557
|
-
created.
|
|
558
|
-
created.
|
|
555
|
+
created._isUser = true;
|
|
556
|
+
created._wasLegacy = true;
|
|
557
|
+
created._context = legacyToSingleKind(context);
|
|
558
|
+
created._privateAttributeReferences = {
|
|
559
559
|
user: processPrivateAttributes(context.privateAttributeNames, true),
|
|
560
560
|
};
|
|
561
561
|
return created;
|
|
@@ -568,18 +568,18 @@ class Context {
|
|
|
568
568
|
*/
|
|
569
569
|
static fromLDContext(context) {
|
|
570
570
|
if (!context) {
|
|
571
|
-
return Context.
|
|
571
|
+
return Context._contextForError('unknown', 'No context specified. Returning default value');
|
|
572
572
|
}
|
|
573
573
|
if (isSingleKind(context)) {
|
|
574
|
-
return Context.
|
|
574
|
+
return Context._fromSingleKindContext(context);
|
|
575
575
|
}
|
|
576
576
|
if (isMultiKind(context)) {
|
|
577
|
-
return Context.
|
|
577
|
+
return Context._fromMultiKindContext(context);
|
|
578
578
|
}
|
|
579
579
|
if (isLegacyUser(context)) {
|
|
580
|
-
return Context.
|
|
580
|
+
return Context._fromLegacyUser(context);
|
|
581
581
|
}
|
|
582
|
-
return Context.
|
|
582
|
+
return Context._contextForError('unknown', 'Context was not of a valid kind');
|
|
583
583
|
}
|
|
584
584
|
/**
|
|
585
585
|
* Creates a {@link LDContext} from a {@link Context}.
|
|
@@ -591,7 +591,7 @@ class Context {
|
|
|
591
591
|
return undefined;
|
|
592
592
|
}
|
|
593
593
|
const contexts = context.getContexts();
|
|
594
|
-
if (!context.
|
|
594
|
+
if (!context._isMulti) {
|
|
595
595
|
return contexts[0][1];
|
|
596
596
|
}
|
|
597
597
|
const result = {
|
|
@@ -614,7 +614,7 @@ class Context {
|
|
|
614
614
|
if (reference.isKind) {
|
|
615
615
|
return this.kinds;
|
|
616
616
|
}
|
|
617
|
-
return Context.
|
|
617
|
+
return Context._getValueFromContext(reference, this._contextForKind(kind));
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
620
620
|
* Attempt to get a key for the specified kind.
|
|
@@ -622,35 +622,35 @@ class Context {
|
|
|
622
622
|
* @returns The key for the specified kind, or undefined.
|
|
623
623
|
*/
|
|
624
624
|
key(kind = DEFAULT_KIND) {
|
|
625
|
-
return this.
|
|
625
|
+
return this._contextForKind(kind)?.key;
|
|
626
626
|
}
|
|
627
627
|
/**
|
|
628
628
|
* True if this is a multi-kind context.
|
|
629
629
|
*/
|
|
630
630
|
get isMultiKind() {
|
|
631
|
-
return this.
|
|
631
|
+
return this._isMulti;
|
|
632
632
|
}
|
|
633
633
|
/**
|
|
634
634
|
* Get the canonical key for this context.
|
|
635
635
|
*/
|
|
636
636
|
get canonicalKey() {
|
|
637
|
-
if (this.
|
|
638
|
-
return this.
|
|
637
|
+
if (this._isUser) {
|
|
638
|
+
return this._context.key;
|
|
639
639
|
}
|
|
640
|
-
if (this.
|
|
641
|
-
return Object.keys(this.
|
|
640
|
+
if (this._isMulti) {
|
|
641
|
+
return Object.keys(this._contexts)
|
|
642
642
|
.sort()
|
|
643
|
-
.map((key) => `${key}:${encodeKey(this.
|
|
643
|
+
.map((key) => `${key}:${encodeKey(this._contexts[key].key)}`)
|
|
644
644
|
.join(':');
|
|
645
645
|
}
|
|
646
|
-
return `${this.kind}:${encodeKey(this.
|
|
646
|
+
return `${this.kind}:${encodeKey(this._context.key)}`;
|
|
647
647
|
}
|
|
648
648
|
/**
|
|
649
649
|
* Get the kinds of this context.
|
|
650
650
|
*/
|
|
651
651
|
get kinds() {
|
|
652
|
-
if (this.
|
|
653
|
-
return Object.keys(this.
|
|
652
|
+
if (this._isMulti) {
|
|
653
|
+
return Object.keys(this._contexts);
|
|
654
654
|
}
|
|
655
655
|
return [this.kind];
|
|
656
656
|
}
|
|
@@ -658,13 +658,13 @@ class Context {
|
|
|
658
658
|
* Get the kinds, and their keys, for this context.
|
|
659
659
|
*/
|
|
660
660
|
get kindsAndKeys() {
|
|
661
|
-
if (this.
|
|
662
|
-
return Object.entries(this.
|
|
661
|
+
if (this._isMulti) {
|
|
662
|
+
return Object.entries(this._contexts).reduce((acc, [kind, context]) => {
|
|
663
663
|
acc[kind] = context.key;
|
|
664
664
|
return acc;
|
|
665
665
|
}, {});
|
|
666
666
|
}
|
|
667
|
-
return { [this.kind]: this.
|
|
667
|
+
return { [this.kind]: this._context.key };
|
|
668
668
|
}
|
|
669
669
|
/**
|
|
670
670
|
* Get the attribute references.
|
|
@@ -672,7 +672,7 @@ class Context {
|
|
|
672
672
|
* @param kind
|
|
673
673
|
*/
|
|
674
674
|
privateAttributes(kind) {
|
|
675
|
-
return this.
|
|
675
|
+
return this._privateAttributeReferences?.[kind] || [];
|
|
676
676
|
}
|
|
677
677
|
/**
|
|
678
678
|
* Get the underlying context objects from this context.
|
|
@@ -682,16 +682,16 @@ class Context {
|
|
|
682
682
|
* The returned objects should not be modified.
|
|
683
683
|
*/
|
|
684
684
|
getContexts() {
|
|
685
|
-
if (this.
|
|
686
|
-
return Object.entries(this.
|
|
685
|
+
if (this._isMulti) {
|
|
686
|
+
return Object.entries(this._contexts);
|
|
687
687
|
}
|
|
688
|
-
return [[this.kind, this.
|
|
688
|
+
return [[this.kind, this._context]];
|
|
689
689
|
}
|
|
690
690
|
get legacy() {
|
|
691
|
-
return this.
|
|
691
|
+
return this._wasLegacy;
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
-
Context.
|
|
694
|
+
Context.UserKind = DEFAULT_KIND;
|
|
695
695
|
|
|
696
696
|
// _meta is part of the specification.
|
|
697
697
|
// These attributes cannot be removed via a private attribute.
|
|
@@ -765,31 +765,31 @@ function cloneWithRedactions(target, references) {
|
|
|
765
765
|
return { cloned, excluded: excluded.sort() };
|
|
766
766
|
}
|
|
767
767
|
class ContextFilter {
|
|
768
|
-
constructor(
|
|
769
|
-
this.
|
|
770
|
-
this.
|
|
768
|
+
constructor(_allAttributesPrivate, _privateAttributes) {
|
|
769
|
+
this._allAttributesPrivate = _allAttributesPrivate;
|
|
770
|
+
this._privateAttributes = _privateAttributes;
|
|
771
771
|
}
|
|
772
772
|
filter(context, redactAnonymousAttributes = false) {
|
|
773
773
|
const contexts = context.getContexts();
|
|
774
774
|
if (contexts.length === 1) {
|
|
775
|
-
return this.
|
|
775
|
+
return this._filterSingleKind(context, contexts[0][1], contexts[0][0], redactAnonymousAttributes);
|
|
776
776
|
}
|
|
777
777
|
const filteredMulti = {
|
|
778
778
|
kind: 'multi',
|
|
779
779
|
};
|
|
780
780
|
contexts.forEach(([kind, single]) => {
|
|
781
|
-
filteredMulti[kind] = this.
|
|
781
|
+
filteredMulti[kind] = this._filterSingleKind(context, single, kind, redactAnonymousAttributes);
|
|
782
782
|
});
|
|
783
783
|
return filteredMulti;
|
|
784
784
|
}
|
|
785
|
-
|
|
785
|
+
_getAttributesToFilter(context, single, kind, redactAllAttributes) {
|
|
786
786
|
return (redactAllAttributes
|
|
787
787
|
? Object.keys(single).map((k) => new AttributeReference(k, true))
|
|
788
|
-
: [...this.
|
|
788
|
+
: [...this._privateAttributes, ...context.privateAttributes(kind)]).filter((attr) => !protectedAttributes.some((protectedAttr) => protectedAttr.compare(attr)));
|
|
789
789
|
}
|
|
790
|
-
|
|
791
|
-
const redactAllAttributes = this.
|
|
792
|
-
const { cloned, excluded } = cloneWithRedactions(single, this.
|
|
790
|
+
_filterSingleKind(context, single, kind, redactAnonymousAttributes) {
|
|
791
|
+
const redactAllAttributes = this._allAttributesPrivate || (redactAnonymousAttributes && single.anonymous === true);
|
|
792
|
+
const { cloned, excluded } = cloneWithRedactions(single, this._getAttributesToFilter(context, single, kind, redactAllAttributes));
|
|
793
793
|
if (context.legacy) {
|
|
794
794
|
legacyTopLevelCopyAttributes.forEach((name) => {
|
|
795
795
|
if (name in cloned) {
|
|
@@ -981,6 +981,7 @@ const escapes = {
|
|
|
981
981
|
f: (val) => toFloat(val),
|
|
982
982
|
j: (val) => tryStringify(val),
|
|
983
983
|
o: (val) => tryStringify(val),
|
|
984
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
984
985
|
O: (val) => tryStringify(val),
|
|
985
986
|
c: () => '',
|
|
986
987
|
};
|
|
@@ -1067,17 +1068,17 @@ class BasicLogger {
|
|
|
1067
1068
|
return new BasicLogger({});
|
|
1068
1069
|
}
|
|
1069
1070
|
constructor(options) {
|
|
1070
|
-
this.
|
|
1071
|
-
this.
|
|
1071
|
+
this._logLevel = LogPriority[options.level ?? 'info'] ?? LogPriority.info;
|
|
1072
|
+
this._name = options.name ?? 'LaunchDarkly';
|
|
1072
1073
|
// eslint-disable-next-line no-console
|
|
1073
|
-
this.
|
|
1074
|
-
this.
|
|
1074
|
+
this._destination = options.destination;
|
|
1075
|
+
this._formatter = options.formatter;
|
|
1075
1076
|
}
|
|
1076
|
-
|
|
1077
|
+
_tryFormat(...args) {
|
|
1077
1078
|
try {
|
|
1078
|
-
if (this.
|
|
1079
|
+
if (this._formatter) {
|
|
1079
1080
|
// In case the provided formatter fails.
|
|
1080
|
-
return this.
|
|
1081
|
+
return this._formatter?.(...args);
|
|
1081
1082
|
}
|
|
1082
1083
|
return format(...args);
|
|
1083
1084
|
}
|
|
@@ -1085,21 +1086,21 @@ class BasicLogger {
|
|
|
1085
1086
|
return format(...args);
|
|
1086
1087
|
}
|
|
1087
1088
|
}
|
|
1088
|
-
|
|
1089
|
+
_tryWrite(msg) {
|
|
1089
1090
|
try {
|
|
1090
|
-
this.
|
|
1091
|
+
this._destination(msg);
|
|
1091
1092
|
}
|
|
1092
1093
|
catch {
|
|
1093
1094
|
// eslint-disable-next-line no-console
|
|
1094
1095
|
console.error(msg);
|
|
1095
1096
|
}
|
|
1096
1097
|
}
|
|
1097
|
-
|
|
1098
|
-
if (level >= this.
|
|
1099
|
-
const prefix = `${LevelNames[level]}: [${this.
|
|
1098
|
+
_log(level, args) {
|
|
1099
|
+
if (level >= this._logLevel) {
|
|
1100
|
+
const prefix = `${LevelNames[level]}: [${this._name}]`;
|
|
1100
1101
|
try {
|
|
1101
|
-
if (this.
|
|
1102
|
-
this.
|
|
1102
|
+
if (this._destination) {
|
|
1103
|
+
this._tryWrite(`${prefix} ${this._tryFormat(...args)}`);
|
|
1103
1104
|
}
|
|
1104
1105
|
else {
|
|
1105
1106
|
// `console.error` has its own formatter.
|
|
@@ -1116,16 +1117,16 @@ class BasicLogger {
|
|
|
1116
1117
|
}
|
|
1117
1118
|
}
|
|
1118
1119
|
error(...args) {
|
|
1119
|
-
this.
|
|
1120
|
+
this._log(LogPriority.error, args);
|
|
1120
1121
|
}
|
|
1121
1122
|
warn(...args) {
|
|
1122
|
-
this.
|
|
1123
|
+
this._log(LogPriority.warn, args);
|
|
1123
1124
|
}
|
|
1124
1125
|
info(...args) {
|
|
1125
|
-
this.
|
|
1126
|
+
this._log(LogPriority.info, args);
|
|
1126
1127
|
}
|
|
1127
1128
|
debug(...args) {
|
|
1128
|
-
this.
|
|
1129
|
+
this._log(LogPriority.debug, args);
|
|
1129
1130
|
}
|
|
1130
1131
|
}
|
|
1131
1132
|
|
|
@@ -1162,29 +1163,29 @@ class SafeLogger {
|
|
|
1162
1163
|
// criteria since the SDK calls the logger during nearly all of its operations.
|
|
1163
1164
|
}
|
|
1164
1165
|
});
|
|
1165
|
-
this.
|
|
1166
|
-
this.
|
|
1166
|
+
this._logger = logger;
|
|
1167
|
+
this._fallback = fallback;
|
|
1167
1168
|
}
|
|
1168
|
-
|
|
1169
|
+
_log(level, args) {
|
|
1169
1170
|
try {
|
|
1170
|
-
this.
|
|
1171
|
+
this._logger[level](...args);
|
|
1171
1172
|
}
|
|
1172
1173
|
catch {
|
|
1173
1174
|
// If all else fails do not break.
|
|
1174
|
-
this.
|
|
1175
|
+
this._fallback[level](...args);
|
|
1175
1176
|
}
|
|
1176
1177
|
}
|
|
1177
1178
|
error(...args) {
|
|
1178
|
-
this.
|
|
1179
|
+
this._log('error', args);
|
|
1179
1180
|
}
|
|
1180
1181
|
warn(...args) {
|
|
1181
|
-
this.
|
|
1182
|
+
this._log('warn', args);
|
|
1182
1183
|
}
|
|
1183
1184
|
info(...args) {
|
|
1184
|
-
this.
|
|
1185
|
+
this._log('info', args);
|
|
1185
1186
|
}
|
|
1186
1187
|
debug(...args) {
|
|
1187
|
-
this.
|
|
1188
|
+
this._log('debug', args);
|
|
1188
1189
|
}
|
|
1189
1190
|
}
|
|
1190
1191
|
|
|
@@ -1315,6 +1316,7 @@ class ServiceEndpoints {
|
|
|
1315
1316
|
this.payloadFilterKey = payloadFilterKey;
|
|
1316
1317
|
}
|
|
1317
1318
|
}
|
|
1319
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1318
1320
|
ServiceEndpoints.DEFAULT_EVENTS = 'https://events.launchdarkly.com';
|
|
1319
1321
|
function getWithParams(uri, parameters) {
|
|
1320
1322
|
if (parameters.length === 0) {
|
|
@@ -1653,14 +1655,14 @@ const timedPromise = (t, taskName) => new Promise((_res, reject) => {
|
|
|
1653
1655
|
});
|
|
1654
1656
|
|
|
1655
1657
|
class DiagnosticsManager {
|
|
1656
|
-
constructor(sdkKey,
|
|
1657
|
-
this.
|
|
1658
|
-
this.
|
|
1659
|
-
this.
|
|
1660
|
-
this.
|
|
1661
|
-
this.
|
|
1662
|
-
this.
|
|
1663
|
-
diagnosticId:
|
|
1658
|
+
constructor(sdkKey, _platform, _diagnosticInitConfig) {
|
|
1659
|
+
this._platform = _platform;
|
|
1660
|
+
this._diagnosticInitConfig = _diagnosticInitConfig;
|
|
1661
|
+
this._streamInits = [];
|
|
1662
|
+
this._startTime = Date.now();
|
|
1663
|
+
this._dataSinceDate = this._startTime;
|
|
1664
|
+
this._id = {
|
|
1665
|
+
diagnosticId: _platform.crypto.randomUUID(),
|
|
1664
1666
|
sdkKeySuffix: sdkKey.length > 6 ? sdkKey.substring(sdkKey.length - 6) : sdkKey,
|
|
1665
1667
|
};
|
|
1666
1668
|
}
|
|
@@ -1669,14 +1671,14 @@ class DiagnosticsManager {
|
|
|
1669
1671
|
* not be repeated during the lifetime of the SDK client.
|
|
1670
1672
|
*/
|
|
1671
1673
|
createInitEvent() {
|
|
1672
|
-
const sdkData = this.
|
|
1673
|
-
const platformData = this.
|
|
1674
|
+
const sdkData = this._platform.info.sdkData();
|
|
1675
|
+
const platformData = this._platform.info.platformData();
|
|
1674
1676
|
return {
|
|
1675
1677
|
kind: 'diagnostic-init',
|
|
1676
|
-
id: this.
|
|
1677
|
-
creationDate: this.
|
|
1678
|
+
id: this._id,
|
|
1679
|
+
creationDate: this._startTime,
|
|
1678
1680
|
sdk: sdkData,
|
|
1679
|
-
configuration: this.
|
|
1681
|
+
configuration: this._diagnosticInitConfig,
|
|
1680
1682
|
platform: {
|
|
1681
1683
|
name: platformData.name,
|
|
1682
1684
|
osArch: platformData.os?.arch,
|
|
@@ -1696,7 +1698,7 @@ class DiagnosticsManager {
|
|
|
1696
1698
|
*/
|
|
1697
1699
|
recordStreamInit(timestamp, failed, durationMillis) {
|
|
1698
1700
|
const item = { timestamp, failed, durationMillis };
|
|
1699
|
-
this.
|
|
1701
|
+
this._streamInits.push(item);
|
|
1700
1702
|
}
|
|
1701
1703
|
/**
|
|
1702
1704
|
* Creates a periodic event containing time-dependent stats, and resets the state of the manager
|
|
@@ -1710,16 +1712,16 @@ class DiagnosticsManager {
|
|
|
1710
1712
|
const currentTime = Date.now();
|
|
1711
1713
|
const evt = {
|
|
1712
1714
|
kind: 'diagnostic',
|
|
1713
|
-
id: this.
|
|
1715
|
+
id: this._id,
|
|
1714
1716
|
creationDate: currentTime,
|
|
1715
|
-
dataSinceDate: this.
|
|
1717
|
+
dataSinceDate: this._dataSinceDate,
|
|
1716
1718
|
droppedEvents,
|
|
1717
1719
|
deduplicatedUsers,
|
|
1718
1720
|
eventsInLastBatch,
|
|
1719
|
-
streamInits: this.
|
|
1721
|
+
streamInits: this._streamInits,
|
|
1720
1722
|
};
|
|
1721
|
-
this.
|
|
1722
|
-
this.
|
|
1723
|
+
this._streamInits = [];
|
|
1724
|
+
this._dataSinceDate = currentTime;
|
|
1723
1725
|
return evt;
|
|
1724
1726
|
}
|
|
1725
1727
|
}
|
|
@@ -1746,25 +1748,25 @@ class ClientMessages {
|
|
|
1746
1748
|
` (${badType}), only numeric metric values are supported.`);
|
|
1747
1749
|
}
|
|
1748
1750
|
}
|
|
1749
|
-
ClientMessages.
|
|
1751
|
+
ClientMessages.MissingContextKeyNoEvent = 'Context was unspecified or had no key; event will not be sent';
|
|
1750
1752
|
|
|
1751
1753
|
class EventSender {
|
|
1752
1754
|
constructor(clientContext, baseHeaders) {
|
|
1753
1755
|
const { basicConfiguration, platform } = clientContext;
|
|
1754
1756
|
const { serviceEndpoints: { analyticsEventPath, diagnosticEventPath }, } = basicConfiguration;
|
|
1755
1757
|
const { crypto, requests } = platform;
|
|
1756
|
-
this.
|
|
1757
|
-
this.
|
|
1758
|
-
this.
|
|
1759
|
-
this.
|
|
1760
|
-
this.
|
|
1758
|
+
this._defaultHeaders = { ...baseHeaders };
|
|
1759
|
+
this._eventsUri = getEventsUri(basicConfiguration.serviceEndpoints, analyticsEventPath, []);
|
|
1760
|
+
this._diagnosticEventsUri = getEventsUri(basicConfiguration.serviceEndpoints, diagnosticEventPath, []);
|
|
1761
|
+
this._requests = requests;
|
|
1762
|
+
this._crypto = crypto;
|
|
1761
1763
|
}
|
|
1762
|
-
async
|
|
1764
|
+
async _tryPostingEvents(events, uri, payloadId, canRetry) {
|
|
1763
1765
|
const tryRes = {
|
|
1764
1766
|
status: LDDeliveryStatus.Succeeded,
|
|
1765
1767
|
};
|
|
1766
1768
|
const headers = {
|
|
1767
|
-
...this.
|
|
1769
|
+
...this._defaultHeaders,
|
|
1768
1770
|
'content-type': 'application/json',
|
|
1769
1771
|
};
|
|
1770
1772
|
if (payloadId) {
|
|
@@ -1773,7 +1775,7 @@ class EventSender {
|
|
|
1773
1775
|
}
|
|
1774
1776
|
let error;
|
|
1775
1777
|
try {
|
|
1776
|
-
const { status, headers: resHeaders } = await this.
|
|
1778
|
+
const { status, headers: resHeaders } = await this._requests.fetch(uri, {
|
|
1777
1779
|
headers,
|
|
1778
1780
|
body: JSON.stringify(events),
|
|
1779
1781
|
method: 'POST',
|
|
@@ -1815,12 +1817,12 @@ class EventSender {
|
|
|
1815
1817
|
}
|
|
1816
1818
|
// wait 1 second before retrying
|
|
1817
1819
|
await sleep();
|
|
1818
|
-
return this.
|
|
1820
|
+
return this._tryPostingEvents(events, this._eventsUri, payloadId, false);
|
|
1819
1821
|
}
|
|
1820
1822
|
async sendEventData(type, data) {
|
|
1821
|
-
const payloadId = type === LDEventType.AnalyticsEvents ? this.
|
|
1822
|
-
const uri = type === LDEventType.AnalyticsEvents ? this.
|
|
1823
|
-
return this.
|
|
1823
|
+
const payloadId = type === LDEventType.AnalyticsEvents ? this._crypto.randomUUID() : undefined;
|
|
1824
|
+
const uri = type === LDEventType.AnalyticsEvents ? this._eventsUri : this._diagnosticEventsUri;
|
|
1825
|
+
return this._tryPostingEvents(data, uri, payloadId, true);
|
|
1824
1826
|
}
|
|
1825
1827
|
}
|
|
1826
1828
|
|
|
@@ -1859,43 +1861,43 @@ function counterKey(event) {
|
|
|
1859
1861
|
*/
|
|
1860
1862
|
class EventSummarizer {
|
|
1861
1863
|
constructor() {
|
|
1862
|
-
this.
|
|
1863
|
-
this.
|
|
1864
|
-
this.
|
|
1865
|
-
this.
|
|
1864
|
+
this._startDate = 0;
|
|
1865
|
+
this._endDate = 0;
|
|
1866
|
+
this._counters = {};
|
|
1867
|
+
this._contextKinds = {};
|
|
1866
1868
|
}
|
|
1867
1869
|
summarizeEvent(event) {
|
|
1868
1870
|
if (isFeature(event) && !event.excludeFromSummaries) {
|
|
1869
1871
|
const countKey = counterKey(event);
|
|
1870
|
-
const counter = this.
|
|
1871
|
-
let kinds = this.
|
|
1872
|
+
const counter = this._counters[countKey];
|
|
1873
|
+
let kinds = this._contextKinds[event.key];
|
|
1872
1874
|
if (!kinds) {
|
|
1873
1875
|
kinds = new Set();
|
|
1874
|
-
this.
|
|
1876
|
+
this._contextKinds[event.key] = kinds;
|
|
1875
1877
|
}
|
|
1876
1878
|
event.context.kinds.forEach((kind) => kinds.add(kind));
|
|
1877
1879
|
if (counter) {
|
|
1878
1880
|
counter.increment();
|
|
1879
1881
|
}
|
|
1880
1882
|
else {
|
|
1881
|
-
this.
|
|
1883
|
+
this._counters[countKey] = new SummaryCounter(1, event.key, event.value, event.default, event.version, event.variation);
|
|
1882
1884
|
}
|
|
1883
|
-
if (this.
|
|
1884
|
-
this.
|
|
1885
|
+
if (this._startDate === 0 || event.creationDate < this._startDate) {
|
|
1886
|
+
this._startDate = event.creationDate;
|
|
1885
1887
|
}
|
|
1886
|
-
if (event.creationDate > this.
|
|
1887
|
-
this.
|
|
1888
|
+
if (event.creationDate > this._endDate) {
|
|
1889
|
+
this._endDate = event.creationDate;
|
|
1888
1890
|
}
|
|
1889
1891
|
}
|
|
1890
1892
|
}
|
|
1891
1893
|
getSummary() {
|
|
1892
|
-
const features = Object.values(this.
|
|
1894
|
+
const features = Object.values(this._counters).reduce((acc, counter) => {
|
|
1893
1895
|
let flagSummary = acc[counter.key];
|
|
1894
1896
|
if (!flagSummary) {
|
|
1895
1897
|
flagSummary = {
|
|
1896
1898
|
default: counter.default,
|
|
1897
1899
|
counters: [],
|
|
1898
|
-
contextKinds: [...this.
|
|
1900
|
+
contextKinds: [...this._contextKinds[counter.key]],
|
|
1899
1901
|
};
|
|
1900
1902
|
acc[counter.key] = flagSummary;
|
|
1901
1903
|
}
|
|
@@ -1916,17 +1918,17 @@ class EventSummarizer {
|
|
|
1916
1918
|
return acc;
|
|
1917
1919
|
}, {});
|
|
1918
1920
|
return {
|
|
1919
|
-
startDate: this.
|
|
1920
|
-
endDate: this.
|
|
1921
|
+
startDate: this._startDate,
|
|
1922
|
+
endDate: this._endDate,
|
|
1921
1923
|
features,
|
|
1922
1924
|
kind: 'summary',
|
|
1923
1925
|
};
|
|
1924
1926
|
}
|
|
1925
1927
|
clearSummary() {
|
|
1926
|
-
this.
|
|
1927
|
-
this.
|
|
1928
|
-
this.
|
|
1929
|
-
this.
|
|
1928
|
+
this._startDate = 0;
|
|
1929
|
+
this._endDate = 0;
|
|
1930
|
+
this._counters = {};
|
|
1931
|
+
this._contextKinds = {};
|
|
1930
1932
|
}
|
|
1931
1933
|
}
|
|
1932
1934
|
|
|
@@ -1958,88 +1960,88 @@ function shouldSample(ratio) {
|
|
|
1958
1960
|
}
|
|
1959
1961
|
|
|
1960
1962
|
class EventProcessor {
|
|
1961
|
-
constructor(
|
|
1962
|
-
this.
|
|
1963
|
-
this.
|
|
1964
|
-
this.
|
|
1965
|
-
this.
|
|
1966
|
-
this.
|
|
1967
|
-
this.
|
|
1968
|
-
this.
|
|
1969
|
-
this.
|
|
1970
|
-
this.
|
|
1971
|
-
this.
|
|
1972
|
-
this.
|
|
1973
|
-
this.
|
|
1974
|
-
this.
|
|
1975
|
-
this.
|
|
1976
|
-
this.
|
|
1977
|
-
this.
|
|
1963
|
+
constructor(_config, clientContext, baseHeaders, _contextDeduplicator, _diagnosticsManager, start = true) {
|
|
1964
|
+
this._config = _config;
|
|
1965
|
+
this._contextDeduplicator = _contextDeduplicator;
|
|
1966
|
+
this._diagnosticsManager = _diagnosticsManager;
|
|
1967
|
+
this._summarizer = new EventSummarizer();
|
|
1968
|
+
this._queue = [];
|
|
1969
|
+
this._lastKnownPastTime = 0;
|
|
1970
|
+
this._droppedEvents = 0;
|
|
1971
|
+
this._deduplicatedUsers = 0;
|
|
1972
|
+
this._exceededCapacity = false;
|
|
1973
|
+
this._eventsInLastBatch = 0;
|
|
1974
|
+
this._shutdown = false;
|
|
1975
|
+
this._flushUsersTimer = null;
|
|
1976
|
+
this._capacity = _config.eventsCapacity;
|
|
1977
|
+
this._logger = clientContext.basicConfiguration.logger;
|
|
1978
|
+
this._eventSender = new EventSender(clientContext, baseHeaders);
|
|
1979
|
+
this._contextFilter = new ContextFilter(_config.allAttributesPrivate, _config.privateAttributes.map((ref) => new AttributeReference(ref)));
|
|
1978
1980
|
if (start) {
|
|
1979
1981
|
this.start();
|
|
1980
1982
|
}
|
|
1981
1983
|
}
|
|
1982
1984
|
start() {
|
|
1983
|
-
if (this.
|
|
1984
|
-
this.
|
|
1985
|
-
this.
|
|
1986
|
-
}, this.
|
|
1985
|
+
if (this._contextDeduplicator?.flushInterval !== undefined) {
|
|
1986
|
+
this._flushUsersTimer = setInterval(() => {
|
|
1987
|
+
this._contextDeduplicator?.flush();
|
|
1988
|
+
}, this._contextDeduplicator.flushInterval * 1000);
|
|
1987
1989
|
}
|
|
1988
|
-
this.
|
|
1990
|
+
this._flushTimer = setInterval(async () => {
|
|
1989
1991
|
try {
|
|
1990
1992
|
await this.flush();
|
|
1991
1993
|
}
|
|
1992
1994
|
catch (e) {
|
|
1993
1995
|
// Log errors and swallow them
|
|
1994
|
-
this.
|
|
1996
|
+
this._logger?.debug(`Flush failed: ${e}`);
|
|
1995
1997
|
}
|
|
1996
|
-
}, this.
|
|
1997
|
-
if (this.
|
|
1998
|
-
const initEvent = this.
|
|
1999
|
-
this.
|
|
2000
|
-
this.
|
|
2001
|
-
const statsEvent = this.
|
|
2002
|
-
this.
|
|
2003
|
-
this.
|
|
2004
|
-
this.
|
|
2005
|
-
}, this.
|
|
2006
|
-
}
|
|
2007
|
-
this.
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
this.
|
|
1998
|
+
}, this._config.flushInterval * 1000);
|
|
1999
|
+
if (this._diagnosticsManager) {
|
|
2000
|
+
const initEvent = this._diagnosticsManager.createInitEvent();
|
|
2001
|
+
this._postDiagnosticEvent(initEvent);
|
|
2002
|
+
this._diagnosticsTimer = setInterval(() => {
|
|
2003
|
+
const statsEvent = this._diagnosticsManager.createStatsEventAndReset(this._droppedEvents, this._deduplicatedUsers, this._eventsInLastBatch);
|
|
2004
|
+
this._droppedEvents = 0;
|
|
2005
|
+
this._deduplicatedUsers = 0;
|
|
2006
|
+
this._postDiagnosticEvent(statsEvent);
|
|
2007
|
+
}, this._config.diagnosticRecordingInterval * 1000);
|
|
2008
|
+
}
|
|
2009
|
+
this._logger?.debug('Started EventProcessor.');
|
|
2010
|
+
}
|
|
2011
|
+
_postDiagnosticEvent(event) {
|
|
2012
|
+
this._eventSender.sendEventData(LDEventType.DiagnosticEvent, event);
|
|
2011
2013
|
}
|
|
2012
2014
|
close() {
|
|
2013
|
-
clearInterval(this.
|
|
2014
|
-
if (this.
|
|
2015
|
-
clearInterval(this.
|
|
2015
|
+
clearInterval(this._flushTimer);
|
|
2016
|
+
if (this._flushUsersTimer) {
|
|
2017
|
+
clearInterval(this._flushUsersTimer);
|
|
2016
2018
|
}
|
|
2017
|
-
if (this.
|
|
2018
|
-
clearInterval(this.
|
|
2019
|
+
if (this._diagnosticsTimer) {
|
|
2020
|
+
clearInterval(this._diagnosticsTimer);
|
|
2019
2021
|
}
|
|
2020
2022
|
}
|
|
2021
2023
|
async flush() {
|
|
2022
|
-
if (this.
|
|
2024
|
+
if (this._shutdown) {
|
|
2023
2025
|
throw new LDInvalidSDKKeyError('Events cannot be posted because a permanent error has been encountered. ' +
|
|
2024
2026
|
'This is most likely an invalid SDK key. The specific error information ' +
|
|
2025
2027
|
'is logged independently.');
|
|
2026
2028
|
}
|
|
2027
|
-
const eventsToFlush = this.
|
|
2028
|
-
this.
|
|
2029
|
-
const summary = this.
|
|
2030
|
-
this.
|
|
2029
|
+
const eventsToFlush = this._queue;
|
|
2030
|
+
this._queue = [];
|
|
2031
|
+
const summary = this._summarizer.getSummary();
|
|
2032
|
+
this._summarizer.clearSummary();
|
|
2031
2033
|
if (Object.keys(summary.features).length) {
|
|
2032
2034
|
eventsToFlush.push(summary);
|
|
2033
2035
|
}
|
|
2034
2036
|
if (!eventsToFlush.length) {
|
|
2035
2037
|
return;
|
|
2036
2038
|
}
|
|
2037
|
-
this.
|
|
2038
|
-
this.
|
|
2039
|
-
await this.
|
|
2039
|
+
this._eventsInLastBatch = eventsToFlush.length;
|
|
2040
|
+
this._logger?.debug('Flushing %d events', eventsToFlush.length);
|
|
2041
|
+
await this._tryPostingEvents(eventsToFlush);
|
|
2040
2042
|
}
|
|
2041
2043
|
sendEvent(inputEvent) {
|
|
2042
|
-
if (this.
|
|
2044
|
+
if (this._shutdown) {
|
|
2043
2045
|
return;
|
|
2044
2046
|
}
|
|
2045
2047
|
if (isMigration(inputEvent)) {
|
|
@@ -2053,25 +2055,25 @@ class EventProcessor {
|
|
|
2053
2055
|
if (migrationEvent.samplingRatio === 1) {
|
|
2054
2056
|
delete migrationEvent.samplingRatio;
|
|
2055
2057
|
}
|
|
2056
|
-
this.
|
|
2058
|
+
this._enqueue(migrationEvent);
|
|
2057
2059
|
}
|
|
2058
2060
|
return;
|
|
2059
2061
|
}
|
|
2060
|
-
this.
|
|
2062
|
+
this._summarizer.summarizeEvent(inputEvent);
|
|
2061
2063
|
const isFeatureEvent = isFeature(inputEvent);
|
|
2062
2064
|
const addFullEvent = (isFeatureEvent && inputEvent.trackEvents) || !isFeatureEvent;
|
|
2063
|
-
const addDebugEvent = this.
|
|
2065
|
+
const addDebugEvent = this._shouldDebugEvent(inputEvent);
|
|
2064
2066
|
const isIdentifyEvent = isIdentify(inputEvent);
|
|
2065
|
-
const shouldNotDeduplicate = this.
|
|
2067
|
+
const shouldNotDeduplicate = this._contextDeduplicator?.processContext(inputEvent.context);
|
|
2066
2068
|
// If there is no cache, then it will never be in the cache.
|
|
2067
2069
|
if (!shouldNotDeduplicate) {
|
|
2068
2070
|
if (!isIdentifyEvent) {
|
|
2069
|
-
this.
|
|
2071
|
+
this._deduplicatedUsers += 1;
|
|
2070
2072
|
}
|
|
2071
2073
|
}
|
|
2072
2074
|
const addIndexEvent = shouldNotDeduplicate && !isIdentifyEvent;
|
|
2073
2075
|
if (addIndexEvent) {
|
|
2074
|
-
this.
|
|
2076
|
+
this._enqueue(this._makeOutputEvent({
|
|
2075
2077
|
kind: 'index',
|
|
2076
2078
|
creationDate: inputEvent.creationDate,
|
|
2077
2079
|
context: inputEvent.context,
|
|
@@ -2079,19 +2081,19 @@ class EventProcessor {
|
|
|
2079
2081
|
}, false));
|
|
2080
2082
|
}
|
|
2081
2083
|
if (addFullEvent && shouldSample(inputEvent.samplingRatio)) {
|
|
2082
|
-
this.
|
|
2084
|
+
this._enqueue(this._makeOutputEvent(inputEvent, false));
|
|
2083
2085
|
}
|
|
2084
2086
|
if (addDebugEvent && shouldSample(inputEvent.samplingRatio)) {
|
|
2085
|
-
this.
|
|
2087
|
+
this._enqueue(this._makeOutputEvent(inputEvent, true));
|
|
2086
2088
|
}
|
|
2087
2089
|
}
|
|
2088
|
-
|
|
2090
|
+
_makeOutputEvent(event, debug) {
|
|
2089
2091
|
switch (event.kind) {
|
|
2090
2092
|
case 'feature': {
|
|
2091
2093
|
const out = {
|
|
2092
2094
|
kind: debug ? 'debug' : 'feature',
|
|
2093
2095
|
creationDate: event.creationDate,
|
|
2094
|
-
context: this.
|
|
2096
|
+
context: this._contextFilter.filter(event.context, !debug),
|
|
2095
2097
|
key: event.key,
|
|
2096
2098
|
value: event.value,
|
|
2097
2099
|
default: event.default,
|
|
@@ -2118,7 +2120,7 @@ class EventProcessor {
|
|
|
2118
2120
|
const out = {
|
|
2119
2121
|
kind: event.kind,
|
|
2120
2122
|
creationDate: event.creationDate,
|
|
2121
|
-
context: this.
|
|
2123
|
+
context: this._contextFilter.filter(event.context),
|
|
2122
2124
|
};
|
|
2123
2125
|
if (event.samplingRatio !== 1) {
|
|
2124
2126
|
out.samplingRatio = event.samplingRatio;
|
|
@@ -2172,32 +2174,32 @@ class EventProcessor {
|
|
|
2172
2174
|
return event;
|
|
2173
2175
|
}
|
|
2174
2176
|
}
|
|
2175
|
-
|
|
2176
|
-
if (this.
|
|
2177
|
-
this.
|
|
2178
|
-
this.
|
|
2177
|
+
_enqueue(event) {
|
|
2178
|
+
if (this._queue.length < this._capacity) {
|
|
2179
|
+
this._queue.push(event);
|
|
2180
|
+
this._exceededCapacity = false;
|
|
2179
2181
|
}
|
|
2180
2182
|
else {
|
|
2181
|
-
if (!this.
|
|
2182
|
-
this.
|
|
2183
|
-
this.
|
|
2183
|
+
if (!this._exceededCapacity) {
|
|
2184
|
+
this._exceededCapacity = true;
|
|
2185
|
+
this._logger?.warn('Exceeded event queue capacity. Increase capacity to avoid dropping events.');
|
|
2184
2186
|
}
|
|
2185
|
-
this.
|
|
2187
|
+
this._droppedEvents += 1;
|
|
2186
2188
|
}
|
|
2187
2189
|
}
|
|
2188
|
-
|
|
2190
|
+
_shouldDebugEvent(event) {
|
|
2189
2191
|
return (isFeature(event) &&
|
|
2190
2192
|
event.debugEventsUntilDate &&
|
|
2191
|
-
event.debugEventsUntilDate > this.
|
|
2193
|
+
event.debugEventsUntilDate > this._lastKnownPastTime &&
|
|
2192
2194
|
event.debugEventsUntilDate > Date.now());
|
|
2193
2195
|
}
|
|
2194
|
-
async
|
|
2195
|
-
const res = await this.
|
|
2196
|
+
async _tryPostingEvents(events) {
|
|
2197
|
+
const res = await this._eventSender.sendEventData(LDEventType.AnalyticsEvents, events);
|
|
2196
2198
|
if (res.status === LDDeliveryStatus.FailedAndMustShutDown) {
|
|
2197
|
-
this.
|
|
2199
|
+
this._shutdown = true;
|
|
2198
2200
|
}
|
|
2199
2201
|
if (res.serverTime) {
|
|
2200
|
-
this.
|
|
2202
|
+
this._lastKnownPastTime = res.serverTime;
|
|
2201
2203
|
}
|
|
2202
2204
|
if (res.error) {
|
|
2203
2205
|
throw res.error;
|
|
@@ -2277,16 +2279,16 @@ class NullEventProcessor {
|
|
|
2277
2279
|
}
|
|
2278
2280
|
|
|
2279
2281
|
class EventFactoryBase {
|
|
2280
|
-
constructor(
|
|
2281
|
-
this.
|
|
2282
|
+
constructor(_withReasons) {
|
|
2283
|
+
this._withReasons = _withReasons;
|
|
2282
2284
|
}
|
|
2283
2285
|
evalEvent(e) {
|
|
2284
|
-
return new InputEvalEvent(this.
|
|
2286
|
+
return new InputEvalEvent(this._withReasons, e.context, e.flagKey, e.value, e.defaultVal, e.version,
|
|
2285
2287
|
// Exclude null as a possibility.
|
|
2286
|
-
e.variation ?? undefined, e.trackEvents || e.addExperimentData, e.prereqOfFlagKey, this.
|
|
2288
|
+
e.variation ?? undefined, e.trackEvents || e.addExperimentData, e.prereqOfFlagKey, this._withReasons || e.addExperimentData ? e.reason : undefined, e.debugEventsUntilDate, e.excludeFromSummaries, e.samplingRatio);
|
|
2287
2289
|
}
|
|
2288
2290
|
unknownFlagEvent(key, defVal, context) {
|
|
2289
|
-
return new InputEvalEvent(this.
|
|
2291
|
+
return new InputEvalEvent(this._withReasons, context, key, defVal, defVal,
|
|
2290
2292
|
// This isn't ideal, but the purpose of the factory is to at least
|
|
2291
2293
|
// handle this situation.
|
|
2292
2294
|
undefined, // version
|
|
@@ -2316,27 +2318,27 @@ const reportJsonError = (type, data, logger, errorHandler) => {
|
|
|
2316
2318
|
};
|
|
2317
2319
|
// TODO: SDK-156 - Move to Server SDK specific location
|
|
2318
2320
|
class StreamingProcessor {
|
|
2319
|
-
constructor(clientContext, streamUriPath, parameters,
|
|
2320
|
-
this.
|
|
2321
|
-
this.
|
|
2322
|
-
this.
|
|
2323
|
-
this.
|
|
2321
|
+
constructor(clientContext, streamUriPath, parameters, _listeners, baseHeaders, _diagnosticsManager, _errorHandler, _streamInitialReconnectDelay = 1) {
|
|
2322
|
+
this._listeners = _listeners;
|
|
2323
|
+
this._diagnosticsManager = _diagnosticsManager;
|
|
2324
|
+
this._errorHandler = _errorHandler;
|
|
2325
|
+
this._streamInitialReconnectDelay = _streamInitialReconnectDelay;
|
|
2324
2326
|
const { basicConfiguration, platform } = clientContext;
|
|
2325
2327
|
const { logger } = basicConfiguration;
|
|
2326
2328
|
const { requests } = platform;
|
|
2327
|
-
this.
|
|
2328
|
-
this.
|
|
2329
|
-
this.
|
|
2330
|
-
this.
|
|
2329
|
+
this._headers = { ...baseHeaders };
|
|
2330
|
+
this._logger = logger;
|
|
2331
|
+
this._requests = requests;
|
|
2332
|
+
this._streamUri = getStreamingUri(basicConfiguration.serviceEndpoints, streamUriPath, parameters);
|
|
2331
2333
|
}
|
|
2332
|
-
|
|
2333
|
-
this.
|
|
2334
|
+
_logConnectionStarted() {
|
|
2335
|
+
this._connectionAttemptStartTime = Date.now();
|
|
2334
2336
|
}
|
|
2335
|
-
|
|
2336
|
-
if (this.
|
|
2337
|
-
this.
|
|
2337
|
+
_logConnectionResult(success) {
|
|
2338
|
+
if (this._connectionAttemptStartTime && this._diagnosticsManager) {
|
|
2339
|
+
this._diagnosticsManager.recordStreamInit(this._connectionAttemptStartTime, !success, Date.now() - this._connectionAttemptStartTime);
|
|
2338
2340
|
}
|
|
2339
|
-
this.
|
|
2341
|
+
this._connectionAttemptStartTime = undefined;
|
|
2340
2342
|
}
|
|
2341
2343
|
/**
|
|
2342
2344
|
* This is a wrapper around the passed errorHandler which adds additional
|
|
@@ -2347,63 +2349,63 @@ class StreamingProcessor {
|
|
|
2347
2349
|
*
|
|
2348
2350
|
* @private
|
|
2349
2351
|
*/
|
|
2350
|
-
|
|
2352
|
+
_retryAndHandleError(err) {
|
|
2351
2353
|
if (!shouldRetry(err)) {
|
|
2352
|
-
this.
|
|
2353
|
-
this.
|
|
2354
|
-
this.
|
|
2354
|
+
this._logConnectionResult(false);
|
|
2355
|
+
this._errorHandler?.(new LDStreamingError(exports.DataSourceErrorKind.ErrorResponse, err.message, err.status));
|
|
2356
|
+
this._logger?.error(httpErrorMessage(err, 'streaming request'));
|
|
2355
2357
|
return false;
|
|
2356
2358
|
}
|
|
2357
|
-
this.
|
|
2358
|
-
this.
|
|
2359
|
-
this.
|
|
2359
|
+
this._logger?.warn(httpErrorMessage(err, 'streaming request', 'will retry'));
|
|
2360
|
+
this._logConnectionResult(false);
|
|
2361
|
+
this._logConnectionStarted();
|
|
2360
2362
|
return true;
|
|
2361
2363
|
}
|
|
2362
2364
|
start() {
|
|
2363
|
-
this.
|
|
2365
|
+
this._logConnectionStarted();
|
|
2364
2366
|
// TLS is handled by the platform implementation.
|
|
2365
|
-
const eventSource = this.
|
|
2366
|
-
headers: this.
|
|
2367
|
-
errorFilter: (error) => this.
|
|
2368
|
-
initialRetryDelayMillis: 1000 * this.
|
|
2367
|
+
const eventSource = this._requests.createEventSource(this._streamUri, {
|
|
2368
|
+
headers: this._headers,
|
|
2369
|
+
errorFilter: (error) => this._retryAndHandleError(error),
|
|
2370
|
+
initialRetryDelayMillis: 1000 * this._streamInitialReconnectDelay,
|
|
2369
2371
|
readTimeoutMillis: 5 * 60 * 1000,
|
|
2370
2372
|
retryResetIntervalMillis: 60 * 1000,
|
|
2371
2373
|
});
|
|
2372
|
-
this.
|
|
2374
|
+
this._eventSource = eventSource;
|
|
2373
2375
|
eventSource.onclose = () => {
|
|
2374
|
-
this.
|
|
2376
|
+
this._logger?.info('Closed LaunchDarkly stream connection');
|
|
2375
2377
|
};
|
|
2376
2378
|
eventSource.onerror = () => {
|
|
2377
2379
|
// The work is done by `errorFilter`.
|
|
2378
2380
|
};
|
|
2379
2381
|
eventSource.onopen = () => {
|
|
2380
|
-
this.
|
|
2382
|
+
this._logger?.info('Opened LaunchDarkly stream connection');
|
|
2381
2383
|
};
|
|
2382
2384
|
eventSource.onretrying = (e) => {
|
|
2383
|
-
this.
|
|
2385
|
+
this._logger?.info(`Will retry stream connection in ${e.delayMillis} milliseconds`);
|
|
2384
2386
|
};
|
|
2385
|
-
this.
|
|
2387
|
+
this._listeners.forEach(({ deserializeData, processJson }, eventName) => {
|
|
2386
2388
|
eventSource.addEventListener(eventName, (event) => {
|
|
2387
|
-
this.
|
|
2389
|
+
this._logger?.debug(`Received ${eventName} event`);
|
|
2388
2390
|
if (event?.data) {
|
|
2389
|
-
this.
|
|
2391
|
+
this._logConnectionResult(true);
|
|
2390
2392
|
const { data } = event;
|
|
2391
2393
|
const dataJson = deserializeData(data);
|
|
2392
2394
|
if (!dataJson) {
|
|
2393
|
-
reportJsonError(eventName, data, this.
|
|
2395
|
+
reportJsonError(eventName, data, this._logger, this._errorHandler);
|
|
2394
2396
|
return;
|
|
2395
2397
|
}
|
|
2396
2398
|
processJson(dataJson);
|
|
2397
2399
|
}
|
|
2398
2400
|
else {
|
|
2399
|
-
this.
|
|
2401
|
+
this._errorHandler?.(new LDStreamingError(exports.DataSourceErrorKind.Unknown, 'Unexpected payload from event stream'));
|
|
2400
2402
|
}
|
|
2401
2403
|
});
|
|
2402
2404
|
});
|
|
2403
2405
|
}
|
|
2404
2406
|
stop() {
|
|
2405
|
-
this.
|
|
2406
|
-
this.
|
|
2407
|
+
this._eventSource?.close();
|
|
2408
|
+
this._eventSource = undefined;
|
|
2407
2409
|
}
|
|
2408
2410
|
close() {
|
|
2409
2411
|
this.stop();
|