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

[WIP] feat(core): PoC implementation of Remote Configuration #12090

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented May 16, 2024

Do not merge

Initial proof of concept of how remote configuration could work in the JS SDKs.

@@ -51,6 +51,7 @@ export function makeFetchTransport(
pendingBodySize -= requestSize;
pendingCount--;
return {
response,
Copy link
Member Author

Choose a reason for hiding this comment

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

TBD if we re-use the transport, but we'll need access to the response body (as well as changing http req method to GET)

// sampleRate is used. then set client as ready after remote config is loaded and flush queue
// TODO: create/pass transport

const storage = this._createRemoteStorage();
Copy link
Member Author

Choose a reason for hiding this comment

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

implemented by client sdks for local storage/caching

Comment on lines 348 to 359
// if (this.config.getSource() === 'DEFAULT' && blockForRemoteConfig && blockForRemoteConfig.timeout > 0) {
// new Promise(resolve => {
// setTimeout(resolve, blockForRemoteConfig.timeout);
// remoteConfigFetchPromise.then(resolve);
// })
// .then(() => this.finishInit())
// .catch(() => {
// // TODO: Error handling
// });
//
// return;
// }
Copy link
Member Author

Choose a reason for hiding this comment

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

Can't do this 😬 , we'll have to apply new configs and have sdks restart if possible.

Comment on lines 371 to 372
// replaysSessionSampleRate: options.replaysSessionSampleRate,
// replaysOnErrorSampleRate: options.replatsOnErrorSampleRate,
Copy link
Member Author

Choose a reason for hiding this comment

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

not typed in browser sdk, will need to have the replay integration handle this.

Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser 22.23 KB (+2.37% 🔺)
@sentry/browser (incl. Tracing) 33.37 KB (+1.56% 🔺)
@sentry/browser (incl. Tracing, Replay) 68.72 KB (+0.75% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.12 KB (+0.85% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 72.76 KB (+0.71% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 84.76 KB (+0.61% 🔺)
@sentry/browser (incl. Feedback) 38.2 KB (+1.4% 🔺)
@sentry/browser (incl. sendFeedback) 26.8 KB (+1.94% 🔺)
@sentry/browser (incl. FeedbackAsync) 31.19 KB (+1.72% 🔺)
@sentry/react 24.92 KB (+2.11% 🔺)
@sentry/react (incl. Tracing) 36.36 KB (+1.42% 🔺)
@sentry/vue 26.2 KB (+2.14% 🔺)
@sentry/vue (incl. Tracing) 35.19 KB (+1.48% 🔺)
@sentry/svelte 22.37 KB (+2.38% 🔺)
CDN Bundle 24.78 KB (+2.13% 🔺)
CDN Bundle (incl. Tracing) 34.79 KB (+1.46% 🔺)
CDN Bundle (incl. Tracing, Replay) 68.47 KB (+0.71% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 73.45 KB (+0.68% 🔺)
CDN Bundle - uncompressed 72.75 KB (+2% 🔺)
CDN Bundle (incl. Tracing) - uncompressed 103.1 KB (+1.41% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 212.72 KB (+0.68% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 225.02 KB (+0.64% 🔺)
@sentry/nextjs (client) 35.61 KB (+1.52% 🔺)
@sentry/sveltekit (client) 33.98 KB (+1.62% 🔺)
@sentry/node 141.76 KB (+0.31% 🔺)
@sentry/aws-serverless 128.51 KB (+0.34% 🔺)

@billyvg billyvg changed the title release: 8.2.1 [WIP] feat(core): PoC implementation of Remote Configuration May 17, 2024
// Use cached configuration if it exists
const cachedValue = storage.get(defaultConfigName);
if (cachedValue) {
_activeConfig = JSON.parse(cachedValue);
Copy link
Member

@ryan953 ryan953 May 17, 2024

Choose a reason for hiding this comment

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

I think we should be putting JSON.parse/serialize into the storage object itself, and it's going to need try/catch guards around it

let _lastUpdate: Date | undefined;
let _source: RemoteConfigSource = 'DEFAULT';
let _hasUpdate: boolean = false;
let _state: RemoteConfigState = 'INITIALIZING';
Copy link
Member

Choose a reason for hiding this comment

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

I can't find the dfn of RemoteConfigState so far.

I think this state machine in here is going to be really important to get right because any of the state names we export will be hard to change later, and testing the different transitions will give the confidence that things are working well

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that we need to expose these states, they'll be used internally

}

/** @inheritdoc */
function get<T>(defaultConfig: T): T {
Copy link
Member

@ryan953 ryan953 Jun 3, 2024

Choose a reason for hiding this comment

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

It's a big cumbersome to pass in defaultConfig each time, unless there's something else for the public api.

Users could endup having to do:

const defaultConfig = [{key: 'is_enabled', value: false}];
const is_enabled = remoteConfigInst
  .get(defaultConfig)
  .find(feature => feature.key == 'is_enabled')
  .value;

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah this hasn't been updated for the new API, will be: get(key, defaultValue)

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.

None yet

2 participants