@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.
Files changed (48) hide show
  1. package/README.md +11 -8
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/rum.entry.js +24 -8
  4. package/cjs/boot/rum.js +14 -2
  5. package/cjs/core/baseInfo.js +0 -6
  6. package/cjs/core/configuration.js +4 -0
  7. package/cjs/core/errorCollection.js +5 -6
  8. package/cjs/core/errorFilter.js +47 -0
  9. package/cjs/core/errorTools.js +16 -8
  10. package/cjs/core/lifeCycle.js +1 -0
  11. package/cjs/core/sdk.js +0 -1
  12. package/cjs/core/sessionManagement.js +45 -0
  13. package/cjs/core/transport.js +0 -9
  14. package/cjs/helper/enums.js +13 -7
  15. package/cjs/helper/limitModification.js +83 -0
  16. package/cjs/helper/tracekit.js +1 -1
  17. package/cjs/helper/utils.js +86 -1
  18. package/cjs/rumEventsCollection/action/actionCollection.js +19 -1
  19. package/cjs/rumEventsCollection/app/appCollection.js +0 -1
  20. package/cjs/rumEventsCollection/assembly.js +25 -15
  21. package/cjs/rumEventsCollection/error/errorCollection.js +37 -5
  22. package/cjs/rumEventsCollection/internalContext.js +34 -0
  23. package/cjs/rumEventsCollection/page/index.js +1 -0
  24. package/cjs/rumEventsCollection/resource/resourceCollection.js +0 -1
  25. package/esm/boot/buildEnv.js +1 -1
  26. package/esm/boot/rum.entry.js +24 -9
  27. package/esm/boot/rum.js +12 -2
  28. package/esm/core/baseInfo.js +0 -5
  29. package/esm/core/configuration.js +4 -0
  30. package/esm/core/errorCollection.js +5 -6
  31. package/esm/core/errorFilter.js +38 -0
  32. package/esm/core/errorTools.js +14 -8
  33. package/esm/core/lifeCycle.js +1 -0
  34. package/esm/core/sdk.js +0 -1
  35. package/esm/core/sessionManagement.js +20 -0
  36. package/esm/core/transport.js +0 -9
  37. package/esm/helper/enums.js +8 -2
  38. package/esm/helper/limitModification.js +57 -0
  39. package/esm/helper/tracekit.js +1 -1
  40. package/esm/helper/utils.js +68 -0
  41. package/esm/rumEventsCollection/action/actionCollection.js +20 -2
  42. package/esm/rumEventsCollection/app/appCollection.js +0 -1
  43. package/esm/rumEventsCollection/assembly.js +24 -16
  44. package/esm/rumEventsCollection/error/errorCollection.js +36 -5
  45. package/esm/rumEventsCollection/internalContext.js +27 -0
  46. package/esm/rumEventsCollection/page/index.js +1 -0
  47. package/esm/rumEventsCollection/resource/resourceCollection.js +0 -1
  48. package/package.json +1 -1
@@ -21,10 +21,18 @@ function startActionCollection(lifeCycle, configuration, Vue) {
21
21
  if (configuration.trackInteractions) {
22
22
  (0, _trackActions.trackActions)(lifeCycle, Vue);
23
23
  }
24
+
25
+ return {
26
+ addAction: function addAction(action, savedCommonContext) {
27
+ lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, (0, _utils.extend2Lev)({
28
+ savedCommonContext: savedCommonContext
29
+ }, processAction(action)));
30
+ }
31
+ };
24
32
  }
25
33
 
26
34
  function processAction(action) {
27
- var autoActionProperties = {
35
+ var autoActionProperties = isAutoAction(action) ? {
28
36
  action: {
29
37
  error: {
30
38
  count: action.counts.errorCount
@@ -38,7 +46,12 @@ function processAction(action) {
38
46
  count: action.counts.resourceCount
39
47
  }
40
48
  }
49
+ } : {
50
+ action: {
51
+ loadingTime: 0
52
+ }
41
53
  };
54
+ var customerContext = !isAutoAction(action) ? action.context : undefined;
42
55
  var actionEvent = (0, _utils.extend2Lev)({
43
56
  action: {
44
57
  target: {
@@ -50,7 +63,12 @@ function processAction(action) {
50
63
  type: _enums.RumEventType.ACTION
51
64
  }, autoActionProperties);
52
65
  return {
66
+ customerContext: customerContext,
53
67
  rawRumEvent: actionEvent,
54
68
  startTime: action.startClocks
55
69
  };
70
+ }
71
+
72
+ function isAutoAction(action) {
73
+ return action.type !== _enums.ActionType.custom;
56
74
  }
@@ -31,7 +31,6 @@ function processAppUpdate(appinfo) {
31
31
  duration: (0, _utils.msToNs)(appinfo.duration)
32
32
  }
33
33
  };
34
- console.log(appEvent, 'appEvent====');
35
34
  return {
36
35
  rawRumEvent: appEvent,
37
36
  startTime: appinfo.startTime
@@ -13,29 +13,29 @@ var _enums = require("../helper/enums");
13
13
 
14
14
  var _baseInfo = _interopRequireDefault(require("../core/baseInfo"));
15
15
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ var _sessionManagement = require("../core/sessionManagement");
17
17
 
18
- function isTracked(configuration) {
19
- return (0, _utils.performDraw)(configuration.sampleRate);
20
- }
18
+ var _errorFilter = require("../core/errorFilter");
21
19
 
22
- var SessionType = {
23
- SYNTHETICS: 'synthetics',
24
- USER: 'user'
25
- };
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
26
21
 
27
- function startRumAssembly(applicationId, configuration, lifeCycle, parentContexts, getCommonContext) {
22
+ function startRumAssembly(applicationId, configuration, session, lifeCycle, parentContexts, getCommonContext) {
23
+ var errorFilter = (0, _errorFilter.createErrorFilter)(configuration, function (error) {
24
+ lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_ERROR_COLLECTED, {
25
+ error: error
26
+ });
27
+ });
28
28
  lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
29
29
  var startTime = data.startTime;
30
30
  var rawRumEvent = data.rawRumEvent;
31
31
  var viewContext = parentContexts.findView(startTime);
32
- var savedCommonContext = data.savedGlobalContext;
32
+ var savedCommonContext = data.savedCommonContext;
33
33
  var customerContext = data.customerContext;
34
34
  var deviceContext = {
35
35
  device: _baseInfo["default"].deviceInfo
36
36
  };
37
37
 
38
- if (isTracked(configuration) && (viewContext || rawRumEvent.type === _enums.RumEventType.APP)) {
38
+ if (session.isTracked() && (viewContext || rawRumEvent.type === _enums.RumEventType.APP)) {
39
39
  var actionContext = parentContexts.findAction(startTime);
40
40
  var commonContext = savedCommonContext || getCommonContext();
41
41
  var rumContext = {
@@ -52,8 +52,8 @@ function startRumAssembly(applicationId, configuration, lifeCycle, parentContext
52
52
  device: {},
53
53
  date: new Date().getTime(),
54
54
  session: {
55
- id: _baseInfo["default"].getSessionId(),
56
- type: SessionType.USER
55
+ id: session.getSessionId(),
56
+ type: _sessionManagement.SessionType.USER
57
57
  },
58
58
  user: {
59
59
  id: configuration.user_id || _baseInfo["default"].getClientID(),
@@ -62,7 +62,7 @@ function startRumAssembly(applicationId, configuration, lifeCycle, parentContext
62
62
  };
63
63
  var rumEvent = (0, _utils.extend2Lev)(rumContext, deviceContext, viewContext, actionContext, rawRumEvent);
64
64
  var serverRumEvent = (0, _utils.withSnakeCaseKeys)(rumEvent);
65
- var context = (0, _utils.extend2Lev)(commonContext.context, customerContext);
65
+ var context = (0, _utils.extend2Lev)({}, commonContext.context, customerContext);
66
66
 
67
67
  if (!(0, _utils.isEmptyObject)(context)) {
68
68
  serverRumEvent.tags = context;
@@ -76,7 +76,17 @@ function startRumAssembly(applicationId, configuration, lifeCycle, parentContext
76
76
  }, commonContext.user);
77
77
  }
78
78
 
79
- lifeCycle.notify(_lifeCycle.LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
79
+ if (shouldSend(serverRumEvent, errorFilter)) {
80
+ lifeCycle.notify(_lifeCycle.LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
81
+ }
80
82
  }
81
83
  });
84
+ }
85
+
86
+ function shouldSend(event, errorFilter) {
87
+ if (event.type === _enums.RumEventType.ERROR) {
88
+ return !errorFilter.isLimitReached();
89
+ }
90
+
91
+ return true;
82
92
  }
@@ -15,14 +15,46 @@ var _lifeCycle = require("../../core/lifeCycle");
15
15
  var _utils = require("../../helper/utils");
16
16
 
17
17
  function startErrorCollection(lifeCycle, configuration) {
18
- return doStartErrorCollection(lifeCycle, configuration, (0, _errorCollection.startAutomaticErrorCollection)(configuration));
18
+ // return doStartErrorCollection(
19
+ // lifeCycle,
20
+ // configuration,
21
+ // startAutomaticErrorCollection(configuration),
22
+ // )
23
+ (0, _errorCollection.startAutomaticErrorCollection)(configuration).subscribe(function (error) {
24
+ lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_ERROR_COLLECTED, {
25
+ error: error
26
+ });
27
+ });
28
+ return doStartErrorCollection(lifeCycle);
19
29
  }
20
30
 
21
- function doStartErrorCollection(lifeCycle, configuration, observable) {
22
- observable.subscribe(function (error) {
23
- lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error));
31
+ function doStartErrorCollection(lifeCycle) {
32
+ lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.RAW_ERROR_COLLECTED, function (error) {
33
+ lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error.error));
24
34
  });
25
- }
35
+ return {
36
+ addError: function addError(customError, savedCommonContext) {// var rawError = computeRawError(
37
+ // customError.error,
38
+ // customError.startTime,
39
+ // customError.source
40
+ // )
41
+ // lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, {
42
+ // customerContext: customError.context,
43
+ // savedCommonContext: savedCommonContext,
44
+ // error: rawError
45
+ // })
46
+ }
47
+ };
48
+ } // function computeRawError(error, handlingStack, startClocks) {
49
+ // const stackTrace = error instanceof Error ? computeStackTrace(error) : undefined
50
+ // return extend({
51
+ // startClocks,
52
+ // source: ErrorSource.CUSTOM,
53
+ // originalError: error,
54
+ // handling: ErrorHandling.HANDLED
55
+ // }, formatUnknownError(stackTrace, error, 'Provided', handlingStack) )
56
+ // }
57
+
26
58
 
27
59
  function processError(error) {
28
60
  var resource = error.resource;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.startInternalContext = startInternalContext;
7
+
8
+ /**
9
+ * Internal context keep returning v1 format
10
+ * to not break compatibility with logs data format
11
+ */
12
+ function startInternalContext(applicationId, session, parentContexts) {
13
+ return {
14
+ get: function get(startTime) {
15
+ var viewContext = parentContexts.findView(startTime);
16
+
17
+ if (session.isTracked() && viewContext) {
18
+ var actionContext = parentContexts.findAction(startTime);
19
+ return {
20
+ application: {
21
+ id: applicationId
22
+ },
23
+ session: {
24
+ id: session.getSessionId()
25
+ },
26
+ userAction: actionContext ? {
27
+ id: actionContext.userAction.id
28
+ } : undefined,
29
+ page: viewContext.page
30
+ };
31
+ }
32
+ }
33
+ };
34
+ }
@@ -48,6 +48,7 @@ function rewritePage(configuration, lifeCycle, Vue) {
48
48
 
49
49
  if (methodName === 'onUnload' || methodName === 'onHide') {
50
50
  currentView.end();
51
+ currentView = undefined;
51
52
  }
52
53
  }
53
54
 
@@ -26,7 +26,6 @@ function processRequest(request) {
26
26
  var tracingInfo = computeRequestTracingInfo(request);
27
27
  var urlObj = (0, _utils.urlParse)(request.url).getParse();
28
28
  var startTime = request.startTime;
29
- console.log(request, 'request=========');
30
29
  var resourceEvent = (0, _utils.extend2Lev)({
31
30
  date: startTime,
32
31
  resource: {
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.0.1',
2
+ sdkVersion: '2.1.3',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -1,16 +1,14 @@
1
- import { isPercentage, extend2Lev, createContextManager } from '../helper/utils';
1
+ import { isPercentage, extend2Lev, now, createContextManager, defineGlobal, getGlobalObject, isString, isObject } from '../helper/utils';
2
2
  import { startRum } from './rum';
3
+ import { ActionType } from '../helper/enums';
3
4
  export var makeRum = function makeRum(startRumImpl) {
4
5
  var isAlreadyInitialized = false;
5
6
  var globalContextManager = createContextManager();
6
7
  var user = {};
7
8
 
8
- function clonedCommonContext() {
9
- return extend2Lev({}, {
10
- context: globalContextManager.get(),
11
- user: user
12
- });
13
- }
9
+ var _getInternalContext = function getInternalContext() {};
10
+
11
+ var addActionStrategy = function addActionStrategy() {};
14
12
 
15
13
  var rumGlobal = {
16
14
  init: function init(Vue, userConfiguration) {
@@ -24,18 +22,34 @@ export var makeRum = function makeRum(startRumImpl) {
24
22
  return;
25
23
  }
26
24
 
27
- startRumImpl(Vue, userConfiguration, function () {
25
+ var _startRumImpl = startRumImpl(Vue, userConfiguration, function () {
28
26
  return {
29
27
  user: user,
30
28
  context: globalContextManager.get()
31
29
  };
32
30
  });
31
+
32
+ _getInternalContext = _startRumImpl.getInternalContext;
33
+ addActionStrategy = _startRumImpl.addAction;
33
34
  isAlreadyInitialized = true;
34
35
  },
36
+ getInternalContext: function getInternalContext(startTime) {
37
+ return _getInternalContext(startTime);
38
+ },
35
39
  addRumGlobalContext: globalContextManager.add,
36
40
  removeRumGlobalContext: globalContextManager.remove,
37
41
  getRumGlobalContext: globalContextManager.get,
38
42
  setRumGlobalContext: globalContextManager.set,
43
+ addAction: function addAction(name, context) {
44
+ if (isObject(context) && isString(name)) {
45
+ addActionStrategy({
46
+ name: name,
47
+ context: extend2Lev({}, context),
48
+ startClocks: now(),
49
+ type: ActionType.custom
50
+ });
51
+ }
52
+ },
39
53
  setUser: function setUser(newUser) {
40
54
  var sanitizedUser = sanitizeUser(newUser);
41
55
 
@@ -97,4 +111,5 @@ export var makeRum = function makeRum(startRumImpl) {
97
111
  return result;
98
112
  }
99
113
  };
100
- export var datafluxRum = makeRum(startRum);
114
+ export var datafluxRum = makeRum(startRum);
115
+ defineGlobal(getGlobalObject(), 'DATAFLUX_RUM_MIN', datafluxRum);
package/esm/boot/rum.js CHANGED
@@ -12,13 +12,16 @@ import { startAppCollection } from '../rumEventsCollection/app/appCollection';
12
12
  import { startPagePerformanceObservable } from '../rumEventsCollection/performanceCollection';
13
13
  import { startSetDataColloction } from '../rumEventsCollection/setDataCollection';
14
14
  import { startActionCollection } from '../rumEventsCollection/action/actionCollection';
15
+ import { sessionManagement } from '../core/sessionManagement';
16
+ import { startInternalContext } from '../rumEventsCollection/internalContext';
15
17
  import { sdk } from '../core/sdk';
16
18
  export var startRum = function startRum(Vue, userConfiguration, getCommonContext) {
17
19
  var configuration = commonInit(userConfiguration, buildEnv);
18
20
  var lifeCycle = new LifeCycle();
19
21
  var parentContexts = startParentContexts(lifeCycle);
20
22
  var batch = startRumBatch(configuration, lifeCycle);
21
- startRumAssembly(userConfiguration.applicationId, configuration, lifeCycle, parentContexts, getCommonContext);
23
+ var session = new sessionManagement(configuration);
24
+ startRumAssembly(userConfiguration.applicationId, configuration, session, lifeCycle, parentContexts, getCommonContext);
22
25
  startAppCollection(lifeCycle, configuration);
23
26
  startResourceCollection(lifeCycle, configuration);
24
27
  startViewCollection(lifeCycle, configuration, Vue);
@@ -26,5 +29,12 @@ export var startRum = function startRum(Vue, userConfiguration, getCommonContext
26
29
  startRequestCollection(lifeCycle, configuration);
27
30
  startPagePerformanceObservable(lifeCycle, configuration);
28
31
  startSetDataColloction(lifeCycle, Vue);
29
- startActionCollection(lifeCycle, configuration, Vue);
32
+
33
+ var _startActionCollection = startActionCollection(lifeCycle, configuration, Vue);
34
+
35
+ var internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts);
36
+ return {
37
+ addAction: _startActionCollection.addAction,
38
+ getInternalContext: internalContext.get
39
+ };
30
40
  };
@@ -4,7 +4,6 @@ import { CLIENT_ID_TOKEN } from '../helper/enums';
4
4
 
5
5
  class BaseInfo {
6
6
  constructor() {
7
- this.sessionId = UUID();
8
7
  this.getDeviceInfo();
9
8
  this.getNetWork();
10
9
  }
@@ -63,10 +62,6 @@ class BaseInfo {
63
62
  });
64
63
  }
65
64
 
66
- getSessionId() {
67
- return this.sessionId;
68
- }
69
-
70
65
  }
71
66
 
72
67
  export default new BaseInfo();
@@ -66,6 +66,10 @@ export function commonInit(userConfiguration, buildEnv) {
66
66
  transportConfiguration.traceType = userConfiguration.traceType;
67
67
  }
68
68
 
69
+ if ('sampleRate' in userConfiguration) {
70
+ transportConfiguration.sampleRate = userConfiguration.sampleRate;
71
+ }
72
+
69
73
  return extend2Lev(DEFAULT_CONFIGURATION, transportConfiguration);
70
74
  }
71
75
 
@@ -79,17 +79,16 @@ export function startRuntimeErrorTracking(errorObservable) {
79
79
  export function stopRuntimeErrorTracking() {
80
80
  report.unsubscribe(traceKitReportHandler);
81
81
  }
82
- var filteredErrorsObservable;
82
+ var errorObservable;
83
83
  export function startAutomaticErrorCollection(configuration) {
84
- if (!filteredErrorsObservable) {
85
- var errorObservable = new Observable();
84
+ if (!errorObservable) {
85
+ errorObservable = new Observable();
86
86
  trackNetworkError(configuration, errorObservable);
87
87
  startConsoleTracking(errorObservable);
88
- startRuntimeErrorTracking(errorObservable);
89
- filteredErrorsObservable = filterErrors(configuration, errorObservable);
88
+ startRuntimeErrorTracking(errorObservable); // filteredErrorsObservable = filterErrors(configuration, errorObservable)
90
89
  }
91
90
 
92
- return filteredErrorsObservable;
91
+ return errorObservable;
93
92
  }
94
93
  export function trackNetworkError(configuration, errorObservable) {
95
94
  startXhrProxy().onRequestComplete(function (context) {
@@ -0,0 +1,38 @@
1
+ import { ErrorSource } from './errorTools';
2
+ import { now, ONE_MINUTE } from '../helper/utils';
3
+ export function createErrorFilter(configuration, onLimitReached) {
4
+ var errorCount = 0;
5
+ var allowNextError = false;
6
+ return {
7
+ isLimitReached: function isLimitReached() {
8
+ if (errorCount === 0) {
9
+ setTimeout(function () {
10
+ errorCount = 0;
11
+ }, ONE_MINUTE);
12
+ }
13
+
14
+ errorCount += 1;
15
+
16
+ if (errorCount <= configuration.maxErrorsByMinute || allowNextError) {
17
+ allowNextError = false;
18
+ return false;
19
+ }
20
+
21
+ if (errorCount === configuration.maxErrorsByMinute + 1) {
22
+ allowNextError = true;
23
+
24
+ try {
25
+ onLimitReached({
26
+ message: "Reached max number of errors by minute: ".concat(configuration.maxErrorsByMinute),
27
+ source: ErrorSource.AGENT,
28
+ startTime: now()
29
+ });
30
+ } finally {
31
+ allowNextError = false;
32
+ }
33
+ }
34
+
35
+ return true;
36
+ }
37
+ };
38
+ }
@@ -1,9 +1,11 @@
1
+ import { isArray } from '../helper/utils';
1
2
  export var ErrorSource = {
2
3
  AGENT: 'agent',
3
4
  CONSOLE: 'console',
4
5
  NETWORK: 'network',
5
6
  SOURCE: 'source',
6
- LOGGER: 'logger'
7
+ LOGGER: 'logger',
8
+ CUSTOM: 'custom'
7
9
  };
8
10
  export function formatUnknownError(stackTrace, errorObject, nonErrorPrefix) {
9
11
  if (!stackTrace || stackTrace.message === undefined && !(errorObject instanceof Error)) {
@@ -22,12 +24,16 @@ export function formatUnknownError(stackTrace, errorObject, nonErrorPrefix) {
22
24
  }
23
25
  export function toStackTraceString(stack) {
24
26
  var result = stack.name || 'Error' + ': ' + stack.message;
25
- stack.stack.forEach(function (frame) {
26
- var func = frame.func === '?' ? '<anonymous>' : frame.func;
27
- var args = frame.args && frame.args.length > 0 ? '(' + frame.args.join(', ') + ')' : '';
28
- var line = frame.line ? ':' + frame.line : '';
29
- var column = frame.line && frame.column ? ':' + frame.column : '';
30
- result += '\n at ' + func + args + ' @ ' + frame.url + line + column;
31
- });
27
+
28
+ if (isArray(stack.stack)) {
29
+ stack.stack.forEach(function (frame) {
30
+ var func = frame.func === '?' ? '<anonymous>' : frame.func;
31
+ var args = frame.args && frame.args.length > 0 ? '(' + frame.args.join(', ') + ')' : '';
32
+ var line = frame.line ? ':' + frame.line : '';
33
+ var column = frame.line && frame.column ? ':' + frame.column : '';
34
+ result += '\n at ' + func + args + ' @ ' + frame.url + line + column;
35
+ });
36
+ }
37
+
32
38
  return result;
33
39
  }
@@ -40,5 +40,6 @@ export var LifeCycleEventType = {
40
40
  REQUEST_STARTED: 'REQUEST_STARTED',
41
41
  REQUEST_COMPLETED: 'REQUEST_COMPLETED',
42
42
  RAW_RUM_EVENT_COLLECTED: 'RAW_RUM_EVENT_COLLECTED',
43
+ RAW_ERROR_COLLECTED: 'RAW_ERROR_COLLECTED',
43
44
  RUM_EVENT_COLLECTED: 'RUM_EVENT_COLLECTED'
44
45
  };
package/esm/core/sdk.js CHANGED
@@ -34,7 +34,6 @@ function getSDK() {
34
34
  console.warn('unsupport platform, Fail to start');
35
35
  }
36
36
 
37
- console.log('------get SDK-------');
38
37
  return {
39
38
  sdk,
40
39
  tracker
@@ -0,0 +1,20 @@
1
+ import { UUID, performDraw } from '../helper/utils';
2
+ export var SessionType = {
3
+ SYNTHETICS: 'synthetics',
4
+ USER: 'user'
5
+ };
6
+ export class sessionManagement {
7
+ constructor(configuration) {
8
+ this.sessionId = UUID();
9
+ this.isTrack = performDraw(configuration.sampleRate);
10
+ }
11
+
12
+ getSessionId() {
13
+ return this.sessionId;
14
+ }
15
+
16
+ isTracked() {
17
+ return this.isTrack;
18
+ }
19
+
20
+ }
@@ -118,15 +118,6 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
118
118
  }
119
119
  });
120
120
 
121
- if (message.type === RumEventType.LOGGER) {
122
- // 这里处理日志类型数据自定义字段
123
- each(message, function (value, key) {
124
- if (filterFileds.indexOf(key) === -1 && (isNumber(value) || isString(value) || isBoolean(value))) {
125
- tagsStr.push(escapeRowData(key) + '=' + escapeRowData(value));
126
- }
127
- });
128
- }
129
-
130
121
  if (tagsStr.length) {
131
122
  rowStr += tagsStr.join(',');
132
123
  }
@@ -10,7 +10,8 @@ export var RumEventType = {
10
10
  VIEW: 'view',
11
11
  RESOURCE: 'resource',
12
12
  APP: 'app',
13
- ACTION: 'action'
13
+ ACTION: 'action',
14
+ LOGGER: 'logger'
14
15
  };
15
16
  export var RequestType = {
16
17
  XHR: 'network',
@@ -19,7 +20,8 @@ export var RequestType = {
19
20
  export var ActionType = {
20
21
  tap: 'tap',
21
22
  longpress: 'longpress',
22
- longtap: 'longtap'
23
+ longtap: 'longtap',
24
+ custom: 'custom'
23
25
  };
24
26
  export var MpHook = {
25
27
  data: 1,
@@ -41,4 +43,8 @@ export var TraceType = {
41
43
  W3C_TRACEPARENT: 'w3c_traceparent',
42
44
  SKYWALKING_V3: 'skywalking_v3',
43
45
  JAEGER: 'jaeger'
46
+ };
47
+ export var ErrorHandling = {
48
+ HANDLED: 'handled',
49
+ UNHANDLED: 'unhandled'
44
50
  };
@@ -0,0 +1,57 @@
1
+ import { extend2Lev, each } from './utils';
2
+ /**
3
+ * Current limitations:
4
+ * - field path do not support array, 'a.b.c' only
5
+ * - modifiable fields type must be string
6
+ */
7
+
8
+ export function limitModification(object, modifiableFieldPaths, modifier) {
9
+ var clone = extend2Lev({}, object);
10
+ var result = modifier(clone);
11
+ each(modifiableFieldPaths, function (path) {
12
+ var originalValue = get(object, path);
13
+ var newValue = get(clone, path);
14
+
15
+ if (typeof originalValue === 'string' && typeof newValue === 'string') {
16
+ set(object, path, newValue);
17
+ }
18
+ });
19
+ return result;
20
+ }
21
+
22
+ function get(object, path) {
23
+ var current = object;
24
+
25
+ for (var field of path.split('.')) {
26
+ if (!isValidObjectContaining(current, field)) {
27
+ return;
28
+ }
29
+
30
+ current = current[field];
31
+ }
32
+
33
+ return current;
34
+ }
35
+
36
+ function set(object, path, value) {
37
+ var current = object;
38
+ var fields = path.split('.');
39
+
40
+ for (var i = 0; i < fields.length; i += 1) {
41
+ var field = fields[i];
42
+
43
+ if (!isValidObjectContaining(current, field)) {
44
+ return;
45
+ }
46
+
47
+ if (i !== fields.length - 1) {
48
+ current = current[field];
49
+ } else {
50
+ current[field] = value;
51
+ }
52
+ }
53
+ }
54
+
55
+ function isValidObjectContaining(object, field) {
56
+ return typeof object === 'object' && object !== null && field in object;
57
+ }
@@ -904,7 +904,7 @@ export var computeStackTrace = function computeStackTraceWrapper() {
904
904
  var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;
905
905
 
906
906
  function extractMessage(ex) {
907
- var message = ex && ex.message; // console.log('message',message)
907
+ var message = ex && ex.message;
908
908
 
909
909
  if (!message) {
910
910
  return 'No error message';