polyv-rum-sdk 0.1.8 → 0.1.11
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/index.js +0 -1
- package/dist/index.mjs +0 -1
- package/package.json +5 -3
- package/.github/workflows/publish.yml +0 -34
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/jest.config.cjs +0 -8
- package/src/__tests__/SLSWebTrackingAdapter.test.ts +0 -46
- package/src/__tests__/config.test.ts +0 -76
- package/src/core/MitoSLSAdapter.ts +0 -469
- package/src/core/config.ts +0 -338
- package/src/core/env.ts +0 -17
- package/src/index.ts +0 -26
- package/src/transport/SLSWebTrackingAdapter.ts +0 -626
- package/src/types/aliyun-web-track-browser-es.d.ts +0 -4
- package/src/types/external.d.ts +0 -8
- package/src/vue2/RUMManager.vue2.ts +0 -487
- package/src/vue2/plugin.vue2.ts +0 -56
- package/src/vue3/RUMManager.vue3.ts +0 -56
- package/src/vue3/plugin.vue3.ts +0 -40
- package/tsconfig.json +0 -16
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
import { mitoConfig, slsConfig, type TransformContext } from '../core/config';
|
|
2
|
-
import { getRUMEnv } from '../core/env';
|
|
3
|
-
import {
|
|
4
|
-
initRUMCore,
|
|
5
|
-
type MitoSLSAdapterOptions
|
|
6
|
-
} from '../core/MitoSLSAdapter';
|
|
7
|
-
|
|
8
|
-
export interface RUMManagerContext extends TransformContext {
|
|
9
|
-
Vue?: any;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class RUMManagerVue2 {
|
|
13
|
-
private adapter: any = null;
|
|
14
|
-
private isInitialized = false;
|
|
15
|
-
private isEnabled = true;
|
|
16
|
-
private context: RUMManagerContext = {};
|
|
17
|
-
|
|
18
|
-
async init(
|
|
19
|
-
context: RUMManagerContext,
|
|
20
|
-
options: Partial<MitoSLSAdapterOptions> = {}
|
|
21
|
-
): Promise<void> {
|
|
22
|
-
try {
|
|
23
|
-
if (!this.shouldEnableRUM()) {
|
|
24
|
-
if (mitoConfig.debug) {
|
|
25
|
-
console.log('RUM system is disabled');
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (this.isInitialized) {
|
|
31
|
-
if (mitoConfig.debug) {
|
|
32
|
-
console.log('RUM system already initialized');
|
|
33
|
-
}
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.context = {
|
|
38
|
-
store: context.store,
|
|
39
|
-
router: context.router,
|
|
40
|
-
Vue: context.Vue,
|
|
41
|
-
...context
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const mergedOptions: Partial<MitoSLSAdapterOptions> = {
|
|
45
|
-
...mitoConfig,
|
|
46
|
-
...options,
|
|
47
|
-
vue: {
|
|
48
|
-
...(mitoConfig as any).vue,
|
|
49
|
-
...(options as any).vue
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
this.adapter = await initRUMCore(
|
|
54
|
-
{
|
|
55
|
-
store: this.context.store,
|
|
56
|
-
router: this.context.router,
|
|
57
|
-
Vue: this.context.Vue
|
|
58
|
-
},
|
|
59
|
-
mergedOptions
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
this.setUserInfo();
|
|
63
|
-
this.setupUserStateListener();
|
|
64
|
-
this.setupUserInteractionTracking();
|
|
65
|
-
|
|
66
|
-
this.trackInitialRoute();
|
|
67
|
-
|
|
68
|
-
this.isInitialized = true;
|
|
69
|
-
if (mitoConfig.debug) {
|
|
70
|
-
console.log('RUM system initialized successfully');
|
|
71
|
-
}
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error('Failed to initialize RUM system:', error);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private shouldEnableRUM(): boolean {
|
|
78
|
-
if (!this.isEnabled) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const env = getRUMEnv();
|
|
83
|
-
|
|
84
|
-
const rumEnabled = (env as any).VUE_APP_RUM_ENABLED;
|
|
85
|
-
if (rumEnabled !== undefined) {
|
|
86
|
-
return rumEnabled === 'true';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const mode = (env as any).MODE;
|
|
90
|
-
const isProdEnv = mode === 'prod' || mode === 'production';
|
|
91
|
-
|
|
92
|
-
return !isProdEnv;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private setUserInfo(): void {
|
|
96
|
-
if (!this.context.store) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
const userModule = this.context.store.state.user || {};
|
|
102
|
-
const user = userModule.userInfo || userModule || {};
|
|
103
|
-
|
|
104
|
-
if (this.adapter && user.userId) {
|
|
105
|
-
this.adapter.setUser({
|
|
106
|
-
userId: user.userId,
|
|
107
|
-
userName: user.userName,
|
|
108
|
-
accountId: user.accountId,
|
|
109
|
-
roles: user.roles,
|
|
110
|
-
email: user.email
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
} catch (error) {
|
|
114
|
-
console.warn('Failed to set user info:', error);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private setupUserStateListener(): void {
|
|
119
|
-
if (!this.context.store) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.context.store.subscribe((mutation: any) => {
|
|
124
|
-
if (mutation.type.includes('user')) {
|
|
125
|
-
this.setUserInfo();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private setupUserInteractionTracking(): void {
|
|
131
|
-
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
document.addEventListener(
|
|
136
|
-
'click',
|
|
137
|
-
(event: MouseEvent) => {
|
|
138
|
-
try {
|
|
139
|
-
const originalTarget = event.target as HTMLElement | null;
|
|
140
|
-
|
|
141
|
-
const findClosest = (el: any, selector: string): HTMLElement | null =>
|
|
142
|
-
el && typeof el.closest === 'function' ? el.closest(selector) : null;
|
|
143
|
-
|
|
144
|
-
let target = findClosest(originalTarget, '[rum-id],[rum-name]');
|
|
145
|
-
|
|
146
|
-
if (!target) {
|
|
147
|
-
target = findClosest(
|
|
148
|
-
originalTarget,
|
|
149
|
-
'button, a, [role="button"], [role="link"]'
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (!target && originalTarget && window.getComputedStyle) {
|
|
154
|
-
const style = window.getComputedStyle(originalTarget);
|
|
155
|
-
if (style.cursor === 'pointer') {
|
|
156
|
-
target = originalTarget;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (!target) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const getAttr = (el: any, name: string): string | null =>
|
|
165
|
-
el && typeof el.getAttribute === 'function'
|
|
166
|
-
? el.getAttribute(name)
|
|
167
|
-
: null;
|
|
168
|
-
|
|
169
|
-
let bizId =
|
|
170
|
-
getAttr(target, 'rum-id') || getAttr(target, 'rum-name') || '';
|
|
171
|
-
|
|
172
|
-
if (!bizId) {
|
|
173
|
-
const tagName = target.tagName
|
|
174
|
-
? target.tagName.toLowerCase()
|
|
175
|
-
: 'element';
|
|
176
|
-
|
|
177
|
-
const classList = (target.className || '')
|
|
178
|
-
.toString()
|
|
179
|
-
.split(/\s+/)
|
|
180
|
-
.filter((c: string) => c.trim());
|
|
181
|
-
const primaryClass = classList[0] || 'no-class';
|
|
182
|
-
|
|
183
|
-
const getLabel = (el: any): string => {
|
|
184
|
-
if (!el) return '';
|
|
185
|
-
const text = (el.textContent || '').trim();
|
|
186
|
-
if (text) return text;
|
|
187
|
-
const ariaLabel = getAttr(el, 'aria-label');
|
|
188
|
-
if (ariaLabel) return ariaLabel;
|
|
189
|
-
const title = getAttr(el, 'title');
|
|
190
|
-
if (title) return title;
|
|
191
|
-
const alt = getAttr(el, 'alt');
|
|
192
|
-
if (alt) return alt;
|
|
193
|
-
const placeholder = getAttr(el, 'placeholder');
|
|
194
|
-
if (placeholder) return placeholder;
|
|
195
|
-
const value = typeof el.value === 'string' ? el.value.trim() : '';
|
|
196
|
-
if (value) return value;
|
|
197
|
-
return '';
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const label = getLabel(target);
|
|
201
|
-
const safeLabel =
|
|
202
|
-
(label || primaryClass).replace(/\s+/g, '_').slice(0, 32) ||
|
|
203
|
-
'no_label';
|
|
204
|
-
|
|
205
|
-
const route = (this.context?.router as any)?.currentRoute || {};
|
|
206
|
-
|
|
207
|
-
const buildRouteKey = (r: any): string => {
|
|
208
|
-
try {
|
|
209
|
-
if (!r) return 'unknown_route';
|
|
210
|
-
|
|
211
|
-
if (r.name) {
|
|
212
|
-
return String(r.name);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (Array.isArray(r.matched) && r.matched.length > 0) {
|
|
216
|
-
const record = r.matched[r.matched.length - 1];
|
|
217
|
-
if (record && record.path) {
|
|
218
|
-
return record.path;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (r.path) {
|
|
223
|
-
return r.path;
|
|
224
|
-
}
|
|
225
|
-
} catch {
|
|
226
|
-
// ignore
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return window.location.pathname || 'unknown_route';
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const routeKey = buildRouteKey(route);
|
|
233
|
-
|
|
234
|
-
let indexSuffix = '';
|
|
235
|
-
try {
|
|
236
|
-
const parent = target.parentNode as HTMLElement | null;
|
|
237
|
-
if (parent && parent.children && parent.children.length) {
|
|
238
|
-
const siblings = Array.from(parent.children).filter(
|
|
239
|
-
(el) =>
|
|
240
|
-
el.tagName === target.tagName &&
|
|
241
|
-
(el as HTMLElement).className === target.className
|
|
242
|
-
);
|
|
243
|
-
const index = siblings.indexOf(target);
|
|
244
|
-
if (index >= 0) {
|
|
245
|
-
indexSuffix = `[${index}]`;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
} catch {
|
|
249
|
-
// ignore
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
bizId = `${routeKey}|${tagName}.${primaryClass}${indexSuffix}|${safeLabel}`;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const targetInfo = {
|
|
256
|
-
tagName: target.tagName,
|
|
257
|
-
className: target.className,
|
|
258
|
-
id: target.id,
|
|
259
|
-
textContent: target.textContent?.substring(0, 50) || '',
|
|
260
|
-
selector: this.getCSSSelector(target)
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
this.trackAction('click', {
|
|
264
|
-
type: 'click',
|
|
265
|
-
bizId,
|
|
266
|
-
x: event.clientX,
|
|
267
|
-
y: event.clientY,
|
|
268
|
-
target: targetInfo,
|
|
269
|
-
page: {
|
|
270
|
-
url: window.location.href,
|
|
271
|
-
title: document.title,
|
|
272
|
-
path: window.location.pathname
|
|
273
|
-
},
|
|
274
|
-
timestamp: Date.now()
|
|
275
|
-
});
|
|
276
|
-
} catch (error) {
|
|
277
|
-
console.warn('Failed to track click event:', error);
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
true
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
document.addEventListener('visibilitychange', () => {});
|
|
284
|
-
|
|
285
|
-
if (mitoConfig.debug) {
|
|
286
|
-
console.log('User interaction tracking configured');
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
private trackInitialRoute(): void {
|
|
291
|
-
if (!this.context.router || !this.adapter) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
try {
|
|
296
|
-
const router = this.context.router as any;
|
|
297
|
-
const currentRoute =
|
|
298
|
-
router.currentRoute || (router.app && router.app.$route) || {};
|
|
299
|
-
|
|
300
|
-
const from = {
|
|
301
|
-
path: currentRoute.fullPath || currentRoute.path,
|
|
302
|
-
name: currentRoute.name,
|
|
303
|
-
params: currentRoute.params,
|
|
304
|
-
query: currentRoute.query
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const to = { ...from };
|
|
308
|
-
|
|
309
|
-
const adapter: any = this.adapter;
|
|
310
|
-
if (adapter && typeof adapter.handleRouteChange === 'function') {
|
|
311
|
-
adapter.handleRouteChange(to, from);
|
|
312
|
-
}
|
|
313
|
-
} catch (error) {
|
|
314
|
-
if (mitoConfig.debug) {
|
|
315
|
-
console.warn('Failed to track initial route:', error);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
private getCSSSelector(element: Element | null): string {
|
|
321
|
-
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
|
322
|
-
return '';
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const path: string[] = [];
|
|
326
|
-
let current: Element | null = element;
|
|
327
|
-
|
|
328
|
-
while (current && current.nodeType === Node.ELEMENT_NODE) {
|
|
329
|
-
let selector = current.tagName.toLowerCase();
|
|
330
|
-
|
|
331
|
-
if (current.id) {
|
|
332
|
-
selector += `#${current.id}`;
|
|
333
|
-
path.unshift(selector);
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if ((current as HTMLElement).className) {
|
|
338
|
-
const classes = (current as HTMLElement).className
|
|
339
|
-
.split(' ')
|
|
340
|
-
.filter((c) => c.trim());
|
|
341
|
-
if (classes.length > 0) {
|
|
342
|
-
selector += `.${classes[0]}`;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
path.unshift(selector);
|
|
347
|
-
current = current.parentElement;
|
|
348
|
-
|
|
349
|
-
if (path.length > 5) {
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return path.join(' > ');
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
trackEvent(eventName: string, eventData: Record<string, any> = {}): void {
|
|
358
|
-
if (!this.checkRUMAvailable()) {
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
try {
|
|
363
|
-
this.adapter.trackEvent({
|
|
364
|
-
name: eventName,
|
|
365
|
-
...eventData
|
|
366
|
-
});
|
|
367
|
-
} catch (error) {
|
|
368
|
-
console.error('Failed to track event:', error);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
trackPerformance(performanceData: Record<string, any>): void {
|
|
373
|
-
if (!this.checkRUMAvailable()) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
try {
|
|
378
|
-
this.adapter.trackEvent({
|
|
379
|
-
name: 'performance',
|
|
380
|
-
type: 'performance',
|
|
381
|
-
...performanceData
|
|
382
|
-
});
|
|
383
|
-
} catch (error) {
|
|
384
|
-
console.error('Failed to track performance:', error);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
trackAction(action: string, actionData: Record<string, any> = {}): void {
|
|
389
|
-
if (!this.checkRUMAvailable()) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
try {
|
|
394
|
-
this.adapter.trackEvent({
|
|
395
|
-
name: 'user_action',
|
|
396
|
-
action,
|
|
397
|
-
...actionData
|
|
398
|
-
});
|
|
399
|
-
} catch (error) {
|
|
400
|
-
console.error('Failed to track action:', error);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
trackMetric(
|
|
405
|
-
metricName: string,
|
|
406
|
-
value: number,
|
|
407
|
-
dimensions: Record<string, any> = {}
|
|
408
|
-
): void {
|
|
409
|
-
if (!this.checkRUMAvailable()) {
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
try {
|
|
414
|
-
this.adapter.trackEvent({
|
|
415
|
-
name: 'metric',
|
|
416
|
-
metricName,
|
|
417
|
-
value,
|
|
418
|
-
dimensions
|
|
419
|
-
});
|
|
420
|
-
} catch (error) {
|
|
421
|
-
console.error('Failed to track metric:', error);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
getBreadcrumbs(): any[] {
|
|
426
|
-
if (!this.checkRUMAvailable()) {
|
|
427
|
-
return [];
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
try {
|
|
431
|
-
return this.adapter.getBreadcrumbs();
|
|
432
|
-
} catch (error) {
|
|
433
|
-
console.error('Failed to get breadcrumbs:', error);
|
|
434
|
-
return [];
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
enable(): void {
|
|
439
|
-
this.isEnabled = true;
|
|
440
|
-
if (mitoConfig.debug) {
|
|
441
|
-
console.log('RUM system enabled');
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
disable(): void {
|
|
446
|
-
this.isEnabled = false;
|
|
447
|
-
if (mitoConfig.debug) {
|
|
448
|
-
console.log('RUM system disabled');
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
private checkRUMAvailable(): boolean {
|
|
453
|
-
return this.isEnabled && this.isInitialized && !!this.adapter;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
getConfig(): Record<string, any> {
|
|
457
|
-
return {
|
|
458
|
-
isInitialized: this.isInitialized,
|
|
459
|
-
isEnabled: this.isEnabled,
|
|
460
|
-
environment: mitoConfig.environment,
|
|
461
|
-
debug: mitoConfig.debug,
|
|
462
|
-
sls: {
|
|
463
|
-
enabled: slsConfig.enabled,
|
|
464
|
-
configured: true,
|
|
465
|
-
project: slsConfig.project,
|
|
466
|
-
logstore: slsConfig.logstore
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
destroy(): void {
|
|
472
|
-
try {
|
|
473
|
-
if (this.adapter) {
|
|
474
|
-
this.adapter.destroy();
|
|
475
|
-
this.adapter = null;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
this.isInitialized = false;
|
|
479
|
-
this.context = {} as RUMManagerContext;
|
|
480
|
-
if (mitoConfig.debug) {
|
|
481
|
-
console.log('RUM system destroyed');
|
|
482
|
-
}
|
|
483
|
-
} catch (error) {
|
|
484
|
-
console.error('Failed to destroy RUM system:', error);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
package/src/vue2/plugin.vue2.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RUMManagerVue2,
|
|
3
|
-
type RUMManagerContext
|
|
4
|
-
} from './RUMManager.vue2';
|
|
5
|
-
import type { MitoSLSAdapterOptions } from '../core/MitoSLSAdapter';
|
|
6
|
-
|
|
7
|
-
const rumManagerVue2 = new RUMManagerVue2();
|
|
8
|
-
|
|
9
|
-
export const initRUMSystem = (
|
|
10
|
-
context: RUMManagerContext,
|
|
11
|
-
options: Partial<MitoSLSAdapterOptions> = {}
|
|
12
|
-
) => rumManagerVue2.init(context, options);
|
|
13
|
-
|
|
14
|
-
export const trackEvent = (
|
|
15
|
-
eventName: string,
|
|
16
|
-
eventData?: Record<string, any>
|
|
17
|
-
) => rumManagerVue2.trackEvent(eventName, eventData || {});
|
|
18
|
-
|
|
19
|
-
export const trackPerformance = (performanceData: Record<string, any>) =>
|
|
20
|
-
rumManagerVue2.trackPerformance(performanceData);
|
|
21
|
-
|
|
22
|
-
export const trackAction = (
|
|
23
|
-
action: string,
|
|
24
|
-
actionData?: Record<string, any>
|
|
25
|
-
) => rumManagerVue2.trackAction(action, actionData || {});
|
|
26
|
-
|
|
27
|
-
export const trackMetric = (
|
|
28
|
-
metricName: string,
|
|
29
|
-
value: number,
|
|
30
|
-
dimensions?: Record<string, any>
|
|
31
|
-
) => rumManagerVue2.trackMetric(metricName, value, dimensions || {});
|
|
32
|
-
|
|
33
|
-
export const getBreadcrumbs = () => rumManagerVue2.getBreadcrumbs();
|
|
34
|
-
|
|
35
|
-
export const enableRUM = () => rumManagerVue2.enable();
|
|
36
|
-
export const disableRUM = () => rumManagerVue2.disable();
|
|
37
|
-
export const getRUMConfig = () => rumManagerVue2.getConfig();
|
|
38
|
-
export const destroyRUM = () => rumManagerVue2.destroy();
|
|
39
|
-
export const getRUMManager = () => rumManagerVue2;
|
|
40
|
-
|
|
41
|
-
export const RUMPluginVue2 = {
|
|
42
|
-
install(Vue: any) {
|
|
43
|
-
Vue.prototype.$rum = {
|
|
44
|
-
trackEvent,
|
|
45
|
-
trackPerformance,
|
|
46
|
-
trackAction,
|
|
47
|
-
trackMetric,
|
|
48
|
-
getBreadcrumbs,
|
|
49
|
-
enable: enableRUM,
|
|
50
|
-
disable: disableRUM,
|
|
51
|
-
getConfig: getRUMConfig
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
(Vue as any).$rumManager = rumManagerVue2;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { TransformContext } from '../core/config';
|
|
2
|
-
import type { MitoSLSAdapterOptions } from '../core/MitoSLSAdapter';
|
|
3
|
-
import { RUMManagerVue2 } from '../vue2/RUMManager.vue2';
|
|
4
|
-
|
|
5
|
-
export interface RUMManagerContextVue3 extends TransformContext {}
|
|
6
|
-
|
|
7
|
-
export class RUMManagerVue3 {
|
|
8
|
-
private inner = new RUMManagerVue2();
|
|
9
|
-
|
|
10
|
-
init(
|
|
11
|
-
context: RUMManagerContextVue3,
|
|
12
|
-
options: Partial<MitoSLSAdapterOptions> = {}
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
return this.inner.init(context as any, options);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
trackEvent(eventName: string, eventData: Record<string, any> = {}): void {
|
|
18
|
-
this.inner.trackEvent(eventName, eventData);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
trackPerformance(performanceData: Record<string, any>): void {
|
|
22
|
-
this.inner.trackPerformance(performanceData);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
trackAction(action: string, actionData: Record<string, any> = {}): void {
|
|
26
|
-
this.inner.trackAction(action, actionData);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
trackMetric(
|
|
30
|
-
metricName: string,
|
|
31
|
-
value: number,
|
|
32
|
-
dimensions: Record<string, any> = {}
|
|
33
|
-
): void {
|
|
34
|
-
this.inner.trackMetric(metricName, value, dimensions);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getBreadcrumbs(): any[] {
|
|
38
|
-
return this.inner.getBreadcrumbs();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
enable(): void {
|
|
42
|
-
this.inner.enable();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
disable(): void {
|
|
46
|
-
this.inner.disable();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getConfig(): Record<string, any> {
|
|
50
|
-
return this.inner.getConfig();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
destroy(): void {
|
|
54
|
-
this.inner.destroy();
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/vue3/plugin.vue3.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { App } from 'vue';
|
|
2
|
-
import * as Vue from 'vue';
|
|
3
|
-
import type { MitoSLSAdapterOptions } from '../core/MitoSLSAdapter';
|
|
4
|
-
import { RUMManagerVue3 } from './RUMManager.vue3';
|
|
5
|
-
|
|
6
|
-
export interface RUMVue3PluginOptions {
|
|
7
|
-
store?: any;
|
|
8
|
-
router?: any;
|
|
9
|
-
coreOptions?: Partial<MitoSLSAdapterOptions>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function createRUMPluginVue3(options: RUMVue3PluginOptions) {
|
|
13
|
-
const manager = new RUMManagerVue3();
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
install(app: App) {
|
|
17
|
-
manager.init(
|
|
18
|
-
{ store: options.store, router: options.router },
|
|
19
|
-
options.coreOptions || {}
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
(app.config.globalProperties as any).$rum = {
|
|
23
|
-
trackEvent: manager.trackEvent.bind(manager),
|
|
24
|
-
trackPerformance: manager.trackPerformance.bind(manager),
|
|
25
|
-
trackAction: manager.trackAction.bind(manager),
|
|
26
|
-
trackMetric: manager.trackMetric.bind(manager),
|
|
27
|
-
getBreadcrumbs: manager.getBreadcrumbs.bind(manager),
|
|
28
|
-
enable: manager.enable.bind(manager),
|
|
29
|
-
disable: manager.disable.bind(manager),
|
|
30
|
-
getConfig: manager.getConfig.bind(manager)
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
app.provide('rum', manager);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function useRUM(): RUMManagerVue3 | undefined {
|
|
39
|
-
return Vue.inject<RUMManagerVue3>('rum');
|
|
40
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2019",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "Node",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"outDir": "dist",
|
|
12
|
-
"rootDir": "src",
|
|
13
|
-
"resolveJsonModule": true
|
|
14
|
-
},
|
|
15
|
-
"include": ["src"]
|
|
16
|
-
}
|