@cloudcare/rum-uniapp 2.0.1 → 2.0.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.
Files changed (46) hide show
  1. package/README.md +11 -8
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/rum.entry.js +10 -2
  4. package/cjs/boot/rum.js +10 -1
  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 +2 -1
  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 +11 -6
  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/app/appCollection.js +0 -1
  19. package/cjs/rumEventsCollection/assembly.js +23 -13
  20. package/cjs/rumEventsCollection/error/errorCollection.js +37 -5
  21. package/cjs/rumEventsCollection/internalContext.js +34 -0
  22. package/cjs/rumEventsCollection/page/index.js +1 -0
  23. package/cjs/rumEventsCollection/resource/resourceCollection.js +0 -1
  24. package/esm/boot/buildEnv.js +1 -1
  25. package/esm/boot/rum.entry.js +11 -3
  26. package/esm/boot/rum.js +8 -1
  27. package/esm/core/baseInfo.js +0 -5
  28. package/esm/core/configuration.js +4 -0
  29. package/esm/core/errorCollection.js +5 -6
  30. package/esm/core/errorFilter.js +38 -0
  31. package/esm/core/errorTools.js +2 -1
  32. package/esm/core/lifeCycle.js +1 -0
  33. package/esm/core/sdk.js +0 -1
  34. package/esm/core/sessionManagement.js +20 -0
  35. package/esm/core/transport.js +0 -9
  36. package/esm/helper/enums.js +6 -1
  37. package/esm/helper/limitModification.js +57 -0
  38. package/esm/helper/tracekit.js +1 -1
  39. package/esm/helper/utils.js +68 -0
  40. package/esm/rumEventsCollection/app/appCollection.js +0 -1
  41. package/esm/rumEventsCollection/assembly.js +22 -14
  42. package/esm/rumEventsCollection/error/errorCollection.js +36 -5
  43. package/esm/rumEventsCollection/internalContext.js +27 -0
  44. package/esm/rumEventsCollection/page/index.js +1 -0
  45. package/esm/rumEventsCollection/resource/resourceCollection.js +0 -1
  46. package/package.json +1 -1
@@ -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.0.2',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -1,10 +1,12 @@
1
- import { isPercentage, extend2Lev, createContextManager } from '../helper/utils';
1
+ import { isPercentage, extend2Lev, createContextManager, defineGlobal, getGlobalObject } from '../helper/utils';
2
2
  import { startRum } from './rum';
3
3
  export var makeRum = function makeRum(startRumImpl) {
4
4
  var isAlreadyInitialized = false;
5
5
  var globalContextManager = createContextManager();
6
6
  var user = {};
7
7
 
8
+ var _getInternalContext = function getInternalContext() {};
9
+
8
10
  function clonedCommonContext() {
9
11
  return extend2Lev({}, {
10
12
  context: globalContextManager.get(),
@@ -24,14 +26,19 @@ export var makeRum = function makeRum(startRumImpl) {
24
26
  return;
25
27
  }
26
28
 
27
- startRumImpl(Vue, userConfiguration, function () {
29
+ var _startRumImpl = startRumImpl(Vue, userConfiguration, function () {
28
30
  return {
29
31
  user: user,
30
32
  context: globalContextManager.get()
31
33
  };
32
34
  });
35
+
36
+ _getInternalContext = _startRumImpl.getInternalContext;
33
37
  isAlreadyInitialized = true;
34
38
  },
39
+ getInternalContext: function getInternalContext(startTime) {
40
+ return _getInternalContext(startTime);
41
+ },
35
42
  addRumGlobalContext: globalContextManager.add,
36
43
  removeRumGlobalContext: globalContextManager.remove,
37
44
  getRumGlobalContext: globalContextManager.get,
@@ -97,4 +104,5 @@ export var makeRum = function makeRum(startRumImpl) {
97
104
  return result;
98
105
  }
99
106
  };
100
- export var datafluxRum = makeRum(startRum);
107
+ export var datafluxRum = makeRum(startRum);
108
+ 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);
@@ -27,4 +30,8 @@ export var startRum = function startRum(Vue, userConfiguration, getCommonContext
27
30
  startPagePerformanceObservable(lifeCycle, configuration);
28
31
  startSetDataColloction(lifeCycle, Vue);
29
32
  startActionCollection(lifeCycle, configuration, Vue);
33
+ var internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts);
34
+ return {
35
+ getInternalContext: internalContext.get
36
+ };
30
37
  };
@@ -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
+ }
@@ -3,7 +3,8 @@ export var ErrorSource = {
3
3
  CONSOLE: 'console',
4
4
  NETWORK: 'network',
5
5
  SOURCE: 'source',
6
- LOGGER: 'logger'
6
+ LOGGER: 'logger',
7
+ CUSTOM: 'custom'
7
8
  };
8
9
  export function formatUnknownError(stackTrace, errorObject, nonErrorPrefix) {
9
10
  if (!stackTrace || stackTrace.message === undefined && !(errorObject instanceof Error)) {
@@ -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',
@@ -41,4 +42,8 @@ export var TraceType = {
41
42
  W3C_TRACEPARENT: 'w3c_traceparent',
42
43
  SKYWALKING_V3: 'skywalking_v3',
43
44
  JAEGER: 'jaeger'
45
+ };
46
+ export var ErrorHandling = {
47
+ HANDLED: 'handled',
48
+ UNHANDLED: 'unhandled'
44
49
  };
@@ -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';
@@ -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
  }
@@ -20,7 +20,6 @@ function processAppUpdate(appinfo) {
20
20
  duration: msToNs(appinfo.duration)
21
21
  }
22
22
  };
23
- console.log(appEvent, 'appEvent====');
24
23
  return {
25
24
  rawRumEvent: appEvent,
26
25
  startTime: appinfo.startTime
@@ -1,17 +1,15 @@
1
- import { extend2Lev, withSnakeCaseKeys, performDraw, isEmptyObject } from '../helper/utils';
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
- function isTracked(configuration) {
7
- return performDraw(configuration.sampleRate);
8
- }
9
-
10
- var SessionType = {
11
- SYNTHETICS: 'synthetics',
12
- USER: 'user'
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;
@@ -22,7 +20,7 @@ export function startRumAssembly(applicationId, configuration, lifeCycle, parent
22
20
  device: baseInfo.deviceInfo
23
21
  };
24
22
 
25
- if (isTracked(configuration) && (viewContext || rawRumEvent.type === RumEventType.APP)) {
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: baseInfo.getSessionId(),
40
+ id: session.getSessionId(),
43
41
  type: SessionType.USER
44
42
  },
45
43
  user: {
@@ -63,7 +61,17 @@ export function startRumAssembly(applicationId, configuration, lifeCycle, parent
63
61
  }, commonContext.user);
64
62
  }
65
63
 
66
- lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
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(lifeCycle, configuration, startAutomaticErrorCollection(configuration));
7
- }
8
- export function doStartErrorCollection(lifeCycle, configuration, observable) {
9
- observable.subscribe(function (error) {
10
- lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error));
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
+ }
@@ -34,6 +34,7 @@ export function rewritePage(configuration, lifeCycle, Vue) {
34
34
 
35
35
  if (methodName === 'onUnload' || methodName === 'onHide') {
36
36
  currentView.end();
37
+ currentView = undefined;
37
38
  }
38
39
  }
39
40