@grainql/analytics-web 2.7.0 → 2.7.1
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/cjs/heatmap-tracking.d.ts.map +1 -1
- package/dist/cjs/heatmap-tracking.js +2 -1
- package/dist/cjs/heatmap-tracking.js.map +1 -1
- package/dist/cjs/interaction-tracking.d.ts.map +1 -1
- package/dist/cjs/interaction-tracking.js +2 -1
- package/dist/cjs/interaction-tracking.js.map +1 -1
- package/dist/cjs/text-utils.d.ts +14 -0
- package/dist/cjs/text-utils.d.ts.map +1 -0
- package/dist/cjs/text-utils.js +49 -0
- package/dist/cjs/text-utils.js.map +1 -0
- package/dist/esm/heatmap-tracking.d.ts.map +1 -1
- package/dist/esm/heatmap-tracking.js +2 -1
- package/dist/esm/heatmap-tracking.js.map +1 -1
- package/dist/esm/interaction-tracking.d.ts.map +1 -1
- package/dist/esm/interaction-tracking.js +2 -1
- package/dist/esm/interaction-tracking.js.map +1 -1
- package/dist/esm/text-utils.d.ts +14 -0
- package/dist/esm/text-utils.d.ts.map +1 -0
- package/dist/esm/text-utils.js +45 -0
- package/dist/esm/text-utils.js.map +1 -0
- package/dist/heatmap-tracking.d.ts.map +1 -1
- package/dist/heatmap-tracking.js +2 -1
- package/dist/index.global.dev.js +25 -3
- package/dist/index.global.dev.js.map +3 -3
- package/dist/index.global.js +2 -2
- package/dist/index.global.js.map +4 -4
- package/dist/interaction-tracking.d.ts.map +1 -1
- package/dist/interaction-tracking.js +2 -1
- package/dist/text-utils.d.ts +14 -0
- package/dist/text-utils.d.ts.map +1 -0
- package/dist/text-utils.js +49 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction-tracking.d.ts","sourceRoot":"","sources":["../src/interaction-tracking.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"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O,CAAC,sBAAsB;IAkB9B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyC1B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA0B7B;;OAEG;IACH,OAAO,CAAC,eAAe;IA+BvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAWvB;;OAEG;IACH,OAAO,CAAC,GAAG;IAMX;;OAEG;IACH,kBAAkB,CAAC,YAAY,EAAE,iBAAiB,EAAE,GAAG,IAAI;IAoB3D;;OAEG;IACH,OAAO,IAAI,IAAI;CA4BhB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.InteractionTrackingManager = void 0;
|
|
8
|
+
const text_utils_1 = require("./text-utils");
|
|
8
9
|
class InteractionTrackingManager {
|
|
9
10
|
constructor(tracker, interactions, config = {}) {
|
|
10
11
|
this.isDestroyed = false;
|
|
@@ -91,7 +92,7 @@ class InteractionTrackingManager {
|
|
|
91
92
|
interaction_description: interaction.description,
|
|
92
93
|
interaction_priority: interaction.priority,
|
|
93
94
|
element_tag: element.tagName?.toLowerCase(),
|
|
94
|
-
element_text:
|
|
95
|
+
element_text: (0, text_utils_1.cleanElementText)(element.textContent),
|
|
95
96
|
element_id: element.id || undefined,
|
|
96
97
|
element_class: element.className || undefined,
|
|
97
98
|
...(isNavigationLink && { href: element.href }),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text utility functions for cleaning and processing text content
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Remove emojis and other Unicode symbols from text
|
|
6
|
+
* This regex matches emoji ranges and other Unicode symbols
|
|
7
|
+
*/
|
|
8
|
+
export declare function removeEmojis(text: string | null | undefined): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Clean and truncate text content for event tracking
|
|
11
|
+
* Removes emojis, trims whitespace, and limits length
|
|
12
|
+
*/
|
|
13
|
+
export declare function cleanElementText(text: string | null | undefined, maxLength?: number): string | undefined;
|
|
14
|
+
//# sourceMappingURL=text-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-utils.d.ts","sourceRoot":"","sources":["../src/text-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAwBhF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM,GAAG,SAAS,CAO7G"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Text utility functions for cleaning and processing text content
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.removeEmojis = removeEmojis;
|
|
7
|
+
exports.cleanElementText = cleanElementText;
|
|
8
|
+
/**
|
|
9
|
+
* Remove emojis and other Unicode symbols from text
|
|
10
|
+
* This regex matches emoji ranges and other Unicode symbols
|
|
11
|
+
*/
|
|
12
|
+
function removeEmojis(text) {
|
|
13
|
+
if (!text)
|
|
14
|
+
return undefined;
|
|
15
|
+
// Remove emojis and other Unicode symbols
|
|
16
|
+
// This regex covers:
|
|
17
|
+
// - Emoticons (😀-🙏)
|
|
18
|
+
// - Miscellaneous Symbols and Pictographs (🀀-)
|
|
19
|
+
// - Supplemental Symbols and Pictographs (🈀-)
|
|
20
|
+
// - Transport and Map Symbols (🚀-)
|
|
21
|
+
// - Enclosed characters (Ⓜ-⓿)
|
|
22
|
+
// - Regional indicator symbols (🇦-🇿)
|
|
23
|
+
// - Other Unicode symbol ranges
|
|
24
|
+
return text
|
|
25
|
+
.replace(/[\u{1F300}-\u{1F9FF}]/gu, '') // Miscellaneous Symbols and Pictographs
|
|
26
|
+
.replace(/[\u{1F600}-\u{1F64F}]/gu, '') // Emoticons
|
|
27
|
+
.replace(/[\u{1F680}-\u{1F6FF}]/gu, '') // Transport and Map Symbols
|
|
28
|
+
.replace(/[\u{2600}-\u{26FF}]/gu, '') // Miscellaneous Symbols
|
|
29
|
+
.replace(/[\u{2700}-\u{27BF}]/gu, '') // Dingbats
|
|
30
|
+
.replace(/[\u{1F900}-\u{1F9FF}]/gu, '') // Supplemental Symbols and Pictographs
|
|
31
|
+
.replace(/[\u{1F1E0}-\u{1F1FF}]/gu, '') // Regional Indicator Symbols (flags)
|
|
32
|
+
.replace(/[\u{200D}]/gu, '') // Zero Width Joiner
|
|
33
|
+
.replace(/[\u{FE0F}]/gu, '') // Variation Selector-16
|
|
34
|
+
.replace(/[\u{20E3}]/gu, '') // Combining Enclosing Keycap
|
|
35
|
+
.trim();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Clean and truncate text content for event tracking
|
|
39
|
+
* Removes emojis, trims whitespace, and limits length
|
|
40
|
+
*/
|
|
41
|
+
function cleanElementText(text, maxLength = 100) {
|
|
42
|
+
if (!text)
|
|
43
|
+
return undefined;
|
|
44
|
+
const cleaned = removeEmojis(text);
|
|
45
|
+
if (!cleaned)
|
|
46
|
+
return undefined;
|
|
47
|
+
return cleaned.substring(0, maxLength) || undefined;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=text-utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grainql/analytics-web",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Lightweight TypeScript SDK for sending analytics events and managing remote configurations via Grain's REST API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|