@cloudcare/rum-uniapp 2.0.2 → 2.1.2

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.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildEnv = void 0;
7
7
  var buildEnv = {
8
- sdkVersion: '2.0.2',
8
+ sdkVersion: '2.1.2',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
11
11
  exports.buildEnv = buildEnv;
@@ -9,6 +9,8 @@ var _utils = require("../helper/utils");
9
9
 
10
10
  var _rum = require("./rum");
11
11
 
12
+ var _enums = require("../helper/enums");
13
+
12
14
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13
15
 
14
16
  var makeRum = function makeRum(startRumImpl) {
@@ -18,12 +20,7 @@ var makeRum = function makeRum(startRumImpl) {
18
20
 
19
21
  var _getInternalContext = function getInternalContext() {};
20
22
 
21
- function clonedCommonContext() {
22
- return (0, _utils.extend2Lev)({}, {
23
- context: globalContextManager.get(),
24
- user: user
25
- });
26
- }
23
+ var addActionStrategy = function addActionStrategy() {};
27
24
 
28
25
  var rumGlobal = {
29
26
  init: function init(Vue, userConfiguration) {
@@ -45,6 +42,7 @@ var makeRum = function makeRum(startRumImpl) {
45
42
  });
46
43
 
47
44
  _getInternalContext = _startRumImpl.getInternalContext;
45
+ addActionStrategy = _startRumImpl.addAction;
48
46
  isAlreadyInitialized = true;
49
47
  },
50
48
  getInternalContext: function getInternalContext(startTime) {
@@ -54,6 +52,16 @@ var makeRum = function makeRum(startRumImpl) {
54
52
  removeRumGlobalContext: globalContextManager.remove,
55
53
  getRumGlobalContext: globalContextManager.get,
56
54
  setRumGlobalContext: globalContextManager.set,
55
+ addAction: function addAction(name, context) {
56
+ if ((0, _utils.isObject)(context) && (0, _utils.isString)(name)) {
57
+ addActionStrategy({
58
+ name: name,
59
+ context: (0, _utils.extend2Lev)({}, context),
60
+ startClocks: (0, _utils.now)(),
61
+ type: _enums.ActionType.custom
62
+ });
63
+ }
64
+ },
57
65
  setUser: function setUser(newUser) {
58
66
  var sanitizedUser = sanitizeUser(newUser);
59
67
 
package/cjs/boot/rum.js CHANGED
@@ -53,9 +53,12 @@ var startRum = function startRum(Vue, userConfiguration, getCommonContext) {
53
53
  (0, _requestCollection.startRequestCollection)(lifeCycle, configuration);
54
54
  (0, _performanceCollection.startPagePerformanceObservable)(lifeCycle, configuration);
55
55
  (0, _setDataCollection.startSetDataColloction)(lifeCycle, Vue);
56
- (0, _actionCollection.startActionCollection)(lifeCycle, configuration, Vue);
56
+
57
+ var _startActionCollection = (0, _actionCollection.startActionCollection)(lifeCycle, configuration, Vue);
58
+
57
59
  var internalContext = (0, _internalContext.startInternalContext)(userConfiguration.applicationId, session, parentContexts);
58
60
  return {
61
+ addAction: _startActionCollection.addAction,
59
62
  getInternalContext: internalContext.get
60
63
  };
61
64
  };
@@ -36,7 +36,8 @@ exports.RequestType = RequestType;
36
36
  var ActionType = {
37
37
  tap: 'tap',
38
38
  longpress: 'longpress',
39
- longtap: 'longtap'
39
+ longtap: 'longtap',
40
+ custom: 'custom'
40
41
  };
41
42
  exports.ActionType = ActionType;
42
43
  var MpHook = {
@@ -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
  }
@@ -29,7 +29,7 @@ function startRumAssembly(applicationId, configuration, session, lifeCycle, pare
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
@@ -62,7 +62,7 @@ function startRumAssembly(applicationId, configuration, session, lifeCycle, pare
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;
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.0.2',
2
+ sdkVersion: '2.1.2',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -1,5 +1,6 @@
1
- import { isPercentage, extend2Lev, createContextManager, defineGlobal, getGlobalObject } 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();
@@ -7,12 +8,7 @@ export var makeRum = function makeRum(startRumImpl) {
7
8
 
8
9
  var _getInternalContext = function getInternalContext() {};
9
10
 
10
- function clonedCommonContext() {
11
- return extend2Lev({}, {
12
- context: globalContextManager.get(),
13
- user: user
14
- });
15
- }
11
+ var addActionStrategy = function addActionStrategy() {};
16
12
 
17
13
  var rumGlobal = {
18
14
  init: function init(Vue, userConfiguration) {
@@ -34,6 +30,7 @@ export var makeRum = function makeRum(startRumImpl) {
34
30
  });
35
31
 
36
32
  _getInternalContext = _startRumImpl.getInternalContext;
33
+ addActionStrategy = _startRumImpl.addAction;
37
34
  isAlreadyInitialized = true;
38
35
  },
39
36
  getInternalContext: function getInternalContext(startTime) {
@@ -43,6 +40,16 @@ export var makeRum = function makeRum(startRumImpl) {
43
40
  removeRumGlobalContext: globalContextManager.remove,
44
41
  getRumGlobalContext: globalContextManager.get,
45
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
+ },
46
53
  setUser: function setUser(newUser) {
47
54
  var sanitizedUser = sanitizeUser(newUser);
48
55
 
package/esm/boot/rum.js CHANGED
@@ -29,9 +29,12 @@ export var startRum = function startRum(Vue, userConfiguration, getCommonContext
29
29
  startRequestCollection(lifeCycle, configuration);
30
30
  startPagePerformanceObservable(lifeCycle, configuration);
31
31
  startSetDataColloction(lifeCycle, Vue);
32
- startActionCollection(lifeCycle, configuration, Vue);
32
+
33
+ var _startActionCollection = startActionCollection(lifeCycle, configuration, Vue);
34
+
33
35
  var internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts);
34
36
  return {
37
+ addAction: _startActionCollection.addAction,
35
38
  getInternalContext: internalContext.get
36
39
  };
37
40
  };
@@ -20,7 +20,8 @@ export var RequestType = {
20
20
  export var ActionType = {
21
21
  tap: 'tap',
22
22
  longpress: 'longpress',
23
- longtap: 'longtap'
23
+ longtap: 'longtap',
24
+ custom: 'custom'
24
25
  };
25
26
  export var MpHook = {
26
27
  data: 1,
@@ -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
  }
@@ -14,7 +14,7 @@ export function startRumAssembly(applicationId, configuration, session, lifeCycl
14
14
  var startTime = data.startTime;
15
15
  var rawRumEvent = data.rawRumEvent;
16
16
  var viewContext = parentContexts.findView(startTime);
17
- var savedCommonContext = data.savedGlobalContext;
17
+ var savedCommonContext = data.savedCommonContext;
18
18
  var customerContext = data.customerContext;
19
19
  var deviceContext = {
20
20
  device: baseInfo.deviceInfo
@@ -47,7 +47,7 @@ export function startRumAssembly(applicationId, configuration, session, lifeCycl
47
47
  };
48
48
  var rumEvent = extend2Lev(rumContext, deviceContext, viewContext, actionContext, rawRumEvent);
49
49
  var serverRumEvent = withSnakeCaseKeys(rumEvent);
50
- var context = extend2Lev(commonContext.context, customerContext);
50
+ var context = extend2Lev({}, commonContext.context, customerContext);
51
51
 
52
52
  if (!isEmptyObject(context)) {
53
53
  serverRumEvent.tags = context;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.0.2",
3
+ "version": "2.1.2",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",