|
| 1 | +<html> |
| 2 | +<!--<script src="src/amplitude-snippet.js" type="text/javascript"></script>--> |
| 3 | +<script src='require.js' type='text/javascript'></script> |
| 4 | +<script> |
| 5 | + require(['../../amplitude.js'], function(amplitude) { |
| 6 | + amplitude.init('a2dbce0e18dfe5f8e74493843ff5c053', null, {includeReferrer: true}, function() { |
| 7 | + alert(amplitude.options.deviceId); |
| 8 | + }); |
| 9 | + |
| 10 | + window.amplitude = amplitude; |
| 11 | + }); |
| 12 | + |
| 13 | + var setUserId = function() { |
| 14 | + var userId = prompt('Input userId', 'user01'); |
| 15 | + amplitude.setUserId(userId); |
| 16 | + }; |
| 17 | + var setEventUploadThreshold = function() { |
| 18 | + var eventUploadThreshold = parseInt(prompt('Input eventUploadThreshold', 5)); |
| 19 | + amplitude.options.eventUploadThreshold = eventUploadThreshold; |
| 20 | + }; |
| 21 | + var logEvent = function() { |
| 22 | + var event = prompt('Input event type', 'clicked'); |
| 23 | + amplitude.logEvent(event); |
| 24 | + }; |
| 25 | + var setCity = function() { |
| 26 | + var city = prompt('Input city', 'San Francisco, CA'); |
| 27 | + amplitude.setUserProperties({city: city}); |
| 28 | + }; |
| 29 | + var addToPhotoCount = function() { |
| 30 | + var photoCount = parseInt(prompt('Input amount to increment photo count by', '2'), 10); |
| 31 | + amplitude.identify(new amplitude.Identify().add('photoCount', photoCount)); |
| 32 | + }; |
| 33 | + var clickOnLinkA = function() { |
| 34 | + amplitude.logEvent('Clicked on link A', null, function() { window.location='https://www.google.com'; }); |
| 35 | + }; |
| 36 | + var setPhotoCount = function() { |
| 37 | + var photoCount = parseInt(prompt('Input photo count to set', '2'), 10); |
| 38 | + amplitude.identify(new amplitude.Identify().set('photoCount', photoCount)); |
| 39 | + }; |
| 40 | + var setOncePhotoCount = function() { |
| 41 | + var photoCount = parseInt(prompt('Input photo count to setOnce', '2'), 10); |
| 42 | + amplitude.identify(new amplitude.Identify().setOnce('photoCount', photoCount)); |
| 43 | + }; |
| 44 | +</script> |
| 45 | + |
| 46 | +<body> |
| 47 | +<h3>Amplitude JS Test with RequireJS</h3> |
| 48 | +<ul> |
| 49 | + <li><a href="javascript:setUserId();">Set user ID</a></li> |
| 50 | + <li><a href="javascript:amplitude.setOptOut(!amplitude.options.optOut);">Toggle opt out</a></li> |
| 51 | + <li><a href="javascript:logEvent();">Log event</a></li> |
| 52 | + <li><a href="javascript:amplitude.logEvent('clicked button', {color: 'red;', shape: 'triangle', sides: 3});">Log |
| 53 | + event with event properties</a></li> |
| 54 | + <li><a href="javascript:amplitude.setUserProperties({age: 30, city: 'San Francisco, CA'});">Set user properties</a></li> |
| 55 | + <li><a href="javascript:amplitude.options.batchEvents = !amplitude.options.batchEvents;">Toggle batch events</a></li> |
| 56 | + <li><a href="javascript:setEventUploadThreshold();">Set event upload threshold</a></li> |
| 57 | + <li><a href="javascript:clickOnLinkA();">Click on link A</a></li> |
| 58 | + <br><br>Testing Identify calls<br> |
| 59 | + <li><a href="javascript:addToPhotoCount();">Add to photo count</a></li> |
| 60 | + <li><a href="javascript:amplitude.identify(new amplitude.Identify().unset('photoCount'));">Unset photo count</a></li> |
| 61 | + <li><a href="javascript:setPhotoCount();">Set photo count</a></li> |
| 62 | + <li><a href="javascript:setOncePhotoCount();">Set photo count once</a></li> |
| 63 | + <li><a href="javascript:setCity();">Set city via setUserProperties</a></li> |
| 64 | + <li><a href="javascript:amplitude.clearUserProperties();">Clear all user properties</a></li> |
| 65 | + <br><br> |
| 66 | + <li><a href="/test/browser/amplitudejs2.html">Go to second page</a></li> |
| 67 | +</body> |
| 68 | +</html> |
0 commit comments