Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.8k
feat(js-loader): Support logs+metrics bundle#106959
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6cdedc7a29febd5e16f2b6afca4fc0907dc0a17f9eae84380e5aa2c3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -31,6 +31,7 @@ class SdkConfig(TypedDict): | ||
| replaysOnErrorSampleRate: NotRequired[float] | ||
| debug: NotRequired[bool] | ||
| autoInjectFeedback: NotRequired[bool] | ||
| enableLogs: NotRequired[bool] | ||
| class LoaderInternalConfig(TypedDict): | ||
| @@ -40,6 +41,11 @@ class LoaderInternalConfig(TypedDict): | ||
| hasReplay: bool | ||
| hasDebug: bool | ||
| hasFeedback: bool | ||
| hasLogsAndMetrics: bool | ||
| userEnabledPerformance: bool | ||
| userEnabledReplay: bool | ||
| userEnabledFeedback: bool | ||
| userEnabledLogsAndMetrics: bool | ||
| class LoaderContext(TypedDict): | ||
| @@ -64,34 +70,73 @@ def _get_loader_config( | ||
| "hasReplay": False, | ||
| "hasDebug": False, | ||
| "hasFeedback": False, | ||
| "hasLogsAndMetrics": False, | ||
| "userEnabledPerformance": False, | ||
| "userEnabledReplay": False, | ||
| "userEnabledFeedback": False, | ||
| "userEnabledLogsAndMetrics": False, | ||
| } | ||
| is_v7_sdk = sdk_version >= Version("7.0.0") and sdk_version < Version("8.0.0") | ||
| is_greater_or_equal_v7_sdk = sdk_version >= Version("7.0.0") | ||
| is_greater_or_equal_v10_sdk = sdk_version >= Version("10.0.0") | ||
| is_lazy = True | ||
| bundle_kind_modifier = "" | ||
| has_replay = get_dynamic_sdk_loader_option(key, DynamicSdkLoaderOption.HAS_REPLAY) | ||
| has_performance = get_dynamic_sdk_loader_option(key, DynamicSdkLoaderOption.HAS_PERFORMANCE) | ||
| has_debug = get_dynamic_sdk_loader_option(key, DynamicSdkLoaderOption.HAS_DEBUG) | ||
| has_feedback = get_dynamic_sdk_loader_option(key, DynamicSdkLoaderOption.HAS_FEEDBACK) | ||
| has_logs_and_metrics = get_dynamic_sdk_loader_option( | ||
| key, DynamicSdkLoaderOption.HAS_LOGS_AND_METRICS | ||
| ) | ||
| # Store the user's original preferences before we modify them for bundle selection. | ||
| # We only want to enable features that the user explicitly requested. | ||
| user_enabled_performance = has_performance | ||
| user_enabled_replay = has_replay | ||
| user_enabled_feedback = has_feedback | ||
| user_enabled_logs_and_metrics = has_logs_and_metrics | ||
| # The order in which these modifiers are added is important, as the | ||
| # bundle name is built up from left to right. | ||
| # https://docs.sentry.io/platforms/javascript/install/cdn/ | ||
| # Available bundles: bundle, bundle.tracing, bundle.replay, bundle.feedback, | ||
| # bundle.tracing.replay, bundle.tracing.replay.feedback | ||
| # Note: There is NO bundle.tracing.feedback or bundle.replay.feedback. | ||
| # If feedback is combined with tracing or replay, we must use the full bundle. | ||
| # Available bundles: | ||
| # - bundle (base) | ||
| # - bundle.feedback | ||
| # - bundle.logs.metrics | ||
| # - bundle.replay | ||
| # - bundle.replay.feedback | ||
| # - bundle.replay.logs.metrics | ||
| # - bundle.tracing | ||
| # - bundle.tracing.logs.metrics | ||
| # - bundle.tracing.replay | ||
| # - bundle.tracing.replay.feedback | ||
| # - bundle.tracing.replay.feedback.logs.metrics | ||
| # - bundle.tracing.replay.logs.metrics | ||
| # | ||
| # Note: There is NO bundle.tracing.feedback (tracing + feedback without replay). | ||
| # If feedback is combined with tracing (without replay), we must use the full bundle. | ||
| # | ||
| # Note: There is NO bundle.feedback.logs.metrics, bundle.tracing.feedback.logs.metrics, | ||
| # or bundle.replay.feedback.logs.metrics. If feedback is combined with logs+metrics, | ||
| # we must use the full bundle (tracing.replay.feedback.logs.metrics). | ||
| # Feedback bundles require SDK >= 7.85.0, but the frontend only allows selecting | ||
| # major versions (7.x, 8.x), which resolve to versions that support feedback. | ||
| feedback_with_other_features = has_feedback and (has_performance or has_replay) | ||
| # When feedback is combined with tracing or replay, we must serve the full bundle | ||
| # which includes all three features. Update the flags accordingly. | ||
| if is_greater_or_equal_v7_sdk and feedback_with_other_features: | ||
| # When feedback is combined with tracing (but not replay), we must serve the full bundle | ||
| # which includes tracing, replay, and feedback. Update the flags accordingly. | ||
| feedback_with_tracing_no_replay = has_feedback and has_performance and not has_replay | ||
| if is_greater_or_equal_v7_sdk and feedback_with_tracing_no_replay: | ||
| has_replay = True | ||
| # Logs and metrics bundles require SDK >= 10.0.0. | ||
| # When logs+metrics is combined with feedback, we must serve the full bundle | ||
| # (tracing.replay.feedback.logs.metrics) because there's no feedback.logs.metrics bundle. | ||
| logs_metrics_with_feedback = has_logs_and_metrics and has_feedback | ||
| if is_greater_or_equal_v10_sdk and logs_metrics_with_feedback: | ||
| has_performance = True | ||
| has_replay = True | ||
| @@ -109,11 +154,19 @@ def _get_loader_config( | ||
| bundle_kind_modifier += ".feedback" | ||
| is_lazy = False | ||
| if is_greater_or_equal_v10_sdk and has_logs_and_metrics: | ||
| bundle_kind_modifier += ".logs.metrics" | ||
| is_lazy = False | ||
| else: | ||
| # If SDK < 10.0.0, disable logs+metrics feature even if user requested it | ||
| has_logs_and_metrics = False | ||
| user_enabled_logs_and_metrics = False | ||
| # In JavaScript SDK version 7, the default bundle code is ES6, however, in the loader we | ||
| # want to provide the ES5 version. This is why we need to modify the requested bundle name here. | ||
| # | ||
| # If we are loading replay or feedback, do not add the es5 modifier, as those bundles are | ||
chargome marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # ES6 only. | ||
| # If we are loading replay or feedback, do not add the es5 modifier, as those bundles are ES6 only. | ||
| # Note: logs+metrics bundles don't exist for v7 (they require v10+) | ||
| if is_v7_sdk and not has_replay and not has_feedback: | ||
| bundle_kind_modifier += ".es5" | ||
| @@ -127,6 +180,11 @@ def _get_loader_config( | ||
| "hasReplay": has_replay, | ||
| "hasDebug": has_debug, | ||
| "hasFeedback": has_feedback, | ||
| "hasLogsAndMetrics": has_logs_and_metrics, | ||
| "userEnabledPerformance": user_enabled_performance, | ||
| "userEnabledReplay": user_enabled_replay, | ||
| "userEnabledFeedback": user_enabled_feedback, | ||
| "userEnabledLogsAndMetrics": user_enabled_logs_and_metrics, | ||
| } | ||
| def _get_context( | ||
| @@ -166,17 +224,21 @@ def _get_context( | ||
| if loader_config["hasDebug"]: | ||
| config["debug"] = True | ||
| if loader_config["hasPerformance"]: | ||
| # Only enable feature configs if the user explicitly enabled them, not just because | ||
| # we're loading a bundle that includes those features for compatibility reasons. | ||
| if loader_config["userEnabledPerformance"]: | ||
| config["tracesSampleRate"] = 1 | ||
| if loader_config["hasReplay"]: | ||
| if loader_config["userEnabledReplay"]: | ||
| config["replaysSessionSampleRate"] = 0.1 | ||
| config["replaysOnErrorSampleRate"] = 1 | ||
| # Although this is not a top-level SDK option we pass this flag so we can auto-add the integration in the loader template later | ||
| if loader_config["hasFeedback"]: | ||
| if loader_config["userEnabledFeedback"]: | ||
| config["autoInjectFeedback"] = True | ||
| if loader_config["userEnabledLogsAndMetrics"]: | ||
| config["enableLogs"] = True | ||
chargome marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return ( | ||
| { | ||
| "config": config, | ||
| @@ -227,6 +289,7 @@ def get( | ||
| has_replay=loader_config["hasReplay"], | ||
| has_debug=loader_config["hasDebug"], | ||
| has_feedback=loader_config["hasFeedback"], | ||
| has_logs_and_metrics=loader_config["hasLogsAndMetrics"], | ||
| sdk_version=str(sdk_version) if sdk_version else None, | ||
| tmpl=tmpl, | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.