Skip to content

Active session recordings should respect changes in config.disable_persistence #541

Description

@bhamiltoncx

Here's where SessionRecording is instantiated. It reads config.disable_persistence only once at init time:

var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
// each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
this.batcher = new RequestBatcher(this.batcherKey, {
errorReporter: this.reportError.bind(this),
flushOnlyOnInterval: true,
libConfig: RECORDER_BATCHER_LIB_CONFIG,
sendRequestFunc: this.flushEventsWithOptOut.bind(this),
queueStorage: this.queueStorage,
sharedLockStorage: options.sharedLockStorage,
usePersistence: usePersistence,

It's instantiated here when startRecording() is invoked:

this.activeRecording = new SessionRecording(sessionRecordingOptions);

But nothing calls into active SessionRecordings when mixpanel.set_config() is called to update changes to config.disable_persistence:

MixpanelLib.prototype.set_config = function(config) {
if (_.isObject(config)) {
_.extend(this['config'], config);
var new_batch_size = config['batch_size'];
if (new_batch_size) {
_.each(this.request_batchers, function(batcher) {
batcher.resetBatchSize();
});
}
if (!this.get_config('persistence_name')) {
this['config']['persistence_name'] = this['config']['cookie_name'];
}
if (!this.get_config('disable_persistence')) {
this['config']['disable_persistence'] = this['config']['disable_cookie'];
}
if (this['persistence']) {
this['persistence'].update_config(this['config']);
}
Config.DEBUG = Config.DEBUG || this.get_config('debug');
if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
this.autocapture.init();
}
}
};

To correctly handle consent changes (e.g., for EU GDPR users who have to provide explicit consent), I would expect changes to config.disable_persistence to be propagated to any active SessionRecording s in flight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions