Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@launchdarkly/js-sdk-common

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@launchdarkly/js-sdk-common - npm Package Compare versions

Comparing version 1.3.0-alpha.2 to 2.0.0-alpha.1

dist/api/subsystem/LDStreamProcessor.d.ts

13

dist/api/options/LDClientContext.d.ts

@@ -12,8 +12,3 @@ import { LDLogger } from '../logging';

export interface LDBasicConfiguration {
logger?: LDLogger;
/**
* True if the SDK was configured to be completely offline.
*/
offline: boolean;
/**
* The configured SDK key.

@@ -26,2 +21,10 @@ */

serviceEndpoints: LDServiceEndpoints;
/**
* True if the SDK was configured to be completely offline.
*/
offline?: boolean;
logger?: LDLogger;
tags?: {
value?: string;
};
}

@@ -28,0 +31,0 @@ /**

@@ -0,1 +1,9 @@

export type EventName = 'delete' | 'patch' | 'ping' | 'put';
export type EventListener = (event?: {
data?: any;
}) => void;
export type ProcessStreamResponse = {
deserializeData: (data: string) => any;
processJson: (json: any) => void;
};
export interface EventSource {

@@ -8,5 +16,3 @@ onclose: (() => void) | undefined;

}) => void) | undefined;
addEventListener(type: string, listener: (event?: {
data?: any;
}) => void): void;
addEventListener(type: EventName, listener: EventListener): void;
close(): void;

@@ -13,0 +19,0 @@ }

import LDContextDeduplicator from './LDContextDeduplicator';
import LDEventProcessor from './LDEventProcessor';
import LDEventSender, { LDDeliveryStatus, LDEventSenderResult, LDEventType } from './LDEventSender';
export { LDEventProcessor, LDContextDeduplicator, LDEventSender, LDDeliveryStatus, LDEventType, LDEventSenderResult, };
import { LDStreamProcessor } from './LDStreamProcessor';
export { LDEventProcessor, LDContextDeduplicator, LDEventSender, LDDeliveryStatus, LDEventType, LDEventSenderResult, LDStreamProcessor, };
//# sourceMappingURL=index.d.ts.map

@@ -10,3 +10,4 @@ import AttributeReference from './AttributeReference';

export * as internal from './internal';
export * from './errors';
export { AttributeReference, Context, ContextFilter };
//# sourceMappingURL=index.d.ts.map

@@ -30,2 +30,3 @@ "use strict";

exports.internal = require("./internal");
__exportStar(require("./errors"), exports);
//# sourceMappingURL=index.js.map
import LDContextDeduplicator from '../../api/subsystem/LDContextDeduplicator';
import LDEventProcessor from '../../api/subsystem/LDEventProcessor';
import LDEventSender from '../../api/subsystem/LDEventSender';
import ClientContext from '../../options/ClientContext';
import { ClientContext } from '../../options';
import { DiagnosticsManager } from '../diagnostics';
import InputEvent from './InputEvent';
/**
* The event processor doesn't need to know anything about the shape of the
* diagnostic events.
*/
type DiagnosticEvent = any;
export interface EventProcessorOptions {

@@ -18,10 +13,6 @@ allAttributesPrivate: boolean;

}
interface LDDiagnosticsManager {
createInitEvent(): DiagnosticEvent;
createStatsEventAndReset(droppedEvents: number, deduplicatedUsers: number, eventsInLastBatch: number): DiagnosticEvent;
}
export default class EventProcessor implements LDEventProcessor {
private readonly eventSender;
private readonly contextDeduplicator;
private readonly contextDeduplicator?;
private readonly diagnosticsManager?;
private eventSender;
private summarizer;

@@ -41,3 +32,3 @@ private queue;

private flushUsersTimer;
constructor(config: EventProcessorOptions, clientContext: ClientContext, eventSender: LDEventSender, contextDeduplicator: LDContextDeduplicator, diagnosticsManager?: LDDiagnosticsManager | undefined);
constructor(config: EventProcessorOptions, clientContext: ClientContext, contextDeduplicator?: LDContextDeduplicator | undefined, diagnosticsManager?: DiagnosticsManager | undefined);
private postDiagnosticEvent;

@@ -52,3 +43,2 @@ close(): void;

}
export {};
//# sourceMappingURL=EventProcessor.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const LDEventSender_1 = require("../../api/subsystem/LDEventSender");
const subsystem_1 = require("../../api/subsystem");
const AttributeReference_1 = require("../../AttributeReference");
const ContextFilter_1 = require("../../ContextFilter");
const EventSender_1 = require("./EventSender");
const EventSummarizer_1 = require("./EventSummarizer");

@@ -11,4 +12,4 @@ const guards_1 = require("./guards");

class EventProcessor {
constructor(config, clientContext, eventSender, contextDeduplicator, diagnosticsManager) {
this.eventSender = eventSender;
constructor(config, clientContext, contextDeduplicator, diagnosticsManager) {
var _a;
this.contextDeduplicator = contextDeduplicator;

@@ -27,14 +28,18 @@ this.diagnosticsManager = diagnosticsManager;

this.logger = clientContext.basicConfiguration.logger;
this.eventSender = new EventSender_1.default(clientContext);
this.contextFilter = new ContextFilter_1.default(config.allAttributesPrivate, config.privateAttributes.map((ref) => new AttributeReference_1.default(ref)));
if (this.contextDeduplicator.flushInterval !== undefined) {
if (((_a = this.contextDeduplicator) === null || _a === void 0 ? void 0 : _a.flushInterval) !== undefined) {
this.flushUsersTimer = setInterval(() => {
this.contextDeduplicator.flush();
var _a;
(_a = this.contextDeduplicator) === null || _a === void 0 ? void 0 : _a.flush();
}, this.contextDeduplicator.flushInterval * 1000);
}
this.flushTimer = setInterval(async () => {
var _a;
try {
await this.flush();
}
catch (_a) {
// Eat the errors.
catch (e) {
// Log errors and swallow them
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`Flush failed: ${e}`);
}

@@ -54,3 +59,3 @@ }, config.flushInterval * 1000);

postDiagnosticEvent(event) {
this.eventSender.sendEventData(LDEventSender_1.LDEventType.DiagnosticEvent, event);
this.eventSender.sendEventData(subsystem_1.LDEventType.DiagnosticEvent, event);
}

@@ -86,2 +91,3 @@ close() {

sendEvent(inputEvent) {
var _a;
if (this.shutdown) {

@@ -108,5 +114,3 @@ return;

const isIdentifyEvent = (0, guards_1.isIdentify)(inputEvent);
// We only want to notify the de-duplicator if we would sample the index event.
// Otherwise we could deduplicate and then not send the event.
const shouldNotDeduplicate = this.contextDeduplicator.processContext(inputEvent.context);
const shouldNotDeduplicate = (_a = this.contextDeduplicator) === null || _a === void 0 ? void 0 : _a.processContext(inputEvent.context);
// If there is no cache, then it will never be in the cache.

@@ -119,3 +123,3 @@ if (!shouldNotDeduplicate) {

const addIndexEvent = shouldNotDeduplicate && !isIdentifyEvent;
if (addIndexEvent && (0, sampling_1.default)(inputEvent.indexSamplingRatio)) {
if (addIndexEvent) {
this.enqueue(this.makeOutputEvent({

@@ -125,3 +129,3 @@ kind: 'index',

context: inputEvent.context,
samplingRatio: inputEvent.indexSamplingRatio,
samplingRatio: 1,
}, false));

@@ -225,4 +229,4 @@ }

async tryPostingEvents(events) {
const res = await this.eventSender.sendEventData(LDEventSender_1.LDEventType.AnalyticsEvents, events);
if (res.status === LDEventSender_1.LDDeliveryStatus.FailedAndMustShutDown) {
const res = await this.eventSender.sendEventData(subsystem_1.LDEventType.AnalyticsEvents, events);
if (res.status === subsystem_1.LDDeliveryStatus.FailedAndMustShutDown) {
this.shutdown = true;

@@ -229,0 +233,0 @@ }

@@ -7,5 +7,5 @@ import EventProcessor from './EventProcessor';

import InputMigrationEvent from './InputMigrationEvent';
import { LDEventOverrides } from './LDEventOverrides';
import NullEventProcessor from './NullEventProcessor';
import shouldSample from './sampling';
export { InputCustomEvent, InputEvalEvent, InputEvent, InputIdentifyEvent, InputMigrationEvent, EventProcessor, LDEventOverrides, shouldSample, };
export { InputCustomEvent, InputEvalEvent, InputEvent, InputIdentifyEvent, InputMigrationEvent, EventProcessor, shouldSample, NullEventProcessor, };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldSample = exports.EventProcessor = exports.InputIdentifyEvent = exports.InputEvalEvent = exports.InputCustomEvent = void 0;
exports.NullEventProcessor = exports.shouldSample = exports.EventProcessor = exports.InputIdentifyEvent = exports.InputEvalEvent = exports.InputCustomEvent = void 0;
const EventProcessor_1 = require("./EventProcessor");

@@ -12,4 +12,6 @@ exports.EventProcessor = EventProcessor_1.default;

exports.InputIdentifyEvent = InputIdentifyEvent_1.default;
const NullEventProcessor_1 = require("./NullEventProcessor");
exports.NullEventProcessor = NullEventProcessor_1.default;
const sampling_1 = require("./sampling");
exports.shouldSample = sampling_1.default;
//# sourceMappingURL=index.js.map

@@ -8,7 +8,6 @@ import Context from '../../Context';

readonly samplingRatio: number;
readonly indexSamplingRatio: number;
readonly kind = "custom";
readonly creationDate: number;
constructor(context: Context, key: string, data?: any, metricValue?: number | undefined, samplingRatio?: number, indexSamplingRatio?: number);
constructor(context: Context, key: string, data?: any, metricValue?: number | undefined, samplingRatio?: number);
}
//# sourceMappingURL=InputCustomEvent.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class InputCustomEvent {
constructor(context, key, data, metricValue, samplingRatio = 1, indexSamplingRatio = 1) {
constructor(context, key, data, metricValue,
// Currently custom events are not sampled, but this is here to make the handling
// code more uniform.
samplingRatio = 1) {
this.context = context;

@@ -10,3 +13,2 @@ this.key = key;

this.samplingRatio = samplingRatio;
this.indexSamplingRatio = indexSamplingRatio;
this.kind = 'custom';

@@ -13,0 +15,0 @@ this.creationDate = Date.now();

@@ -8,3 +8,2 @@ import { LDEvaluationDetail, LDEvaluationReason } from '../../api/data';

readonly samplingRatio: number;
readonly indexSamplingRatio: number;
readonly kind = "feature";

@@ -22,4 +21,4 @@ readonly creationDate: number;

constructor(withReasons: boolean, context: Context, key: string, defValue: any, // default is a reserved keyword in this context.
detail: LDEvaluationDetail, version?: number, variation?: number, trackEvents?: boolean, prereqOf?: string, reason?: LDEvaluationReason, debugEventsUntilDate?: number, excludeFromSummaries?: boolean, samplingRatio?: number, indexSamplingRatio?: number);
detail: LDEvaluationDetail, version?: number, variation?: number, trackEvents?: boolean, prereqOf?: string, reason?: LDEvaluationReason, debugEventsUntilDate?: number, excludeFromSummaries?: boolean, samplingRatio?: number);
}
//# sourceMappingURL=InputEvalEvent.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

constructor(withReasons, context, key, defValue, // default is a reserved keyword in this context.
detail, version, variation, trackEvents, prereqOf, reason, debugEventsUntilDate, excludeFromSummaries, samplingRatio = 1, indexSamplingRatio = 1) {
detail, version, variation, trackEvents, prereqOf, reason, debugEventsUntilDate, excludeFromSummaries, samplingRatio = 1) {
var _a;

@@ -12,3 +12,2 @@ this.withReasons = withReasons;

this.samplingRatio = samplingRatio;
this.indexSamplingRatio = indexSamplingRatio;
this.kind = 'feature';

@@ -15,0 +14,0 @@ this.creationDate = Date.now();

@@ -0,2 +1,4 @@

export * from './diagnostics';
export * from './events';
export * from './stream';
//# sourceMappingURL=index.d.ts.map

@@ -17,3 +17,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./diagnostics"), exports);
__exportStar(require("./events"), exports);
__exportStar(require("./stream"), exports);
//# sourceMappingURL=index.js.map
import BasicLogger from './BasicLogger';
import createSafeLogger from './createSafeLogger';
import SafeLogger from './SafeLogger';
export { BasicLogger, SafeLogger };
export { BasicLogger, SafeLogger, createSafeLogger };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SafeLogger = exports.BasicLogger = void 0;
exports.createSafeLogger = exports.SafeLogger = exports.BasicLogger = void 0;
const BasicLogger_1 = require("./BasicLogger");
exports.BasicLogger = BasicLogger_1.default;
const createSafeLogger_1 = require("./createSafeLogger");
exports.createSafeLogger = createSafeLogger_1.default;
const SafeLogger_1 = require("./SafeLogger");
exports.SafeLogger = SafeLogger_1.default;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { LDLogger } from '../api';
import type { LDLogger } from '../api';
/**

@@ -3,0 +3,0 @@ * The safeLogger logic exists because we allow the application to pass in a custom logger, but

import { LDClientContext, LDLogger, Platform } from '../api';
import ApplicationTags from './ApplicationTags';
import ServiceEndpoints from './ServiceEndpoints';

@@ -8,2 +9,3 @@ /**

interface BasicConfiguration {
tags?: ApplicationTags;
logger?: LDLogger;

@@ -13,3 +15,3 @@ /**

*/
offline: boolean;
offline?: boolean;
/**

@@ -23,2 +25,6 @@ * The configured SDK key.

serviceEndpoints: ServiceEndpoints;
/**
* Sets the initial reconnect delay for the streaming connection, in seconds.
*/
streamInitialReconnectDelay?: number;
}

@@ -34,4 +40,5 @@ /**

logger?: LDLogger;
offline: boolean;
offline?: boolean;
serviceEndpoints: ServiceEndpoints;
tags?: ApplicationTags;
}, platform: Platform);

@@ -38,0 +45,0 @@ }

@@ -11,6 +11,7 @@ "use strict";

this.basicConfiguration = {
tags: configuration.tags,
logger: configuration.logger,
offline: configuration.offline,
serviceEndpoints: configuration.serviceEndpoints,
sdkKey,
serviceEndpoints: configuration.serviceEndpoints,
};

@@ -17,0 +18,0 @@ }

@@ -5,7 +5,8 @@ /**

export default class ServiceEndpoints {
static DEFAULT_EVENTS: string;
readonly streaming: string;
readonly polling: string;
readonly events: string;
constructor(streaming: string, polling: string, events: string);
constructor(streaming: string, polling: string, events?: string);
}
//# sourceMappingURL=ServiceEndpoints.d.ts.map

@@ -10,3 +10,3 @@ "use strict";

class ServiceEndpoints {
constructor(streaming, polling, events) {
constructor(streaming, polling, events = ServiceEndpoints.DEFAULT_EVENTS) {
this.streaming = canonicalizeUri(streaming);

@@ -17,3 +17,4 @@ this.polling = canonicalizeUri(polling);

}
ServiceEndpoints.DEFAULT_EVENTS = 'https://events.launchdarkly.com';
exports.default = ServiceEndpoints;
//# sourceMappingURL=ServiceEndpoints.js.map

@@ -0,3 +1,7 @@

import { secondsToMillis } from './date';
import { defaultHeaders, httpErrorMessage, LDHeaders } from './http';
import noop from './noop';
export { noop };
import sleep from './sleep';
import { VoidFunction } from './VoidFunction';
export { defaultHeaders, httpErrorMessage, noop, LDHeaders, secondsToMillis, sleep, VoidFunction };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.noop = void 0;
exports.sleep = exports.secondsToMillis = exports.noop = exports.httpErrorMessage = exports.defaultHeaders = void 0;
const date_1 = require("./date");
Object.defineProperty(exports, "secondsToMillis", { enumerable: true, get: function () { return date_1.secondsToMillis; } });
const http_1 = require("./http");
Object.defineProperty(exports, "defaultHeaders", { enumerable: true, get: function () { return http_1.defaultHeaders; } });
Object.defineProperty(exports, "httpErrorMessage", { enumerable: true, get: function () { return http_1.httpErrorMessage; } });
const noop_1 = require("./noop");
exports.noop = noop_1.default;
const sleep_1 = require("./sleep");
exports.sleep = sleep_1.default;
//# sourceMappingURL=index.js.map

@@ -61,2 +61,6 @@ /**

}
export declare class NullableBoolean implements TypeValidator {
is(u: unknown): boolean;
getType(): string;
}
/**

@@ -88,2 +92,3 @@ * Validate a value is a date. Values which are numbers are treated as dates and any string

static readonly Function: Function;
static createTypeArray<T>(typeName: string, example: T): TypeArray<T>;
static numberWithMin(min: number): NumberWithMinimum;

@@ -93,3 +98,4 @@ static stringMatchingRegex(expression: RegExp): StringMatchingRegex;

static readonly Kind: KindValidator;
static readonly NullableBoolean: NullableBoolean;
}
//# sourceMappingURL=validators.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeValidators = exports.KindValidator = exports.DateValidator = exports.Function = exports.StringMatchingRegex = exports.NumberWithMinimum = exports.TypeArray = exports.Type = exports.FactoryOrInstance = void 0;
exports.TypeValidators = exports.KindValidator = exports.DateValidator = exports.NullableBoolean = exports.Function = exports.StringMatchingRegex = exports.NumberWithMinimum = exports.TypeArray = exports.Type = exports.FactoryOrInstance = void 0;
/**

@@ -110,2 +110,11 @@ * Validate a factory or instance.

exports.Function = Function;
class NullableBoolean {
is(u) {
return typeof u === 'boolean' || typeof u === 'undefined' || u === null;
}
getType() {
return 'boolean | undefined | null';
}
}
exports.NullableBoolean = NullableBoolean;
// Our reference SDK, Go, parses date/time strings with the time.RFC3339Nano format.

@@ -147,2 +156,5 @@ // This regex should match strings that are valid in that format, and no others.

class TypeValidators {
static createTypeArray(typeName, example) {
return new TypeArray(typeName, example);
}
static numberWithMin(min) {

@@ -165,2 +177,3 @@ return new NumberWithMinimum(min);

TypeValidators.Kind = new KindValidator();
TypeValidators.NullableBoolean = new NullableBoolean();
//# sourceMappingURL=validators.js.map
{
"name": "@launchdarkly/js-sdk-common",
"version": "1.3.0-alpha.2",
"version": "2.0.0-alpha.1",
"type": "commonjs",

@@ -23,2 +23,3 @@ "main": "./dist/index.js",

"test": "npx jest --ci",
"build-types": "npx tsc --declaration true --emitDeclarationOnly true --declarationDir dist",
"build": "npx tsc",

@@ -31,2 +32,3 @@ "clean": "npx tsc --build --clean",

"devDependencies": {
"@launchdarkly/private-js-mocks": "0.0.1",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",

@@ -33,0 +35,0 @@ "@types/jest": "^29.4.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc