@flipfeatureflag/core 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  type FlagValue = boolean | string | number | Record<string, unknown>;
2
2
  type SdkReason = "rule_match" | "fallthrough" | "default" | "disabled";
3
3
  interface SdkContext {
4
- userId?: string;
4
+ userId: string;
5
5
  attributes?: Record<string, unknown>;
6
6
  }
7
7
  interface SdkEvaluateRequest {
@@ -28,7 +28,7 @@ interface SdkMetricEvent {
28
28
  variationKey: string;
29
29
  reason: SdkReason | string;
30
30
  ts: string;
31
- context?: SdkContext;
31
+ context: SdkContext;
32
32
  }
33
33
  interface SdkMetricsRequest {
34
34
  env?: string;
@@ -78,7 +78,7 @@ interface FlipFlagClientOptions {
78
78
  metricsIntervalMs?: number;
79
79
  disableRefresh?: boolean;
80
80
  disableMetrics?: boolean;
81
- context?: SdkContext;
81
+ context: SdkContext;
82
82
  fetch?: typeof fetch;
83
83
  }
84
84
  interface FlagsStatus {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  type FlagValue = boolean | string | number | Record<string, unknown>;
2
2
  type SdkReason = "rule_match" | "fallthrough" | "default" | "disabled";
3
3
  interface SdkContext {
4
- userId?: string;
4
+ userId: string;
5
5
  attributes?: Record<string, unknown>;
6
6
  }
7
7
  interface SdkEvaluateRequest {
@@ -28,7 +28,7 @@ interface SdkMetricEvent {
28
28
  variationKey: string;
29
29
  reason: SdkReason | string;
30
30
  ts: string;
31
- context?: SdkContext;
31
+ context: SdkContext;
32
32
  }
33
33
  interface SdkMetricsRequest {
34
34
  env?: string;
@@ -78,7 +78,7 @@ interface FlipFlagClientOptions {
78
78
  metricsIntervalMs?: number;
79
79
  disableRefresh?: boolean;
80
80
  disableMetrics?: boolean;
81
- context?: SdkContext;
81
+ context: SdkContext;
82
82
  fetch?: typeof fetch;
83
83
  }
84
84
  interface FlagsStatus {
package/dist/index.js CHANGED
@@ -154,7 +154,10 @@ var FlipFlagClient = class {
154
154
  metricsIntervalMs: DEFAULT_METRICS_MS,
155
155
  ...options
156
156
  };
157
- this.context = options.context ?? {};
157
+ if (!options.context?.userId) {
158
+ throw new Error("flipFeatureFlag SDK requires context.userId");
159
+ }
160
+ this.context = options.context;
158
161
  const fetchFn = options.fetch ?? fetch;
159
162
  this.http = new HttpClient({
160
163
  baseUrl: this.options.url,
package/dist/index.mjs CHANGED
@@ -128,7 +128,10 @@ var FlipFlagClient = class {
128
128
  metricsIntervalMs: DEFAULT_METRICS_MS,
129
129
  ...options
130
130
  };
131
- this.context = options.context ?? {};
131
+ if (!options.context?.userId) {
132
+ throw new Error("flipFeatureFlag SDK requires context.userId");
133
+ }
134
+ this.context = options.context;
132
135
  const fetchFn = options.fetch ?? fetch;
133
136
  this.http = new HttpClient({
134
137
  baseUrl: this.options.url,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipfeatureflag/core",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "flipFeatureFlag core SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",