@openfeature/web-sdk
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -499,3 +499,3 @@ "use strict"; | ||
} | ||
track(occurrenceKey, occurrenceDetails) { | ||
track(occurrenceKey, occurrenceDetails = {}) { | ||
var _a, _b, _c; | ||
@@ -533,2 +533,3 @@ try { | ||
}; | ||
let evaluationDetails; | ||
try { | ||
@@ -538,19 +539,20 @@ this.beforeHooks(allHooks, hookContext, options); | ||
const resolution = resolver.call(this._provider, flagKey, defaultValue, context, this._logger); | ||
const evaluationDetails = __spreadProps(__spreadValues({}, resolution), { | ||
const resolutionDetails = __spreadProps(__spreadValues({}, resolution), { | ||
flagMetadata: Object.freeze((_b = resolution.flagMetadata) != null ? _b : {}), | ||
flagKey | ||
}); | ||
if (evaluationDetails.errorCode) { | ||
const err = (0, import_core6.instantiateErrorByErrorCode)(evaluationDetails.errorCode); | ||
if (resolutionDetails.errorCode) { | ||
const err = (0, import_core6.instantiateErrorByErrorCode)(resolutionDetails.errorCode); | ||
this.errorHooks(allHooksReversed, hookContext, err, options); | ||
return this.getErrorEvaluationDetails(flagKey, defaultValue, err); | ||
evaluationDetails = this.getErrorEvaluationDetails(flagKey, defaultValue, err, resolutionDetails.flagMetadata); | ||
} else { | ||
this.afterHooks(allHooksReversed, hookContext, resolutionDetails, options); | ||
evaluationDetails = resolutionDetails; | ||
} | ||
this.afterHooks(allHooksReversed, hookContext, evaluationDetails, options); | ||
return evaluationDetails; | ||
} catch (err) { | ||
this.errorHooks(allHooksReversed, hookContext, err, options); | ||
return this.getErrorEvaluationDetails(flagKey, defaultValue, err); | ||
} finally { | ||
this.finallyHooks(allHooksReversed, hookContext, options); | ||
evaluationDetails = this.getErrorEvaluationDetails(flagKey, defaultValue, err); | ||
} | ||
this.finallyHooks(allHooksReversed, hookContext, evaluationDetails, options); | ||
return evaluationDetails; | ||
} | ||
@@ -585,7 +587,7 @@ beforeHooks(hooks, hookContext, options) { | ||
} | ||
finallyHooks(hooks, hookContext, options) { | ||
finallyHooks(hooks, hookContext, evaluationDetails, options) { | ||
var _a; | ||
for (const hook of hooks) { | ||
try { | ||
(_a = hook == null ? void 0 : hook.finally) == null ? void 0 : _a.call(hook, hookContext, options.hookHints); | ||
(_a = hook == null ? void 0 : hook.finally) == null ? void 0 : _a.call(hook, hookContext, evaluationDetails, options.hookHints); | ||
} catch (err) { | ||
@@ -613,3 +615,3 @@ this._logger.error(`Unhandled error during 'finally' hook: ${err}`); | ||
} | ||
getErrorEvaluationDetails(flagKey, defaultValue, err) { | ||
getErrorEvaluationDetails(flagKey, defaultValue, err, flagMetadata = {}) { | ||
const errorMessage = err == null ? void 0 : err.message; | ||
@@ -622,3 +624,3 @@ const errorCode = (err == null ? void 0 : err.code) || import_core6.ErrorCode.GENERAL; | ||
reason: import_core6.StandardResolutionReasons.ERROR, | ||
flagMetadata: Object.freeze({}), | ||
flagMetadata: Object.freeze(flagMetadata), | ||
flagKey | ||
@@ -625,0 +627,0 @@ }; |
@@ -498,3 +498,3 @@ var __create = Object.create; | ||
} | ||
track(occurrenceKey, occurrenceDetails) { | ||
track(occurrenceKey, occurrenceDetails = {}) { | ||
var _a, _b, _c; | ||
@@ -532,2 +532,3 @@ try { | ||
}; | ||
let evaluationDetails; | ||
try { | ||
@@ -537,19 +538,20 @@ this.beforeHooks(allHooks, hookContext, options); | ||
const resolution = resolver.call(this._provider, flagKey, defaultValue, context, this._logger); | ||
const evaluationDetails = __spreadProps(__spreadValues({}, resolution), { | ||
const resolutionDetails = __spreadProps(__spreadValues({}, resolution), { | ||
flagMetadata: Object.freeze((_b = resolution.flagMetadata) != null ? _b : {}), | ||
flagKey | ||
}); | ||
if (evaluationDetails.errorCode) { | ||
const err = instantiateErrorByErrorCode(evaluationDetails.errorCode); | ||
if (resolutionDetails.errorCode) { | ||
const err = instantiateErrorByErrorCode(resolutionDetails.errorCode); | ||
this.errorHooks(allHooksReversed, hookContext, err, options); | ||
return this.getErrorEvaluationDetails(flagKey, defaultValue, err); | ||
evaluationDetails = this.getErrorEvaluationDetails(flagKey, defaultValue, err, resolutionDetails.flagMetadata); | ||
} else { | ||
this.afterHooks(allHooksReversed, hookContext, resolutionDetails, options); | ||
evaluationDetails = resolutionDetails; | ||
} | ||
this.afterHooks(allHooksReversed, hookContext, evaluationDetails, options); | ||
return evaluationDetails; | ||
} catch (err) { | ||
this.errorHooks(allHooksReversed, hookContext, err, options); | ||
return this.getErrorEvaluationDetails(flagKey, defaultValue, err); | ||
} finally { | ||
this.finallyHooks(allHooksReversed, hookContext, options); | ||
evaluationDetails = this.getErrorEvaluationDetails(flagKey, defaultValue, err); | ||
} | ||
this.finallyHooks(allHooksReversed, hookContext, evaluationDetails, options); | ||
return evaluationDetails; | ||
} | ||
@@ -584,7 +586,7 @@ beforeHooks(hooks, hookContext, options) { | ||
} | ||
finallyHooks(hooks, hookContext, options) { | ||
finallyHooks(hooks, hookContext, evaluationDetails, options) { | ||
var _a; | ||
for (const hook of hooks) { | ||
try { | ||
(_a = hook == null ? void 0 : hook.finally) == null ? void 0 : _a.call(hook, hookContext, options.hookHints); | ||
(_a = hook == null ? void 0 : hook.finally) == null ? void 0 : _a.call(hook, hookContext, evaluationDetails, options.hookHints); | ||
} catch (err) { | ||
@@ -612,3 +614,3 @@ this._logger.error(`Unhandled error during 'finally' hook: ${err}`); | ||
} | ||
getErrorEvaluationDetails(flagKey, defaultValue, err) { | ||
getErrorEvaluationDetails(flagKey, defaultValue, err, flagMetadata = {}) { | ||
const errorMessage = err == null ? void 0 : err.message; | ||
@@ -621,3 +623,3 @@ const errorCode = (err == null ? void 0 : err.code) || ErrorCode2.GENERAL; | ||
reason: StandardResolutionReasons2.ERROR, | ||
flagMetadata: Object.freeze({}), | ||
flagMetadata: Object.freeze(flagMetadata), | ||
flagKey | ||
@@ -624,0 +626,0 @@ }; |
{ | ||
"name": "@openfeature/web-sdk", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "OpenFeature SDK for Web", | ||
@@ -49,7 +49,7 @@ "main": "./dist/cjs/index.js", | ||
"peerDependencies": { | ||
"@openfeature/core": "^1.5.0" | ||
"@openfeature/core": "^1.6.0" | ||
}, | ||
"devDependencies": { | ||
"@openfeature/core": "^1.5.0" | ||
"@openfeature/core": "^1.6.0" | ||
} | ||
} |
@@ -19,4 +19,4 @@ <!-- markdownlint-disable MD033 --> | ||
<!-- x-release-please-start-version --> | ||
<a href="https://github.com/open-feature/js-sdk/releases/tag/web-sdk-v1.3.2"> | ||
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v1.3.2&color=blue&style=for-the-badge" /> | ||
<a href="https://github.com/open-feature/js-sdk/releases/tag/web-sdk-v1.4.0"> | ||
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v1.4.0&color=blue&style=for-the-badge" /> | ||
</a> | ||
@@ -383,3 +383,3 @@ <!-- x-release-please-end --> | ||
after(hookContext: HookContext, evaluationDetails: EvaluationDetails<FlagValue>) { | ||
// code that runs when there's an error during a flag evaluation | ||
// code that runs after flag values are successfully resolved from the provider | ||
} | ||
@@ -386,0 +386,0 @@ } |
Sorry, the diff of this file is not supported yet
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
258707
2175