@dynatrace/react-native-plugin 2.341.1 → 2.345.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/README.md +674 -668
- package/android/build.gradle +16 -3
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceAppStartModule.kt +9 -31
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceConfigurationModule.kt +1 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +41 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.kt +1 -0
- package/android/src/main/java/com/dynatrace/android/agent/ScreenshotSelfMonitor.kt +175 -0
- package/android/src/main/java/com/dynatrace/android/agent/UIChangeScreenshotListener.kt +124 -0
- package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +33 -0
- package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +40 -0
- package/files/plugin-runtime.gradle +17 -33
- package/files/plugin.gradle +1 -1
- package/instrumentation/BabelPluginDynatrace.js +1 -1
- package/instrumentation/libs/UserInteraction.js +21 -7
- package/instrumentation/libs/react-navigation/ReactNavigation.js +14 -58
- package/instrumentation/libs/withOnPressMonitoring.js +3 -54
- package/internal.d.ts +1 -0
- package/internal.js +3 -1
- package/ios/DTXScreenshotSelfMonitor.h +29 -0
- package/ios/DTXScreenshotSelfMonitor.mm +213 -0
- package/ios/DTXScreenshotSelfMonitorSwizzler.h +15 -0
- package/ios/DTXScreenshotSelfMonitorSwizzler.mm +68 -0
- package/ios/DynatraceRNBridge.h +6 -0
- package/ios/DynatraceRNBridge.mm +62 -0
- package/lib/core/Dynatrace.js +2 -0
- package/lib/core/configuration/ConfigurationHandler.js +0 -21
- package/lib/core/logging/LogMessages.js +42 -0
- package/lib/dynatrace-reporter.js +1 -30
- package/lib/dynatrace-transformer.js +6 -34
- package/lib/next/Dynatrace.js +26 -1
- package/lib/next/configuration/INativeRuntimeConfiguration.js +0 -1
- package/lib/next/configuration/RuntimeConfigurationObserver.js +1 -6
- package/lib/next/events/EventPipeline.js +48 -31
- package/lib/next/events/HttpRequestEventData.js +1 -1
- package/lib/next/events/spec/EventSpecContstants.js +1 -1
- package/lib/next/navigation/NavigationTracker.js +93 -0
- package/lib/next/navigation/useNavigationTracking.js +54 -0
- package/lib/next/userAction/NullUserAction.js +15 -0
- package/lib/next/userAction/UserActionConfiguration.js +10 -0
- package/lib/next/userAction/UserActionImpl.js +70 -0
- package/lib/next/util/TraceContextUtils.js +8 -14
- package/lib/next/util/Utils.js +13 -0
- package/package.json +10 -18
- package/public.js +5 -1
- package/react-native-dynatrace.podspec +10 -3
- package/scripts/Android.js +1 -20
- package/scripts/Config.js +17 -7
- package/scripts/Deprecations.js +18 -0
- package/scripts/Install.js +13 -0
- package/scripts/PathsConstants.js +0 -4
- package/scripts/Uninstall.js +0 -15
- package/scripts/core/InstrumentCall.js +14 -7
- package/scripts/util/DeprecationReport.js +24 -0
- package/src/lib/core/interface/NativeDynatraceBridge.ts +34 -1
- package/types.d.ts +236 -7
- package/instrumentation/DynatraceInstrumentation.js +0 -1
- package/instrumentation/libs/community/Picker.InstrInfo.js +0 -20
- package/instrumentation/libs/community/gesture-handler/Touchables.InstrInfo.js +0 -25
- package/instrumentation/libs/react-native/RefreshControl.InstrInfo.js +0 -12
- package/instrumentation/libs/react-native/Switch.InstrInfo.js +0 -12
- package/instrumentation/libs/react-native/Touchables.InstrInfo.js +0 -25
- package/instrumentation/parser/Babel.js +0 -60
- package/instrumentation/parser/ParserUtil.js +0 -11
- package/lib/features/ui-interaction/Config.js +0 -42
- package/lib/features/ui-interaction/IUserInteractionEvent.js +0 -16
- package/lib/features/ui-interaction/Plugin.Fragment.Test.js +0 -170
- package/lib/features/ui-interaction/Plugin.js +0 -289
- package/lib/features/ui-interaction/RootDetection.js +0 -51
- package/lib/features/ui-interaction/RootWrapper.js +0 -236
- package/lib/features/ui-interaction/Run.js +0 -38
- package/lib/features/ui-interaction/Runtime.js +0 -843
- package/lib/features/ui-interaction/TouchMetaResolver.js +0 -493
- package/lib/features/ui-interaction/Types.js +0 -14
- package/lib/metro/getSourceMapInfo.js +0 -26
- package/scripts/LineOffsetAnalyze.js +0 -25
- package/scripts/core/LineOffsetAnalyzeCall.js +0 -165
- package/scripts/util/SourceMapUtil.js +0 -68
- /package/{instrumentation/model/Reference.js → lib/next/userAction/UserAction.js} +0 -0
|
@@ -1,843 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AnalyticsRoot = exports._an_flat = exports.buildUiEventShape = exports.compactify = void 0;
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const react_native_1 = require("react-native");
|
|
7
|
-
const EventPipeline_1 = require("../../../lib/next/events/EventPipeline");
|
|
8
|
-
const EventTimestamp_1 = require("../../../lib/next/events/EventTimestamp");
|
|
9
|
-
const ConsoleLogger_1 = require("../../../lib/core/logging/ConsoleLogger");
|
|
10
|
-
const LogMessages_1 = require("../../../lib/core/logging/LogMessages");
|
|
11
|
-
const IUserInteractionEvent_1 = require("./IUserInteractionEvent");
|
|
12
|
-
const ConfigurationHandler_1 = require("../../../lib/core/configuration/ConfigurationHandler");
|
|
13
|
-
const RuntimeConfigurationObserver_1 = require("../../../lib/next/configuration/RuntimeConfigurationObserver");
|
|
14
|
-
const TouchMetaResolver_1 = require("./TouchMetaResolver");
|
|
15
|
-
const TimestampProvider_1 = require("../../next/provider/TimestampProvider");
|
|
16
|
-
const logger = new ConsoleLogger_1.ConsoleLogger('DyntraceUserInteraction');
|
|
17
|
-
function isUiDebugEnabled() {
|
|
18
|
-
return (globalThis
|
|
19
|
-
.__DT_UII_DEBUG === true);
|
|
20
|
-
}
|
|
21
|
-
function uiDebugLog(message, data) {
|
|
22
|
-
if (!isUiDebugEnabled())
|
|
23
|
-
return;
|
|
24
|
-
if (data) {
|
|
25
|
-
console.log(`[DT UI DEBUG] ${message}`, data);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
console.log(`[DT UI DEBUG] ${message}`);
|
|
29
|
-
}
|
|
30
|
-
let LAST_EMIT_KEY = null;
|
|
31
|
-
let LAST_EMIT_TS = 0;
|
|
32
|
-
let LAST_PRESS_ID = null;
|
|
33
|
-
let LAST_PRESS_TS = 0;
|
|
34
|
-
function getDtLastTouch() {
|
|
35
|
-
var _a;
|
|
36
|
-
const g = globalThis;
|
|
37
|
-
(_a = g.__DT_LAST_TOUCH) !== null && _a !== void 0 ? _a : (g.__DT_LAST_TOUCH = { ts: 0, x: 0, y: 0 });
|
|
38
|
-
return g.__DT_LAST_TOUCH;
|
|
39
|
-
}
|
|
40
|
-
function flattenTextChildren(children) {
|
|
41
|
-
if (Array.isArray(children)) {
|
|
42
|
-
return children.map((child) => flattenTextChildren(child)).join('');
|
|
43
|
-
}
|
|
44
|
-
if (children === null || children === undefined || children === false)
|
|
45
|
-
return '';
|
|
46
|
-
return String(children);
|
|
47
|
-
}
|
|
48
|
-
function findRCTTextChild(fiber) {
|
|
49
|
-
let node = fiber === null || fiber === void 0 ? void 0 : fiber.child;
|
|
50
|
-
while (node) {
|
|
51
|
-
if (node.type === 'RCTText') {
|
|
52
|
-
return node;
|
|
53
|
-
}
|
|
54
|
-
const found = findRCTTextChild(node);
|
|
55
|
-
if (found)
|
|
56
|
-
return found;
|
|
57
|
-
node = node.sibling;
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
function getAnyParentMasked(fiber) {
|
|
62
|
-
var _a;
|
|
63
|
-
let cursor = fiber;
|
|
64
|
-
while (cursor) {
|
|
65
|
-
if ((_a = cursor.memoizedProps) === null || _a === void 0 ? void 0 : _a.dtMask)
|
|
66
|
-
return true;
|
|
67
|
-
cursor = cursor.return;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
function getHostComponentInfoFromEvent(event, cfg) {
|
|
72
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
73
|
-
let fiber = (_a = event === null || event === void 0 ? void 0 : event._targetInst) !== null && _a !== void 0 ? _a : (_b = event === null || event === void 0 ? void 0 : event.nativeEvent) === null || _b === void 0 ? void 0 : _b._targetInst;
|
|
74
|
-
if (!fiber)
|
|
75
|
-
return undefined;
|
|
76
|
-
const meta = (0, TouchMetaResolver_1.getTouchElementMeta)(event);
|
|
77
|
-
const resolvedPath = (_d = (_c = meta.press) === null || _c === void 0 ? void 0 : _c.appCodeTagPath) !== null && _d !== void 0 ? _d : meta.touch.appCodeTagPath;
|
|
78
|
-
if (!resolvedPath || resolvedPath === 'unknown')
|
|
79
|
-
return undefined;
|
|
80
|
-
const anyParentMasked = getAnyParentMasked(fiber);
|
|
81
|
-
const components = [lastSegment(resolvedPath) || 'Anonymous'];
|
|
82
|
-
const targetIsContainerHost = fiber.type === 'RCTView' ||
|
|
83
|
-
fiber.type === 'View' ||
|
|
84
|
-
fiber.type === 'RCTScrollView' ||
|
|
85
|
-
fiber.type === 'ScrollView';
|
|
86
|
-
if (!targetIsContainerHost && fiber.type !== 'RCTText') {
|
|
87
|
-
fiber = (_e = findRCTTextChild(fiber)) !== null && _e !== void 0 ? _e : fiber;
|
|
88
|
-
}
|
|
89
|
-
const textValue = flattenTextChildren((_f = fiber === null || fiber === void 0 ? void 0 : fiber.memoizedProps) === null || _f === void 0 ? void 0 : _f.children).trim();
|
|
90
|
-
const textMaskedByRule = textValue.length > 0 && ((_h = (_g = cfg === null || cfg === void 0 ? void 0 : cfg.mask) === null || _g === void 0 ? void 0 : _g.text) === null || _h === void 0 ? void 0 : _h.call(_g, textValue)) === true;
|
|
91
|
-
const testId = (_j = fiber === null || fiber === void 0 ? void 0 : fiber.memoizedProps) === null || _j === void 0 ? void 0 : _j.testID;
|
|
92
|
-
const testIdMaskedByRule = typeof testId === 'string' && !!((_l = (_k = cfg === null || cfg === void 0 ? void 0 : cfg.mask) === null || _k === void 0 ? void 0 : _k.testID) === null || _l === void 0 ? void 0 : _l.call(_k, testId));
|
|
93
|
-
const isMasked = anyParentMasked || textMaskedByRule || testIdMaskedByRule;
|
|
94
|
-
if (fiber.type === 'RCTText' && textValue.length > 0) {
|
|
95
|
-
if (isMasked) {
|
|
96
|
-
return {
|
|
97
|
-
id: resolvedPath,
|
|
98
|
-
components,
|
|
99
|
-
detectedName: maskLabel(textValue, cfg),
|
|
100
|
-
nameOrigin: 'masked',
|
|
101
|
-
isMasked: true,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
id: resolvedPath,
|
|
106
|
-
components,
|
|
107
|
-
detectedName: textValue,
|
|
108
|
-
nameOrigin: 'text',
|
|
109
|
-
isMasked: false,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const detectedName = (_p = (_o = (_m = meta.press) === null || _m === void 0 ? void 0 : _m.elementName) !== null && _o !== void 0 ? _o : meta.touch.elementName) !== null && _p !== void 0 ? _p : 'Anonymous';
|
|
113
|
-
return {
|
|
114
|
-
id: resolvedPath,
|
|
115
|
-
components,
|
|
116
|
-
detectedName,
|
|
117
|
-
nameOrigin: 'component',
|
|
118
|
-
isMasked,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function readGlobalPrefix() {
|
|
122
|
-
const globalRuntime = globalThis;
|
|
123
|
-
const globalPrefix = globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.__AN_PREFIX;
|
|
124
|
-
if (Array.isArray(globalPrefix))
|
|
125
|
-
return globalPrefix;
|
|
126
|
-
if (typeof globalPrefix === 'function') {
|
|
127
|
-
try {
|
|
128
|
-
const resolvedPrefix = globalPrefix();
|
|
129
|
-
if (Array.isArray(resolvedPrefix))
|
|
130
|
-
return resolvedPrefix;
|
|
131
|
-
}
|
|
132
|
-
catch (e) {
|
|
133
|
-
const errorMsg = e instanceof Error ? e.stack || e.message : String(e);
|
|
134
|
-
logger.debug(LogMessages_1.LogMessage.RESOLVE_GLOBAL_PREFIX_FAILED, { errorMsg });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
function maskLabel(_s, cfg) {
|
|
140
|
-
var _a, _b;
|
|
141
|
-
return (_b = (_a = cfg === null || cfg === void 0 ? void 0 : cfg.mask) === null || _a === void 0 ? void 0 : _a.replaceWith) !== null && _b !== void 0 ? _b : '***';
|
|
142
|
-
}
|
|
143
|
-
function compactify(cfg, obj) {
|
|
144
|
-
var _a;
|
|
145
|
-
if (!((_a = cfg === null || cfg === void 0 ? void 0 : cfg.touch) === null || _a === void 0 ? void 0 : _a.compact))
|
|
146
|
-
return obj;
|
|
147
|
-
const mapKey = (k) => {
|
|
148
|
-
var _a;
|
|
149
|
-
const keyMap = {
|
|
150
|
-
path: 'p',
|
|
151
|
-
element: 'el',
|
|
152
|
-
isMasked: 'msk',
|
|
153
|
-
position: 'pos',
|
|
154
|
-
meta: 'm',
|
|
155
|
-
sessionId: 'sid',
|
|
156
|
-
touch: 't',
|
|
157
|
-
reason: 'r',
|
|
158
|
-
};
|
|
159
|
-
return (_a = keyMap[k]) !== null && _a !== void 0 ? _a : k;
|
|
160
|
-
};
|
|
161
|
-
const normalizeCompactObject = (compactObject) => {
|
|
162
|
-
var _a, _b;
|
|
163
|
-
if ((_a = compactObject.pos) === null || _a === void 0 ? void 0 : _a.type) {
|
|
164
|
-
compactObject.pos = {
|
|
165
|
-
x: compactObject.pos.x,
|
|
166
|
-
y: compactObject.pos.y,
|
|
167
|
-
t: compactObject.pos.type,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
if ((_b = compactObject.m) === null || _b === void 0 ? void 0 : _b.phase) {
|
|
171
|
-
compactObject.ph = compactObject.m.phase;
|
|
172
|
-
compactObject.ts = compactObject.m.ts;
|
|
173
|
-
delete compactObject.m;
|
|
174
|
-
}
|
|
175
|
-
if (compactObject.t) {
|
|
176
|
-
if (compactObject.t.path !== undefined) {
|
|
177
|
-
compactObject.tp = compactObject.t.path;
|
|
178
|
-
}
|
|
179
|
-
if (compactObject.t.delayMs !== undefined) {
|
|
180
|
-
compactObject.td = compactObject.t.delayMs;
|
|
181
|
-
}
|
|
182
|
-
delete compactObject.t;
|
|
183
|
-
}
|
|
184
|
-
return compactObject;
|
|
185
|
-
};
|
|
186
|
-
const walk = (value) => {
|
|
187
|
-
if (Array.isArray(value))
|
|
188
|
-
return value.map(walk);
|
|
189
|
-
if (!value || typeof value !== 'object')
|
|
190
|
-
return value;
|
|
191
|
-
const compactObject = {};
|
|
192
|
-
for (const key of Object.keys(value)) {
|
|
193
|
-
compactObject[mapKey(key)] = walk(value[key]);
|
|
194
|
-
}
|
|
195
|
-
return normalizeCompactObject(compactObject);
|
|
196
|
-
};
|
|
197
|
-
return walk(obj);
|
|
198
|
-
}
|
|
199
|
-
exports.compactify = compactify;
|
|
200
|
-
function findHostInfoHit(event, cfg) {
|
|
201
|
-
const hostInfo = getHostComponentInfoFromEvent(event, cfg);
|
|
202
|
-
if (!hostInfo)
|
|
203
|
-
return null;
|
|
204
|
-
return {
|
|
205
|
-
path: hostInfo.id,
|
|
206
|
-
element: hostInfo.detectedName,
|
|
207
|
-
isMasked: hostInfo.isMasked,
|
|
208
|
-
name_origin: hostInfo.nameOrigin,
|
|
209
|
-
__dtMatch: 'scan',
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function makeSid() {
|
|
213
|
-
const t = TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp().toString(36);
|
|
214
|
-
const r = Math.random().toString(36).slice(2, 6);
|
|
215
|
-
return `tch_${t}_${r}`;
|
|
216
|
-
}
|
|
217
|
-
function makePos(ne, cap) {
|
|
218
|
-
if (!ne)
|
|
219
|
-
return undefined;
|
|
220
|
-
if (cap === 'page')
|
|
221
|
-
return {
|
|
222
|
-
x: Number(ne.pageX),
|
|
223
|
-
y: Number(ne.pageY),
|
|
224
|
-
type: 'page',
|
|
225
|
-
};
|
|
226
|
-
if (cap === 'local')
|
|
227
|
-
return {
|
|
228
|
-
x: Number(ne.locationX),
|
|
229
|
-
y: Number(ne.locationY),
|
|
230
|
-
type: 'local',
|
|
231
|
-
};
|
|
232
|
-
if (cap === 'both')
|
|
233
|
-
return {
|
|
234
|
-
x: Number(ne.pageX),
|
|
235
|
-
y: Number(ne.pageY),
|
|
236
|
-
type: 'both',
|
|
237
|
-
};
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
240
|
-
function lastSegment(path) {
|
|
241
|
-
if (!path)
|
|
242
|
-
return '';
|
|
243
|
-
const arrow = path.lastIndexOf('->');
|
|
244
|
-
const slash = path.lastIndexOf('/');
|
|
245
|
-
const i = Math.max(arrow, slash);
|
|
246
|
-
if (i < 0)
|
|
247
|
-
return path;
|
|
248
|
-
const step = i === arrow ? 2 : 1;
|
|
249
|
-
return path.slice(i + step);
|
|
250
|
-
}
|
|
251
|
-
function parseComponent(seg) {
|
|
252
|
-
if (!seg)
|
|
253
|
-
return 'Anonymous';
|
|
254
|
-
const base = seg.split(':', 1)[0];
|
|
255
|
-
const withoutPathId = base.split('#', 1)[0];
|
|
256
|
-
const m = /^([^(]+)(?:\(.*\))?$/.exec(withoutPathId);
|
|
257
|
-
return (m ? m[1] : base) || 'Anonymous';
|
|
258
|
-
}
|
|
259
|
-
function __dt_set_scope_path(path) {
|
|
260
|
-
const g = globalThis;
|
|
261
|
-
g.__DT_UII_SCOPE_PATH = path;
|
|
262
|
-
}
|
|
263
|
-
function __dt_get_scope_path() {
|
|
264
|
-
const g = globalThis;
|
|
265
|
-
const p = g.__DT_UII_SCOPE_PATH;
|
|
266
|
-
return typeof p === 'string' && p.length > 0 ? p : 'App';
|
|
267
|
-
}
|
|
268
|
-
function liftStaticTextHitPath(path) {
|
|
269
|
-
if (!path)
|
|
270
|
-
return path;
|
|
271
|
-
const rx = /\/Text:[^/]+\/Text\([^)]*\)$/;
|
|
272
|
-
if (!rx.test(path))
|
|
273
|
-
return path;
|
|
274
|
-
return path.replace(rx, '');
|
|
275
|
-
}
|
|
276
|
-
function buildUiEventShape(input) {
|
|
277
|
-
var _a;
|
|
278
|
-
const id = input.pressPath || input.touchPath || '';
|
|
279
|
-
const seg = lastSegment(id);
|
|
280
|
-
const comp = parseComponent(seg);
|
|
281
|
-
const detected_name = input.pressElementName || input.touchElementName || comp;
|
|
282
|
-
const base = {
|
|
283
|
-
ui_element: {
|
|
284
|
-
detected_name,
|
|
285
|
-
components: [comp],
|
|
286
|
-
id,
|
|
287
|
-
masked: !!input.touchMasked,
|
|
288
|
-
reason: (_a = input.reason) !== null && _a !== void 0 ? _a : null,
|
|
289
|
-
meta: input.meta,
|
|
290
|
-
name_origin: input.name_origin ||
|
|
291
|
-
(input.touchMasked ? 'masked' : 'component'),
|
|
292
|
-
},
|
|
293
|
-
positions: input.pos ? [{ x: input.pos.x, y: input.pos.y }] : [],
|
|
294
|
-
sessionId: input.sessionId,
|
|
295
|
-
};
|
|
296
|
-
if (input.pressPath) {
|
|
297
|
-
const pressSeg = lastSegment(input.pressPath);
|
|
298
|
-
const pressComp = parseComponent(pressSeg);
|
|
299
|
-
const pressName = input.pressElementName || pressComp;
|
|
300
|
-
base.ui_element.responder = {
|
|
301
|
-
detected_name: pressName,
|
|
302
|
-
components: [pressComp],
|
|
303
|
-
id: input.pressPath,
|
|
304
|
-
name_origin: 'component',
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
return base;
|
|
308
|
-
}
|
|
309
|
-
exports.buildUiEventShape = buildUiEventShape;
|
|
310
|
-
function _an_interaction_type(e) {
|
|
311
|
-
var _a, _b;
|
|
312
|
-
const p = (_b = (_a = e === null || e === void 0 ? void 0 : e.ui_element) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.phase;
|
|
313
|
-
if (!p)
|
|
314
|
-
return null;
|
|
315
|
-
return 'touch';
|
|
316
|
-
}
|
|
317
|
-
function _an_flat(e) {
|
|
318
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
319
|
-
const uiComponents = (_a = e === null || e === void 0 ? void 0 : e.ui_element) === null || _a === void 0 ? void 0 : _a.components;
|
|
320
|
-
let normalizedUiComponents = [];
|
|
321
|
-
if (Array.isArray(uiComponents)) {
|
|
322
|
-
normalizedUiComponents = uiComponents.filter((x) => typeof x === 'string' && x.length > 0);
|
|
323
|
-
}
|
|
324
|
-
else if (uiComponents) {
|
|
325
|
-
normalizedUiComponents =
|
|
326
|
-
typeof uiComponents === 'string' ? [uiComponents] : [];
|
|
327
|
-
}
|
|
328
|
-
const out = {
|
|
329
|
-
[IUserInteractionEvent_1.UserInteractionEventKey.EventHasUserInteraction]: true,
|
|
330
|
-
[IUserInteractionEvent_1.UserInteractionEventKey.UiElementDetectedName]: (_c = (_b = e === null || e === void 0 ? void 0 : e.ui_element) === null || _b === void 0 ? void 0 : _b.detected_name) !== null && _c !== void 0 ? _c : null,
|
|
331
|
-
[IUserInteractionEvent_1.UserInteractionEventKey.UiElementComponents]: normalizedUiComponents,
|
|
332
|
-
[IUserInteractionEvent_1.UserInteractionEventKey.UiElementId]: (_e = (_d = e === null || e === void 0 ? void 0 : e.ui_element) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : null,
|
|
333
|
-
[IUserInteractionEvent_1.UserInteractionEventKey.InteractionName]: _an_interaction_type(e),
|
|
334
|
-
positions: Array.isArray(e === null || e === void 0 ? void 0 : e.positions)
|
|
335
|
-
? e.positions.map((pos) => ({
|
|
336
|
-
x: Math.trunc(pos.x),
|
|
337
|
-
y: Math.trunc(pos.y),
|
|
338
|
-
}))
|
|
339
|
-
: [],
|
|
340
|
-
};
|
|
341
|
-
const uiComponent = (_f = e === null || e === void 0 ? void 0 : e.ui_element) === null || _f === void 0 ? void 0 : _f.component;
|
|
342
|
-
const uiComponentList = uiComponent === null || uiComponent === undefined
|
|
343
|
-
? null
|
|
344
|
-
: [uiComponent];
|
|
345
|
-
const compsRaw = (_h = (_g = e === null || e === void 0 ? void 0 : e.ui_element) === null || _g === void 0 ? void 0 : _g.components) !== null && _h !== void 0 ? _h : uiComponentList;
|
|
346
|
-
out[IUserInteractionEvent_1.UserInteractionEventKey.UiElementComponents] = Array.isArray(compsRaw)
|
|
347
|
-
? compsRaw.filter((x) => typeof x === 'string' && x.length > 0)
|
|
348
|
-
: [];
|
|
349
|
-
out[IUserInteractionEvent_1.UserInteractionEventKey.UiElementNameOrigin] =
|
|
350
|
-
(_k = (_j = e === null || e === void 0 ? void 0 : e.ui_element) === null || _j === void 0 ? void 0 : _j.name_origin) !== null && _k !== void 0 ? _k : null;
|
|
351
|
-
const responder = (_m = (_l = e === null || e === void 0 ? void 0 : e.ui_element) === null || _l === void 0 ? void 0 : _l.responder) !== null && _m !== void 0 ? _m : null;
|
|
352
|
-
if (responder) {
|
|
353
|
-
out[IUserInteractionEvent_1.UserInteractionEventKey.UiElementResponderDetectedName] =
|
|
354
|
-
(_o = responder.detected_name) !== null && _o !== void 0 ? _o : null;
|
|
355
|
-
const responderComponent = responder.component;
|
|
356
|
-
const responderComponentList = responderComponent === null || responderComponent === undefined
|
|
357
|
-
? null
|
|
358
|
-
: [responderComponent];
|
|
359
|
-
const rCompsRaw = (_p = responder.components) !== null && _p !== void 0 ? _p : responderComponentList;
|
|
360
|
-
out[IUserInteractionEvent_1.UserInteractionEventKey.UiElementResponderComponents] =
|
|
361
|
-
Array.isArray(rCompsRaw)
|
|
362
|
-
? rCompsRaw.filter((x) => typeof x === 'string' && x.length > 0)
|
|
363
|
-
: [];
|
|
364
|
-
out[IUserInteractionEvent_1.UserInteractionEventKey.UiElementResponderId] =
|
|
365
|
-
(_q = responder.id) !== null && _q !== void 0 ? _q : null;
|
|
366
|
-
out[IUserInteractionEvent_1.UserInteractionEventKey.UiElementResponderOriginName] =
|
|
367
|
-
(_r = responder.name_origin) !== null && _r !== void 0 ? _r : null;
|
|
368
|
-
}
|
|
369
|
-
return out;
|
|
370
|
-
}
|
|
371
|
-
exports._an_flat = _an_flat;
|
|
372
|
-
function useTouchManager(cfg, log) {
|
|
373
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
374
|
-
const mode = (_b = (_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.mode) !== null && _b !== void 0 ? _b : 'grouped';
|
|
375
|
-
const sidRef = React.useRef(null);
|
|
376
|
-
const startXRef = React.useRef(null);
|
|
377
|
-
const startYRef = React.useRef(null);
|
|
378
|
-
const movedRef = React.useRef(false);
|
|
379
|
-
const startTsRef = React.useRef(null);
|
|
380
|
-
const startPathRef = React.useRef(null);
|
|
381
|
-
const threshold = Math.max(1, (_e = (_d = (_c = cfg.touch) === null || _c === void 0 ? void 0 : _c.scroll) === null || _d === void 0 ? void 0 : _d.moveThresholdPx) !== null && _e !== void 0 ? _e : 12);
|
|
382
|
-
const touchRef = React.useRef(null);
|
|
383
|
-
const pressRef = React.useRef(null);
|
|
384
|
-
const timerRef = React.useRef(null);
|
|
385
|
-
const flushedRef = React.useRef(false);
|
|
386
|
-
const clearAll = () => {
|
|
387
|
-
if (timerRef.current) {
|
|
388
|
-
clearTimeout(timerRef.current);
|
|
389
|
-
timerRef.current = null;
|
|
390
|
-
}
|
|
391
|
-
touchRef.current = null;
|
|
392
|
-
pressRef.current = null;
|
|
393
|
-
sidRef.current = null;
|
|
394
|
-
startXRef.current = null;
|
|
395
|
-
startYRef.current = null;
|
|
396
|
-
startTsRef.current = null;
|
|
397
|
-
movedRef.current = false;
|
|
398
|
-
startPathRef.current = null;
|
|
399
|
-
flushedRef.current = false;
|
|
400
|
-
};
|
|
401
|
-
const doFlush = () => {
|
|
402
|
-
if (flushedRef.current) {
|
|
403
|
-
clearAll();
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
const t = touchRef.current;
|
|
407
|
-
const p = pressRef.current;
|
|
408
|
-
let out = null;
|
|
409
|
-
if (t && p) {
|
|
410
|
-
const pos = p.pos || t.pos;
|
|
411
|
-
out = buildUiEventShape({
|
|
412
|
-
touchPath: t.path,
|
|
413
|
-
touchElementName: t.elementName || undefined,
|
|
414
|
-
touchMasked: t.masked,
|
|
415
|
-
pressPath: p.path,
|
|
416
|
-
pressElementName: p.elementName,
|
|
417
|
-
meta: {
|
|
418
|
-
phase: 'press',
|
|
419
|
-
ts: TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp(),
|
|
420
|
-
},
|
|
421
|
-
pos: pos ? { x: pos.x, y: pos.y } : undefined,
|
|
422
|
-
reason: t.reason,
|
|
423
|
-
sessionId: sidRef.current || undefined,
|
|
424
|
-
name_origin: t.name_origin,
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
else if (p) {
|
|
428
|
-
out = buildUiEventShape({
|
|
429
|
-
pressPath: p.path,
|
|
430
|
-
pressElementName: p.elementName,
|
|
431
|
-
meta: {
|
|
432
|
-
phase: 'press',
|
|
433
|
-
ts: TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp(),
|
|
434
|
-
},
|
|
435
|
-
pos: p.pos ? { x: p.pos.x, y: p.pos.y } : undefined,
|
|
436
|
-
sessionId: sidRef.current || undefined,
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
else if (t) {
|
|
440
|
-
out = buildUiEventShape({
|
|
441
|
-
touchPath: t.path,
|
|
442
|
-
touchElementName: t.elementName || undefined,
|
|
443
|
-
touchMasked: t.masked,
|
|
444
|
-
meta: {
|
|
445
|
-
phase: 'touch',
|
|
446
|
-
ts: TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp(),
|
|
447
|
-
},
|
|
448
|
-
pos: t.pos ? { x: t.pos.x, y: t.pos.y } : undefined,
|
|
449
|
-
reason: t.reason,
|
|
450
|
-
sessionId: sidRef.current || undefined,
|
|
451
|
-
name_origin: t.name_origin,
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
if (out)
|
|
455
|
-
log(compactify(cfg, out));
|
|
456
|
-
flushedRef.current = true;
|
|
457
|
-
clearAll();
|
|
458
|
-
};
|
|
459
|
-
const scheduleFlush = (delay) => {
|
|
460
|
-
if (timerRef.current) {
|
|
461
|
-
clearTimeout(timerRef.current);
|
|
462
|
-
timerRef.current = null;
|
|
463
|
-
}
|
|
464
|
-
timerRef.current = setTimeout(() => doFlush(), delay);
|
|
465
|
-
};
|
|
466
|
-
const resolveTouchHit = (_nativeTarget, event) => {
|
|
467
|
-
const hostHit = findHostInfoHit(event, cfg);
|
|
468
|
-
if (hostHit) {
|
|
469
|
-
uiDebugLog('resolveTouchHit: host hit found', {
|
|
470
|
-
path: hostHit.path,
|
|
471
|
-
element: hostHit.element,
|
|
472
|
-
match: hostHit.__dtMatch,
|
|
473
|
-
});
|
|
474
|
-
return hostHit;
|
|
475
|
-
}
|
|
476
|
-
uiDebugLog('resolveTouchHit: no hit found');
|
|
477
|
-
return null;
|
|
478
|
-
};
|
|
479
|
-
const maybeLiftTouchHit = (hit) => {
|
|
480
|
-
var _a;
|
|
481
|
-
if (!hit || hit.__dtMatch === 'exact') {
|
|
482
|
-
return {
|
|
483
|
-
usePath: (_a = hit === null || hit === void 0 ? void 0 : hit.path) !== null && _a !== void 0 ? _a : null,
|
|
484
|
-
useElement: hit === null || hit === void 0 ? void 0 : hit.element,
|
|
485
|
-
nameOrigin: hit === null || hit === void 0 ? void 0 : hit.name_origin,
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
const lifted = liftStaticTextHitPath(hit.path);
|
|
489
|
-
if (lifted && lifted !== hit.path) {
|
|
490
|
-
return {
|
|
491
|
-
usePath: lifted,
|
|
492
|
-
useElement: undefined,
|
|
493
|
-
nameOrigin: 'component',
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
return {
|
|
497
|
-
usePath: hit.path,
|
|
498
|
-
useElement: hit.element,
|
|
499
|
-
nameOrigin: hit.name_origin,
|
|
500
|
-
};
|
|
501
|
-
};
|
|
502
|
-
const phaseReason = (phase) => phase === 'cancel' && movedRef.current ? 'moved' : undefined;
|
|
503
|
-
const flushOrSchedule = () => {
|
|
504
|
-
var _a, _b;
|
|
505
|
-
if (pressRef.current)
|
|
506
|
-
doFlush();
|
|
507
|
-
else
|
|
508
|
-
scheduleFlush((_b = (_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.linkWindowMs) !== null && _b !== void 0 ? _b : 250);
|
|
509
|
-
};
|
|
510
|
-
const handleStreamEnd = (event, phase) => {
|
|
511
|
-
var _a, _b;
|
|
512
|
-
const ne = event === null || event === void 0 ? void 0 : event.nativeEvent;
|
|
513
|
-
const hit = resolveTouchHit(ne === null || ne === void 0 ? void 0 : ne.target, event);
|
|
514
|
-
if (!(hit === null || hit === void 0 ? void 0 : hit.path))
|
|
515
|
-
return;
|
|
516
|
-
const lifted = maybeLiftTouchHit(hit);
|
|
517
|
-
const pos = makePos(ne, (_b = (_a = cfg.click) === null || _a === void 0 ? void 0 : _a.capturePosition) !== null && _b !== void 0 ? _b : 'none');
|
|
518
|
-
const out = buildUiEventShape({
|
|
519
|
-
touchPath: lifted.usePath || hit.path,
|
|
520
|
-
touchElementName: lifted.useElement,
|
|
521
|
-
touchMasked: !!hit.isMasked,
|
|
522
|
-
meta: {
|
|
523
|
-
phase: phase === 'cancel' ? 'touch-cancel' : 'touch',
|
|
524
|
-
ts: TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp(),
|
|
525
|
-
},
|
|
526
|
-
pos: pos ? { x: pos.x, y: pos.y } : undefined,
|
|
527
|
-
reason: phaseReason(phase),
|
|
528
|
-
sessionId: sidRef.current || undefined,
|
|
529
|
-
name_origin: lifted.nameOrigin,
|
|
530
|
-
});
|
|
531
|
-
log(compactify(cfg, out));
|
|
532
|
-
clearAll();
|
|
533
|
-
};
|
|
534
|
-
const onStart = React.useCallback((e) => {
|
|
535
|
-
var _a, _b, _c, _d, _e;
|
|
536
|
-
if (!((_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.enabled))
|
|
537
|
-
return;
|
|
538
|
-
const ne = e === null || e === void 0 ? void 0 : e.nativeEvent;
|
|
539
|
-
const hit = resolveTouchHit(ne === null || ne === void 0 ? void 0 : ne.target, e);
|
|
540
|
-
uiDebugLog('onStart', {
|
|
541
|
-
hasHit: !!(hit === null || hit === void 0 ? void 0 : hit.path),
|
|
542
|
-
targetType: typeof (ne === null || ne === void 0 ? void 0 : ne.target),
|
|
543
|
-
pageX: Number(ne === null || ne === void 0 ? void 0 : ne.pageX) || 0,
|
|
544
|
-
pageY: Number(ne === null || ne === void 0 ? void 0 : ne.pageY) || 0,
|
|
545
|
-
mode,
|
|
546
|
-
});
|
|
547
|
-
if (!(hit === null || hit === void 0 ? void 0 : hit.path)) {
|
|
548
|
-
clearAll();
|
|
549
|
-
sidRef.current = makeSid();
|
|
550
|
-
startTsRef.current =
|
|
551
|
-
TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp();
|
|
552
|
-
startXRef.current = Number(ne === null || ne === void 0 ? void 0 : ne.pageX) || 0;
|
|
553
|
-
startYRef.current = Number(ne === null || ne === void 0 ? void 0 : ne.pageY) || 0;
|
|
554
|
-
movedRef.current = false;
|
|
555
|
-
startPathRef.current = __dt_get_scope_path();
|
|
556
|
-
if (mode === 'stream') {
|
|
557
|
-
const pos = makePos(ne, (_c = (_b = cfg.click) === null || _b === void 0 ? void 0 : _b.capturePosition) !== null && _c !== void 0 ? _c : 'none');
|
|
558
|
-
const out = buildUiEventShape({
|
|
559
|
-
touchPath: startPathRef.current,
|
|
560
|
-
meta: {
|
|
561
|
-
phase: 'touch-start',
|
|
562
|
-
ts: TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp(),
|
|
563
|
-
},
|
|
564
|
-
pos: pos ? { x: pos.x, y: pos.y } : undefined,
|
|
565
|
-
sessionId: sidRef.current || undefined,
|
|
566
|
-
});
|
|
567
|
-
log(compactify(cfg, out));
|
|
568
|
-
}
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
clearAll();
|
|
572
|
-
startPathRef.current = hit.path;
|
|
573
|
-
sidRef.current = makeSid();
|
|
574
|
-
startTsRef.current = TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp();
|
|
575
|
-
startXRef.current = Number(ne === null || ne === void 0 ? void 0 : ne.pageX) || 0;
|
|
576
|
-
startYRef.current = Number(ne === null || ne === void 0 ? void 0 : ne.pageY) || 0;
|
|
577
|
-
movedRef.current = false;
|
|
578
|
-
if (mode === 'stream') {
|
|
579
|
-
const pos = makePos(ne, (_e = (_d = cfg.click) === null || _d === void 0 ? void 0 : _d.capturePosition) !== null && _e !== void 0 ? _e : 'none');
|
|
580
|
-
const out = buildUiEventShape({
|
|
581
|
-
touchPath: hit.path,
|
|
582
|
-
touchElementName: hit.element || undefined,
|
|
583
|
-
touchMasked: !!hit.isMasked,
|
|
584
|
-
meta: {
|
|
585
|
-
phase: 'touch-start',
|
|
586
|
-
ts: TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp(),
|
|
587
|
-
},
|
|
588
|
-
pos: pos ? { x: pos.x, y: pos.y } : undefined,
|
|
589
|
-
sessionId: sidRef.current || undefined,
|
|
590
|
-
name_origin: hit.name_origin,
|
|
591
|
-
});
|
|
592
|
-
log(compactify(cfg, out));
|
|
593
|
-
}
|
|
594
|
-
}, [(_f = cfg.touch) === null || _f === void 0 ? void 0 : _f.enabled, (_g = cfg.click) === null || _g === void 0 ? void 0 : _g.capturePosition, mode]);
|
|
595
|
-
const onMove = React.useCallback((e) => {
|
|
596
|
-
var _a, _b, _c;
|
|
597
|
-
if (!((_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.enabled))
|
|
598
|
-
return;
|
|
599
|
-
if (movedRef.current)
|
|
600
|
-
return;
|
|
601
|
-
const ne = e === null || e === void 0 ? void 0 : e.nativeEvent;
|
|
602
|
-
const x = Number(ne === null || ne === void 0 ? void 0 : ne.pageX) || 0;
|
|
603
|
-
const y = Number(ne === null || ne === void 0 ? void 0 : ne.pageY) || 0;
|
|
604
|
-
const sx = (_b = startXRef.current) !== null && _b !== void 0 ? _b : x;
|
|
605
|
-
const sy = (_c = startYRef.current) !== null && _c !== void 0 ? _c : y;
|
|
606
|
-
const dx = x - sx;
|
|
607
|
-
const dy = y - sy;
|
|
608
|
-
if (dx * dx + dy * dy >= threshold * threshold)
|
|
609
|
-
movedRef.current = true;
|
|
610
|
-
}, [(_h = cfg.touch) === null || _h === void 0 ? void 0 : _h.enabled, threshold]);
|
|
611
|
-
const onEnd = React.useCallback((e, phase) => {
|
|
612
|
-
var _a, _b, _c;
|
|
613
|
-
if (!((_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.enabled))
|
|
614
|
-
return;
|
|
615
|
-
const ne = e === null || e === void 0 ? void 0 : e.nativeEvent;
|
|
616
|
-
if (mode === 'stream') {
|
|
617
|
-
handleStreamEnd(e, phase);
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
const pos = makePos(ne, (_c = (_b = cfg.click) === null || _b === void 0 ? void 0 : _b.capturePosition) !== null && _c !== void 0 ? _c : 'none');
|
|
621
|
-
const hitRaw = resolveTouchHit(ne === null || ne === void 0 ? void 0 : ne.target, e);
|
|
622
|
-
const now = TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp();
|
|
623
|
-
const lifted = maybeLiftTouchHit(hitRaw);
|
|
624
|
-
const usePath = lifted.usePath;
|
|
625
|
-
const useEl = lifted.useElement || '';
|
|
626
|
-
uiDebugLog('onEnd', {
|
|
627
|
-
phase,
|
|
628
|
-
hasHit: !!(hitRaw === null || hitRaw === void 0 ? void 0 : hitRaw.path),
|
|
629
|
-
usePath: usePath || null,
|
|
630
|
-
useElement: useEl || null,
|
|
631
|
-
mode,
|
|
632
|
-
});
|
|
633
|
-
if (!usePath) {
|
|
634
|
-
const scopePath = startPathRef.current || __dt_get_scope_path();
|
|
635
|
-
touchRef.current = {
|
|
636
|
-
path: scopePath,
|
|
637
|
-
elementName: '',
|
|
638
|
-
masked: false,
|
|
639
|
-
name_origin: 'component',
|
|
640
|
-
pos: pos ? { x: pos.x, y: pos.y } : undefined,
|
|
641
|
-
reason: 'unmapped',
|
|
642
|
-
ts: now,
|
|
643
|
-
};
|
|
644
|
-
flushOrSchedule();
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
touchRef.current = {
|
|
648
|
-
path: usePath,
|
|
649
|
-
elementName: useEl,
|
|
650
|
-
masked: !!(hitRaw === null || hitRaw === void 0 ? void 0 : hitRaw.isMasked),
|
|
651
|
-
name_origin: lifted.nameOrigin,
|
|
652
|
-
pos: pos ? { x: pos.x, y: pos.y } : undefined,
|
|
653
|
-
reason: phaseReason(phase),
|
|
654
|
-
ts: now,
|
|
655
|
-
};
|
|
656
|
-
flushOrSchedule();
|
|
657
|
-
}, [
|
|
658
|
-
(_j = cfg.touch) === null || _j === void 0 ? void 0 : _j.enabled,
|
|
659
|
-
(_k = cfg.click) === null || _k === void 0 ? void 0 : _k.capturePosition,
|
|
660
|
-
(_l = cfg.touch) === null || _l === void 0 ? void 0 : _l.linkWindowMs,
|
|
661
|
-
mode,
|
|
662
|
-
]);
|
|
663
|
-
const registerPress = React.useCallback((info) => {
|
|
664
|
-
var _a, _b, _c;
|
|
665
|
-
if (!((_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.enabled))
|
|
666
|
-
return;
|
|
667
|
-
const now = TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp();
|
|
668
|
-
uiDebugLog('registerPress', {
|
|
669
|
-
path: info.path,
|
|
670
|
-
elementName: info.elementName,
|
|
671
|
-
hasPos: !!info.pos,
|
|
672
|
-
mode,
|
|
673
|
-
});
|
|
674
|
-
if (mode === 'stream') {
|
|
675
|
-
const out = buildUiEventShape({
|
|
676
|
-
pressPath: info.path,
|
|
677
|
-
pressElementName: info.elementName,
|
|
678
|
-
meta: { phase: 'press', ts: now },
|
|
679
|
-
name_origin: 'component',
|
|
680
|
-
pos: info.pos
|
|
681
|
-
? { x: info.pos.x, y: info.pos.y }
|
|
682
|
-
: undefined,
|
|
683
|
-
sessionId: sidRef.current || undefined,
|
|
684
|
-
});
|
|
685
|
-
log(compactify(cfg, out));
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
pressRef.current = {
|
|
689
|
-
path: info.path,
|
|
690
|
-
elementName: info.elementName,
|
|
691
|
-
pos: info.pos ? { x: info.pos.x, y: info.pos.y } : undefined,
|
|
692
|
-
ts: now,
|
|
693
|
-
};
|
|
694
|
-
if (touchRef.current)
|
|
695
|
-
doFlush();
|
|
696
|
-
else
|
|
697
|
-
scheduleFlush((_c = (_b = cfg.touch) === null || _b === void 0 ? void 0 : _b.linkWindowMs) !== null && _c !== void 0 ? _c : 250);
|
|
698
|
-
}, [(_m = cfg.touch) === null || _m === void 0 ? void 0 : _m.enabled, (_o = cfg.touch) === null || _o === void 0 ? void 0 : _o.linkWindowMs, mode]);
|
|
699
|
-
return {
|
|
700
|
-
onStart,
|
|
701
|
-
onMove,
|
|
702
|
-
onEnd,
|
|
703
|
-
getSessionId: React.useCallback(() => sidRef.current, []),
|
|
704
|
-
getTouchPath: React.useCallback(() => { var _a, _b; return (_b = (_a = touchRef.current) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : null; }, []),
|
|
705
|
-
getStartTs: React.useCallback(() => startTsRef.current, []),
|
|
706
|
-
getStartPath: React.useCallback(() => startPathRef.current, []),
|
|
707
|
-
registerPress,
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
function TouchCapture({ children, cfg, mgr, }) {
|
|
711
|
-
var _a, _b;
|
|
712
|
-
const last = getDtLastTouch();
|
|
713
|
-
const onStart = React.useCallback((e) => {
|
|
714
|
-
var _a, _b;
|
|
715
|
-
last.ts = TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp();
|
|
716
|
-
last.x = Number((_a = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _a === void 0 ? void 0 : _a.pageX) || 0;
|
|
717
|
-
last.y = Number((_b = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _b === void 0 ? void 0 : _b.pageY) || 0;
|
|
718
|
-
return mgr === null || mgr === void 0 ? void 0 : mgr.onStart(e);
|
|
719
|
-
}, [mgr]);
|
|
720
|
-
const onMove = React.useCallback((e) => mgr === null || mgr === void 0 ? void 0 : mgr.onMove(e), [mgr]);
|
|
721
|
-
const onEnd = React.useCallback((e) => {
|
|
722
|
-
return mgr === null || mgr === void 0 ? void 0 : mgr.onEnd(e, 'end');
|
|
723
|
-
}, [mgr]);
|
|
724
|
-
const onCancel = React.useCallback((e) => {
|
|
725
|
-
return mgr === null || mgr === void 0 ? void 0 : mgr.onEnd(e, 'cancel');
|
|
726
|
-
}, [mgr]);
|
|
727
|
-
if (!ConfigurationHandler_1.ConfigurationHandler.isUserInteractionEnabled() ||
|
|
728
|
-
!((_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.enabled) ||
|
|
729
|
-
!mgr) {
|
|
730
|
-
uiDebugLog('TouchCapture bypassed', {
|
|
731
|
-
uiEnabled: ConfigurationHandler_1.ConfigurationHandler.isUserInteractionEnabled(),
|
|
732
|
-
touchEnabled: !!((_b = cfg.touch) === null || _b === void 0 ? void 0 : _b.enabled),
|
|
733
|
-
hasManager: !!mgr,
|
|
734
|
-
});
|
|
735
|
-
return React.createElement(React.Fragment, null, children);
|
|
736
|
-
}
|
|
737
|
-
return (React.createElement(react_native_1.View, { pointerEvents: "box-none", collapsable: false, style: { flex: 1 }, onTouchStart: onStart, onTouchMove: onMove, onTouchEnd: onEnd, onTouchCancel: onCancel, onResponderRelease: onEnd, onResponderTerminate: onCancel }, children));
|
|
738
|
-
}
|
|
739
|
-
function AnalyticsRoot({ name = 'App', label, log, prefix, config, children, }) {
|
|
740
|
-
var _a, _b, _c, _d, _e;
|
|
741
|
-
const cfg = (0, react_1.useMemo)(() => config !== null && config !== void 0 ? config : {}, [config]);
|
|
742
|
-
const fileConfiguredUiEnabled = ((_a = cfg === null || cfg === void 0 ? void 0 : cfg.touch) === null || _a === void 0 ? void 0 : _a.enabled) === true;
|
|
743
|
-
const baseLogger = log ||
|
|
744
|
-
((e) => logger.debug(LogMessages_1.LogMessage.UI_INTERACTION_DEBUG, {
|
|
745
|
-
event: JSON.stringify(e),
|
|
746
|
-
}));
|
|
747
|
-
React.useEffect(() => {
|
|
748
|
-
ConfigurationHandler_1.ConfigurationHandler.setUserInteractionEnabledLastKnownGood(fileConfiguredUiEnabled);
|
|
749
|
-
uiDebugLog('AnalyticsRoot initialized fallback from config', {
|
|
750
|
-
fileConfiguredUiEnabled,
|
|
751
|
-
userInteractionEnabled: ConfigurationHandler_1.ConfigurationHandler.isUserInteractionEnabled(),
|
|
752
|
-
});
|
|
753
|
-
}, [fileConfiguredUiEnabled]);
|
|
754
|
-
const emit = React.useCallback((e) => {
|
|
755
|
-
var _a, _b, _c, _d;
|
|
756
|
-
const uiEnabled = ConfigurationHandler_1.ConfigurationHandler.isUserInteractionEnabled();
|
|
757
|
-
if (!uiEnabled) {
|
|
758
|
-
const isInitiated = RuntimeConfigurationObserver_1.RuntimeConfigurationObserver.isInitiated();
|
|
759
|
-
const remoteCfg = isInitiated
|
|
760
|
-
? RuntimeConfigurationObserver_1.RuntimeConfigurationObserver.getCurrentRuntimeConfiguration()
|
|
761
|
-
: undefined;
|
|
762
|
-
uiDebugLog('emit skipped: user interaction disabled', {
|
|
763
|
-
isRuntimeConfigInitiated: isInitiated,
|
|
764
|
-
remoteValue: remoteCfg === null || remoteCfg === void 0 ? void 0 : remoteCfg.touch_interaction_enabled,
|
|
765
|
-
});
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
const phase = ((_b = (_a = e === null || e === void 0 ? void 0 : e.ui_element) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.phase) || '';
|
|
769
|
-
const id = ((_c = e === null || e === void 0 ? void 0 : e.ui_element) === null || _c === void 0 ? void 0 : _c.id) || '';
|
|
770
|
-
const now = TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp();
|
|
771
|
-
if (phase === 'touch' &&
|
|
772
|
-
LAST_PRESS_ID &&
|
|
773
|
-
id &&
|
|
774
|
-
id === LAST_PRESS_ID &&
|
|
775
|
-
now - LAST_PRESS_TS < 300) {
|
|
776
|
-
uiDebugLog('emit skipped: touch dedup after press', {
|
|
777
|
-
id,
|
|
778
|
-
deltaMs: now - LAST_PRESS_TS,
|
|
779
|
-
});
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
const key = id && phase ? id + '|' + phase : '';
|
|
783
|
-
if (key && key === LAST_EMIT_KEY && now - LAST_EMIT_TS < 10) {
|
|
784
|
-
uiDebugLog('emit skipped: duplicate key window', {
|
|
785
|
-
key,
|
|
786
|
-
deltaMs: now - LAST_EMIT_TS,
|
|
787
|
-
});
|
|
788
|
-
return;
|
|
789
|
-
}
|
|
790
|
-
LAST_EMIT_KEY = key;
|
|
791
|
-
LAST_EMIT_TS = now;
|
|
792
|
-
if (phase === 'press' && id) {
|
|
793
|
-
LAST_PRESS_ID = id;
|
|
794
|
-
LAST_PRESS_TS = now;
|
|
795
|
-
}
|
|
796
|
-
const eventTimestamp = new EventTimestamp_1.EventTimestamp(TimestampProvider_1.defaultTimestampProvider);
|
|
797
|
-
const produceEvent = _an_flat(e);
|
|
798
|
-
const event = Object.assign(Object.assign({}, produceEvent), eventTimestamp.getEventTimeInfo());
|
|
799
|
-
EventPipeline_1.EventPipeline.insertEvent(event);
|
|
800
|
-
uiDebugLog('emit inserted event', {
|
|
801
|
-
phase,
|
|
802
|
-
id,
|
|
803
|
-
hasResponder: !!((_d = e === null || e === void 0 ? void 0 : e.ui_element) === null || _d === void 0 ? void 0 : _d.responder),
|
|
804
|
-
});
|
|
805
|
-
return baseLogger(produceEvent);
|
|
806
|
-
}, [baseLogger]);
|
|
807
|
-
const touch = useTouchManager(cfg, emit);
|
|
808
|
-
React.useEffect(() => {
|
|
809
|
-
var _a, _b, _c;
|
|
810
|
-
const g = globalThis;
|
|
811
|
-
g.__DT_UII_BRIDGE = {
|
|
812
|
-
registerPress: touch.registerPress,
|
|
813
|
-
getStartPath: touch.getStartPath,
|
|
814
|
-
};
|
|
815
|
-
uiDebugLog('AnalyticsRoot mounted: bridge registered', {
|
|
816
|
-
touchEnabled: !!((_a = cfg.touch) === null || _a === void 0 ? void 0 : _a.enabled),
|
|
817
|
-
mode: (_c = (_b = cfg.touch) === null || _b === void 0 ? void 0 : _b.mode) !== null && _c !== void 0 ? _c : 'grouped',
|
|
818
|
-
});
|
|
819
|
-
return () => {
|
|
820
|
-
var _a;
|
|
821
|
-
if (((_a = g.__DT_UII_BRIDGE) === null || _a === void 0 ? void 0 : _a.registerPress) === touch.registerPress) {
|
|
822
|
-
delete g.__DT_UII_BRIDGE;
|
|
823
|
-
uiDebugLog('AnalyticsRoot unmounted: bridge removed');
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
}, [touch, (_b = cfg.touch) === null || _b === void 0 ? void 0 : _b.enabled, (_c = cfg.touch) === null || _c === void 0 ? void 0 : _c.mode]);
|
|
827
|
-
const pref = Array.isArray(prefix) ? prefix : readGlobalPrefix();
|
|
828
|
-
const scopePath = React.useMemo(() => {
|
|
829
|
-
var _a, _b;
|
|
830
|
-
const names = [
|
|
831
|
-
...pref
|
|
832
|
-
.map((p) => p === null || p === void 0 ? void 0 : p.name)
|
|
833
|
-
.filter((n) => typeof n === 'string' && n.length > 0),
|
|
834
|
-
name,
|
|
835
|
-
];
|
|
836
|
-
return names.join((_b = (_a = config === null || config === void 0 ? void 0 : config.path) === null || _a === void 0 ? void 0 : _a.separator) !== null && _b !== void 0 ? _b : '/');
|
|
837
|
-
}, [pref, name, (_d = config === null || config === void 0 ? void 0 : config.path) === null || _d === void 0 ? void 0 : _d.separator]);
|
|
838
|
-
React.useEffect(() => {
|
|
839
|
-
__dt_set_scope_path(scopePath);
|
|
840
|
-
}, [scopePath]);
|
|
841
|
-
return ((_e = cfg === null || cfg === void 0 ? void 0 : cfg.touch) === null || _e === void 0 ? void 0 : _e.enabled) ? (React.createElement(TouchCapture, { cfg: cfg, mgr: touch }, children)) : (React.createElement(React.Fragment, null, children));
|
|
842
|
-
}
|
|
843
|
-
exports.AnalyticsRoot = AnalyticsRoot;
|