-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
203 lines (186 loc) · 5.24 KB
/
index.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>IntegrationsJs Test Page</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body style="background-color: rgba(0, 45, 0, .5)">
<script>
(function() {
// create a queue
var integrations = window.integrations = window.integrations || [];
// Don't do this once loaded already
if (integrations.loaded) { return; }
// Ignore loading more that once
if (integrations.invoked) {
return;
}
// Prevent double load
integrations.invoked = true;
// Setup queue
integrations.methods = ['identify', 'setContext', 'set', 'get', 'do'];
integrations.factory = function (method) {
return function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(method);
integrations.push(args);
return integrations;
};
};
// load the js
for (var i = 0; i < integrations.methods.length; i++) {
var key = integrations.methods[i];
integrations[key] = integrations.factory(key);
}
integrations.load = function(siteId) {
integrations.siteId = siteId;
// Create an async script element
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = '/dev/bundle.js';
// Insert our script next to the first script element.
var first = document.getElementsByTagName('script')[0];
first.parentNode.insertBefore(script, first);
};
// Load
integrations.load('pk_demo_key');
// Identify the user
integrations.identify({
userId: '3234oji'
});
integrations.setContext({
people: [{
email: '[email protected]',
name: 'Jason Tokoph'
}],
title: 'Random Page',
description: 'Longer description',
datasets: {
foo: [['name','age'],['jason', 29]]
}
});
})();
</script>
<button id="all">All</button>
<button id="datasets">Datasets</button>
<button id="people">People</button>
<button id="basic">Basic</button>
<button id="toggle-people">Toggle People</button>
<button id="multiple-people">Multiple People</button>
<button id="none">None</button>
<script>
document.getElementById('all').addEventListener('click', function () {
integrations.setContext({
people: [{
email: '[email protected]',
name: 'Jason Tokoph'
}],
title: 'Random Page',
description: 'Longer description',
datasets: {
foo: [['name', 'age'], ['jason', 29]]
}
});
});
document.getElementById('none').addEventListener('click', function () {
integrations.setContext({});
});
document.getElementById('datasets').addEventListener('click', function() {
integrations.setContext({
datasets: {
Foo: [['name', 'age'], ['foo', 29]],
Bar: [['name', 'age'], ['bar', 33]]
}
});
});
document.getElementById('people').addEventListener('click', function () {
integrations.setContext({
people: [{
email: '[email protected]',
name: 'Jason Tokoph'
}],
});
});
document.getElementById('toggle-people').addEventListener('click', function () {
var options = [
{
email: '[email protected]',
name: 'Jason Tokoph'
},
{
email: '[email protected]'
},
{
email: '[email protected]'
}
];
integrations.setContext({
people: [options[Math.floor(Math.random()*options.length)]],
});
});
document.getElementById('multiple-people').addEventListener('click', function () {
integrations.setContext({
people: [{
email: '[email protected]',
name: 'Jason Tokoph'
}, {
email: '[email protected]'
}, {
email: '[email protected]'
}],
});
});
document.getElementById('basic').addEventListener('click', function () {
integrations.setContext({
title: 'Random Page',
description: 'Longer description',
});
});
</script>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
</body>
</html>