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
}
)
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
}
)