@coralogix/browser 3.8.2 → 3.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/index.esm2.js +94 -18
- package/package.json +1 -1
- package/src/instrumentations/instrumentation.consts.d.ts +0 -2
- package/src/instrumentations/instrumentation.model.d.ts +0 -14
- package/src/instrumentations/{CoralogixWebVitalsInstrumentation.d.ts → web-vitals/CoralogixWebVitalsInstrumentation.d.ts} +1 -1
- package/src/instrumentations/web-vitals/web-vitals.constants.d.ts +2 -0
- package/src/instrumentations/web-vitals/web-vitals.types.d.ts +64 -0
- package/src/types.d.ts +1 -1
- package/src/version.d.ts +1 -1
package/CHANGELOG.md
CHANGED
package/index.esm2.js
CHANGED
|
@@ -1295,16 +1295,6 @@ var XHR_INSTRUMENTATION_NAME = 'xhr';
|
|
|
1295
1295
|
var FETCH_INSTRUMENTATION_NAME = 'fetch';
|
|
1296
1296
|
var CUSTOM_INSTRUMENTATION_NAME = 'custom';
|
|
1297
1297
|
var SESSION_RECORDING_INSTRUMENTATION_NAME = 'session_recording';
|
|
1298
|
-
var ALL_WEB_VITALS_METRICS = {
|
|
1299
|
-
lcp: true,
|
|
1300
|
-
fid: true,
|
|
1301
|
-
cls: true,
|
|
1302
|
-
fcp: true,
|
|
1303
|
-
inp: true,
|
|
1304
|
-
ttfb: true,
|
|
1305
|
-
tbt: false,
|
|
1306
|
-
lt: true,
|
|
1307
|
-
};
|
|
1308
1298
|
var LONGTASK_DURATION = 50;
|
|
1309
1299
|
var INTERNAL_INSTRUMENTATION_NAME = 'internal';
|
|
1310
1300
|
var FONTS_URL = 'fonts.googleapis.com';
|
|
@@ -1346,6 +1336,75 @@ var IMG_EXTENSIONS = [
|
|
|
1346
1336
|
'.webp',
|
|
1347
1337
|
];
|
|
1348
1338
|
|
|
1339
|
+
var ALL_WEB_VITALS_METRICS = {
|
|
1340
|
+
lcp: true,
|
|
1341
|
+
fid: true,
|
|
1342
|
+
cls: true,
|
|
1343
|
+
fcp: true,
|
|
1344
|
+
inp: true,
|
|
1345
|
+
ttfb: true,
|
|
1346
|
+
tbt: false,
|
|
1347
|
+
lt: true,
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
var attributionSanitizers = {
|
|
1351
|
+
LCP: function (metric) {
|
|
1352
|
+
metric.entries; var attribution = metric.attribution, rest = __rest(metric, ["entries", "attribution"]);
|
|
1353
|
+
var lcpEntry = attribution.lcpEntry;
|
|
1354
|
+
return __assign(__assign({}, rest), { attribution: {
|
|
1355
|
+
element: attribution.element,
|
|
1356
|
+
url: attribution.url,
|
|
1357
|
+
timeToFirstByte: attribution.timeToFirstByte,
|
|
1358
|
+
resourceLoadDelay: attribution.resourceLoadDelay,
|
|
1359
|
+
resourceLoadDuration: attribution.resourceLoadDuration,
|
|
1360
|
+
elementRenderDelay: attribution.elementRenderDelay,
|
|
1361
|
+
lcpEntry: lcpEntry && {
|
|
1362
|
+
url: lcpEntry.url,
|
|
1363
|
+
size: lcpEntry.size,
|
|
1364
|
+
loadTime: lcpEntry.loadTime,
|
|
1365
|
+
renderTime: lcpEntry.renderTime,
|
|
1366
|
+
startTime: lcpEntry.startTime,
|
|
1367
|
+
},
|
|
1368
|
+
} });
|
|
1369
|
+
},
|
|
1370
|
+
FCP: function (metric) {
|
|
1371
|
+
metric.entries; var attribution = metric.attribution, rest = __rest(metric, ["entries", "attribution"]);
|
|
1372
|
+
return __assign(__assign({}, rest), { attribution: {
|
|
1373
|
+
loadState: attribution.loadState,
|
|
1374
|
+
fcpEntry: attribution.fcpEntry && {
|
|
1375
|
+
duration: attribution.fcpEntry.duration,
|
|
1376
|
+
startTime: attribution.fcpEntry.startTime,
|
|
1377
|
+
},
|
|
1378
|
+
} });
|
|
1379
|
+
},
|
|
1380
|
+
CLS: function (metric) {
|
|
1381
|
+
metric.entries; var attribution = metric.attribution, rest = __rest(metric, ["entries", "attribution"]);
|
|
1382
|
+
return __assign(__assign({}, rest), { attribution: {
|
|
1383
|
+
largestShiftTarget: attribution.largestShiftTarget,
|
|
1384
|
+
largestShiftTime: attribution.largestShiftTime,
|
|
1385
|
+
largestShiftValue: attribution.largestShiftValue,
|
|
1386
|
+
loadState: attribution.loadState,
|
|
1387
|
+
} });
|
|
1388
|
+
},
|
|
1389
|
+
FID: function (metric) {
|
|
1390
|
+
metric.entries; var attribution = metric.attribution, rest = __rest(metric, ["entries", "attribution"]);
|
|
1391
|
+
return __assign(__assign({}, rest), { attribution: {
|
|
1392
|
+
eventTarget: attribution.eventTarget,
|
|
1393
|
+
eventType: attribution.eventType,
|
|
1394
|
+
loadState: attribution.loadState,
|
|
1395
|
+
} });
|
|
1396
|
+
},
|
|
1397
|
+
TTFB: function (metric) {
|
|
1398
|
+
metric.entries; var attribution = metric.attribution, rest = __rest(metric, ["entries", "attribution"]);
|
|
1399
|
+
attribution.navigationEntry; var sanitizedAttribution = __rest(attribution, ["navigationEntry"]);
|
|
1400
|
+
return __assign(__assign({}, rest), { attribution: sanitizedAttribution });
|
|
1401
|
+
},
|
|
1402
|
+
INP: function (metric) {
|
|
1403
|
+
metric.entries; metric.attribution; var rest = __rest(metric, ["entries", "attribution"]);
|
|
1404
|
+
return rest;
|
|
1405
|
+
},
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1349
1408
|
function getBrowserWindow() {
|
|
1350
1409
|
return CxGlobal;
|
|
1351
1410
|
}
|
|
@@ -1683,6 +1742,26 @@ function isPerformanceObserverSupported() {
|
|
|
1683
1742
|
return true;
|
|
1684
1743
|
}
|
|
1685
1744
|
|
|
1745
|
+
function sanitizeAttribution(metric) {
|
|
1746
|
+
if (!('attribution' in metric)) {
|
|
1747
|
+
metric.entries; var rest = __rest(metric, ["entries"]);
|
|
1748
|
+
return rest;
|
|
1749
|
+
}
|
|
1750
|
+
switch (metric.name) {
|
|
1751
|
+
case 'LCP':
|
|
1752
|
+
return attributionSanitizers.LCP(metric);
|
|
1753
|
+
case 'FCP':
|
|
1754
|
+
return attributionSanitizers.FCP(metric);
|
|
1755
|
+
case 'CLS':
|
|
1756
|
+
return attributionSanitizers.CLS(metric);
|
|
1757
|
+
case 'FID':
|
|
1758
|
+
return attributionSanitizers.FID(metric);
|
|
1759
|
+
case 'TTFB':
|
|
1760
|
+
return attributionSanitizers.TTFB(metric);
|
|
1761
|
+
case 'INP':
|
|
1762
|
+
return attributionSanitizers.INP(metric);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1686
1765
|
var CoralogixWebVitalsInstrumentation = (function (_super) {
|
|
1687
1766
|
__extends(CoralogixWebVitalsInstrumentation, _super);
|
|
1688
1767
|
function CoralogixWebVitalsInstrumentation(config) {
|
|
@@ -1697,11 +1776,7 @@ var CoralogixWebVitalsInstrumentation = (function (_super) {
|
|
|
1697
1776
|
_this.registerToTBTMetric();
|
|
1698
1777
|
}
|
|
1699
1778
|
var webVitalsSpan = _this.tracer.startSpan(CoralogixEventType.WEB_VITALS);
|
|
1700
|
-
var metricData =
|
|
1701
|
-
metricData = omit(metricData, 'attribution.navigationEntry');
|
|
1702
|
-
if (metricData.name === 'INP') {
|
|
1703
|
-
metricData = omit(metricData, 'attribution');
|
|
1704
|
-
}
|
|
1779
|
+
var metricData = sanitizeAttribution(metric);
|
|
1705
1780
|
webVitalsSpan.setAttribute(CoralogixAttributes.EVENT_TYPE, CoralogixEventType.WEB_VITALS);
|
|
1706
1781
|
webVitalsSpan.setAttribute(WEB_VITALS_INSTRUMENTATION_NAME, JSON.stringify(metricData, getCircularReplacer()));
|
|
1707
1782
|
webVitalsSpan.end();
|
|
@@ -1823,11 +1898,12 @@ var CoralogixWebVitalsInstrumentation = (function (_super) {
|
|
|
1823
1898
|
var _a, _b;
|
|
1824
1899
|
if (tti) {
|
|
1825
1900
|
_this.onReport(tbtMetric);
|
|
1826
|
-
|
|
1901
|
+
var ttiMetric = {
|
|
1827
1902
|
name: 'TTI',
|
|
1828
1903
|
value: tti,
|
|
1829
1904
|
id: generateWebVitalUniqueID(),
|
|
1830
|
-
}
|
|
1905
|
+
};
|
|
1906
|
+
_this.onReport(ttiMetric);
|
|
1831
1907
|
totalBLockingTimeObserver.disconnect();
|
|
1832
1908
|
(_b = (_a = CxGlobal.__tti) === null || _a === void 0 ? void 0 : _a.o) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
1833
1909
|
}
|
|
@@ -4300,7 +4376,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
|
|
|
4300
4376
|
return resolvedUrlBlueprinters;
|
|
4301
4377
|
}
|
|
4302
4378
|
|
|
4303
|
-
var SDK_VERSION = '3.8.
|
|
4379
|
+
var SDK_VERSION = '3.8.3';
|
|
4304
4380
|
|
|
4305
4381
|
function shouldDropEvent(cxRumEvent, options) {
|
|
4306
4382
|
if (isDocumentErrorWithoutMessage(cxRumEvent)) {
|
package/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CoralogixWebVitalsMetrics } from './instrumentation.model';
|
|
2
1
|
export declare const WEB_VITALS_INSTRUMENTATION_NAME = "web_vitals";
|
|
3
2
|
export declare const WEB_VITALS_INSTRUMENTATION_VERSION = "1.0.0";
|
|
4
3
|
export declare const LONG_TASK_INSTRUMENTATION_VERSION = "1.0.0";
|
|
@@ -15,7 +14,6 @@ export declare const XHR_INSTRUMENTATION_NAME = "xhr";
|
|
|
15
14
|
export declare const FETCH_INSTRUMENTATION_NAME = "fetch";
|
|
16
15
|
export declare const CUSTOM_INSTRUMENTATION_NAME = "custom";
|
|
17
16
|
export declare const SESSION_RECORDING_INSTRUMENTATION_NAME = "session_recording";
|
|
18
|
-
export declare const ALL_WEB_VITALS_METRICS: CoralogixWebVitalsMetrics;
|
|
19
17
|
export declare const LONGTASK_DURATION = 50;
|
|
20
18
|
export declare const INTERNAL_INSTRUMENTATION_NAME = "internal";
|
|
21
19
|
export declare const FONTS_URL = "fonts.googleapis.com";
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
2
1
|
import { CoralogixEventType, CoralogixOtelWebOptionsInstrumentations } from '../types';
|
|
3
|
-
export interface CoralogixWebVitalsMetrics {
|
|
4
|
-
lcp: boolean;
|
|
5
|
-
fid: boolean;
|
|
6
|
-
cls: boolean;
|
|
7
|
-
inp: boolean;
|
|
8
|
-
ttfb: boolean;
|
|
9
|
-
fcp: boolean;
|
|
10
|
-
tbt: boolean;
|
|
11
|
-
lt: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface CoralogixWebVitalsInstrumentationConfig extends InstrumentationConfig {
|
|
14
|
-
metrics: Partial<CoralogixWebVitalsMetrics>;
|
|
15
|
-
}
|
|
16
2
|
export declare enum ResourceInitiatorTypes {
|
|
17
3
|
Media = "media",
|
|
18
4
|
Script = "script",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstrumentationBase } from '@opentelemetry/instrumentation';
|
|
2
|
-
import { CoralogixWebVitalsInstrumentationConfig } from './
|
|
2
|
+
import { CoralogixWebVitalsInstrumentationConfig } from './web-vitals.types';
|
|
3
3
|
export declare class CoralogixWebVitalsInstrumentation extends InstrumentationBase {
|
|
4
4
|
private metrics;
|
|
5
5
|
private observers;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CLSMetricWithAttribution, FCPMetricWithAttribution, FIDMetricWithAttribution, INPMetricWithAttribution, LCPMetricWithAttribution, Metric, TTFBMetricWithAttribution } from 'web-vitals/attribution';
|
|
2
|
+
import { WebVitalsRating } from '../../types';
|
|
3
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
4
|
+
export type CustomMetric = {
|
|
5
|
+
name: 'SN' | 'LT' | 'TBT' | 'TTI';
|
|
6
|
+
id: string;
|
|
7
|
+
value: number;
|
|
8
|
+
url?: string;
|
|
9
|
+
navigationType?: Metric['navigationType'];
|
|
10
|
+
navigationId?: string;
|
|
11
|
+
startTime?: number;
|
|
12
|
+
rating?: WebVitalsRating;
|
|
13
|
+
entries?: PerformanceEntry[];
|
|
14
|
+
};
|
|
15
|
+
export type LoadingTimeMetric = CustomMetric & Partial<PerformanceNavigationTiming>;
|
|
16
|
+
type LCPAttribution = LCPMetricWithAttribution['attribution'];
|
|
17
|
+
type FCPAttribution = FCPMetricWithAttribution['attribution'];
|
|
18
|
+
type CLSAttribution = CLSMetricWithAttribution['attribution'];
|
|
19
|
+
type FIDAttribution = FIDMetricWithAttribution['attribution'];
|
|
20
|
+
type TTFBAttribution = TTFBMetricWithAttribution['attribution'];
|
|
21
|
+
type SanitizedLCPMetric = Omit<LCPMetricWithAttribution, 'entries' | 'attribution'> & {
|
|
22
|
+
attribution: Pick<LCPAttribution, 'element' | 'url' | 'timeToFirstByte' | 'resourceLoadDelay' | 'resourceLoadDuration' | 'elementRenderDelay'> & {
|
|
23
|
+
lcpEntry?: Pick<NonNullable<LCPAttribution['lcpEntry']>, 'url' | 'size' | 'loadTime' | 'renderTime' | 'startTime'>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
type SanitizedFCPMetric = Omit<FCPMetricWithAttribution, 'entries' | 'attribution'> & {
|
|
27
|
+
attribution: Pick<FCPAttribution, 'loadState'> & {
|
|
28
|
+
fcpEntry?: Pick<NonNullable<FCPAttribution['fcpEntry']>, 'duration' | 'startTime'>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
type SanitizedCLSMetric = Omit<CLSMetricWithAttribution, 'entries' | 'attribution'> & {
|
|
32
|
+
attribution: Pick<CLSAttribution, 'largestShiftTarget' | 'largestShiftTime' | 'largestShiftValue' | 'loadState'>;
|
|
33
|
+
};
|
|
34
|
+
type SanitizedFIDMetric = Omit<FIDMetricWithAttribution, 'entries' | 'attribution'> & {
|
|
35
|
+
attribution: Pick<FIDAttribution, 'eventTarget' | 'eventType' | 'loadState'>;
|
|
36
|
+
};
|
|
37
|
+
export type SanitizedTTFBMetric = Omit<TTFBMetricWithAttribution, 'entries' | 'attribution'> & {
|
|
38
|
+
attribution: Omit<TTFBAttribution, 'navigationEntry'>;
|
|
39
|
+
};
|
|
40
|
+
type SanitizedINPMetric = Omit<INPMetricWithAttribution, 'entries' | 'attribution'>;
|
|
41
|
+
export type SanitizedMetric = SanitizedLCPMetric | SanitizedFCPMetric | SanitizedCLSMetric | SanitizedFIDMetric | SanitizedTTFBMetric | SanitizedINPMetric | CustomMetric;
|
|
42
|
+
export type SanitizerMap = {
|
|
43
|
+
LCP: (m: LCPMetricWithAttribution) => SanitizedLCPMetric;
|
|
44
|
+
FCP: (m: FCPMetricWithAttribution) => SanitizedFCPMetric;
|
|
45
|
+
CLS: (m: CLSMetricWithAttribution) => SanitizedCLSMetric;
|
|
46
|
+
FID: (m: FIDMetricWithAttribution) => SanitizedFIDMetric;
|
|
47
|
+
TTFB: (m: TTFBMetricWithAttribution) => SanitizedTTFBMetric;
|
|
48
|
+
INP: (m: INPMetricWithAttribution) => SanitizedINPMetric;
|
|
49
|
+
};
|
|
50
|
+
export interface CoralogixWebVitalsMetrics {
|
|
51
|
+
lcp: boolean;
|
|
52
|
+
fid: boolean;
|
|
53
|
+
cls: boolean;
|
|
54
|
+
inp: boolean;
|
|
55
|
+
ttfb: boolean;
|
|
56
|
+
fcp: boolean;
|
|
57
|
+
tbt: boolean;
|
|
58
|
+
lt: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface CoralogixWebVitalsInstrumentationConfig extends InstrumentationConfig {
|
|
61
|
+
metrics: Partial<CoralogixWebVitalsMetrics>;
|
|
62
|
+
}
|
|
63
|
+
export declare const ALL_WEB_VITALS_METRICS: CoralogixWebVitalsMetrics;
|
|
64
|
+
export {};
|
package/src/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { LogSource } from './instrumentations/CoralogixCustomLogInstrumentation'
|
|
|
8
8
|
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
9
9
|
import { CoralogixUserInteractionInstrumentationConfig } from './instrumentations/user-interaction/CoralogixUserInteractionInstrumentation';
|
|
10
10
|
import { Metric } from 'web-vitals/attribution';
|
|
11
|
-
import { CoralogixWebVitalsInstrumentationConfig } from './instrumentations/
|
|
11
|
+
import { CoralogixWebVitalsInstrumentationConfig } from './instrumentations/web-vitals/web-vitals.types';
|
|
12
12
|
import { SessionConfig, SessionRecordingConfig } from './session/session.model';
|
|
13
13
|
import { CoralogixInternalEvent } from './instrumentations/CoralogixInternalInstrumentation';
|
|
14
14
|
import { SnapshotContext } from './snapshot/snapshot.model';
|
package/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "3.8.
|
|
1
|
+
export declare const SDK_VERSION = "3.8.3";
|