@spotify-confidence/sdk
Advanced tools
Comparing version 0.1.6 to 0.2.0
# Changelog | ||
## [0.2.0](https://github.com/spotify/confidence-sdk-js/compare/sdk-v0.1.6...sdk-v0.2.0) (2024-09-12) | ||
### ⚠ BREAKING CHANGES | ||
* visitor id disabled by default ([#199](https://github.com/spotify/confidence-sdk-js/issues/199)) | ||
* mark Confidence constructor as internal ([#195](https://github.com/spotify/confidence-sdk-js/issues/195)) | ||
### 🐛 Bug Fixes | ||
* mark Confidence constructor as internal ([#195](https://github.com/spotify/confidence-sdk-js/issues/195)) ([1eb79c0](https://github.com/spotify/confidence-sdk-js/commit/1eb79c039dfcde30dd4a279f96b8b903e5b356ff)) | ||
* visitor id disabled by default ([#199](https://github.com/spotify/confidence-sdk-js/issues/199)) ([aea60c4](https://github.com/spotify/confidence-sdk-js/commit/aea60c466f9780e0fb252a74dd80a2834230a0b1)) | ||
### ✨ New Features | ||
* add a custom baseURL for sidecar resolves ([#200](https://github.com/spotify/confidence-sdk-js/issues/200)) ([f838752](https://github.com/spotify/confidence-sdk-js/commit/f838752046abb0afa383dc2c8d421f196fddf8c7)) | ||
### 📚 Documentation | ||
* clarify importance of withContext in server usage ([#197](https://github.com/spotify/confidence-sdk-js/issues/197)) ([57aad0a](https://github.com/spotify/confidence-sdk-js/commit/57aad0a31cf14fd0e97f606630a2ac8d056d9fe4)) | ||
* fix styling of alert box ([#198](https://github.com/spotify/confidence-sdk-js/issues/198)) ([935a195](https://github.com/spotify/confidence-sdk-js/commit/935a19548b462dd886a5128f30b7b61559dbfdc3)) | ||
### 🔄 Refactoring | ||
* remove the widen type ([#193](https://github.com/spotify/confidence-sdk-js/issues/193)) ([99c9659](https://github.com/spotify/confidence-sdk-js/commit/99c9659e857ad862f6273fe2209abdd47073440c)) | ||
## [0.1.6](https://github.com/spotify/confidence-sdk-js/compare/sdk-v0.1.5...sdk-v0.1.6) (2024-08-20) | ||
@@ -4,0 +33,0 @@ |
@@ -48,3 +48,3 @@ declare class AccessiblePromise<T> { | ||
private readonly flagStateSubject; | ||
constructor(config: Configuration, parent?: Confidence); | ||
/* Excluded from this release type: __constructor */ | ||
/** Returns currently used environment */ | ||
@@ -87,5 +87,11 @@ get environment(): string; | ||
/** Evaluates a flag */ | ||
evaluateFlag<T extends Value>(path: string, defaultValue: T): FlagEvaluation<Value.Widen<T>>; | ||
evaluateFlag(path: string, defaultValue: string): FlagEvaluation<string>; | ||
evaluateFlag(path: string, defaultValue: boolean): FlagEvaluation<boolean>; | ||
evaluateFlag(path: string, defaultValue: number): FlagEvaluation<number>; | ||
evaluateFlag<T extends Value>(path: string, defaultValue: T): FlagEvaluation<T>; | ||
/** Returns flag value for a given flag */ | ||
getFlag<T extends Value>(path: string, defaultValue: T): Promise<Value.Widen<T>>; | ||
getFlag(path: string, defaultValue: string): Promise<string>; | ||
getFlag(path: string, defaultValue: boolean): Promise<boolean>; | ||
getFlag(path: string, defaultValue: number): Promise<number>; | ||
getFlag<T extends Value>(path: string, defaultValue: T): Promise<T>; | ||
/** | ||
@@ -99,5 +105,6 @@ * Creates a Confidence instance | ||
* @param logger - debug logger | ||
* @param resolveBaseUrl - custom backend resolve URL | ||
* @returns | ||
*/ | ||
static create({ clientSecret, region, timeout, environment, fetchImplementation, logger, }: ConfidenceOptions): Confidence; | ||
static create({ clientSecret, region, timeout, environment, fetchImplementation, logger, resolveBaseUrl, }: ConfidenceOptions): Confidence; | ||
} | ||
@@ -114,4 +121,2 @@ | ||
region?: 'eu' | 'us'; | ||
/** Resolve URL */ | ||
resolveUrl?: string; | ||
/** Environment: can be either client of backend */ | ||
@@ -125,2 +130,4 @@ environment: 'client' | 'backend'; | ||
logger?: Logger; | ||
/** Sets an alternative resolve url */ | ||
resolveBaseUrl?: string; | ||
} | ||
@@ -301,6 +308,18 @@ | ||
subscribe(onStateChange?: StateObserver): () => void; | ||
/** Evaluates a string flag */ | ||
evaluateFlag(path: string, defaultValue: string): FlagEvaluation<string>; | ||
/** Evaluates a boolean flag */ | ||
evaluateFlag(path: string, defaultValue: boolean): FlagEvaluation<boolean>; | ||
/** Evaluates a numeric flag */ | ||
evaluateFlag(path: string, defaultValue: number): FlagEvaluation<number>; | ||
/** Evaluates a flag */ | ||
evaluateFlag<T extends Value>(path: string, defaultValue: T): FlagEvaluation<Value.Widen<T>>; | ||
/** Returns flag value for a given flag */ | ||
getFlag<T extends Value>(path: string, defaultValue: T): Promise<Value.Widen<T>>; | ||
evaluateFlag<T extends Value>(path: string, defaultValue: T): FlagEvaluation<T>; | ||
/** Returns flag value for a string flag */ | ||
getFlag(path: string, defaultValue: string): Promise<string>; | ||
/** Returns flag value for a boolean flag */ | ||
getFlag(path: string, defaultValue: boolean): Promise<boolean>; | ||
/** Returns flag value for a numeric flag */ | ||
getFlag(path: string, defaultValue: number): Promise<number>; | ||
/** Returns flag value for a flag */ | ||
getFlag<T extends Value>(path: string, defaultValue: T): Promise<T>; | ||
} | ||
@@ -590,4 +609,2 @@ | ||
export type List = ReadonlyArray<number> | ReadonlyArray<string> | ReadonlyArray<boolean>; | ||
/** Sets Confidence used Values to be implementations of primitive types */ | ||
export type Widen<T extends Value> = T extends number ? number : T extends string ? string : T extends boolean ? boolean : T; | ||
/** Asserts a Value */ | ||
@@ -594,0 +611,0 @@ export function assertValue(value: unknown): asserts value is Value; |
{ | ||
"name": "@spotify-confidence/sdk", | ||
"license": "Apache-2.0", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"types": "dist/index.d.ts", | ||
@@ -6,0 +6,0 @@ "engineStrict": true, |
@@ -64,2 +64,5 @@ # Confidence SDK | ||
> [!IMPORTANT] | ||
> When using the SDK in a server environment, you should call `withContext` rather than `setContext`. This will give you a new instance scoped to the request and prevent context from leaking between requests. | ||
## Event tracking | ||
@@ -76,2 +79,16 @@ | ||
Confidence supports automatically tracking certain things out of the box and supports API's for you to extend that functionality. | ||
#### Visitor ID (web) | ||
Confidence can provide all flag resolves and tracking events with a browser specific identifier. We call this `visitor_id`. | ||
The `visitor_id` is stored in a cookie. To add a generated `visitor_id` to the context, use the following: | ||
```ts | ||
import { visitorIdentity } from './trackers'; | ||
confidence.track(visitorIdentity()); | ||
``` | ||
#### Page Views (web) | ||
Confidence can automatically track `page views` on events such as `load`, `pushState`, `replaceState`, `popstate` and `hashchange`. | ||
To automatically track `page views`, use the following: | ||
@@ -84,4 +101,6 @@ | ||
and to automatically track events containing web vitals data, use: | ||
#### Web vitals (web) | ||
To automatically send tracking events containing [web vitals data](https://web.dev/articles/vitals), use: | ||
```ts | ||
@@ -88,0 +107,0 @@ import { Confidence, webVitals } from '@spotify-confidence/sdk'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
603272
5781
107
2