-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
132 lines (114 loc) · 3.39 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Tracey Demo</title>
<style type="text/tailwindcss">
html {
font-size: 20px;
}
section {
height: calc(100vh - 4rem);
background-color: #fafafa;
margin: 2rem;
padding: 2rem;
}
h1 {
@apply text-2xl;
}
h2 {
@apply text-xl;
}
p {
@apply mb-2;
}
</style>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<section>
<h1 data-tracey-name="first-section-heading">First section</h1>
<p>Welcome to this demo of Tracey</p>
</section>
<section>
<h2 data-tracey-name="second-section-heading">Second section</h2>
<p>
Welcome to the second section. This is some text to be captured by
Tracey.
</p>
</section>
<section>
<h2>Third section</h2>
<p>In this third section, we have a button to test interactions.</p>
<button>Click me</button>
</section>
<script src="./src/index.ts" type="module"></script>
<script type="module">
import { ClickAnalysis, IntersectionAnalysis, Tracey } from "./src";
const tracey = new Tracey({
debug: false,
breakpoints: {
base: 0,
px300: 300,
px500: 500,
px1000: 1000,
px1500: 1500,
},
producers: {
intersection: {
selectors: ["h1, h2"],
},
},
});
tracey.init();
window.TRACEY = window.TRACEY || {};
window.TRACEY.instance = tracey;
window.TRACEY.analytics = window.TRACEY.analytics || {};
window.TRACEY.analytics.IntersectionAnalysis = IntersectionAnalysis;
window.TRACEY.analytics.ClickAnalysis = ClickAnalysis;
console.log("");
console.log("Use window.TRACEY.instance to interact with Tracey");
console.log("Use window.TRACEY.analytics.* to create analysis classes");
console.log("");
const options = {
debug: true,
visualize: {
enabled: true,
interval: 500,
position: "element",
},
};
const [h1IntersectionAnalysis] =
window.TRACEY.analytics.IntersectionAnalysis.create(
"h1",
window.TRACEY.instance,
options,
);
h1IntersectionAnalysis.start();
const h2IntersectionAnalyses =
window.TRACEY.analytics.IntersectionAnalysis.create(
"h2",
window.TRACEY.instance,
options,
);
h2IntersectionAnalyses.forEach((analysis) => analysis.start());
const clickAnalysis = new window.TRACEY.analytics.ClickAnalysis(
window.TRACEY.instance,
options,
);
clickAnalysis.start();
window.TRACEY.analytics.h1IntersectionAnalysis = h1IntersectionAnalysis;
window.TRACEY.analytics.h2IntersectionAnalyses = h2IntersectionAnalyses;
window.TRACEY.analytics.clickAnalysis = clickAnalysis;
console.log("");
console.log(
"Use window.TRACEY.analytics.* or window.TRACEY.instance.analyses to interact with the analysis instances",
);
</script>
</body>
</html>