<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';

const BaseGroupingRule = require('./base');

const GROUPS = ['control', 'treatment'];

module.exports = class RecoveryKeyGroupingRule extends BaseGroupingRule {
  constructor() {
    super();
    this.name = 'recoveryKey';
    this.ROLLOUT_RATE = 0;
  }

  choose(subject) {
    if (! subject || ! subject.account || ! subject.uniqueUserId) {
      return false;
    }

    // Is feature enabled explicitly? ex. from `?showAccountRecovery=true` feature flag?
    if (subject.showAccountRecovery) {
      return 'treatment';
    }

    if (this.isTestEmail(subject.account.get('email'))) {
      return 'treatment';
    }

    // Are they apart of rollout?
    if (this.bernoulliTrial(this.ROLLOUT_RATE, subject.uniqueUserId)) {
      return this.uniformChoice(GROUPS, subject.uniqueUserId);
    }

    // Otherwise don't show panel
    return false;
  }
};
<commit_msg>fix(codes): enable recovery key for 10% users<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';

const BaseGroupingRule = require('./base');

const GROUPS = ['control', 'treatment'];

module.exports = class RecoveryKeyGroupingRule extends BaseGroupingRule {
  constructor() {
    super();
    this.name = 'recoveryKey';
    this.ROLLOUT_RATE = 0.1;
  }

  choose(subject) {
    if (! subject || ! subject.account || ! subject.uniqueUserId) {
      return false;
    }

    // Is feature enabled explicitly? ex. from `?showAccountRecovery=true` feature flag?
    if (subject.showAccountRecovery) {
      return 'treatment';
    }

    if (this.isTestEmail(subject.account.get('email'))) {
      return 'treatment';
    }

    // Are they apart of rollout?
    if (this.bernoulliTrial(this.ROLLOUT_RATE, subject.uniqueUserId)) {
      return this.uniformChoice(GROUPS, subject.uniqueUserId);
    }

    // Otherwise don't show panel
    return false;
  }
};

{'fraction_non_alphanumeric': 0.12444246208742195, 'fraction_numerical': 0.005798394290811775, 'mean_word_length': 3.1847014925373136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6099758', 'n_tokens_mistral': 713, 'n_tokens_neox': 678, 'n_words': 198}