@cloudcare/rum-uniapp 2.0.1 → 2.1.3
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 +11 -8
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/rum.entry.js +24 -8
- package/cjs/boot/rum.js +14 -2
- package/cjs/core/baseInfo.js +0 -6
- package/cjs/core/configuration.js +4 -0
- package/cjs/core/errorCollection.js +5 -6
- package/cjs/core/errorFilter.js +47 -0
- package/cjs/core/errorTools.js +16 -8
- package/cjs/core/lifeCycle.js +1 -0
- package/cjs/core/sdk.js +0 -1
- package/cjs/core/sessionManagement.js +45 -0
- package/cjs/core/transport.js +0 -9
- package/cjs/helper/enums.js +13 -7
- package/cjs/helper/limitModification.js +83 -0
- package/cjs/helper/tracekit.js +1 -1
- package/cjs/helper/utils.js +86 -1
- package/cjs/rumEventsCollection/action/actionCollection.js +19 -1
- package/cjs/rumEventsCollection/app/appCollection.js +0 -1
- package/cjs/rumEventsCollection/assembly.js +25 -15
- package/cjs/rumEventsCollection/error/errorCollection.js +37 -5
- package/cjs/rumEventsCollection/internalContext.js +34 -0
- package/cjs/rumEventsCollection/page/index.js +1 -0
- package/cjs/rumEventsCollection/resource/resourceCollection.js +0 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rum.entry.js +24 -9
- package/esm/boot/rum.js +12 -2
- package/esm/core/baseInfo.js +0 -5
- package/esm/core/configuration.js +4 -0
- package/esm/core/errorCollection.js +5 -6
- package/esm/core/errorFilter.js +38 -0
- package/esm/core/errorTools.js +14 -8
- package/esm/core/lifeCycle.js +1 -0
- package/esm/core/sdk.js +0 -1
- package/esm/core/sessionManagement.js +20 -0
- package/esm/core/transport.js +0 -9
- package/esm/helper/enums.js +8 -2
- package/esm/helper/limitModification.js +57 -0
- package/esm/helper/tracekit.js +1 -1
- package/esm/helper/utils.js +68 -0
- package/esm/rumEventsCollection/action/actionCollection.js +20 -2
- package/esm/rumEventsCollection/app/appCollection.js +0 -1
- package/esm/rumEventsCollection/assembly.js +24 -16
- package/esm/rumEventsCollection/error/errorCollection.js +36 -5
- package/esm/rumEventsCollection/internalContext.js +27 -0
- package/esm/rumEventsCollection/page/index.js +1 -0
- package/esm/rumEventsCollection/resource/resourceCollection.js +0 -1
- package/package.json +1 -1
package/esm/helper/utils.js
CHANGED
|
@@ -44,6 +44,33 @@ export var values = function values(obj) {
|
|
|
44
44
|
});
|
|
45
45
|
return results;
|
|
46
46
|
};
|
|
47
|
+
export var keys = function keys(obj) {
|
|
48
|
+
var results = [];
|
|
49
|
+
|
|
50
|
+
if (obj === null) {
|
|
51
|
+
return results;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
each(obj, function (value, key) {
|
|
55
|
+
results[results.length] = key;
|
|
56
|
+
});
|
|
57
|
+
return results;
|
|
58
|
+
};
|
|
59
|
+
export var indexOf = function indexOf(arr, target) {
|
|
60
|
+
var indexOf = arr.indexOf;
|
|
61
|
+
|
|
62
|
+
if (indexOf) {
|
|
63
|
+
return indexOf.call(arr, target);
|
|
64
|
+
} else {
|
|
65
|
+
for (var i = 0; i < arr.length; i++) {
|
|
66
|
+
if (target === arr[i]) {
|
|
67
|
+
return i;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return -1;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
47
74
|
export function round(num, decimals) {
|
|
48
75
|
return +num.toFixed(decimals);
|
|
49
76
|
}
|
|
@@ -665,4 +692,45 @@ export function getActivePage() {
|
|
|
665
692
|
}
|
|
666
693
|
|
|
667
694
|
return {};
|
|
695
|
+
}
|
|
696
|
+
export function findCommaSeparatedValue(rawString, name) {
|
|
697
|
+
var matches = rawString.match('(?:^|;)\\s*' + name + '\\s*=\\s*([^;]+)');
|
|
698
|
+
return matches ? matches[1] : undefined;
|
|
699
|
+
}
|
|
700
|
+
export var ONE_SECOND = 1000;
|
|
701
|
+
export var ONE_MINUTE = 60 * ONE_SECOND;
|
|
702
|
+
export var ONE_HOUR = 60 * ONE_MINUTE;
|
|
703
|
+
export var ONE_KILO_BYTE = 1024;
|
|
704
|
+
export function defineGlobal(global, name, api) {
|
|
705
|
+
global[name] = api;
|
|
706
|
+
}
|
|
707
|
+
export function getGlobalObject() {
|
|
708
|
+
if (typeof globalThis === 'object') {
|
|
709
|
+
return globalThis;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
Object.defineProperty(Object.prototype, '_dd_temp_', {
|
|
713
|
+
get: function get() {
|
|
714
|
+
return this;
|
|
715
|
+
},
|
|
716
|
+
configurable: true
|
|
717
|
+
}); // @ts-ignore
|
|
718
|
+
|
|
719
|
+
var globalObject = _dd_temp_; // @ts-ignore
|
|
720
|
+
|
|
721
|
+
delete Object.prototype._dd_temp_;
|
|
722
|
+
|
|
723
|
+
if (typeof globalObject !== 'object') {
|
|
724
|
+
// on safari _dd_temp_ is available on window but not globally
|
|
725
|
+
// fallback on other browser globals check
|
|
726
|
+
if (typeof self === 'object') {
|
|
727
|
+
globalObject = self;
|
|
728
|
+
} else if (typeof window === 'object') {
|
|
729
|
+
globalObject = window;
|
|
730
|
+
} else {
|
|
731
|
+
globalObject = {};
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
return globalObject;
|
|
668
736
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { msToNs, extend2Lev } from '../../helper/utils';
|
|
2
2
|
import { LifeCycleEventType } from '../../core/lifeCycle';
|
|
3
|
-
import { RumEventType } from '../../helper/enums';
|
|
3
|
+
import { RumEventType, ActionType } from '../../helper/enums';
|
|
4
4
|
import { trackActions } from './trackActions';
|
|
5
5
|
export function startActionCollection(lifeCycle, configuration, Vue) {
|
|
6
6
|
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
|
|
@@ -10,10 +10,18 @@ export function startActionCollection(lifeCycle, configuration, Vue) {
|
|
|
10
10
|
if (configuration.trackInteractions) {
|
|
11
11
|
trackActions(lifeCycle, Vue);
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
addAction: function addAction(action, savedCommonContext) {
|
|
16
|
+
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, extend2Lev({
|
|
17
|
+
savedCommonContext: savedCommonContext
|
|
18
|
+
}, processAction(action)));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
function processAction(action) {
|
|
16
|
-
var autoActionProperties = {
|
|
24
|
+
var autoActionProperties = isAutoAction(action) ? {
|
|
17
25
|
action: {
|
|
18
26
|
error: {
|
|
19
27
|
count: action.counts.errorCount
|
|
@@ -27,7 +35,12 @@ function processAction(action) {
|
|
|
27
35
|
count: action.counts.resourceCount
|
|
28
36
|
}
|
|
29
37
|
}
|
|
38
|
+
} : {
|
|
39
|
+
action: {
|
|
40
|
+
loadingTime: 0
|
|
41
|
+
}
|
|
30
42
|
};
|
|
43
|
+
var customerContext = !isAutoAction(action) ? action.context : undefined;
|
|
31
44
|
var actionEvent = extend2Lev({
|
|
32
45
|
action: {
|
|
33
46
|
target: {
|
|
@@ -39,7 +52,12 @@ function processAction(action) {
|
|
|
39
52
|
type: RumEventType.ACTION
|
|
40
53
|
}, autoActionProperties);
|
|
41
54
|
return {
|
|
55
|
+
customerContext: customerContext,
|
|
42
56
|
rawRumEvent: actionEvent,
|
|
43
57
|
startTime: action.startClocks
|
|
44
58
|
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isAutoAction(action) {
|
|
62
|
+
return action.type !== ActionType.custom;
|
|
45
63
|
}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { extend2Lev, withSnakeCaseKeys,
|
|
1
|
+
import { extend2Lev, withSnakeCaseKeys, isEmptyObject } from '../helper/utils';
|
|
2
2
|
import { LifeCycleEventType } from '../core/lifeCycle';
|
|
3
3
|
import { RumEventType } from '../helper/enums';
|
|
4
4
|
import baseInfo from '../core/baseInfo';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
export function startRumAssembly(applicationId, configuration, lifeCycle, parentContexts, getCommonContext) {
|
|
5
|
+
import { SessionType } from '../core/sessionManagement';
|
|
6
|
+
import { createErrorFilter } from '../core/errorFilter';
|
|
7
|
+
export function startRumAssembly(applicationId, configuration, session, lifeCycle, parentContexts, getCommonContext) {
|
|
8
|
+
var errorFilter = createErrorFilter(configuration, function (error) {
|
|
9
|
+
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, {
|
|
10
|
+
error: error
|
|
11
|
+
});
|
|
12
|
+
});
|
|
15
13
|
lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
|
|
16
14
|
var startTime = data.startTime;
|
|
17
15
|
var rawRumEvent = data.rawRumEvent;
|
|
18
16
|
var viewContext = parentContexts.findView(startTime);
|
|
19
|
-
var savedCommonContext = data.
|
|
17
|
+
var savedCommonContext = data.savedCommonContext;
|
|
20
18
|
var customerContext = data.customerContext;
|
|
21
19
|
var deviceContext = {
|
|
22
20
|
device: baseInfo.deviceInfo
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
if (isTracked(
|
|
23
|
+
if (session.isTracked() && (viewContext || rawRumEvent.type === RumEventType.APP)) {
|
|
26
24
|
var actionContext = parentContexts.findAction(startTime);
|
|
27
25
|
var commonContext = savedCommonContext || getCommonContext();
|
|
28
26
|
var rumContext = {
|
|
@@ -39,7 +37,7 @@ export function startRumAssembly(applicationId, configuration, lifeCycle, parent
|
|
|
39
37
|
device: {},
|
|
40
38
|
date: new Date().getTime(),
|
|
41
39
|
session: {
|
|
42
|
-
id:
|
|
40
|
+
id: session.getSessionId(),
|
|
43
41
|
type: SessionType.USER
|
|
44
42
|
},
|
|
45
43
|
user: {
|
|
@@ -49,7 +47,7 @@ export function startRumAssembly(applicationId, configuration, lifeCycle, parent
|
|
|
49
47
|
};
|
|
50
48
|
var rumEvent = extend2Lev(rumContext, deviceContext, viewContext, actionContext, rawRumEvent);
|
|
51
49
|
var serverRumEvent = withSnakeCaseKeys(rumEvent);
|
|
52
|
-
var context = extend2Lev(commonContext.context, customerContext);
|
|
50
|
+
var context = extend2Lev({}, commonContext.context, customerContext);
|
|
53
51
|
|
|
54
52
|
if (!isEmptyObject(context)) {
|
|
55
53
|
serverRumEvent.tags = context;
|
|
@@ -63,7 +61,17 @@ export function startRumAssembly(applicationId, configuration, lifeCycle, parent
|
|
|
63
61
|
}, commonContext.user);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
if (shouldSend(serverRumEvent, errorFilter)) {
|
|
65
|
+
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
|
|
66
|
+
}
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function shouldSend(event, errorFilter) {
|
|
72
|
+
if (event.type === RumEventType.ERROR) {
|
|
73
|
+
return !errorFilter.isLimitReached();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return true;
|
|
69
77
|
}
|
|
@@ -3,13 +3,44 @@ import { RumEventType } from '../../helper/enums';
|
|
|
3
3
|
import { LifeCycleEventType } from '../../core/lifeCycle';
|
|
4
4
|
import { urlParse, replaceNumberCharByPath, getStatusGroup } from '../../helper/utils';
|
|
5
5
|
export function startErrorCollection(lifeCycle, configuration) {
|
|
6
|
-
return doStartErrorCollection(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
// return doStartErrorCollection(
|
|
7
|
+
// lifeCycle,
|
|
8
|
+
// configuration,
|
|
9
|
+
// startAutomaticErrorCollection(configuration),
|
|
10
|
+
// )
|
|
11
|
+
startAutomaticErrorCollection(configuration).subscribe(function (error) {
|
|
12
|
+
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, {
|
|
13
|
+
error: error
|
|
14
|
+
});
|
|
11
15
|
});
|
|
16
|
+
return doStartErrorCollection(lifeCycle);
|
|
12
17
|
}
|
|
18
|
+
export function doStartErrorCollection(lifeCycle) {
|
|
19
|
+
lifeCycle.subscribe(LifeCycleEventType.RAW_ERROR_COLLECTED, function (error) {
|
|
20
|
+
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error.error));
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
addError: function addError(customError, savedCommonContext) {// var rawError = computeRawError(
|
|
24
|
+
// customError.error,
|
|
25
|
+
// customError.startTime,
|
|
26
|
+
// customError.source
|
|
27
|
+
// )
|
|
28
|
+
// lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, {
|
|
29
|
+
// customerContext: customError.context,
|
|
30
|
+
// savedCommonContext: savedCommonContext,
|
|
31
|
+
// error: rawError
|
|
32
|
+
// })
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
} // function computeRawError(error, handlingStack, startClocks) {
|
|
36
|
+
// const stackTrace = error instanceof Error ? computeStackTrace(error) : undefined
|
|
37
|
+
// return extend({
|
|
38
|
+
// startClocks,
|
|
39
|
+
// source: ErrorSource.CUSTOM,
|
|
40
|
+
// originalError: error,
|
|
41
|
+
// handling: ErrorHandling.HANDLED
|
|
42
|
+
// }, formatUnknownError(stackTrace, error, 'Provided', handlingStack) )
|
|
43
|
+
// }
|
|
13
44
|
|
|
14
45
|
function processError(error) {
|
|
15
46
|
var resource = error.resource;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal context keep returning v1 format
|
|
3
|
+
* to not break compatibility with logs data format
|
|
4
|
+
*/
|
|
5
|
+
export function startInternalContext(applicationId, session, parentContexts) {
|
|
6
|
+
return {
|
|
7
|
+
get: function get(startTime) {
|
|
8
|
+
var viewContext = parentContexts.findView(startTime);
|
|
9
|
+
|
|
10
|
+
if (session.isTracked() && viewContext) {
|
|
11
|
+
var actionContext = parentContexts.findAction(startTime);
|
|
12
|
+
return {
|
|
13
|
+
application: {
|
|
14
|
+
id: applicationId
|
|
15
|
+
},
|
|
16
|
+
session: {
|
|
17
|
+
id: session.getSessionId()
|
|
18
|
+
},
|
|
19
|
+
userAction: actionContext ? {
|
|
20
|
+
id: actionContext.userAction.id
|
|
21
|
+
} : undefined,
|
|
22
|
+
page: viewContext.page
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -15,7 +15,6 @@ function processRequest(request) {
|
|
|
15
15
|
var tracingInfo = computeRequestTracingInfo(request);
|
|
16
16
|
var urlObj = urlParse(request.url).getParse();
|
|
17
17
|
var startTime = request.startTime;
|
|
18
|
-
console.log(request, 'request=========');
|
|
19
18
|
var resourceEvent = extend2Lev({
|
|
20
19
|
date: startTime,
|
|
21
20
|
resource: {
|