Skip to content

Commit 4a8876d

Browse files
committed
Move some tracking calls so they only happen on a user action. Couple other tracking updates.
1 parent f6cf14e commit 4a8876d

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

dev/src/Flavor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class Flavor extends EventDispatcher {
3737
set value(id) {
3838
let profile = profiles[(id && id.toLowerCase()) || "js"];
3939
if (!profile || profile === this._profile) { return; }
40-
Track.page("flavor/"+id);
40+
4141
this._profile = profile;
4242
this._buildSupportMap(profile);
4343
app.prefs.write("flavor", id);

dev/src/views/Expression.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default class Expression extends EventDispatcher {
6464

6565
set flags(flags) {
6666
flags = app.flavor.validateFlagsStr(flags);
67-
Track.event("set_flags", "engagement", {flags:flags});
6867
let str = this.editor.getValue(), index = str.lastIndexOf(this.delim);
6968
this.editor.replaceRange(flags, {line: 0, ch: index + 1}, {line: 0, ch: str.length }); // this doesn't work if readOnly is false.
7069
}
@@ -191,11 +190,13 @@ export default class Expression extends EventDispatcher {
191190
_onFlavorListChange() {
192191
app.tooltip.toggle.hide("flavor");
193192
app.flavor.value = this.flavorList.selected;
193+
Track.page("flavor/"+this.flavorList.selected);
194194
}
195195

196196
_onFlagListChange() {
197197
let sel = this.flagsList.selected;
198198
this.flags = sel ? sel.join("") : "";
199+
Track.event("set_flags", "engagement", this.flags);
199200
}
200201

201202
_onFlavorChange() {

dev/src/views/Sidebar.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export default class Sidebar {
6666
if (!item || item.id === "menu") { return; } // expand button on the min menu
6767
this.minimize(false);
6868
if (item.id) {
69-
Track.page("sidebar/"+item.id);
7069
if (item.id === "home" || (item.parent && item.parent.id === "home") || this._isInReference(item)) {
7170
app.prefs.write("side", item.id);
7271
}
@@ -152,7 +151,13 @@ export default class Sidebar {
152151
// list & content:
153152
this.listEl = $.query("> .list", this.fullEl);
154153
this.menuList = new List(this.listEl, {data:content.kids, template:this.menuListTemplate});
155-
this.menuList.on("change", ()=> this.show(this.menuList.selectedItem));
154+
this.menuList.on("change", () => {
155+
const lastId = this.curItem.id;
156+
this.show(this.menuList.selectedItem);
157+
if (lastId !== this.curItem.id) {
158+
Track.page("sidebar/"+this.curItem.id);
159+
}
160+
});
156161
this.menuList.on("dblclick", ()=> this._onDblClick(this.menuList.selectedItem));
157162
this.contentEl = $.query("> .content", this.fullEl);
158163

@@ -162,8 +167,8 @@ export default class Sidebar {
162167

163168
let template = $.template`<svg class="icon"><use xlink:href="#${"id"}"></use></svg>`;
164169
this.minList = new List($.query("> .list", this.minEl), {template});
165-
this.minList.on("change", (evt)=> { this.show(this.minList.selectedItem); evt.preventDefault(); });
166-
170+
this.minList.on("change", (evt)=> { this.show(this.minList.selectedItem); evt.preventDefault(); Track.page("sidebar/"+this.curItem.id); });
171+
167172
// set up special content:
168173
this.community = new Community($.query("#library > #community"));
169174
this.share = new Share($.query("#library > #share"));

dev/src/views/Text.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import TextHighlighter from "./TextHighlighter";
3232
import TextHover from "./TextHover";
3333
import EventDispatcher from "../events/EventDispatcher";
3434
import List from "../controls/List";
35+
import Track from "../utils/Track";
3536

3637
import app from "../app";
3738

@@ -155,6 +156,8 @@ export default class Text extends EventDispatcher {
155156
this.dispatchEvent("modechange");
156157
if (this.mode === "text") { this.editor.refresh(); }
157158
else { $.addClass(this.el, "tests-viewed"); }
159+
160+
Track.page("mode/"+this.mode);
158161
}
159162

160163
_setResult(val) {

dev/src/views/Tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export default class Tools extends EventDispatcher {
6969

7070
show(id) {
7171
if (!id || id === this._toolId) { return; }
72-
Track.page("tool/"+id);
7372

7473
this.toolList.selected = this._toolId = id;
7574
let input = (id === "replace" || id === "list");
@@ -138,6 +137,7 @@ export default class Tools extends EventDispatcher {
138137

139138
_handleListChange() {
140139
this.show(this.toolList.selected);
140+
Track.page("tool/"+this.toolList.selected);
141141
}
142142

143143
_handleHeaderClick(evt) {

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>RegExr: Learn, Build, &amp; Test RegEx</title>
66

77
<!-- Global Site Tag (gtag.js) - Google Analytics -->
8-
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
8+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-3579542-6"></script>
99
<script>
1010
window.dataLayer = window.dataLayer || [];
1111
function gtag(){dataLayer.push(arguments)};

0 commit comments

Comments
 (0)