Skip to content

Framework API

lib/framework.js is the experiment runtime. It is copied verbatim into every generated project and imported via the @lib/framework alias.

js
import { runScript, trackAAEvent, waitFor, watchFor, setupTracking } from '@lib/framework';

Exports

FunctionPurposeSince
runScript(fn)Wraps experiment entry point — ensures DOM is readyv2.0.0
waitFor(selectors, callback)Polls until CSS selectors match, then fires callbackv2.0.0
watchFor(selector, callback, options?)MutationObserver-based alternative to waitForv2.0.0
trackAAEvent(evar, event, data)Fires an Adobe Analytics event via the global s objectv2.0.0
setupTracking(container, options)Attaches click tracking to a rendered elementv2.0.0

Import alias

The alias @lib/framework is configured in vite.config.js:

js
resolve: {
    alias: {
        '@lib/framework': './lib/framework.js',
        '@components': './src/components/',
    },
},

You can import any of the five exports directly without a relative path.

Internal tool — Samsung / Sogody experimentation team