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

@spotify-confidence/sdk

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spotify-confidence/sdk - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

build/cjs/Closer.d.ts

14

build/cjs/Confidence.d.ts

@@ -7,2 +7,4 @@ import { FlagResolverClient, FlagResolution } from './FlagResolverClient';

import { Logger } from './logger';
import { Trackable } from './Trackable';
import { Closer } from './Closer';
export { FlagResolverClient, FlagResolution };

@@ -20,7 +22,8 @@ export interface ConfidenceOptions {

readonly environment: 'client' | 'backend';
readonly logger: Logger;
readonly eventSenderEngine: EventSenderEngine;
readonly flagResolverClient: FlagResolverClient;
}
export declare class Confidence implements EventSender {
private readonly config;
export declare class Confidence implements EventSender, Trackable {
readonly config: Configuration;
private readonly parent?;

@@ -30,10 +33,11 @@ private _context;

get environment(): string;
sendEvent(name: string, message?: Value.Struct): void;
private sendEvent;
private contextEntries;
getContext(): Context;
setContext(context: Context): void;
updateContextEntry<K extends string>(name: K, value: Context[K]): void;
removeContextEntry(name: string): void;
private updateContextEntry;
clearContext(): void;
withContext(context: Context): Confidence;
track(name: string, message?: Value.Struct): void;
track(manager: Trackable.Manager): Closer;
resolve(flagNames: string[]): Promise<FlagResolution>;

@@ -40,0 +44,0 @@ apply(resolveToken: string, flagName: string): void;

@@ -10,2 +10,4 @@ "use strict";

const logger_1 = require("./logger");
const trackers_1 = require("./trackers");
const Trackable_1 = require("./Trackable");
class Confidence {

@@ -45,3 +47,2 @@ constructor(config, parent) {

setContext(context) {
this._context.clear();
for (const key of Object.keys(context)) {

@@ -54,5 +55,2 @@ this.updateContextEntry(key, context[key]);

}
removeContextEntry(name) {
this._context.set(name, undefined);
}
clearContext() {

@@ -66,2 +64,9 @@ this._context.clear();

}
track(nameOrManager, message) {
if (typeof nameOrManager === 'function') {
return Trackable_1.Trackable.setup(this, nameOrManager);
}
this.sendEvent(nameOrManager, message);
return undefined;
}
resolve(flagNames) {

@@ -76,3 +81,3 @@ return this.config.flagResolverClient.resolve(this.getContext(), flagNames);

id: 'SDK_ID_JS_CONFIDENCE',
version: '0.0.2',
version: '0.0.3',
};

@@ -101,7 +106,12 @@ const flagResolverClient = new FlagResolverClient_1.FlagResolverClient({

});
return new Confidence({
const root = new Confidence({
environment: environment,
flagResolverClient,
eventSenderEngine: eventSenderEngine,
logger,
});
if (environment === 'client') {
root.track((0, trackers_1.visitorIdentity)());
}
return root;
}

@@ -108,0 +118,0 @@ }

@@ -5,4 +5,2 @@ import { Value } from './Value';

setContext(context: Context): void;
updateContextEntry<K extends string>(name: K, value: Context[K]): void;
removeContextEntry(name: string): void;
withContext(context: Context): Self;

@@ -12,6 +10,14 @@ clearContext(): void;

export interface Context extends Value.Struct {
visitor_id?: string;
openFeature?: Value.Struct & {
targeting_key?: string;
};
page?: {
path: string;
referrer: string;
search: string;
title: string;
url: string;
};
}
//# sourceMappingURL=context.d.ts.map
import { Value } from './Value';
import { Contextual } from './context';
export interface EventSender extends Contextual<EventSender> {
sendEvent(name: string, message?: Value.Struct): void;
track(name: string, message?: Value.Struct): void;
}
//# sourceMappingURL=events.d.ts.map
import { Value } from './Value';
import { Logger } from './logger';
interface Event {
eventDefinition: string;
eventTime: string;
payload: Value.Struct;
}
interface EventBatch {
sendTime: string;
clientSecret: string;
events: Event[];
}
interface PublishError {
index: number;
reason: string;
message: string;
}
export interface EventSenderEngineOptions {

@@ -27,5 +42,5 @@ clientSecret: string;

clearPendingFlush(): void;
private upload;
upload(batch: EventBatch): Promise<PublishError[]>;
}
export {};
//# sourceMappingURL=EventSenderEngine.d.ts.map

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

this.writeQueue.push({
eventDefinition: `eventDefinitions/${name}`,
eventDefinition: name,
eventTime: new Date().toISOString(),
payload: Object.assign(Object.assign({}, message), context),
payload: Object.assign(Object.assign({}, context), { message: message }),
});

@@ -97,3 +97,3 @@ this.clearPendingFlush();

headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(batch),
body: JSON.stringify(Object.assign(Object.assign({}, batch), { events: batch.events.map(e => (Object.assign(Object.assign({}, e), { eventDefinition: `eventDefinitions/${e.eventDefinition}` }))) })),
})

@@ -100,0 +100,0 @@ .then(resp => resp.json())

@@ -5,2 +5,3 @@ export * from './context';

export * from './Value';
export * from './trackers';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./Value"), exports);
__exportStar(require("./trackers"), exports);
//# sourceMappingURL=index.js.map
export declare namespace Logger {
const LEVELS: readonly ["trace", "warn", "error"];
const LEVELS: readonly ["trace", "debug", "warn", "error"];
export type Fn = (message: string, ...optionalParams: any[]) => void;

@@ -11,2 +11,3 @@ export type Level = (typeof LEVELS)[number];

readonly trace?: Logger.Fn;
readonly debug?: Logger.Fn;
readonly warn?: Logger.Fn;

@@ -13,0 +14,0 @@ readonly error?: Logger.Fn;

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

const NOOP_LOGGER = Object.freeze({});
const LEVELS = ['trace', 'warn', 'error'];
const LEVELS = ['trace', 'debug', 'warn', 'error'];
function noOp() {

@@ -10,0 +10,0 @@ return NOOP_LOGGER;

@@ -7,2 +7,4 @@ import { FlagResolverClient, FlagResolution } from './FlagResolverClient';

import { Logger } from './logger';
import { Trackable } from './Trackable';
import { Closer } from './Closer';
export { FlagResolverClient, FlagResolution };

@@ -20,7 +22,8 @@ export interface ConfidenceOptions {

readonly environment: 'client' | 'backend';
readonly logger: Logger;
readonly eventSenderEngine: EventSenderEngine;
readonly flagResolverClient: FlagResolverClient;
}
export declare class Confidence implements EventSender {
private readonly config;
export declare class Confidence implements EventSender, Trackable {
readonly config: Configuration;
private readonly parent?;

@@ -30,10 +33,11 @@ private _context;

get environment(): string;
sendEvent(name: string, message?: Value.Struct): void;
private sendEvent;
private contextEntries;
getContext(): Context;
setContext(context: Context): void;
updateContextEntry<K extends string>(name: K, value: Context[K]): void;
removeContextEntry(name: string): void;
private updateContextEntry;
clearContext(): void;
withContext(context: Context): Confidence;
track(name: string, message?: Value.Struct): void;
track(manager: Trackable.Manager): Closer;
resolve(flagNames: string[]): Promise<FlagResolution>;

@@ -40,0 +44,0 @@ apply(resolveToken: string, flagName: string): void;

@@ -5,2 +5,4 @@ import { FlagResolverClient, FlagResolution } from './FlagResolverClient';

import { Logger } from './logger';
import { visitorIdentity } from './trackers';
import { Trackable } from './Trackable';
export { FlagResolverClient, FlagResolution };

@@ -41,3 +43,2 @@ export class Confidence {

setContext(context) {
this._context.clear();
for (const key of Object.keys(context)) {

@@ -50,5 +51,2 @@ this.updateContextEntry(key, context[key]);

}
removeContextEntry(name) {
this._context.set(name, undefined);
}
clearContext() {

@@ -62,2 +60,9 @@ this._context.clear();

}
track(nameOrManager, message) {
if (typeof nameOrManager === 'function') {
return Trackable.setup(this, nameOrManager);
}
this.sendEvent(nameOrManager, message);
return undefined;
}
resolve(flagNames) {

@@ -72,3 +77,3 @@ return this.config.flagResolverClient.resolve(this.getContext(), flagNames);

id: 'SDK_ID_JS_CONFIDENCE',
version: '0.0.2',
version: '0.0.3',
};

@@ -97,7 +102,12 @@ const flagResolverClient = new FlagResolverClient({

});
return new Confidence({
const root = new Confidence({
environment: environment,
flagResolverClient,
eventSenderEngine: eventSenderEngine,
logger,
});
if (environment === 'client') {
root.track(visitorIdentity());
}
return root;
}

@@ -104,0 +114,0 @@ }

@@ -5,4 +5,2 @@ import { Value } from './Value';

setContext(context: Context): void;
updateContextEntry<K extends string>(name: K, value: Context[K]): void;
removeContextEntry(name: string): void;
withContext(context: Context): Self;

@@ -12,6 +10,14 @@ clearContext(): void;

export interface Context extends Value.Struct {
visitor_id?: string;
openFeature?: Value.Struct & {
targeting_key?: string;
};
page?: {
path: string;
referrer: string;
search: string;
title: string;
url: string;
};
}
//# sourceMappingURL=context.d.ts.map
import { Value } from './Value';
import { Contextual } from './context';
export interface EventSender extends Contextual<EventSender> {
sendEvent(name: string, message?: Value.Struct): void;
track(name: string, message?: Value.Struct): void;
}
//# sourceMappingURL=events.d.ts.map
import { Value } from './Value';
import { Logger } from './logger';
interface Event {
eventDefinition: string;
eventTime: string;
payload: Value.Struct;
}
interface EventBatch {
sendTime: string;
clientSecret: string;
events: Event[];
}
interface PublishError {
index: number;
reason: string;
message: string;
}
export interface EventSenderEngineOptions {

@@ -27,5 +42,5 @@ clientSecret: string;

clearPendingFlush(): void;
private upload;
upload(batch: EventBatch): Promise<PublishError[]>;
}
export {};
//# sourceMappingURL=EventSenderEngine.d.ts.map

@@ -40,5 +40,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

this.writeQueue.push({
eventDefinition: `eventDefinitions/${name}`,
eventDefinition: name,
eventTime: new Date().toISOString(),
payload: Object.assign(Object.assign({}, message), context),
payload: Object.assign(Object.assign({}, context), { message: message }),
});

@@ -94,3 +94,3 @@ this.clearPendingFlush();

headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(batch),
body: JSON.stringify(Object.assign(Object.assign({}, batch), { events: batch.events.map(e => (Object.assign(Object.assign({}, e), { eventDefinition: `eventDefinitions/${e.eventDefinition}` }))) })),
})

@@ -97,0 +97,0 @@ .then(resp => resp.json())

@@ -5,2 +5,3 @@ export * from './context';

export * from './Value';
export * from './trackers';
//# sourceMappingURL=index.d.ts.map

@@ -5,2 +5,3 @@ export * from './context';

export * from './Value';
export * from './trackers';
//# sourceMappingURL=index.js.map
export declare namespace Logger {
const LEVELS: readonly ["trace", "warn", "error"];
const LEVELS: readonly ["trace", "debug", "warn", "error"];
export type Fn = (message: string, ...optionalParams: any[]) => void;

@@ -11,2 +11,3 @@ export type Level = (typeof LEVELS)[number];

readonly trace?: Logger.Fn;
readonly debug?: Logger.Fn;
readonly warn?: Logger.Fn;

@@ -13,0 +14,0 @@ readonly error?: Logger.Fn;

export var Logger;
(function (Logger) {
const NOOP_LOGGER = Object.freeze({});
const LEVELS = ['trace', 'warn', 'error'];
const LEVELS = ['trace', 'debug', 'warn', 'error'];
function noOp() {

@@ -6,0 +6,0 @@ return NOOP_LOGGER;

@@ -7,2 +7,4 @@ import { FlagResolverClient, FlagResolution } from './FlagResolverClient';

import { Logger } from './logger';
import { Trackable } from './Trackable';
import { Closer } from './Closer';
export { FlagResolverClient, FlagResolution };

@@ -20,7 +22,8 @@ export interface ConfidenceOptions {

readonly environment: 'client' | 'backend';
readonly logger: Logger;
readonly eventSenderEngine: EventSenderEngine;
readonly flagResolverClient: FlagResolverClient;
}
export declare class Confidence implements EventSender {
private readonly config;
export declare class Confidence implements EventSender, Trackable {
readonly config: Configuration;
private readonly parent?;

@@ -30,10 +33,11 @@ private _context;

get environment(): string;
sendEvent(name: string, message?: Value.Struct): void;
private sendEvent;
private contextEntries;
getContext(): Context;
setContext(context: Context): void;
updateContextEntry<K extends string>(name: K, value: Context[K]): void;
removeContextEntry(name: string): void;
private updateContextEntry;
clearContext(): void;
withContext(context: Context): Confidence;
track(name: string, message?: Value.Struct): void;
track(manager: Trackable.Manager): Closer;
resolve(flagNames: string[]): Promise<FlagResolution>;

@@ -40,0 +44,0 @@ apply(resolveToken: string, flagName: string): void;

@@ -5,2 +5,4 @@ import { FlagResolverClient, FlagResolution } from './FlagResolverClient';

import { Logger } from './logger';
import { visitorIdentity } from './trackers';
import { Trackable } from './Trackable';
export { FlagResolverClient, FlagResolution };

@@ -41,3 +43,2 @@ export class Confidence {

setContext(context) {
this._context.clear();
for (const key of Object.keys(context)) {

@@ -50,5 +51,2 @@ this.updateContextEntry(key, context[key]);

}
removeContextEntry(name) {
this._context.set(name, undefined);
}
clearContext() {

@@ -62,2 +60,9 @@ this._context.clear();

}
track(nameOrManager, message) {
if (typeof nameOrManager === 'function') {
return Trackable.setup(this, nameOrManager);
}
this.sendEvent(nameOrManager, message);
return undefined;
}
resolve(flagNames) {

@@ -72,3 +77,3 @@ return this.config.flagResolverClient.resolve(this.getContext(), flagNames);

id: 'SDK_ID_JS_CONFIDENCE',
version: '0.0.2',
version: '0.0.3',
};

@@ -97,7 +102,12 @@ const flagResolverClient = new FlagResolverClient({

});
return new Confidence({
const root = new Confidence({
environment: environment,
flagResolverClient,
eventSenderEngine: eventSenderEngine,
logger,
});
if (environment === 'client') {
root.track(visitorIdentity());
}
return root;
}

@@ -104,0 +114,0 @@ }

@@ -5,4 +5,2 @@ import { Value } from './Value';

setContext(context: Context): void;
updateContextEntry<K extends string>(name: K, value: Context[K]): void;
removeContextEntry(name: string): void;
withContext(context: Context): Self;

@@ -12,6 +10,14 @@ clearContext(): void;

export interface Context extends Value.Struct {
visitor_id?: string;
openFeature?: Value.Struct & {
targeting_key?: string;
};
page?: {
path: string;
referrer: string;
search: string;
title: string;
url: string;
};
}
//# sourceMappingURL=context.d.ts.map
import { Value } from './Value';
import { Contextual } from './context';
export interface EventSender extends Contextual<EventSender> {
sendEvent(name: string, message?: Value.Struct): void;
track(name: string, message?: Value.Struct): void;
}
//# sourceMappingURL=events.d.ts.map
import { Value } from './Value';
import { Logger } from './logger';
interface Event {
eventDefinition: string;
eventTime: string;
payload: Value.Struct;
}
interface EventBatch {
sendTime: string;
clientSecret: string;
events: Event[];
}
interface PublishError {
index: number;
reason: string;
message: string;
}
export interface EventSenderEngineOptions {

@@ -27,5 +42,5 @@ clientSecret: string;

clearPendingFlush(): void;
private upload;
upload(batch: EventBatch): Promise<PublishError[]>;
}
export {};
//# sourceMappingURL=EventSenderEngine.d.ts.map

@@ -40,5 +40,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

this.writeQueue.push({
eventDefinition: `eventDefinitions/${name}`,
eventDefinition: name,
eventTime: new Date().toISOString(),
payload: Object.assign(Object.assign({}, message), context),
payload: Object.assign(Object.assign({}, context), { message: message }),
});

@@ -94,3 +94,3 @@ this.clearPendingFlush();

headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(batch),
body: JSON.stringify(Object.assign(Object.assign({}, batch), { events: batch.events.map(e => (Object.assign(Object.assign({}, e), { eventDefinition: `eventDefinitions/${e.eventDefinition}` }))) })),
})

@@ -97,0 +97,0 @@ .then(resp => resp.json())

@@ -5,2 +5,3 @@ export * from './context';

export * from './Value';
export * from './trackers';
//# sourceMappingURL=index.d.ts.map

@@ -5,2 +5,3 @@ export * from './context';

export * from './Value';
export * from './trackers';
//# sourceMappingURL=index.js.map
export declare namespace Logger {
const LEVELS: readonly ["trace", "warn", "error"];
const LEVELS: readonly ["trace", "debug", "warn", "error"];
export type Fn = (message: string, ...optionalParams: any[]) => void;

@@ -11,2 +11,3 @@ export type Level = (typeof LEVELS)[number];

readonly trace?: Logger.Fn;
readonly debug?: Logger.Fn;
readonly warn?: Logger.Fn;

@@ -13,0 +14,0 @@ readonly error?: Logger.Fn;

export var Logger;
(function (Logger) {
const NOOP_LOGGER = Object.freeze({});
const LEVELS = ['trace', 'warn', 'error'];
const LEVELS = ['trace', 'debug', 'warn', 'error'];
function noOp() {

@@ -6,0 +6,0 @@ return NOOP_LOGGER;

# Changelog
## [0.0.3](https://github.com/spotify/confidence-openfeature-provider-js/compare/sdk-v0.0.2...sdk-v0.0.3) (2024-04-24)
### ✨ New Features
* managed contexts and events ([#102](https://github.com/spotify/confidence-openfeature-provider-js/issues/102)) ([a6dc75c](https://github.com/spotify/confidence-openfeature-provider-js/commit/a6dc75c147b50cda9ce27a1c0ca622cd191c7142))
### 📚 Documentation
* update sendEvent in example app ([#114](https://github.com/spotify/confidence-openfeature-provider-js/issues/114)) ([a19ba68](https://github.com/spotify/confidence-openfeature-provider-js/commit/a19ba683ffbb8cfc959d2484adc4f564b2278a41))
### 🔄 Refactoring
* add message container to payload ([#106](https://github.com/spotify/confidence-openfeature-provider-js/issues/106)) ([31b0eec](https://github.com/spotify/confidence-openfeature-provider-js/commit/31b0eecdefb1d1cb947a0fada0d6683d13dbc9ea))
* rename sendEvent to track ([#113](https://github.com/spotify/confidence-openfeature-provider-js/issues/113)) ([1d4cade](https://github.com/spotify/confidence-openfeature-provider-js/commit/1d4cadec1ac2ad2dd14a3b845e0abc6fa9d29660))
## [0.0.2](https://github.com/spotify/confidence-openfeature-provider-js/compare/sdk-v0.0.1...sdk-v0.0.2) (2024-04-04)

@@ -4,0 +22,0 @@

{
"name": "@spotify-confidence/sdk",
"license": "Apache-2.0",
"version": "0.0.2",
"version": "0.0.3",
"module": "build/esm/index.js",

@@ -22,5 +22,6 @@ "main": "build/cjs/index.js",

"dependencies": {
"@spotify-confidence/client-http": "0.1.5"
"@spotify-confidence/client-http": "0.1.5",
"web-vitals": "^3.5.2"
},
"gitHead": "86023f5a9cb5c641213ae7754be2395174754119"
"gitHead": "e434adc99a1668ffaf6ac95557a877b4af4c3cfb"
}

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

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