-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample.html
292 lines (287 loc) · 16.2 KB
/
sample.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script>
; (function (p, l, o, w, i, n, g) { if (!p[i]) { p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || []; p.GlobalSnowplowNamespace.push(i); p[i] = function () { (p[i].q = p[i].q || []).push(arguments) }; p[i].q = p[i].q || []; n = l.createElement(o); g = l.getElementsByTagName(o)[0]; n.async = 1; n.src = w; g.parentNode.insertBefore(n, g) } }(window, document, "script", "https://cdn.jsdelivr.net/npm/@snowplow/javascript-tracker@3.9.0/dist/sp.min.js", "spget"));
; (function (p, l, o, w, i, n, g) { if (!p[i]) { p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || []; p.GlobalSnowplowNamespace.push(i); p[i] = function () { (p[i].q = p[i].q || []).push(arguments) }; p[i].q = p[i].q || []; n = l.createElement(o); g = l.getElementsByTagName(o)[0]; n.async = 1; n.src = w; g.parentNode.insertBefore(n, g) } }(window, document, "script", "https://cdn.jsdelivr.net/npm/@snowplow/javascript-tracker@3.9.0/dist/sp.min.js", "sppost"));
</script>
<script>
// GET tracker
let contextEntity = {
schema: 'iglu:io.silverton/buz/example/user/v1.0.json',
data: { userid: 1234, name: 'John Doe' }
};
window.spget('newTracker', 'sp', 'localhost:8081', {
appId: 'site',
eventMethod: 'get',
cookieName: "sp-nuid",
cookieSameSite: 'Lax',
forceSecureTracker: false,
withCredentials: false,
});
window.spget('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-link-click-tracking@latest/dist/index.umd.min.js", ["snowplowLinkClickTracking", "LinkClickTrackingPlugin"]);
window.spget('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-ecommerce@latest/dist/index.umd.min.js", ["snowplowEcommerce", "EcommercePlugin"]);
window.spget('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-performance-timing@latest/dist/index.umd.min.js", ["snowplowPerformanceTiming", "PerformanceTimingPlugin"]);
window.spget('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-client-hints@latest/dist/index.umd.min.js", ["snowplowClientHints", "ClientHintsPlugin"]);
window.spget('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-geolocation@latest/dist/index.umd.min.js", ["snowplowGeolocation", "GeolocationtPlugin"], [false]);
window.spget('addGlobalContexts', [contextEntity]);
window.spget('setUserId', 'someone@demo.com');
window.spget('enableFormTracking');
window.spget('trackPageView');
window.spget('enableActivityTracking', {
minimumVisitLength: 10,
heartbeatDelay: 10
});
// POST tracker
window.sppost('newTracker', 'sp', 'localhost:8081', {
appId: 'site',
eventMethod: 'post',
bufferSize: 1,
cookieSameSite: 'Lax',
forceSecureTracker: false,
withCredentials: false
})
window.sppost('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-link-click-tracking@latest/dist/index.umd.min.js", ["snowplowLinkClickTracking", "LinkClickTrackingPlugin"]);
window.sppost('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-ecommerce@latest/dist/index.umd.min.js", ["snowplowEcommerce", "EcommercePlugin"]);
window.sppost('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-performance-timing@latest/dist/index.umd.min.js", ["snowplowPerformanceTiming", "PerformanceTimingPlugin"]);
window.sppost('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-client-hints@latest/dist/index.umd.min.js", ["snowplowClientHints", "ClientHintsPlugin"]);
window.sppost('addPlugin', "https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-geolocation@latest/dist/index.umd.min.js", ["snowplowGeolocation", "GeolocationtPlugin"], [false]);
window.sppost('addGlobalContexts', [contextEntity]);
window.sppost('enableActivityTracking', {
minimumVisitLength: 1,
heartbeatDelay: 1
});
window.sppost('trackPageView');
window.sppost('setUserId', 'someone@demo.com');
window.sppost('enableFormTracking');
</script>
</head>
<body>
<nav class="flex items-center justify-between flex-wrap bg-amber-500 p-6">
<div class="flex items-center flex-shrink-0 text-white mr-8">
<span class="font-semibold text-xl tracking-tight">Buz</span>
</div>
<div class="w-full block flex-grow lg:flex lg:items-center lg:w-auto">
<div class="text-md lg:flex-grow">
<a href="https://buz.dev/" target="_blank"
class="block mt-4 lg:inline-block lg:mt-0 text-white hover:text-white mr-4">
Documentation
</a>
<a href="https://github.com/silverton-io/buz" target="_blank"
class="block mt-4 lg:inline-block lg:mt-0 text-white hover:text-white mr-4">
Github
</a>
</div>
</div>
</nav>
<div class="container mx-auto px-16 pt-4 snowplow-get">
<h1 class="font-semibold text-xl">GET-based Snowplow Events</h1>
</div>
<div class="container mx-auto px-16 py-8 snowplow-get">
<div class="grid grid-cols-4 gap-4">
<button
class="bg-transparent hover:bg-green-600 text-green-800 font-semibold hover:text-white py-2 px-4 border border-green-600 hover:border-transparent rounded"
id="self-describing-get">Valid Self-Describing Event</button>
<button
class="bg-transparent hover:bg-red-600 text-red-800 font-semibold hover:text-white py-2 px-4 border border-red-600 hover:border-transparent rounded"
id="self-describing-get-invalid">Invalid Self-Describing Event</button>
<button
class="bg-transparent hover:bg-violet-600 text-violet-800 font-semibold hover:text-white py-2 px-4 border border-violet-600 hover:border-transparent rounded"
id="struct-get">Struct Event</button>
<button
class="bg-transparent hover:bg-sky-600 text-sky-800 font-semibold hover:text-white py-2 px-4 border border-sky-600 hover:border-transparent rounded"
id="transaction-get">Transaction Event</button>
</div>
</div>
<div class="container mx-auto px-16 pt-4 snowplow-post">
<h1 class="font-semibold text-xl">POST-based Snowplow Events (batched using tracker bufferSize)</h1>
</div>
<div class="container mx-auto px-16 py-8 snowplow-post">
<div class="grid grid-cols-4 gap-4">
<button
class="bg-transparent hover:bg-green-800 text-green-800 font-semibold hover:text-white py-2 px-4 border border-green-600 hover:border-transparent rounded"
id="self-describing-post">Valid Self-Describing Event</button>
<button
class="bg-transparent hover:bg-red-800 text-red-800 font-semibold hover:text-white py-2 px-4 border border-red-600 hover:border-transparent rounded"
id="self-describing-post-invalid">Invalid Self-Describing Event</button>
<button
class="bg-transparent hover:bg-violet-800 text-violet-800 font-semibold hover:text-white py-2 px-4 border border-violet-600 hover:border-transparent rounded"
id="struct-post">Struct Event</button>
<button
class="bg-transparent hover:bg-sky-800 text-sky-800 font-semibold hover:text-white py-2 px-4 border border-sky-600 hover:border-transparent rounded"
id="transaction-post">Transaction Event</button>
</div>
</div>
<!-- <div class="container mx-auto px-16 pt-4 snowplow-post">
<h1 class="font-semibold text-xl">POST-based Cloud Events</h1>
</div>
<div class="container mx-auto px-16 py-8 cloudevents-post">
<div class="grid grid-cols-4 gap-4">
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded">Valid Cloudevent</button>
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded">Invalid Cloudevent</button>
</div>
</div>
<div class="container mx-auto px-16 pt-4 snowplow-post">
<h1 class="font-semibold text-xl">POST-based Generic Self-Describing</h1>
</div>
<div class="container mx-auto px-16 py-8">
<div class="grid grid-cols-4 gap-4">
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded">Valid Self Describing Event</button>
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded">Invalid Self Describing Event</button>
</div>
</div> -->
<!-- <div class="container mx-auto px-16 pt-4 snowplow-post">
<h1 class="font-semibold text-xl">Honeypot Relay Event</h1>
</div>
<div class="container mx-auto px-16 py-8 cloudevents-post">
<div class="grid grid-cols-4 gap-4">
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded">Invalid Relay Envelope</button>
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded">Valid Relay Envelope</button>
</div>
</div>
<div class="container mx-auto px-16 pt-4">
<h1 class="font-semibold text-xl">Webhook</h1>
</div>
<div class="container mx-auto px-16 py-8">
<div class="grid grid-cols-4 gap-4">
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded" id="webhook-named">Webhook with ID</button>
<button class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded" id="webhook-unnamed">Webhook without ID</button>
</div>
</div> -->
<footer>
<script>
// GET-based snowplow
document.getElementById('self-describing-get').addEventListener("click", function () {
window.spget('trackSelfDescribingEvent', {
event: {
schema: 'iglu:io.silverton/buz/example/productView/v1.0.json',
data: {
productId: 'ASO01043',
category: 'Dresses',
brand: 'ACME',
returning: true,
price: 49.95,
sizes: ['xs', 's', 'l', 'xl', 'xxl'],
availableSince: new Date(2013, 3, 7)
}
}
});
});
document.getElementById('self-describing-get-invalid').addEventListener("click", function () {
window.spget('trackSelfDescribingEvent', {
event: {
schema: 'iglu:io.silverton/buz/example/productView/v1.0.json',
data: {
productId: 'ASO01043',
category: 'Dresses',
brand: 'ACME',
returning: null,
sizes: ['xs', 's', 'l', 'xl', 'xxl'],
anotherProp: "whatevers"
}
}
});
});
document.getElementById('struct-get').addEventListener("click", function () {
window.spget('trackStructEvent', {
category: "ui",
action: "clicked-button",
label: "struct-event",
property: "someprop",
value: 118.99
})
});
document.getElementById('transaction-get').addEventListener("click", function () {
window.spget('addTrans', {
orderId: '1234', // required
total: 11.99, // required
affiliation: 'Acme Clothing',
tax: 1.29,
shipping: 5,
city: 'San Jose',
state: 'California',
country: 'USA',
currency: 'USD'
})
window.spget('addItem', {
orderId: '1234', // required
sku: 'DD44', // required
name: 'T-Shirt',
category: 'Green Medium',
price: 11.99,
quantity: 1,
currency: 'USD'
});
window.spget('trackTrans');
});
// POST-based snowplow
document.getElementById('self-describing-post').addEventListener("click", function () {
window.sppost('trackSelfDescribingEvent', {
event: {
schema: 'iglu:io.silverton/buz/example/productView/v1.0.json',
data: {
productId: 'ASO01043',
category: 'Dresses',
brand: 'ACME',
returning: true,
price: 49.95,
sizes: ['xs', 's', 'l', 'xl', 'xxl'],
availableSince: new Date(2013, 3, 7)
}
}
});
});
document.getElementById('self-describing-post-invalid').addEventListener("click", function () {
window.sppost('trackSelfDescribingEvent', {
event: {
schema: 'iglu:io.silverton/buz/example/productView/v1.0.json',
data: {
productId: 'ASO01043',
category: 'Dresses',
brand: 'ACME',
returning: null,
sizes: ['xs', 's', 'l', 'xl', 'xxl'],
anotherProp: "whatevers" // Additional properties not allowed
}
}
});
});
document.getElementById('struct-post').addEventListener("click", function () {
window.sppost('trackStructEvent', {
category: "ui",
action: "clicked-button",
label: "struct-event",
property: "someprop",
value: 10.0
})
});
document.getElementById('transaction-post').addEventListener("click", function () {
window.sppost('addTrans', {
orderId: '1234', // required
total: 11.99, // required
affiliation: 'Acme Clothing',
tax: 1.29,
shipping: 5,
city: 'San Jose',
state: 'California',
country: 'USA',
currency: 'USD'
})
window.sppost('addItem', {
orderId: '1234', // required
sku: 'DD44', // required
name: 'T-Shirt',
category: 'Green Medium',
price: 11.99,
quantity: 1,
currency: 'USD'
});
window.sppost('trackTrans');
});
</script>
</footer>
</body>
</html>