Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: offline-mode #136

Merged
merged 3 commits into from
Oct 24, 2023
Merged

feat: offline-mode #136

merged 3 commits into from
Oct 24, 2023

Conversation

novakzaballa
Copy link
Contributor

Implement offline mode for NodeJs SDK
Further documentation in the issue ticket Flagsmith/flagsmith#2024

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added one minor comment but this looks good in general.

Comment on lines 348 to 349
const environmentFlags:Flags = await flagsmith.getEnvironmentFlags();
const identityFlags:Flags = await flagsmith.getIdentityFlags('identity', {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we don't just assign these values in the calls made a few lines above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I really don't know why. Fixed

@matthewelwell
Copy link
Contributor

@novakzaballa we may also need to consider this in our implementation here too.

@novakzaballa
Copy link
Contributor Author

@novakzaballa we may also need to consider this in our implementation here too.

As per the condition at the beginning of this block, I would say that that's not the case in NodeJS.

if (!this.offlineMode) {
if (!this.environmentKey) {
throw new Error('ValueError: environmentKey is required.');
}
const apiUrl = data.apiUrl || DEFAULT_API_URL;
this.apiUrl = apiUrl.endsWith('/') ? apiUrl : `${apiUrl}/`;
this.environmentFlagsUrl = `${this.apiUrl}flags/`;
this.identitiesUrl = `${this.apiUrl}identities/`;
this.environmentUrl = `${this.apiUrl}environment-document/`;
if (this.enableLocalEvaluation) {
if (!this.environmentKey.startsWith('ser.')) {
console.error(
'In order to use local evaluation, please generate a server key in the environment settings page.'
);
}
this.environmentDataPollingManager = new EnvironmentDataPollingManager(
this,
this.environmentRefreshIntervalSeconds
);
this.environmentDataPollingManager.start();
this.updateEnvironment();
}
this.analyticsProcessor = data.enableAnalytics
? new AnalyticsProcessor({
environmentKey: this.environmentKey,
baseApiUrl: this.apiUrl,
requestTimeoutMs: this.requestTimeoutMs,
logger: this.logger
})
: undefined;
}
}
/**

@novakzaballa novakzaballa merged commit 496b7d6 into main Oct 24, 2023
1 check passed
beeme1mr referenced this pull request in open-feature/playground Dec 6, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [flagsmith-nodejs](http://flagsmith.com/)
([source](https://togithub.com/Flagsmith/flagsmith-nodejs-client)) |
[`^2.5.0` ->
`^3.0.0`](https://renovatebot.com/diffs/npm/flagsmith-nodejs/2.5.2/3.2.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/flagsmith-nodejs/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/flagsmith-nodejs/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/flagsmith-nodejs/2.5.2/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/flagsmith-nodejs/2.5.2/3.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>Flagsmith/flagsmith-nodejs-client (flagsmith-nodejs)</summary>

###
[`v3.2.0`](https://togithub.com/Flagsmith/flagsmith-nodejs-client/releases/tag/v3.2.0):
Version 3.2.0

[Compare
Source](https://togithub.com/Flagsmith/flagsmith-nodejs-client/compare/v3.1.1...v3.2.0)

#### What's Changed

- feat: offline-mode by
[@&#8203;novakzaballa](https://togithub.com/novakzaballa) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/136](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/136)

**Full Changelog**:
Flagsmith/flagsmith-nodejs-client@v3.1.1...v3.2.0

###
[`v3.1.1`](https://togithub.com/Flagsmith/flagsmith-nodejs-client/releases/tag/v3.1.1):
Version 3.1.1

[Compare
Source](https://togithub.com/Flagsmith/flagsmith-nodejs-client/compare/v3.1.0...v3.1.1)

#### What's Changed

- fix: Default requestTimeout by
[@&#8203;novakzaballa](https://togithub.com/novakzaballa) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/133](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/133)

**Full Changelog**:
Flagsmith/flagsmith-nodejs-client@v3.1.0...v3.1.1

###
[`v3.1.0`](https://togithub.com/Flagsmith/flagsmith-nodejs-client/releases/tag/v3.1.0):
Version 3.1.0

[Compare
Source](https://togithub.com/Flagsmith/flagsmith-nodejs-client/compare/v3.0.1...v3.1.0)

#### What's Changed

- Add 10 secs by default to requestTimeoutSeconds by
[@&#8203;novakzaballa](https://togithub.com/novakzaballa) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/128](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/128)
- Bump version to 3.1.0 by
[@&#8203;novakzaballa](https://togithub.com/novakzaballa) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/129](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/129)
- Bump word-wrap from 1.2.3 to 1.2.4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/127](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/127)
- Bump tough-cookie from 4.0.0 to 4.1.3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/125](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/125)
- Lazily calculate the hash by
[@&#8203;eldar-gamisoniya](https://togithub.com/eldar-gamisoniya) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/130](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/130)

#### New Contributors

- [@&#8203;novakzaballa](https://togithub.com/novakzaballa) made their
first contribution in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/128](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/128)
- [@&#8203;eldar-gamisoniya](https://togithub.com/eldar-gamisoniya) made
their first contribution in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/130](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/130)

**Full Changelog**:
Flagsmith/flagsmith-nodejs-client@v3.0.1...v3.1.0

###
[`v3.0.1`](https://togithub.com/Flagsmith/flagsmith-nodejs-client/releases/tag/v3.0.1):
Version 3.0.1

[Compare
Source](https://togithub.com/Flagsmith/flagsmith-nodejs-client/compare/v3.0.0...v3.0.1)

#### What's Changed

- Fix deploy action by [@&#8203;kyle-ssg](https://togithub.com/kyle-ssg)
in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/121](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/121)
- Bump semver from 7.3.7 to 7.5.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/122](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/122)

**Full Changelog**:
Flagsmith/flagsmith-nodejs-client@v3.0.0...v3.0.1

###
[`v3.0.0`](https://togithub.com/Flagsmith/flagsmith-nodejs-client/releases/tag/v3.0.0):
Version 3.0.0

[Compare
Source](https://togithub.com/Flagsmith/flagsmith-nodejs-client/compare/v2.5.2...v3.0.0)

#### What's Changed

- **BREAKING CHANGE**: Ensure percentage split evaluations are
consistent by
[@&#8203;matthewelwell](https://togithub.com/matthewelwell) in
[https://github.com/Flagsmith/flagsmith-nodejs-client/pull/119](https://togithub.com/Flagsmith/flagsmith-nodejs-client/pull/119)

WARNING: We modified the local evaluation behaviour. You may see
different flags returned to identities attributed to your percentage
split-based segments after upgrading to this version.

**Full Changelog**:
Flagsmith/flagsmith-nodejs-client@v2.5.2...v3.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/open-feature/playground).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMzEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjgxLjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants