Snippets Collections
import BaseTreatment, { teardownWithOptimizelyPages } from 'cromedics/classes/BaseTreatment';
import { pages } from 'optimizely.json';


class BasicTreatment extends BaseTreatment {
  constructor(variation) {
    super();
    this.variation = variation;
    teardownWithOptimizelyPages(this, pages);
  }
  apply() {
    super.apply();
    this.applyClass(TAG + this.variation); 

// code here
// use this.variation to access variation variable
//

  }
  teardown() {
    super.teardown();
  }
}

SHARED.applyTreatment = (variation) => {
  SHARED.treatment = SHARED.treatment || (SHARED.treatment = new BasicTreatment(variation));
  SHARED.treatment.on();
};
star

Tue Feb 28 2023 23:02:34 GMT+0000 (Coordinated Universal Time)

#teardown #base #treatment

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension