Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTML5 Crittercism Code Snippets for Docs
// Save event handler with breadcrumb
$('#saveButton').click(function() {
savePlayerInfo();
Crittercism.leaveBreadcrumb("Save button clicked");
});
<!DOCTYPE html>
<html>
<head>
<title>Example Document without Crittercism</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://d1a62freaxhn7x.cloudfront.net/v1/crittercismClientLibraryMin.js"></script>
<script type="text/javascript">
$(document).ready(function() {
Crittercism.init({
appId: 'appId', // Example: 47cc67093475061e3d95369d
appVersion: '1.0', // Developer-provided application version
});
// Initialize event handlers here
});
</script>
</head>
<body>
<p>This document uses the Crittercism HTML5 library.</p>
</body>
</html>
Crittercism.setUsername("TomCritter").setValue('savedItems', 100);
try {
JSON.parse('this isnt valid json');
} catch(e) {
Crittercism.logHandledException(e);
}
// How long did the game take to load?
var gameLoadTime = getGameLoadTime();
Crittercism.setMetadata({
storedSprites: getStoredSprites(),
gameLoadTime: gameLoadTime,
virtualCurrencyBalance: 100
});
var gameLoadTime = getGameLoadTime();
Crittercism.setValue('gameLoadTime', gameLoadTime);
// Example login flow
var authenticatedUser = authenticateUser();
// Assume username is stored in authenticatedUser.username
Crittercism.setUsername(authenticatedUser.username);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment