@cloudcare/browser-core 3.1.24 → 3.2.0
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/cjs/browser/pageExitObservable.js +1 -1
- package/cjs/browser/pageExitObservable.js.map +1 -1
- package/cjs/console/consoleObservable.js +17 -9
- package/cjs/console/consoleObservable.js.map +1 -1
- package/cjs/dataMap.js +11 -2
- package/cjs/dataMap.js.map +1 -1
- package/cjs/helper/boundedBuffer.js +21 -17
- package/cjs/helper/boundedBuffer.js.map +1 -1
- package/cjs/helper/connectivity.js +16 -0
- package/cjs/helper/connectivity.js.map +1 -0
- package/cjs/helper/display.js +15 -12
- package/cjs/helper/display.js.map +1 -1
- package/cjs/helper/displayAlreadyInitializedError.js +13 -0
- package/cjs/helper/displayAlreadyInitializedError.js.map +1 -0
- package/cjs/helper/encoder.js +43 -0
- package/cjs/helper/encoder.js.map +1 -0
- package/cjs/helper/lifeCycle.js +0 -1
- package/cjs/helper/lifeCycle.js.map +1 -1
- package/cjs/helper/monitor.js +6 -6
- package/cjs/helper/monitor.js.map +1 -1
- package/cjs/helper/serialisation/jsonStringify.js.map +1 -1
- package/cjs/index.js +33 -0
- package/cjs/index.js.map +1 -1
- package/cjs/report/reportObservable.js +26 -20
- package/cjs/report/reportObservable.js.map +1 -1
- package/cjs/telemetry/telemetry.js +60 -31
- package/cjs/telemetry/telemetry.js.map +1 -1
- package/cjs/telemetry/types.js +2 -1
- package/cjs/telemetry/types.js.map +1 -1
- package/cjs/transport/batch.js +129 -79
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/flushController.js +18 -5
- package/cjs/transport/flushController.js.map +1 -1
- package/cjs/transport/httpRequest.js +35 -22
- package/cjs/transport/httpRequest.js.map +1 -1
- package/cjs/transport/index.js +4 -4
- package/cjs/transport/index.js.map +1 -1
- package/cjs/transport/startBatchWithReplica.js +26 -10
- package/cjs/transport/startBatchWithReplica.js.map +1 -1
- package/esm/browser/pageExitObservable.js +1 -1
- package/esm/browser/pageExitObservable.js.map +1 -1
- package/esm/console/consoleObservable.js +18 -10
- package/esm/console/consoleObservable.js.map +1 -1
- package/esm/dataMap.js +11 -2
- package/esm/dataMap.js.map +1 -1
- package/esm/helper/boundedBuffer.js +21 -16
- package/esm/helper/boundedBuffer.js.map +1 -1
- package/esm/helper/connectivity.js +10 -0
- package/esm/helper/connectivity.js.map +1 -0
- package/esm/helper/display.js +12 -11
- package/esm/helper/display.js.map +1 -1
- package/esm/helper/displayAlreadyInitializedError.js +7 -0
- package/esm/helper/displayAlreadyInitializedError.js.map +1 -0
- package/esm/helper/encoder.js +37 -0
- package/esm/helper/encoder.js.map +1 -0
- package/esm/helper/lifeCycle.js +0 -1
- package/esm/helper/lifeCycle.js.map +1 -1
- package/esm/helper/monitor.js +6 -6
- package/esm/helper/monitor.js.map +1 -1
- package/esm/helper/serialisation/jsonStringify.js.map +1 -1
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -1
- package/esm/report/reportObservable.js +27 -21
- package/esm/report/reportObservable.js.map +1 -1
- package/esm/telemetry/telemetry.js +57 -31
- package/esm/telemetry/telemetry.js.map +1 -1
- package/esm/telemetry/types.js +2 -1
- package/esm/telemetry/types.js.map +1 -1
- package/esm/transport/batch.js +127 -77
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/flushController.js +18 -5
- package/esm/transport/flushController.js.map +1 -1
- package/esm/transport/httpRequest.js +35 -22
- package/esm/transport/httpRequest.js.map +1 -1
- package/esm/transport/index.js +1 -1
- package/esm/transport/index.js.map +1 -1
- package/esm/transport/startBatchWithReplica.js +27 -11
- package/esm/transport/startBatchWithReplica.js.map +1 -1
- package/package.json +2 -2
- package/src/browser/pageExitObservable.js +2 -2
- package/src/console/consoleObservable.js +22 -14
- package/src/dataMap.js +11 -2
- package/src/helper/boundedBuffer.js +21 -14
- package/src/helper/connectivity.js +11 -0
- package/src/helper/display.js +16 -14
- package/src/helper/displayAlreadyInitializedError.js +7 -0
- package/src/helper/encoder.js +43 -0
- package/src/helper/lifeCycle.js +0 -1
- package/src/helper/monitor.js +6 -6
- package/src/helper/serialisation/jsonStringify.js +1 -1
- package/src/index.js +3 -0
- package/src/report/reportObservable.js +43 -27
- package/src/telemetry/telemetry.js +60 -37
- package/src/telemetry/types.js +2 -1
- package/src/transport/batch.js +154 -89
- package/src/transport/flushController.js +19 -6
- package/src/transport/httpRequest.js +34 -35
- package/src/transport/index.js +1 -1
- package/src/transport/startBatchWithReplica.js +25 -14
- package/types/index.d.ts +12 -0
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { removeItem } from './tools'
|
|
2
2
|
var BUFFER_LIMIT = 500
|
|
3
|
+
export function createBoundedBuffer() {
|
|
4
|
+
var buffer = []
|
|
3
5
|
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
_BoundedBuffer.prototype = {
|
|
8
|
-
add: function (callback) {
|
|
9
|
-
var length = this.buffer.push(callback)
|
|
6
|
+
var add = function (callback) {
|
|
7
|
+
var length = buffer.push(callback)
|
|
10
8
|
if (length > BUFFER_LIMIT) {
|
|
11
|
-
|
|
9
|
+
buffer.splice(0, 1)
|
|
12
10
|
}
|
|
13
|
-
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var remove = function (callback) {
|
|
14
|
+
removeItem(buffer, callback)
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
drain
|
|
16
|
-
|
|
17
|
-
callback()
|
|
17
|
+
const drain = function (arg) {
|
|
18
|
+
buffer.forEach(function (callback) {
|
|
19
|
+
callback(arg)
|
|
18
20
|
})
|
|
19
|
-
|
|
21
|
+
buffer.length = 0
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
add: add,
|
|
26
|
+
remove: add,
|
|
27
|
+
drain: drain
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
|
-
export var BoundedBuffer = _BoundedBuffer
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function getConnectivity() {
|
|
2
|
+
var navigator = window.navigator
|
|
3
|
+
return {
|
|
4
|
+
status: navigator.onLine ? 'connected' : 'not_connected',
|
|
5
|
+
interfaces:
|
|
6
|
+
navigator.connection && navigator.connection.type
|
|
7
|
+
? [navigator.connection.type]
|
|
8
|
+
: undefined,
|
|
9
|
+
effective_type: navigator.connection?.effectiveType
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/helper/display.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
1
|
export var ConsoleApiName = {
|
|
3
2
|
log: 'log',
|
|
4
3
|
debug: 'debug',
|
|
5
4
|
info: 'info',
|
|
6
5
|
warn: 'warn',
|
|
7
|
-
error: 'error'
|
|
8
|
-
}
|
|
9
|
-
export var display = function(api) {
|
|
10
|
-
var args = [].slice.call(arguments, 1)
|
|
11
|
-
if (!Object.prototype.hasOwnProperty.call(ConsoleApiName, api)) {
|
|
12
|
-
api = ConsoleApiName.log
|
|
13
|
-
}
|
|
14
|
-
display[api].apply(display,args)
|
|
6
|
+
error: 'error'
|
|
15
7
|
}
|
|
8
|
+
export var globalConsole = console
|
|
9
|
+
|
|
10
|
+
export var originalConsoleMethods = {}
|
|
11
|
+
Object.keys(ConsoleApiName).forEach(function (name) {
|
|
12
|
+
originalConsoleMethods[name] = globalConsole[name]
|
|
13
|
+
})
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
display
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
var PREFIX = 'GUANCE Browser SDK:'
|
|
16
|
+
|
|
17
|
+
export var display = {
|
|
18
|
+
debug: originalConsoleMethods.debug.bind(globalConsole, PREFIX),
|
|
19
|
+
log: originalConsoleMethods.log.bind(globalConsole, PREFIX),
|
|
20
|
+
info: originalConsoleMethods.info.bind(globalConsole, PREFIX),
|
|
21
|
+
warn: originalConsoleMethods.warn.bind(globalConsole, PREFIX),
|
|
22
|
+
error: originalConsoleMethods.error.bind(globalConsole, PREFIX)
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { computeBytesCount } from './byteUtils'
|
|
2
|
+
|
|
3
|
+
export function createIdentityEncoder() {
|
|
4
|
+
var output = ''
|
|
5
|
+
var outputBytesCount = 0
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
isAsync: false,
|
|
9
|
+
|
|
10
|
+
isEmpty: function () {
|
|
11
|
+
return !output
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
write: function (data, callback) {
|
|
15
|
+
var additionalEncodedBytesCount = computeBytesCount(data)
|
|
16
|
+
outputBytesCount += additionalEncodedBytesCount
|
|
17
|
+
output += data
|
|
18
|
+
if (callback) {
|
|
19
|
+
callback(additionalEncodedBytesCount)
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
finish: function (callback) {
|
|
24
|
+
callback(this.finishSync())
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
finishSync: function () {
|
|
28
|
+
var result = {
|
|
29
|
+
output: output,
|
|
30
|
+
outputBytesCount: outputBytesCount,
|
|
31
|
+
rawBytesCount: outputBytesCount,
|
|
32
|
+
pendingData: ''
|
|
33
|
+
}
|
|
34
|
+
output = ''
|
|
35
|
+
outputBytesCount = 0
|
|
36
|
+
return result
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
estimateEncodedBytesCount: function (data) {
|
|
40
|
+
return data.length
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/helper/lifeCycle.js
CHANGED
package/src/helper/monitor.js
CHANGED
|
@@ -25,21 +25,21 @@ export function callMonitored(fn, context, args) {
|
|
|
25
25
|
try {
|
|
26
26
|
return fn.apply(context, args)
|
|
27
27
|
} catch (e) {
|
|
28
|
-
displayIfDebugEnabled(
|
|
28
|
+
displayIfDebugEnabled(e)
|
|
29
29
|
if (onMonitorErrorCollected) {
|
|
30
30
|
try {
|
|
31
31
|
onMonitorErrorCollected(e)
|
|
32
32
|
} catch (e) {
|
|
33
|
-
displayIfDebugEnabled(
|
|
33
|
+
displayIfDebugEnabled(e)
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function displayIfDebugEnabled(
|
|
40
|
-
var args = [].slice.call(arguments
|
|
41
|
-
// display.apply(null, [
|
|
39
|
+
export function displayIfDebugEnabled() {
|
|
40
|
+
var args = [].slice.call(arguments)
|
|
41
|
+
// display.error.apply(null, ['[MONITOR]'].concat(args))
|
|
42
42
|
if (debugMode) {
|
|
43
|
-
display.apply(null, [
|
|
43
|
+
display.error.apply(null, ['[MONITOR]'].concat(args))
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/index.js
CHANGED
|
@@ -48,7 +48,10 @@ export * from './helper/serialisation/heavyCustomerDataWarning'
|
|
|
48
48
|
export * from './helper/serialisation/jsonStringify'
|
|
49
49
|
export * from './helper/serialisation/rowData'
|
|
50
50
|
export * from './helper/serialisation/storedContextManager'
|
|
51
|
+
export * from './helper/encoder'
|
|
51
52
|
export * from './user'
|
|
52
53
|
export * from './helper/polyfills'
|
|
53
54
|
export * from './telemetry/telemetry'
|
|
54
55
|
export * from './helper/catchUserErrors'
|
|
56
|
+
export * from './helper/connectivity'
|
|
57
|
+
export * from './helper/displayAlreadyInitializedError'
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { toStackTraceString } from '../helper/errorTools'
|
|
2
2
|
import { mergeObservables, Observable } from '../helper/observable'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
includes,
|
|
5
|
+
safeTruncate,
|
|
6
|
+
filter,
|
|
7
|
+
each,
|
|
8
|
+
assign,
|
|
9
|
+
clocksNow
|
|
10
|
+
} from '../helper/tools'
|
|
4
11
|
import { addEventListener } from '../browser/addEventListener'
|
|
5
12
|
import { DOM_EVENT } from '../helper/enums'
|
|
6
13
|
import { monitor } from '../helper/monitor'
|
|
@@ -33,7 +40,7 @@ function createReportObservable(reportTypes) {
|
|
|
33
40
|
|
|
34
41
|
var handleReports = monitor(function (reports) {
|
|
35
42
|
each(reports, function (report) {
|
|
36
|
-
observable.notify(
|
|
43
|
+
observable.notify(buildRawReportErrorFromReport(report))
|
|
37
44
|
})
|
|
38
45
|
})
|
|
39
46
|
|
|
@@ -47,34 +54,29 @@ function createReportObservable(reportTypes) {
|
|
|
47
54
|
observer.disconnect()
|
|
48
55
|
}
|
|
49
56
|
})
|
|
50
|
-
|
|
51
|
-
return observable
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
function createCspViolationReportObservable(configuration) {
|
|
55
60
|
return new Observable(function (observable) {
|
|
56
|
-
var handleCspViolation = function (event) {
|
|
57
|
-
observable.notify(buildRawReportFromCspViolation(event))
|
|
58
|
-
}
|
|
59
|
-
|
|
60
61
|
var _addEventListener = addEventListener(
|
|
61
62
|
document,
|
|
62
63
|
DOM_EVENT.SECURITY_POLICY_VIOLATION,
|
|
63
|
-
|
|
64
|
+
function (event) {
|
|
65
|
+
observable.notify(buildRawReportErrorFromCspViolation(event))
|
|
66
|
+
}
|
|
64
67
|
)
|
|
65
68
|
|
|
66
69
|
return _addEventListener.stop
|
|
67
70
|
})
|
|
68
|
-
return observable
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
function
|
|
73
|
+
function buildRawReportErrorFromReport(report) {
|
|
72
74
|
var body = report.body
|
|
73
75
|
var type = report.type
|
|
74
|
-
return {
|
|
75
|
-
type:
|
|
76
|
-
subtype: body.id,
|
|
76
|
+
return buildRawReportError({
|
|
77
|
+
type: body.id,
|
|
77
78
|
message: type + ': ' + body.message,
|
|
79
|
+
originalError: report,
|
|
78
80
|
stack: buildStack(
|
|
79
81
|
body.id,
|
|
80
82
|
body.message,
|
|
@@ -82,32 +84,46 @@ function buildRawReportFromReport(report) {
|
|
|
82
84
|
body.lineNumber,
|
|
83
85
|
body.columnNumber
|
|
84
86
|
)
|
|
85
|
-
}
|
|
87
|
+
})
|
|
86
88
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
function buildRawReportError(partial) {
|
|
90
|
+
return assign(
|
|
91
|
+
{
|
|
92
|
+
startClocks: clocksNow(),
|
|
93
|
+
source: ErrorSource.REPORT,
|
|
94
|
+
handling: ErrorHandling.UNHANDLED
|
|
95
|
+
},
|
|
96
|
+
partial
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
function buildRawReportErrorFromCspViolation(event) {
|
|
90
100
|
var message =
|
|
91
101
|
"'" +
|
|
92
102
|
event.blockedURI +
|
|
93
103
|
"' blocked by '" +
|
|
94
104
|
event.effectiveDirective +
|
|
95
105
|
"' directive"
|
|
96
|
-
return {
|
|
97
|
-
type:
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
return buildRawReportError({
|
|
107
|
+
type: event.effectiveDirective,
|
|
108
|
+
message: RawReportType.cspViolation + ': ' + message,
|
|
109
|
+
originalError: event,
|
|
110
|
+
csp: {
|
|
111
|
+
disposition: event.disposition
|
|
112
|
+
},
|
|
100
113
|
stack: buildStack(
|
|
101
114
|
event.effectiveDirective,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
event.originalPolicy
|
|
116
|
+
? `${message} of the policy "${safeTruncate(
|
|
117
|
+
event.originalPolicy,
|
|
118
|
+
100,
|
|
119
|
+
'...'
|
|
120
|
+
)}"`
|
|
121
|
+
: 'no policy',
|
|
106
122
|
event.sourceFile,
|
|
107
123
|
event.lineNumber,
|
|
108
124
|
event.columnNumber
|
|
109
125
|
)
|
|
110
|
-
}
|
|
126
|
+
})
|
|
111
127
|
}
|
|
112
128
|
|
|
113
129
|
function buildStack(name, message, sourceFile, lineNumber, columnNumber) {
|
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
toStackTraceString,
|
|
4
4
|
NO_ERROR_STACK_PRESENT_MESSAGE
|
|
5
5
|
} from '../helper/errorTools'
|
|
6
|
+
import { createBoundedBuffer } from '../helper/boundedBuffer'
|
|
6
7
|
import { computeStackTrace } from '../tracekit'
|
|
7
8
|
import { Observable } from '../helper/observable'
|
|
9
|
+
import { getConnectivity } from '../helper/connectivity'
|
|
8
10
|
import {
|
|
9
11
|
displayIfDebugEnabled,
|
|
10
12
|
startMonitorErrorCollection
|
|
@@ -31,35 +33,37 @@ export var TelemetryService = {
|
|
|
31
33
|
RUM: 'browser-rum-sdk'
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// eslint-disable-next-line local-rules/disallow-side-effects
|
|
37
|
+
var preStartTelemetryBuffer = createBoundedBuffer()
|
|
38
|
+
var onRawTelemetryEventCollected = function (event) {
|
|
39
|
+
preStartTelemetryBuffer.add(function () {
|
|
40
|
+
onRawTelemetryEventCollected(event)
|
|
41
|
+
})
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
var onRawTelemetryEventCollected
|
|
41
|
-
|
|
42
44
|
export function startTelemetry(telemetryService, configuration) {
|
|
43
45
|
let contextProvider
|
|
44
46
|
var observable = new Observable()
|
|
45
|
-
|
|
47
|
+
const alreadySentEvents = new Set()
|
|
48
|
+
const telemetryEnabled =
|
|
46
49
|
configuration.telemetryEnabled &&
|
|
47
50
|
performDraw(configuration.telemetrySampleRate)
|
|
48
|
-
|
|
51
|
+
const runtimeEnvInfo = getRuntimeEnvInfo()
|
|
49
52
|
onRawTelemetryEventCollected = function (rawEvent) {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const stringifiedEvent = jsonStringify(rawEvent)
|
|
54
|
+
if (
|
|
55
|
+
telemetryEnabled &&
|
|
56
|
+
alreadySentEvents.size < configuration.maxTelemetryEventsPerPage &&
|
|
57
|
+
!alreadySentEvents.has(stringifiedEvent)
|
|
58
|
+
) {
|
|
59
|
+
var event = toTelemetryEvent(telemetryService, rawEvent, runtimeEnvInfo)
|
|
52
60
|
observable.notify(event)
|
|
61
|
+
alreadySentEvents.add(stringifiedEvent)
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
64
|
startMonitorErrorCollection(addTelemetryError)
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
maxEventsPerPage: configuration.maxTelemetryEventsPerPage,
|
|
59
|
-
sentEventCount: 0
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
function toTelemetryEvent(telemetryService, event) {
|
|
66
|
+
function toTelemetryEvent(telemetryService, event, runtimeEnvInfo) {
|
|
63
67
|
return extend2Lev(
|
|
64
68
|
{
|
|
65
69
|
type: 'telemetry',
|
|
@@ -67,7 +71,10 @@ export function startTelemetry(telemetryService, configuration) {
|
|
|
67
71
|
service: telemetryService,
|
|
68
72
|
version: __BUILD_ENV__SDK_VERSION__,
|
|
69
73
|
source: 'browser',
|
|
70
|
-
telemetry: event
|
|
74
|
+
telemetry: extend2Lev(event, {
|
|
75
|
+
runtime_env: runtimeEnvInfo,
|
|
76
|
+
connectivity: getConnectivity()
|
|
77
|
+
})
|
|
71
78
|
},
|
|
72
79
|
contextProvider !== undefined ? contextProvider() : {}
|
|
73
80
|
)
|
|
@@ -78,17 +85,39 @@ export function startTelemetry(telemetryService, configuration) {
|
|
|
78
85
|
contextProvider = provider
|
|
79
86
|
},
|
|
80
87
|
observable: observable,
|
|
81
|
-
enabled:
|
|
88
|
+
enabled: telemetryEnabled
|
|
82
89
|
}
|
|
83
90
|
}
|
|
91
|
+
function getRuntimeEnvInfo() {
|
|
92
|
+
return {
|
|
93
|
+
is_local_file: window.location.protocol === 'file:',
|
|
94
|
+
is_worker: 'WorkerGlobalScope' in self
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export function startFakeTelemetry() {
|
|
98
|
+
const events = []
|
|
99
|
+
|
|
100
|
+
onRawTelemetryEventCollected = function (event) {
|
|
101
|
+
events.push(event)
|
|
102
|
+
}
|
|
84
103
|
|
|
104
|
+
return events
|
|
105
|
+
}
|
|
106
|
+
export function drainPreStartTelemetry() {
|
|
107
|
+
preStartTelemetryBuffer.drain()
|
|
108
|
+
}
|
|
85
109
|
export function resetTelemetry() {
|
|
86
|
-
|
|
110
|
+
preStartTelemetryBuffer = createBoundedBuffer()
|
|
111
|
+
onRawTelemetryEventCollected = function (event) {
|
|
112
|
+
preStartTelemetryBuffer.add(function () {
|
|
113
|
+
onRawTelemetryEventCollected(event)
|
|
114
|
+
})
|
|
115
|
+
}
|
|
87
116
|
}
|
|
88
117
|
|
|
89
118
|
export function addTelemetryDebug(message, context) {
|
|
90
|
-
displayIfDebugEnabled(
|
|
91
|
-
|
|
119
|
+
displayIfDebugEnabled(message, context)
|
|
120
|
+
onRawTelemetryEventCollected(
|
|
92
121
|
assign(
|
|
93
122
|
{
|
|
94
123
|
type: TelemetryType.log,
|
|
@@ -101,7 +130,7 @@ export function addTelemetryDebug(message, context) {
|
|
|
101
130
|
}
|
|
102
131
|
|
|
103
132
|
export function addTelemetryError(e, context) {
|
|
104
|
-
|
|
133
|
+
onRawTelemetryEventCollected(
|
|
105
134
|
assign(
|
|
106
135
|
{
|
|
107
136
|
type: TelemetryType.log,
|
|
@@ -114,23 +143,17 @@ export function addTelemetryError(e, context) {
|
|
|
114
143
|
}
|
|
115
144
|
|
|
116
145
|
export function addTelemetryConfiguration(configuration) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
})
|
|
122
|
-
}
|
|
146
|
+
onRawTelemetryEventCollected({
|
|
147
|
+
type: TelemetryType.configuration,
|
|
148
|
+
configuration: configuration
|
|
149
|
+
})
|
|
123
150
|
}
|
|
124
151
|
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
) {
|
|
131
|
-
telemetryConfiguration.sentEventCount += 1
|
|
132
|
-
onRawTelemetryEventCollected(event)
|
|
133
|
-
}
|
|
152
|
+
export function addTelemetryUsage(usage) {
|
|
153
|
+
onRawTelemetryEventCollected({
|
|
154
|
+
type: TelemetryType.usage,
|
|
155
|
+
usage: usage
|
|
156
|
+
})
|
|
134
157
|
}
|
|
135
158
|
|
|
136
159
|
export function formatError(e) {
|