Skip to content

Commit b445ce8

Browse files
committed
update test page
1 parent 89cbd58 commit b445ce8

File tree

1 file changed

+23
-45
lines changed

1 file changed

+23
-45
lines changed

test/browser/amplitudejs2.html

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,29 @@
11
<html>
22
<!--<script src="src/amplitude-snippet.js" type="text/javascript"></script>-->
33
<script>
4-
(function(window, document) {
5-
var amplitude = window.amplitude || {'_q':[],'_iq':{}};
6-
var as = document.createElement('script');
7-
as.type = 'text/javascript';
8-
as.async = true;
9-
as.src = '/amplitude.js';
10-
as.onload = function() {if(window.amplitude.runQueuedFunctions) {window.amplitude.runQueuedFunctions();} else {console.log('[Amplitude] Error: could not load SDK');}};
11-
var s = document.getElementsByTagName('script')[0];
12-
s.parentNode.insertBefore(as, s);
13-
function proxy(obj, fn) {
14-
obj.prototype[fn] = function() {
15-
this._q.push([fn].concat(Array.prototype.slice.call(arguments, 0))); return this;
16-
};
17-
}
18-
var Identify = function() {this._q = []; return this;};
19-
var identifyFuncs = ['add', 'append', 'clearAll', 'prepend', 'set', 'setOnce', 'unset'];
20-
for (var i = 0; i < identifyFuncs.length; i++) {proxy(Identify,identifyFuncs[i]);}
21-
amplitude.Identify = Identify;
22-
var Revenue = function() {this._q = []; return this;};
23-
var revenueFuncs = ['setProductId', 'setQuantity', 'setPrice', 'setRevenueType', 'setEventProperties'];
24-
for (var j = 0; j < revenueFuncs.length; j++) {proxy(Revenue, revenueFuncs[j]);}
25-
amplitude.Revenue = Revenue;
26-
var funcs = ['init', 'logEvent', 'logRevenue', 'setUserId', 'setUserProperties',
27-
'setOptOut', 'setVersionName', 'setDomain', 'setDeviceId',
28-
'setGlobalUserProperties', 'identify', 'clearUserProperties',
29-
'setGroup', 'logRevenueV2', 'regenerateDeviceId',
30-
'logEventWithTimestamp', 'logEventWithGroups'];
31-
function setUpProxy(instance) {
32-
function proxyMain(fn) {
33-
instance[fn] = function() {
34-
instance._q.push([fn].concat(Array.prototype.slice.call(arguments, 0)));
35-
};
36-
}
37-
for (var k = 0; k < funcs.length; k++) {proxyMain(funcs[k]);}
38-
}
39-
setUpProxy(amplitude);
40-
amplitude.getInstance = function(instance) {
41-
instance = ((!instance || instance.length===0) ? '$default_instance' : instance).toLowerCase();
42-
if (!amplitude._iq.hasOwnProperty(instance)) {
43-
amplitude._iq[instance] = {'_q':[]}; setUpProxy(amplitude._iq[instance]);
44-
}
45-
return amplitude._iq[instance];
46-
};
47-
window.amplitude = amplitude;
48-
})(window, document);
4+
5+
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script")
6+
;r.type="text/javascript";r.async=true
7+
;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.7.0-min.gz.js"
8+
;r.onload=function(){if(e.amplitude.runQueuedFunctions){
9+
e.amplitude.runQueuedFunctions()}else{
10+
console.log("[Amplitude] Error: could not load SDK")}}
11+
;var i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)
12+
;function s(e,t){e.prototype[t]=function(){
13+
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}
14+
var o=function(){this._q=[];return this}
15+
;var a=["add","append","clearAll","prepend","set","setOnce","unset"]
16+
;for(var u=0;u<a.length;u++){s(o,a[u])}n.Identify=o;var c=function(){this._q=[]
17+
;return this}
18+
;var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]
19+
;for(var p=0;p<l.length;p++){s(c,l[p])}n.Revenue=c
20+
;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","logEventWithTimestamp","logEventWithGroups","setSessionId"]
21+
;function v(e){function t(t){e[t]=function(){
22+
e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}}
23+
for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){
24+
e=(!e||e.length===0?"$default_instance":e).toLowerCase()
25+
;if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]}
26+
;e.amplitude=n})(window,document);
4927

5028

5129
var setUserId = function() {

0 commit comments

Comments
 (0)