nuxt-error-tracker 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/plugin.client.js +11 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -115,6 +115,13 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
115
115
|
"unhandledrejection",
|
|
116
116
|
(event) => capture(event.reason, "promise")
|
|
117
117
|
);
|
|
118
|
+
const formatDataAttrs = (el) => {
|
|
119
|
+
const dataset = el.dataset;
|
|
120
|
+
if (!dataset) return "";
|
|
121
|
+
return Object.entries(dataset).slice(0, 5).map(
|
|
122
|
+
([k, v]) => `data-${k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}=${(v ?? "").slice(0, 40)}`
|
|
123
|
+
).join(" ");
|
|
124
|
+
};
|
|
118
125
|
document.addEventListener(
|
|
119
126
|
"click",
|
|
120
127
|
(event) => {
|
|
@@ -123,11 +130,12 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
123
130
|
const tag = el.tagName.toLowerCase();
|
|
124
131
|
const id = el.id ? `#${el.id}` : "";
|
|
125
132
|
const cls = typeof el.className === "string" && el.className ? `.${el.className.trim().split(/\s+/).slice(0, 2).join(".")}` : "";
|
|
133
|
+
const dataAttrs = formatDataAttrs(el);
|
|
126
134
|
const text = (el.textContent ?? "").trim().slice(0, 40);
|
|
127
135
|
addCrumb({
|
|
128
136
|
type: "click",
|
|
129
137
|
category: "ui.click",
|
|
130
|
-
message: `${tag}${id}${cls}${text ? ` "${text}"` : ""}`
|
|
138
|
+
message: `${tag}${id}${cls}${dataAttrs ? ` [${dataAttrs}]` : ""}${text ? ` "${text}"` : ""}`
|
|
131
139
|
});
|
|
132
140
|
},
|
|
133
141
|
{ capture: true, passive: true }
|
|
@@ -161,10 +169,11 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
161
169
|
if (!raw) return;
|
|
162
170
|
value = raw.length > 100 ? `${raw.slice(0, 100)}\u2026` : raw;
|
|
163
171
|
}
|
|
172
|
+
const dataAttrs = formatDataAttrs(el);
|
|
164
173
|
addCrumb({
|
|
165
174
|
type: "input",
|
|
166
175
|
category: "ui.input",
|
|
167
|
-
message: `${fieldLabel(el)} = ${value}`
|
|
176
|
+
message: `${fieldLabel(el)}${dataAttrs ? ` [${dataAttrs}]` : ""} = ${value}`
|
|
168
177
|
});
|
|
169
178
|
} catch {
|
|
170
179
|
}
|