Skip to content

Commit

Permalink
feat: Report config changes away from default state for UX improvement (
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-messiah authored Feb 12, 2024
1 parent 697f13e commit aa19a9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/common/config/state/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const model = () => {
autoStart: true,
enabled: false,
harvestTimeSeconds: 60,
sampling_rate: 50, // float from 0 - 100
error_sampling_rate: 50, // float from 0 - 100
sampling_rate: 10, // float from 0 - 100
error_sampling_rate: 100, // float from 0 - 100
collect_fonts: false, // serialize fonts for collection without public asset url, this is currently broken in RRWeb -- https://github.com/rrweb-io/rrweb/issues/1304. When fixed, revisit with test cases
inline_images: false, // serialize images for collection without public asset url -- right now this is only useful for testing as it easily generates payloads too large to be harvested
inline_stylesheet: true, // serialize css for collection without public asset url
Expand Down
20 changes: 14 additions & 6 deletions src/features/session_replay/aggregate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ export class Aggregate extends AggregateBase {
}
}, this.featureName, this.ee)

const errorSamplingRate = getConfigurationValue(this.agentIdentifier, 'session_replay.error_sampling_rate')
const samplingRate = getConfigurationValue(this.agentIdentifier, 'session_replay.sampling_rate')
const { error_sampling_rate, sampling_rate, autoStart, block_selector, mask_text_selector, mask_all_inputs, inline_stylesheet, inline_images, collect_fonts } = getConfigurationValue(this.agentIdentifier, 'session_replay')

this.waitForFlags(['sr']).then(([flagOn]) => {
this.entitled = flagOn
Expand All @@ -134,13 +133,22 @@ export class Aggregate extends AggregateBase {
handle(SUPPORTABILITY_METRIC_CHANNEL, ['SessionReplay/EnabledNotEntitled/Detected'], undefined, FEATURE_NAMES.metrics, this.ee)
}
this.initializeRecording(
(Math.random() * 100) < errorSamplingRate,
(Math.random() * 100) < samplingRate
(Math.random() * 100) < error_sampling_rate,
(Math.random() * 100) < sampling_rate
)
}).then(() => sharedChannel.onReplayReady(this.mode)) // notify watchers that replay started with the mode

handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/SamplingRate/Value', samplingRate], undefined, FEATURE_NAMES.metrics, this.ee)
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/ErrorSamplingRate/Value', errorSamplingRate], undefined, FEATURE_NAMES.metrics, this.ee)
/** Detect if the default configs have been altered and report a SM. This is useful to evaluate what the reasonable defaults are across a customer base over time */
if (!autoStart) handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/AutoStart/Modified'], undefined, FEATURE_NAMES.metrics, this.ee)
if (collect_fonts === true) handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/CollectFonts/Modified'], undefined, FEATURE_NAMES.metrics, this.ee)
if (inline_stylesheet !== true) handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/InlineStylesheet/Modified'], undefined, FEATURE_NAMES.metrics, this.ee)
if (inline_images === true) handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/InlineImages/Modifed'], undefined, FEATURE_NAMES.metrics, this.ee)
if (mask_all_inputs !== true) handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/MaskAllInputs/Modified'], undefined, FEATURE_NAMES.metrics, this.ee)
if (block_selector !== '[data-nr-block]') handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/BlockSelector/Modified'], undefined, FEATURE_NAMES.metrics, this.ee)
if (mask_text_selector !== '*') handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/MaskTextSelector/Modified'], undefined, FEATURE_NAMES.metrics, this.ee)

handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/SamplingRate/Value', sampling_rate], undefined, FEATURE_NAMES.metrics, this.ee)
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/ErrorSamplingRate/Value', error_sampling_rate], undefined, FEATURE_NAMES.metrics, this.ee)
this.drain()
}
}
Expand Down

0 comments on commit aa19a9c

Please sign in to comment.