forked from treasure-data/td-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.js
35 lines (31 loc) · 1010 Bytes
/
loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(function (n, c) {
if (c[n] === void 0) {
c[n] = function () {
c[n].clients.push(this)
this._init = [Array.prototype.slice.call(arguments)]
}
c[n].clients = []
var action = function (method) {
return function () {
this['_' + method] = this['_' + method] || []
this['_' + method].push(Array.prototype.slice.call(arguments))
return this
}
}
var methods = ['addRecord', 'fetchGlobalID', 'set', 'trackEvent', 'trackPageview', 'trackClicks', 'ready']
for (var i = 0; i < methods.length; i++) {
var method = methods[i]
c[n].prototype[method] = action(method)
}
var s = document.createElement('script')
s.type = 'text/javascript'
s.async = !0
s.src = (
document.location.protocol === 'https:'
? 'https:'
: 'http:'
) + '//cdn.treasuredata.com/sdk/@VERSION/td.min.js'
var t = document.getElementsByTagName('script')[0]
t.parentNode.insertBefore(s, t)
}
})('@GLOBAL', this)