@coralogix/browser 0.0.9
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 +104 -0
- package/package.json +32 -0
- package/src/CoralogixExporter.d.ts +15 -0
- package/src/CoralogixExporter.js +217 -0
- package/src/CoralogixExporter.js.map +1 -0
- package/src/CoralogixPropgator.d.ts +3 -0
- package/src/CoralogixPropgator.js +9 -0
- package/src/CoralogixPropgator.js.map +1 -0
- package/src/CoralogixSpanAttributesProcessor.d.ts +18 -0
- package/src/CoralogixSpanAttributesProcessor.js +64 -0
- package/src/CoralogixSpanAttributesProcessor.js.map +1 -0
- package/src/CoralogixWebTracerProvider.d.ts +3 -0
- package/src/CoralogixWebTracerProvider.js +11 -0
- package/src/CoralogixWebTracerProvider.js.map +1 -0
- package/src/constants.d.ts +93 -0
- package/src/constants.js +111 -0
- package/src/constants.js.map +1 -0
- package/src/helpers.d.ts +2 -0
- package/src/helpers.js +5 -0
- package/src/helpers.js.map +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +203 -0
- package/src/index.js.map +1 -0
- package/src/instrumentations/CoralogixCustomLogInstrumentation.d.ts +14 -0
- package/src/instrumentations/CoralogixCustomLogInstrumentation.js +41 -0
- package/src/instrumentations/CoralogixCustomLogInstrumentation.js.map +1 -0
- package/src/instrumentations/CoralogixErrorInstrumentation.d.ts +32 -0
- package/src/instrumentations/CoralogixErrorInstrumentation.js +226 -0
- package/src/instrumentations/CoralogixErrorInstrumentation.js.map +1 -0
- package/src/instrumentations/CoralogixFetchInstrumentation.d.ts +8 -0
- package/src/instrumentations/CoralogixFetchInstrumentation.js +36 -0
- package/src/instrumentations/CoralogixFetchInstrumentation.js.map +1 -0
- package/src/instrumentations/CoralogixLongTaskInstrumentation.d.ts +12 -0
- package/src/instrumentations/CoralogixLongTaskInstrumentation.js +71 -0
- package/src/instrumentations/CoralogixLongTaskInstrumentation.js.map +1 -0
- package/src/instrumentations/CoralogixResourcesInstrumentation.d.ts +13 -0
- package/src/instrumentations/CoralogixResourcesInstrumentation.js +129 -0
- package/src/instrumentations/CoralogixResourcesInstrumentation.js.map +1 -0
- package/src/instrumentations/CoralogixUserInteractionInstrumentation.d.ts +17 -0
- package/src/instrumentations/CoralogixUserInteractionInstrumentation.js +79 -0
- package/src/instrumentations/CoralogixUserInteractionInstrumentation.js.map +1 -0
- package/src/instrumentations/CoralogixWebVitalsInstrumentation.d.ts +18 -0
- package/src/instrumentations/CoralogixWebVitalsInstrumentation.js +160 -0
- package/src/instrumentations/CoralogixWebVitalsInstrumentation.js.map +1 -0
- package/src/instrumentations/CoralogixXhrInstrumentation.d.ts +7 -0
- package/src/instrumentations/CoralogixXhrInstrumentation.js +33 -0
- package/src/instrumentations/CoralogixXhrInstrumentation.js.map +1 -0
- package/src/instrumentations/instrumentation.consts.d.ts +18 -0
- package/src/instrumentations/instrumentation.consts.js +57 -0
- package/src/instrumentations/instrumentation.consts.js.map +1 -0
- package/src/instrumentations/instrumentation.helper.d.ts +1 -0
- package/src/instrumentations/instrumentation.helper.js +4 -0
- package/src/instrumentations/instrumentation.helper.js.map +1 -0
- package/src/instrumentations/instrumentation.model.d.ts +30 -0
- package/src/instrumentations/instrumentation.model.js +18 -0
- package/src/instrumentations/instrumentation.model.js.map +1 -0
- package/src/sessionManager.d.ts +12 -0
- package/src/sessionManager.js +69 -0
- package/src/sessionManager.js.map +1 -0
- package/src/tools/addEventListener.d.ts +54 -0
- package/src/tools/addEventListener.js +35 -0
- package/src/tools/addEventListener.js.map +1 -0
- package/src/tools/getGlobalObject.d.ts +5 -0
- package/src/tools/getGlobalObject.js +36 -0
- package/src/tools/getGlobalObject.js.map +1 -0
- package/src/tools/getZoneJsOriginalDom.d.ts +9 -0
- package/src/tools/getZoneJsOriginalDom.js +17 -0
- package/src/tools/getZoneJsOriginalDom.js.map +1 -0
- package/src/types-external.d.ts +8 -0
- package/src/types-external.js +10 -0
- package/src/types-external.js.map +1 -0
- package/src/types.d.ts +270 -0
- package/src/types.js +27 -0
- package/src/types.js.map +1 -0
- package/src/utils.d.ts +24 -0
- package/src/utils.js +156 -0
- package/src/utils.js.map +1 -0
- package/src/version.d.ts +1 -0
- package/src/version.js +2 -0
- package/src/version.js.map +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { CoralogixWebVitalsInstrumentationConfig } from './instrumentation.model';
|
|
3
|
+
export declare class CoralogixWebVitalsInstrumentation extends InstrumentationBase {
|
|
4
|
+
private metrics;
|
|
5
|
+
private loadingPageObserver;
|
|
6
|
+
private totalBLockingTimeObserver;
|
|
7
|
+
private totalBlockingTimeListAfterPageLoaded;
|
|
8
|
+
constructor(config: CoralogixWebVitalsInstrumentationConfig);
|
|
9
|
+
private registerToCoreWebVitalMetrics;
|
|
10
|
+
private registerToCalculatedWebVitalMetrics;
|
|
11
|
+
private onReport;
|
|
12
|
+
private calculateLoadingPageTime;
|
|
13
|
+
private calculateTotalBlockingTimeAfterLoadPage;
|
|
14
|
+
private calculateAllTotalBlockingTime;
|
|
15
|
+
enable(): void;
|
|
16
|
+
disable(): void;
|
|
17
|
+
protected init(): InstrumentationModuleDefinition<any> | InstrumentationModuleDefinition<any>[] | void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import { InstrumentationBase, } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { onCLS, onFCP, onFID, onINP, onLCP, onTTFB, } from 'web-vitals/attribution';
|
|
4
|
+
import { CoralogixAttributes } from '../constants';
|
|
5
|
+
import { CoralogixEventType, PerformanceTypes } from '../types';
|
|
6
|
+
import { isEmpty, omit } from 'lodash-es';
|
|
7
|
+
import { ALL_WEB_VITALS_METRICS, WEB_VITALS_INSTRUMENTATION_NAME, WEB_VITALS_INSTRUMENTATION_VERSION, } from './instrumentation.consts';
|
|
8
|
+
import { calculateTotalBlockingTime, generateWebVitalUniqueID, getCircularReplacer, rateForTBTMetricValue, supportedPerformanceTypes, } from '../utils';
|
|
9
|
+
var CoralogixWebVitalsInstrumentation = /** @class */ (function (_super) {
|
|
10
|
+
__extends(CoralogixWebVitalsInstrumentation, _super);
|
|
11
|
+
function CoralogixWebVitalsInstrumentation(config) {
|
|
12
|
+
var _this = _super.call(this, WEB_VITALS_INSTRUMENTATION_NAME, WEB_VITALS_INSTRUMENTATION_VERSION, config) || this;
|
|
13
|
+
_this.totalBlockingTimeListAfterPageLoaded = [];
|
|
14
|
+
_this.metrics = !isEmpty(config === null || config === void 0 ? void 0 : config.metrics)
|
|
15
|
+
? config.metrics
|
|
16
|
+
: ALL_WEB_VITALS_METRICS;
|
|
17
|
+
_this.registerToCoreWebVitalMetrics();
|
|
18
|
+
_this.registerToCalculatedWebVitalMetrics();
|
|
19
|
+
return _this;
|
|
20
|
+
}
|
|
21
|
+
CoralogixWebVitalsInstrumentation.prototype.registerToCoreWebVitalMetrics = function () {
|
|
22
|
+
var _this = this;
|
|
23
|
+
// Capture First Input Delay
|
|
24
|
+
if (this.metrics.fid) {
|
|
25
|
+
onFID(function (metric) {
|
|
26
|
+
_this.onReport(metric);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Capture Cumulative Layout Shift
|
|
30
|
+
if (this.metrics.cls) {
|
|
31
|
+
onCLS(function (metric) {
|
|
32
|
+
_this.onReport(metric);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// Capture Largest Contentful Paint
|
|
36
|
+
if (this.metrics.lcp) {
|
|
37
|
+
onLCP(function (metric) {
|
|
38
|
+
_this.onReport(metric);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// Capture First Contentful Paint
|
|
42
|
+
if (this.metrics.fcp) {
|
|
43
|
+
onFCP(function (metric) {
|
|
44
|
+
_this.onReport(metric);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// Capture Interaction to Next Paint
|
|
48
|
+
if (this.metrics.inp) {
|
|
49
|
+
onINP(function (metric) {
|
|
50
|
+
_this.onReport(metric);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Capture Time to First Byte
|
|
54
|
+
if (this.metrics.ttfb) {
|
|
55
|
+
onTTFB(function (metric) {
|
|
56
|
+
_this.onReport(metric);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
CoralogixWebVitalsInstrumentation.prototype.registerToCalculatedWebVitalMetrics = function () {
|
|
61
|
+
if (this.metrics.tbt &&
|
|
62
|
+
supportedPerformanceTypes[PerformanceTypes.LongTask]) {
|
|
63
|
+
this.calculateAllTotalBlockingTime();
|
|
64
|
+
this.calculateTotalBlockingTimeAfterLoadPage();
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.warn('RUM SDK - browser doesnt support TBT events');
|
|
68
|
+
}
|
|
69
|
+
if (this.metrics.lt &&
|
|
70
|
+
supportedPerformanceTypes[PerformanceTypes.Navigation]) {
|
|
71
|
+
this.calculateLoadingPageTime();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.warn('RUM SDK - browser doesnt support navigation events');
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// function that creates a span for each web vital and reports the data
|
|
78
|
+
// as attributes
|
|
79
|
+
CoralogixWebVitalsInstrumentation.prototype.onReport = function (metric) {
|
|
80
|
+
var _a;
|
|
81
|
+
// start the span
|
|
82
|
+
var webVitalsSpan = this.tracer.startSpan(CoralogixEventType.WEB_VITALS);
|
|
83
|
+
var metricData = metric.entries
|
|
84
|
+
? omit(metric, 'entries')
|
|
85
|
+
: metric;
|
|
86
|
+
if ((_a = metricData.attribution) === null || _a === void 0 ? void 0 : _a.navigationEntry) {
|
|
87
|
+
metricData = omit(metricData, 'attribution.navigationEntry');
|
|
88
|
+
}
|
|
89
|
+
webVitalsSpan.setAttribute(CoralogixAttributes.TIMESTAMP, Date.now());
|
|
90
|
+
webVitalsSpan.setAttribute(CoralogixAttributes.EVENT_TYPE, CoralogixEventType.WEB_VITALS);
|
|
91
|
+
// add core web vital attributes
|
|
92
|
+
webVitalsSpan.setAttribute(WEB_VITALS_INSTRUMENTATION_NAME, JSON.stringify(metricData, getCircularReplacer()));
|
|
93
|
+
// end the span
|
|
94
|
+
webVitalsSpan.end();
|
|
95
|
+
};
|
|
96
|
+
CoralogixWebVitalsInstrumentation.prototype.calculateLoadingPageTime = function () {
|
|
97
|
+
var _this = this;
|
|
98
|
+
window.addEventListener('load', function () {
|
|
99
|
+
_this.loadingPageObserver = new PerformanceObserver(function (list) {
|
|
100
|
+
var loadTimeMetric = {};
|
|
101
|
+
list.getEntries().forEach(function (entry) {
|
|
102
|
+
loadTimeMetric = {
|
|
103
|
+
//@ts-ignore
|
|
104
|
+
name: 'LT',
|
|
105
|
+
id: generateWebVitalUniqueID(),
|
|
106
|
+
value: entry.duration,
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
_this.onReport(loadTimeMetric);
|
|
110
|
+
});
|
|
111
|
+
_this.loadingPageObserver.observe({ type: PerformanceTypes.Navigation });
|
|
112
|
+
}, { once: true });
|
|
113
|
+
};
|
|
114
|
+
CoralogixWebVitalsInstrumentation.prototype.calculateTotalBlockingTimeAfterLoadPage = function () {
|
|
115
|
+
var _this = this;
|
|
116
|
+
window.addEventListener('load', function () {
|
|
117
|
+
var totalBlockingTime = calculateTotalBlockingTime(_this.totalBlockingTimeListAfterPageLoaded);
|
|
118
|
+
var tbtMetric = {
|
|
119
|
+
//@ts-ignore
|
|
120
|
+
name: 'TBT_AFTER_PAGE_LOADED',
|
|
121
|
+
id: generateWebVitalUniqueID(),
|
|
122
|
+
rating: rateForTBTMetricValue(totalBlockingTime),
|
|
123
|
+
value: totalBlockingTime,
|
|
124
|
+
};
|
|
125
|
+
_this.onReport(tbtMetric);
|
|
126
|
+
}, { once: true });
|
|
127
|
+
};
|
|
128
|
+
CoralogixWebVitalsInstrumentation.prototype.calculateAllTotalBlockingTime = function () {
|
|
129
|
+
var _this = this;
|
|
130
|
+
this.totalBLockingTimeObserver = new PerformanceObserver(function (list) {
|
|
131
|
+
_this.totalBlockingTimeListAfterPageLoaded =
|
|
132
|
+
_this.totalBlockingTimeListAfterPageLoaded.concat(list.getEntries());
|
|
133
|
+
var totalBlockingTime = calculateTotalBlockingTime(list.getEntries());
|
|
134
|
+
var tbtMetric = {
|
|
135
|
+
//@ts-ignore
|
|
136
|
+
name: 'TBT',
|
|
137
|
+
id: generateWebVitalUniqueID(),
|
|
138
|
+
rating: rateForTBTMetricValue(totalBlockingTime),
|
|
139
|
+
value: totalBlockingTime,
|
|
140
|
+
};
|
|
141
|
+
_this.onReport(tbtMetric);
|
|
142
|
+
});
|
|
143
|
+
this.totalBLockingTimeObserver.observe({
|
|
144
|
+
type: PerformanceTypes.LongTask,
|
|
145
|
+
buffered: true,
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
CoralogixWebVitalsInstrumentation.prototype.enable = function () { };
|
|
149
|
+
CoralogixWebVitalsInstrumentation.prototype.disable = function () {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
(_a = this.loadingPageObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
152
|
+
(_b = this.totalBLockingTimeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
153
|
+
};
|
|
154
|
+
CoralogixWebVitalsInstrumentation.prototype.init = function () {
|
|
155
|
+
return undefined;
|
|
156
|
+
};
|
|
157
|
+
return CoralogixWebVitalsInstrumentation;
|
|
158
|
+
}(InstrumentationBase));
|
|
159
|
+
export { CoralogixWebVitalsInstrumentation };
|
|
160
|
+
//# sourceMappingURL=CoralogixWebVitalsInstrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoralogixWebVitalsInstrumentation.js","sourceRoot":"","sources":["../../../../../libs/browser/src/instrumentations/CoralogixWebVitalsInstrumentation.ts"],"names":[],"mappings":";AAAA,OAA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3B,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC;YACrC,IAAI,EAAE,gBAAgB,CAAC,QAAQ;YAC/B,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAEQ,kDAAM,GAAf,cAAyB,CAAC;IAEjB,mDAAO,GAAhB;;QACE,MAAA,IAAI,CAAC,mBAAmB,0CAAE,UAAU,EAAE,CAAC;QACvC,MAAA,IAAI,CAAC,yBAAyB,0CAAE,UAAU,EAAE,CAAC;IAC/C,CAAC;IAES,gDAAI,GAAd;QAIE,OAAO,SAAS,CAAC;IACnB,CAAC;IACH,wCAAC;AAAD,CAAC,AAhND,CAAuD,mBAAmB,GAgNzE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { XMLHttpRequestInstrumentation, XMLHttpRequestInstrumentationConfig } from '@opentelemetry/instrumentation-xml-http-request';
|
|
2
|
+
export declare enum XHRSource {
|
|
3
|
+
XHR = "xhr"
|
|
4
|
+
}
|
|
5
|
+
export declare class CoralogixXhrInstrumentation extends XMLHttpRequestInstrumentation {
|
|
6
|
+
constructor(config: XMLHttpRequestInstrumentationConfig);
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import { XMLHttpRequestInstrumentation, } from '@opentelemetry/instrumentation-xml-http-request';
|
|
3
|
+
import { CoralogixAttributes } from '../constants';
|
|
4
|
+
import { CoralogixEventType } from '../types';
|
|
5
|
+
import { CoralogixLogSeverity } from '../types-external';
|
|
6
|
+
import { isNetworkError } from '../utils';
|
|
7
|
+
import { propagateTraceHeaderCorsUrls } from '../CoralogixPropgator';
|
|
8
|
+
export var XHRSource;
|
|
9
|
+
(function (XHRSource) {
|
|
10
|
+
XHRSource["XHR"] = "xhr";
|
|
11
|
+
})(XHRSource || (XHRSource = {}));
|
|
12
|
+
var CoralogixXhrInstrumentation = /** @class */ (function (_super) {
|
|
13
|
+
__extends(CoralogixXhrInstrumentation, _super);
|
|
14
|
+
function CoralogixXhrInstrumentation(config) {
|
|
15
|
+
propagateTraceHeaderCorsUrls(config);
|
|
16
|
+
config.applyCustomAttributesOnSpan = function (span, xhr) {
|
|
17
|
+
var _a;
|
|
18
|
+
var status = xhr.status;
|
|
19
|
+
span.setAttributes((_a = {},
|
|
20
|
+
_a[CoralogixAttributes.SEVERITY] = isNetworkError(status)
|
|
21
|
+
? CoralogixLogSeverity.Error
|
|
22
|
+
: CoralogixLogSeverity.Info,
|
|
23
|
+
_a[CoralogixAttributes.EVENT_TYPE] = CoralogixEventType.NETWORK_REQUEST,
|
|
24
|
+
_a[CoralogixAttributes.SOURCE] = XHRSource.XHR,
|
|
25
|
+
_a[CoralogixAttributes.TIMESTAMP] = Date.now(),
|
|
26
|
+
_a));
|
|
27
|
+
};
|
|
28
|
+
return _super.call(this, config) || this;
|
|
29
|
+
}
|
|
30
|
+
return CoralogixXhrInstrumentation;
|
|
31
|
+
}(XMLHttpRequestInstrumentation));
|
|
32
|
+
export { CoralogixXhrInstrumentation };
|
|
33
|
+
//# sourceMappingURL=CoralogixXhrInstrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoralogixXhrInstrumentation.js","sourceRoot":"","sources":["../../../../../libs/browser/src/instrumentations/CoralogixXhrInstrumentation.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,6BAA6B,GAE9B,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,wBAAW,CAAA;AACb,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB;AAED;IAAiD,+CAA6B;IAC5E,qCAAY,MAA2C;QACrD,4BAA4B,CAAC,MAAM,CAAC,CAAC;QAErC,MAAM,CAAC,2BAA2B,GAAG,UAAC,IAAU,EAAE,GAAmB;;YAC3D,IAAA,MAAM,GAAK,GAAG,OAAR,CAAS;YAEvB,IAAI,CAAC,aAAa;gBAChB,GAAC,mBAAmB,CAAC,QAAQ,IAAG,cAAc,CAAC,MAAM,CAAC;oBACpD,CAAC,CAAC,oBAAoB,CAAC,KAAK;oBAC5B,CAAC,CAAC,oBAAoB,CAAC,IAAI;gBAC7B,GAAC,mBAAmB,CAAC,UAAU,IAAG,kBAAkB,CAAC,eAAe;gBACpE,GAAC,mBAAmB,CAAC,MAAM,IAAG,SAAS,CAAC,GAAG;gBAC3C,GAAC,mBAAmB,CAAC,SAAS,IAAG,IAAI,CAAC,GAAG,EAAE;oBAC3C,CAAC;QACL,CAAC,CAAC;eAEF,kBAAM,MAAM,CAAC;IACf,CAAC;IACH,kCAAC;AAAD,CAAC,AAnBD,CAAiD,6BAA6B,GAmB7E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CoralogixWebVitalsMetrics } from './instrumentation.model';
|
|
2
|
+
export declare const WEB_VITALS_INSTRUMENTATION_NAME: string;
|
|
3
|
+
export declare const WEB_VITALS_INSTRUMENTATION_VERSION: string;
|
|
4
|
+
export declare const LONG_TASK_INSTRUMENTATION_VERSION: string;
|
|
5
|
+
export declare const LONG_TASK_PERFORMANCE_TYPE: string;
|
|
6
|
+
export declare const LONG_TASKS_INSTRUMENTATION_NAME: string;
|
|
7
|
+
export declare const RESOURCES_INSTRUMENTATION_NAME: string;
|
|
8
|
+
export declare const RESOURCES_INSTRUMENTATION_VERSION: string;
|
|
9
|
+
export declare const ALL_WEB_VITALS_METRICS: CoralogixWebVitalsMetrics;
|
|
10
|
+
export declare const LONGTASK_DURATION: number;
|
|
11
|
+
export declare const FONTS_URL: string;
|
|
12
|
+
export declare const CSS_EXTENSIONS: string[];
|
|
13
|
+
export declare const OTHER_EXTENSIONS: string[];
|
|
14
|
+
export declare const SCRIPT_EXTENSIONS: string[];
|
|
15
|
+
export declare const MEDIA_EXTENSIONS: string[];
|
|
16
|
+
export declare const DOC_EXTENSIONS: string[];
|
|
17
|
+
export declare const FONT_EXTENSIONS: string[];
|
|
18
|
+
export declare const IMG_EXTENSIONS: string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export var WEB_VITALS_INSTRUMENTATION_NAME = 'web_vitals';
|
|
2
|
+
export var WEB_VITALS_INSTRUMENTATION_VERSION = '1';
|
|
3
|
+
export var LONG_TASK_INSTRUMENTATION_VERSION = '1';
|
|
4
|
+
export var LONG_TASK_PERFORMANCE_TYPE = 'longtask';
|
|
5
|
+
export var LONG_TASKS_INSTRUMENTATION_NAME = 'long_tasks';
|
|
6
|
+
export var RESOURCES_INSTRUMENTATION_NAME = 'resources';
|
|
7
|
+
export var RESOURCES_INSTRUMENTATION_VERSION = '1';
|
|
8
|
+
export var ALL_WEB_VITALS_METRICS = {
|
|
9
|
+
lcp: true,
|
|
10
|
+
fid: true,
|
|
11
|
+
cls: true,
|
|
12
|
+
fcp: true,
|
|
13
|
+
inp: true,
|
|
14
|
+
ttfb: true,
|
|
15
|
+
tbt: true,
|
|
16
|
+
lt: true,
|
|
17
|
+
};
|
|
18
|
+
export var LONGTASK_DURATION = 50;
|
|
19
|
+
export var FONTS_URL = 'fonts.googleapis.com';
|
|
20
|
+
export var CSS_EXTENSIONS = ['.css'];
|
|
21
|
+
export var OTHER_EXTENSIONS = ['.wasm', '.manifest'];
|
|
22
|
+
export var SCRIPT_EXTENSIONS = ['.js', '.mjs'];
|
|
23
|
+
export var MEDIA_EXTENSIONS = [
|
|
24
|
+
'.mp3',
|
|
25
|
+
'.mp4',
|
|
26
|
+
'.wav',
|
|
27
|
+
'.ogg',
|
|
28
|
+
'.webm',
|
|
29
|
+
'.avi',
|
|
30
|
+
];
|
|
31
|
+
export var DOC_EXTENSIONS = [
|
|
32
|
+
'.pdf',
|
|
33
|
+
'.doc',
|
|
34
|
+
'.docx',
|
|
35
|
+
'.ppt',
|
|
36
|
+
'.pptx',
|
|
37
|
+
'.xls',
|
|
38
|
+
'.xlsx',
|
|
39
|
+
'.csv',
|
|
40
|
+
'.html',
|
|
41
|
+
];
|
|
42
|
+
export var FONT_EXTENSIONS = [
|
|
43
|
+
'.woff',
|
|
44
|
+
'.woff2',
|
|
45
|
+
'.ttf',
|
|
46
|
+
'.otf',
|
|
47
|
+
'.eot',
|
|
48
|
+
];
|
|
49
|
+
export var IMG_EXTENSIONS = [
|
|
50
|
+
'.svg',
|
|
51
|
+
'.jpg',
|
|
52
|
+
'.png',
|
|
53
|
+
'.jpeg',
|
|
54
|
+
'.bmp',
|
|
55
|
+
'.webp',
|
|
56
|
+
];
|
|
57
|
+
//# sourceMappingURL=instrumentation.consts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.consts.js","sourceRoot":"","sources":["../../../../../libs/browser/src/instrumentations/instrumentation.consts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAM,+BAA+B,GAAW,YAAY,CAAC;AACpE,MAAM,CAAC,IAAM,kCAAkC,GAAW,GAAG,CAAC;AAE9D,MAAM,CAAC,IAAM,iCAAiC,GAAW,GAAG,CAAC;AAC7D,MAAM,CAAC,IAAM,0BAA0B,GAAW,UAAU,CAAC;AAC7D,MAAM,CAAC,IAAM,+BAA+B,GAAW,YAAY,CAAC;AAEpE,MAAM,CAAC,IAAM,8BAA8B,GAAW,WAAW,CAAC;AAClE,MAAM,CAAC,IAAM,iCAAiC,GAAW,GAAG,CAAC;AAE7D,MAAM,CAAC,IAAM,sBAAsB,GAA8B;IAC/D,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,EAAE,EAAE,IAAI;CACT,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAW,EAAE,CAAC;AAC5C,MAAM,CAAC,IAAM,SAAS,GAAW,sBAAsB,CAAC;AAExD,MAAM,CAAC,IAAM,cAAc,GAAa,CAAC,MAAM,CAAC,CAAC;AACjD,MAAM,CAAC,IAAM,gBAAgB,GAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACjE,MAAM,CAAC,IAAM,iBAAiB,GAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC3D,MAAM,CAAC,IAAM,gBAAgB,GAAa;IACxC,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;CACP,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc,GAAa;IACtC,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;CACR,CAAC;AAEF,MAAM,CAAC,IAAM,eAAe,GAAa;IACvC,OAAO;IACP,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;CACP,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc,GAAa;IACtC,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resourceInitiatorTypeIs(value: string, types: string[]): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.helper.js","sourceRoot":"","sources":["../../../../../libs/browser/src/instrumentations/instrumentation.helper.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,uBAAuB,CACrC,KAAa,EACb,KAAe;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,KAAK,KAAK,EAAd,CAAc,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
2
|
+
export interface CoralogixWebVitalsMetrics {
|
|
3
|
+
lcp: boolean;
|
|
4
|
+
fid: boolean;
|
|
5
|
+
cls: boolean;
|
|
6
|
+
inp: boolean;
|
|
7
|
+
ttfb: boolean;
|
|
8
|
+
fcp: boolean;
|
|
9
|
+
tbt: boolean;
|
|
10
|
+
lt: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface CoralogixWebVitalsInstrumentationConfig extends InstrumentationConfig {
|
|
13
|
+
metrics: Partial<CoralogixWebVitalsMetrics>;
|
|
14
|
+
}
|
|
15
|
+
export declare enum ResourceInitiatorTypes {
|
|
16
|
+
Media = "media",
|
|
17
|
+
Script = "script",
|
|
18
|
+
Css = "css",
|
|
19
|
+
Beacon = "beacon",
|
|
20
|
+
Img = "img",
|
|
21
|
+
Font = "font",
|
|
22
|
+
Doc = "doc",
|
|
23
|
+
Xhr = "xmlhttprequest",
|
|
24
|
+
Fetch = "fetch",
|
|
25
|
+
Iframe = " iframe",
|
|
26
|
+
Video = "video",
|
|
27
|
+
Audio = "audio",
|
|
28
|
+
Track = "track",
|
|
29
|
+
Other = "other"
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var ResourceInitiatorTypes;
|
|
2
|
+
(function (ResourceInitiatorTypes) {
|
|
3
|
+
ResourceInitiatorTypes["Media"] = "media";
|
|
4
|
+
ResourceInitiatorTypes["Script"] = "script";
|
|
5
|
+
ResourceInitiatorTypes["Css"] = "css";
|
|
6
|
+
ResourceInitiatorTypes["Beacon"] = "beacon";
|
|
7
|
+
ResourceInitiatorTypes["Img"] = "img";
|
|
8
|
+
ResourceInitiatorTypes["Font"] = "font";
|
|
9
|
+
ResourceInitiatorTypes["Doc"] = "doc";
|
|
10
|
+
ResourceInitiatorTypes["Xhr"] = "xmlhttprequest";
|
|
11
|
+
ResourceInitiatorTypes["Fetch"] = "fetch";
|
|
12
|
+
ResourceInitiatorTypes["Iframe"] = " iframe";
|
|
13
|
+
ResourceInitiatorTypes["Video"] = "video";
|
|
14
|
+
ResourceInitiatorTypes["Audio"] = "audio";
|
|
15
|
+
ResourceInitiatorTypes["Track"] = "track";
|
|
16
|
+
ResourceInitiatorTypes["Other"] = "other";
|
|
17
|
+
})(ResourceInitiatorTypes || (ResourceInitiatorTypes = {}));
|
|
18
|
+
//# sourceMappingURL=instrumentation.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.model.js","sourceRoot":"","sources":["../../../../../libs/browser/src/instrumentations/instrumentation.model.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAN,IAAY,sBAeX;AAfD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,uCAAa,CAAA;IACb,qCAAW,CAAA;IACX,gDAAsB,CAAA;IACtB,yCAAe,CAAA;IACf,4CAAkB,CAAA;IAClB,yCAAe,CAAA;IACf,yCAAe,CAAA;IACf,yCAAe,CAAA;IACf,yCAAe,CAAA;AACjB,CAAC,EAfW,sBAAsB,KAAtB,sBAAsB,QAejC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Session } from './types';
|
|
2
|
+
export declare class SessionManager {
|
|
3
|
+
readonly sessionKey = "rum_session";
|
|
4
|
+
private idle;
|
|
5
|
+
constructor();
|
|
6
|
+
start(): void;
|
|
7
|
+
stop(): void;
|
|
8
|
+
getSession(): Session;
|
|
9
|
+
private initIdle;
|
|
10
|
+
private clearSession;
|
|
11
|
+
setSession(sessionId?: string): Session;
|
|
12
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import IdleJs from 'idle-js';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import { miillisecondsInSecond, MILLISECONDS_PER_HOUR, SESSION_EXPIRATION_IN_HOURS, SESSION_IDLE_TIME_IN_MINUTES, SESSION_MANAGER_KEY, } from './constants';
|
|
4
|
+
var SessionManager = /** @class */ (function () {
|
|
5
|
+
function SessionManager() {
|
|
6
|
+
this.sessionKey = 'rum_session';
|
|
7
|
+
this.initIdle();
|
|
8
|
+
window[SESSION_MANAGER_KEY] = this;
|
|
9
|
+
}
|
|
10
|
+
SessionManager.prototype.start = function () {
|
|
11
|
+
this.idle.start();
|
|
12
|
+
this.setSession();
|
|
13
|
+
};
|
|
14
|
+
SessionManager.prototype.stop = function () {
|
|
15
|
+
this.idle.stop();
|
|
16
|
+
};
|
|
17
|
+
SessionManager.prototype.getSession = function () {
|
|
18
|
+
var storedSession = JSON.parse(window.sessionStorage.getItem(this.sessionKey));
|
|
19
|
+
var now = Date.now();
|
|
20
|
+
var session;
|
|
21
|
+
if (storedSession) {
|
|
22
|
+
if (storedSession.sessionExpirationDate > now) {
|
|
23
|
+
session = storedSession;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.clearSession();
|
|
27
|
+
session = this.setSession();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return session;
|
|
31
|
+
};
|
|
32
|
+
SessionManager.prototype.initIdle = function () {
|
|
33
|
+
var _this = this;
|
|
34
|
+
if (this.idle) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.idle = new IdleJs({
|
|
38
|
+
idle: SESSION_IDLE_TIME_IN_MINUTES * miillisecondsInSecond * 60,
|
|
39
|
+
events: ['mousemove', 'keydown', 'mousedown', 'touchstart'],
|
|
40
|
+
onIdle: function () {
|
|
41
|
+
_this.clearSession();
|
|
42
|
+
},
|
|
43
|
+
onActive: function () {
|
|
44
|
+
_this.setSession();
|
|
45
|
+
},
|
|
46
|
+
// onHide: () => {}, // callback function to be executed when window become hidden
|
|
47
|
+
// onShow: () => {}, // callback function to be executed when window become visible
|
|
48
|
+
keepTracking: true,
|
|
49
|
+
startAtIdle: false, // set it to true if you want to start in the idle state
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
SessionManager.prototype.clearSession = function () {
|
|
53
|
+
window.sessionStorage.removeItem(this.sessionKey);
|
|
54
|
+
};
|
|
55
|
+
SessionManager.prototype.setSession = function (sessionId) {
|
|
56
|
+
var now = Date.now();
|
|
57
|
+
var expirationDate = now + MILLISECONDS_PER_HOUR * SESSION_EXPIRATION_IN_HOURS;
|
|
58
|
+
var session = {
|
|
59
|
+
sessionId: sessionId || uuidv4(),
|
|
60
|
+
sessionCreationDate: now,
|
|
61
|
+
sessionExpirationDate: expirationDate,
|
|
62
|
+
};
|
|
63
|
+
window.sessionStorage.setItem(this.sessionKey, JSON.stringify(session));
|
|
64
|
+
return session;
|
|
65
|
+
};
|
|
66
|
+
return SessionManager;
|
|
67
|
+
}());
|
|
68
|
+
export { SessionManager };
|
|
69
|
+
//# sourceMappingURL=sessionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionManager.js","sourceRoot":"","sources":["../../../../libs/browser/src/sessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAGrB;IAIE;QAHS,eAAU,GAAG,aAAa,CAAC;QAIlC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,MAAM,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,8BAAK,GAAL;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,6BAAI,GAAJ;QACE,IAAI,CAAC,IAAI,CAAC,IAAI,EA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,qBAAqB,GAAG,2BAA2B,CAAC;QAE5D,IAAM,OAAO,GAAY;YACvB,SAAS,EAAE,SAAS,IAAI,MAAM,EAAE;YAChC,mBAAmB,EAAE,GAAG;YACxB,qBAAqB,EAAE,cAAc;SACtC,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAExE,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,qBAAC;AAAD,CAAC,AA7ED,IA6EC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const enum DOM_EVENT {
|
|
2
|
+
BEFORE_UNLOAD = "beforeunload",
|
|
3
|
+
CLICK = "click",
|
|
4
|
+
DBL_CLICK = "dblclick",
|
|
5
|
+
KEY_DOWN = "keydown",
|
|
6
|
+
LOAD = "load",
|
|
7
|
+
POP_STATE = "popstate",
|
|
8
|
+
SCROLL = "scroll",
|
|
9
|
+
TOUCH_START = "touchstart",
|
|
10
|
+
TOUCH_END = "touchend",
|
|
11
|
+
TOUCH_MOVE = "touchmove",
|
|
12
|
+
VISIBILITY_CHANGE = "visibilitychange",
|
|
13
|
+
PAGE_SHOW = "pageshow",
|
|
14
|
+
FREEZE = "freeze",
|
|
15
|
+
RESUME = "resume",
|
|
16
|
+
PAGE_HIDE = "pagehide",
|
|
17
|
+
MOUSE_DOWN = "mousedown",
|
|
18
|
+
MOUSE_UP = "mouseup",
|
|
19
|
+
MOUSE_MOVE = "mousemove",
|
|
20
|
+
FOCUS = "focus",
|
|
21
|
+
BLUR = "blur",
|
|
22
|
+
CONTEXT_MENU = "contextmenu",
|
|
23
|
+
RESIZE = "resize",
|
|
24
|
+
CHANGE = "change",
|
|
25
|
+
INPUT = "input",
|
|
26
|
+
PLAY = "play",
|
|
27
|
+
PAUSE = "pause",
|
|
28
|
+
SECURITY_POLICY_VIOLATION = "securitypolicyviolation",
|
|
29
|
+
SELECTION_CHANGE = "selectionchange",
|
|
30
|
+
DOM_CONTENT_LOADED = "DOMContentLoaded",
|
|
31
|
+
POINTER_DOWN = "pointerdown",
|
|
32
|
+
POINTER_UP = "pointerup",
|
|
33
|
+
POINTER_CANCEL = "pointercancel",
|
|
34
|
+
HASH_CHANGE = "hashchange"
|
|
35
|
+
}
|
|
36
|
+
type EventMap<T> = T extends Window ? WindowEventMap & {
|
|
37
|
+
visibilitychange: Event;
|
|
38
|
+
freeze: Event;
|
|
39
|
+
resume: Event;
|
|
40
|
+
} : T extends Document ? DocumentEventMap : T extends HTMLElement ? HTMLElementEventMap : T extends VisualViewport ? VisualViewportEventMap : T extends ShadowRoot ? GlobalEventHandlersEventMap : T extends XMLHttpRequest ? XMLHttpRequestEventMap : T extends Performance ? PerformanceEventMap : T extends Worker ? WorkerEventMap : Record<never, never>;
|
|
41
|
+
/**
|
|
42
|
+
* Add an event listener to an event target object (Window, Element, mock...).
|
|
43
|
+
* Returns a `stop` function to remove the listener
|
|
44
|
+
*/
|
|
45
|
+
export declare function addEventListener<Target extends EventTarget, EventName extends keyof EventMap<Target> & string>(eventTarget: Target, eventName: EventName, listener: (event: EventMap<Target>[EventName]) => void, options?: AddEventListenerOptions): {
|
|
46
|
+
stop: () => void;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Add event listeners to an event target object.
|
|
50
|
+
*/
|
|
51
|
+
export declare function addEventListeners<Target extends EventTarget, EventName extends keyof EventMap<Target> & string>(eventTarget: Target, eventNames: EventName[], listener: (event: EventMap<Target>[EventName]) => void, { once, capture, passive }?: AddEventListenerOptions): {
|
|
52
|
+
stop: () => void;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getZoneJsOriginalDom } from './getZoneJsOriginalDom';
|
|
2
|
+
/**
|
|
3
|
+
* Add an event listener to an event target object (Window, Element, mock...).
|
|
4
|
+
* Returns a `stop` function to remove the listener
|
|
5
|
+
*/
|
|
6
|
+
export function addEventListener(eventTarget, eventName, listener, options) {
|
|
7
|
+
return addEventListeners(eventTarget, [eventName], listener, options);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Add event listeners to an event target object.
|
|
11
|
+
*/
|
|
12
|
+
export function addEventListeners(eventTarget, eventNames, listener, _a) {
|
|
13
|
+
var _b = _a === void 0 ? {} : _a, once = _b.once, capture = _b.capture, passive = _b.passive;
|
|
14
|
+
var resolvedListener = once
|
|
15
|
+
? function (event) {
|
|
16
|
+
stop();
|
|
17
|
+
listener(event);
|
|
18
|
+
}
|
|
19
|
+
: listener;
|
|
20
|
+
var options = passive ? { capture: capture, passive: passive } : capture;
|
|
21
|
+
var addListener = getZoneJsOriginalDom(eventTarget, 'addEventListener');
|
|
22
|
+
eventNames.forEach(function (eventName) {
|
|
23
|
+
return addListener.call(eventTarget, eventName, resolvedListener, options);
|
|
24
|
+
});
|
|
25
|
+
function stop() {
|
|
26
|
+
var remove = getZoneJsOriginalDom(eventTarget, 'removeEventListener');
|
|
27
|
+
eventNames.forEach(function (eventName) {
|
|
28
|
+
return remove.call(eventTarget, eventName, resolvedListener, options);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
stop: stop,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=addEventListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addEventListener.js","sourceRoot":"","sources":["../../../../../libs/browser/src/tools/addEventListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA8D9D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAI9B,WAAmB,EACnB,SAAoB,EACpB,QAAsD,EACtD,OAAiC;IAEjC,OAAO,iBAAiB,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAI/B,WAAmB,EACnB,UAAuB,EACvB,QAAsD,EACtD,EAAwD;QAAxD,qBAAsD,EAAE,KAAA,EAAtD,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,OAAO,aAAA;IAExB,IAAM,gBAAgB,GAAG,IAAI;QAC3B,CAAC,CAAC,UAAC,KAAY;YACX,IAAI,EAAE,CAAC;YACP,QAAQ,CAAC,KAAoC,CAAC,CAAC;QACjD,CAAC;QACH,CAAC,CAAE,QAAmC,CAAC;IAEzC,IAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAEzD,IAAM,WAAW,GAAG,oBAAoB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAC1E,UAAU,CAAC,OAAO,CAAC,UAAC,SAAS;QAC3B,OAAA,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC;IAAnE,CAAmE,CACpE,CAAC;IAEF,SAAS,IAAI;QACX,IAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;QACxE,UAAU,CAAC,OAAO,CAAC,UAAC,SAAS;YAC3B,OAAA,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC;QAA9D,CAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,MAAA;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* access the global this consistently, making it suitable for various JavaScript contexts.
|
|
3
|
+
* inspired by https://mathiasbynens.be/notes/globalthis
|
|
4
|
+
*/
|
|
5
|
+
export function getGlobalObject() {
|
|
6
|
+
if (typeof globalThis === 'object') {
|
|
7
|
+
return globalThis;
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(Object.prototype, '_dd_temp_', {
|
|
10
|
+
get: function () {
|
|
11
|
+
return this;
|
|
12
|
+
},
|
|
13
|
+
configurable: true,
|
|
14
|
+
});
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore _dd_temp is defined using defineProperty
|
|
17
|
+
var globalObject = _dd_temp_;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
19
|
+
// @ts-ignore _dd_temp is defined using defineProperty
|
|
20
|
+
delete Object.prototype._dd_temp_;
|
|
21
|
+
if (typeof globalObject !== 'object') {
|
|
22
|
+
// on safari _dd_temp_ is available on window but not globally
|
|
23
|
+
// fallback on other browser globals check
|
|
24
|
+
if (typeof self === 'object') {
|
|
25
|
+
globalObject = self;
|
|
26
|
+
}
|
|
27
|
+
else if (typeof window === 'object') {
|
|
28
|
+
globalObject = window;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
globalObject = {};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return globalObject;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=getGlobalObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGlobalObject.js","sourceRoot":"","sources":["../../../../../libs/browser/src/tools/getGlobalObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,eAAe;IAC7B,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,UAA0B,CAAC;KACnC;IACD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE;QACnD,GAAG;YACD,OAAO,IAAc,CAAC;QACxB,CAAC;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IACH,6DAA6D;IAC7D,sDAAsD;IACtD,IAAI,YAAY,GAAY,SAAS,CAAC;IACtC,6DAA6D;IAC7D,sDAAsD;IACtD,OAAO,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;IAClC,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QACpC,8DAA8D;QAC9D,0CAA0C;QAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,YAAY,GAAG,IAAI,CAAC;SACrB;aAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YACrC,YAAY,GAAG,MAAM,CAAC;SACvB;aAAM;YACL,YAAY,GAAG,EAAE,CAAC;SACnB;KACF;IACD,OAAO,YAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface BrowserWindowWithZoneJs extends Window {
|
|
2
|
+
Zone?: {
|
|
3
|
+
__symbol__?: (name: string) => string;
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Gets the original value for a DOM API that was potentially patched by Zone.js.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getZoneJsOriginalDom<Target, Name extends keyof Target & string>(target: Target, name: Name): Target[Name];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getGlobalObject } from './getGlobalObject';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the original value for a DOM API that was potentially patched by Zone.js.
|
|
4
|
+
*/
|
|
5
|
+
export function getZoneJsOriginalDom(target, name) {
|
|
6
|
+
var browserWindow = getGlobalObject();
|
|
7
|
+
var original;
|
|
8
|
+
if (browserWindow.Zone &&
|
|
9
|
+
typeof browserWindow.Zone.__symbol__ === 'function') {
|
|
10
|
+
original = target[browserWindow.Zone.__symbol__(name)];
|
|
11
|
+
}
|
|
12
|
+
if (!original) {
|
|
13
|
+
original = target[name];
|
|
14
|
+
}
|
|
15
|
+
return original;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=getZoneJsOriginalDom.js.map
|