At Wix, we created a BackOffice application to manage our experiments and specs. Our Product Managers have full access to this BackOffice and can create any user experience they like.

Creating Your BackOffice Application

In this section, we will show you how to link your BackOffice application to Petri.

Note: If you prefer to write your BackOffice in a non-JVM language, read more here.

Add petri-core dependency to your POM.xml

<dependency>
	<groupId>com.wixpress.common</groupId>
    <artifactId>wix-petri-core</artifactId>
</dependency>

Create an instance of FullPetriClient pointing to your Petri Server

FullPetriClient  petriClient = PetriRPCClient.makeFullClientFor("http://localhost:9901/petri");

Create a spec definition for your experiment

Better yet, read this, then add the specs to your code and trigger spec scanning when needed.

private  void createSpec(String specKey, List<String> testGroupValues, String scopeName) {
        petriClient.addSpecs(asList(
                aNewlyGeneratedExperimentSpec(specKey).
                        withTestGroups(testGroupValues).
                        withScopes(aScopeDefinitionOnlyForLoggedInUsers(scopeName)).
                        build()));
}

Create an experiment

private  void createExperiment(String specKey, List<TestGroup> testGroups, boolean onlyForLoggedIn) {
        DateTime now = new DateTime();
        petriClient.insertExperiment(
                anExperimentSnapshot().
                        withStartDate(now.minusMinutes(1)).
                        withEndDate(now.plusYears(1)).
                        withKey(specKey).
                        withGroups(testGroups).
                        withOnlyForLoggedInUsers(onlyForLoggedIn).
                        build());
    }