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