Testing

In order to test your engines without affecting recommendations globally, you can create test users. Test users' events only affect their own recommendations, thus leaving your production data clean. Test users are created by setting the special user metadata field tmb_test_user to true.

If this field is later unset or set to false, the user will no longer be counted as a test-user, but you will need to retrain the engine in order for their past events to affect the engine (this may change in the future). Similarly, if you set the tmb_test_user of an existing user to true, retraining is required for any past events to be scrubbed from the engine's global model.

Make an existing user a test user

You can set existing users to test users with the update method. This is handy if your testing environment is setup such that it is easier to create a new user in your app and then test with that account.

Note that updating a user's metadata will overwrite the existing metadata object. If you are using other metadata fields, be sure to load and set the entire metadata object.

var tamber = require('tamber')('Mu6DUPXdDYe98cv5JIfX');

tamber.user.update({
	id: "user_rlox8k927z7p",
	metadata: {
		"tmb_test_user": true
	}
}, function(err, result) {
	if (err) throw err;
	done();
});
package main

import (
	tamber "github.com/tamber/tamber-go"
	"github.com/tamber/tamber-go/user"
	"fmt"
)

func main() {
	tamber.DefaultProjectKey = "Mu6DUPXdDYe98cv5JIfX"

	u, info, err := user.Update(&tamber.UserParams{
		Id: "user_rlox8k927z7p",
		Metadata: map[string]interface{}{
			"tmb_test_user": true,
		},
	})
}
require 'tamber'
Tamber.project_key = 'Mu6DUPXdDYe98cv5JIfX'

Tamber::User.update(
  :id => 'user_rlox8k927z7p',
  :metadata => {
    'tmb_test_user' => true
  }
)
$ curl https://api.tamber.com/v1/user/update \
	-u Mu6DUPXdDYe98cv5JIfX: \
	-d id=user_rlox8k927z7p \
	-d metadata='{"tmb_test_user": true}'
Tamber tamber = new Tamber("Mu6DUPXdDYe98cv5JIfX", "");

HashMap<String, Object> userParams = new HashMap<String, Object>();
userParams.put("id", "user_rlox8k927z7p");

HashMap<String, Object> metadata = new HashMap<String, Object>();
metadata.put("tmb_test_user", true);
userParams.put("metadata", metadata);

JSONObject resp = new JSONObject();
try {
    JSONObject resp = tamber.user.update(userParams);
} catch (TamberException e) {
    System.out.println(String.format("%s=%s", e.getClass().getName(), e.getMessage()));
}
import tamber

tamber.project_key = 'Mu6DUPXdDYe98cv5JIfX'

tamber.User.update(
    id='user_rlox8k927z7p',
    metadata={
        'tmb_test_user': True
    }
)

Create a test user

You may also create new users as test users.

var tamber = require('tamber')('Mu6DUPXdDYe98cv5JIfX');

tamber.user.create({
	id: "user_rlox8k927z7p",
	metadata: {
		"tmb_test_user": true
	}
}, function(err, result) {
	if (err) throw err;
	done();
});
package main

import (
	tamber "github.com/tamber/tamber-go"
	"github.com/tamber/tamber-go/user"
)

func main() {
	tamber.DefaultProjectKey = "Mu6DUPXdDYe98cv5JIfX"

	u, info, err := user.Create(&tamber.UserParams{
		Id: "user_rlox8k927z7p",
		Metadata: map[string]interface{}{
			"city": "Mountain View, CA",
			"age":  "55-65",
			"name": "Rob Pike",
		},
	})
}
require 'tamber'
Tamber.project_key = 'Mu6DUPXdDYe98cv5JIfX'

Tamber::User.create(
  :id => 'user_rlox8k927z7p',
  :metadata => {
    'tmb_test_user' => true
  }
)
$ curl https://api.tamber.com/v1/user/create \
	-u Mu6DUPXdDYe98cv5JIfX: \
	-d id=user_rlox8k927z7p \
	-d metadata='{"tmb_test_user": true}'
Tamber tamber = new Tamber("Mu6DUPXdDYe98cv5JIfX", "");

HashMap<String, Object> userParams = new HashMap<String, Object>();
userParams.put("id", "user_rlox8k927z7p");

HashMap<String, Object> metadata = new HashMap<String, Object>();
metadata.put("tmb_test_user", true);
userParams.put("metadata", metadata);

JSONObject resp = new JSONObject();
try {
    JSONObject resp = tamber.user.create(userParams);
} catch (TamberException e) {
    System.out.println(String.format("%s=%s", e.getClass().getName(), e.getMessage()));
}
import tamber

tamber.project_key = 'Mu6DUPXdDYe98cv5JIfX'

tamber.User.create(
    id='user_rlox8k927z7p',
    metadata={
        'tmb_test_user': True
    }
)