@webex/internal-plugin-metrics 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.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/README.md +36 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.types.js.map +1 -1
- package/dist/new-metrics.js +47 -11
- package/dist/new-metrics.js.map +1 -1
- package/dist/privacy-and-security-permission-enricher/constants.js +18 -0
- package/dist/privacy-and-security-permission-enricher/constants.js.map +1 -0
- package/dist/privacy-and-security-permission-enricher/index.js +143 -0
- package/dist/privacy-and-security-permission-enricher/index.js.map +1 -0
- package/dist/privacy-and-security-permission-enricher/types.js +7 -0
- package/dist/privacy-and-security-permission-enricher/types.js.map +1 -0
- package/dist/privacy-and-security-permission-enricher/utils.js +71 -0
- package/dist/privacy-and-security-permission-enricher/utils.js.map +1 -0
- package/dist/types/config.d.ts +3 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/metrics.types.d.ts +3 -0
- package/dist/types/new-metrics.d.ts +13 -1
- package/dist/types/privacy-and-security-permission-enricher/constants.d.ts +6 -0
- package/dist/types/privacy-and-security-permission-enricher/index.d.ts +40 -0
- package/dist/types/privacy-and-security-permission-enricher/types.d.ts +14 -0
- package/dist/types/privacy-and-security-permission-enricher/utils.d.ts +5 -0
- package/dist/types/unhandled-exception-telemetry/index.d.ts +60 -0
- package/dist/types/unhandled-exception-telemetry/utils.d.ts +6 -0
- package/dist/unhandled-exception-telemetry/index.js +330 -0
- package/dist/unhandled-exception-telemetry/index.js.map +1 -0
- package/dist/unhandled-exception-telemetry/utils.js +105 -0
- package/dist/unhandled-exception-telemetry/utils.js.map +1 -0
- package/package.json +8 -8
- package/src/config.js +3 -0
- package/src/index.ts +2 -0
- package/src/metrics.types.ts +9 -0
- package/src/new-metrics.ts +44 -2
- package/src/privacy-and-security-permission-enricher/constants.ts +33 -0
- package/src/privacy-and-security-permission-enricher/index.ts +142 -0
- package/src/privacy-and-security-permission-enricher/types.ts +21 -0
- package/src/privacy-and-security-permission-enricher/utils.ts +82 -0
- package/src/unhandled-exception-telemetry/index.ts +403 -0
- package/src/unhandled-exception-telemetry/utils.ts +101 -0
- package/test/unit/spec/new-metrics.ts +168 -52
- package/test/unit/spec/privacy-and-security-permission-enricher.ts +318 -0
- package/test/unit/spec/unhandled-exception-telemetry/utils.ts +109 -0
- package/test/unit/spec/unhandled-exception-telemetry.ts +688 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {assert} from '@webex/test-helper-chai';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createFingerprint,
|
|
5
|
+
removeUrlDetails,
|
|
6
|
+
removeUrlDetailsFromText,
|
|
7
|
+
sanitizeResourceUrl,
|
|
8
|
+
stringifyReason,
|
|
9
|
+
truncate,
|
|
10
|
+
} from '@webex/internal-plugin-metrics/src/unhandled-exception-telemetry/utils';
|
|
11
|
+
|
|
12
|
+
const TEST_USERINFO = ['fixture-user', 'fixture-value'].join(':');
|
|
13
|
+
|
|
14
|
+
describe('Unhandled exception telemetry utilities', () => {
|
|
15
|
+
describe('#truncate()', () => {
|
|
16
|
+
it('truncates strings to the requested length', () => {
|
|
17
|
+
assert.equal(truncate('abcdef', 3), 'abc');
|
|
18
|
+
assert.equal(truncate('abc', 3), 'abc');
|
|
19
|
+
assert.isUndefined(truncate(undefined, 3));
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('#removeUrlDetails()', () => {
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
input: `https://${TEST_USERINFO}@example.test/path?secret=x#fragment`,
|
|
27
|
+
expected: 'https://example.test/path',
|
|
28
|
+
},
|
|
29
|
+
{input: `//${TEST_USERINFO}@example.test/path#fragment`, expected: '//example.test/path'},
|
|
30
|
+
{input: '/api/messages?secret=x', expected: '/api/messages'},
|
|
31
|
+
{input: '', expected: undefined},
|
|
32
|
+
{input: 42, expected: undefined},
|
|
33
|
+
].forEach(({input, expected}) => {
|
|
34
|
+
it(`sanitizes ${JSON.stringify(input)}`, () => {
|
|
35
|
+
assert.strictEqual(removeUrlDetails(input), expected);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('#sanitizeResourceUrl()', () => {
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
input: ` https://${TEST_USERINFO}@example.test/app.js?secret=x `,
|
|
44
|
+
expected: 'https://example.test/app.js',
|
|
45
|
+
},
|
|
46
|
+
{input: '/assets/app.js?secret=x', expected: '/assets/app.js'},
|
|
47
|
+
{input: 'data:text/plain,secret', expected: undefined},
|
|
48
|
+
{input: 'blob:https://example.test/id', expected: undefined},
|
|
49
|
+
{input: undefined, expected: undefined},
|
|
50
|
+
].forEach(({input, expected}) => {
|
|
51
|
+
it(`sanitizes ${JSON.stringify(input)}`, () => {
|
|
52
|
+
assert.strictEqual(sanitizeResourceUrl(input), expected);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('caps resource URLs at 2048 characters', () => {
|
|
57
|
+
assert.lengthOf(sanitizeResourceUrl(`/${'x'.repeat(3_000)}`) as string, 2_048);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('#removeUrlDetailsFromText()', () => {
|
|
62
|
+
[
|
|
63
|
+
{
|
|
64
|
+
input: `url=https://${TEST_USERINFO}@example.test/path?secret=x`,
|
|
65
|
+
expected: 'url=https://example.test/path',
|
|
66
|
+
},
|
|
67
|
+
{input: 'payload=data:text/plain,secret', expected: 'payload=[redacted-url]'},
|
|
68
|
+
{input: 'GET /api/messages?secret=x', expected: 'GET /api/messages'},
|
|
69
|
+
{input: 'at load (../app.js#fragment:10:20)', expected: 'at load (../app.js)'},
|
|
70
|
+
{input: 'retry api/messages?secret=x', expected: 'retry api/messages'},
|
|
71
|
+
{input: 'at load (app.js?secret=x:10:20)', expected: 'at load (app.js)'},
|
|
72
|
+
{input: 'GET api?secret=x', expected: 'GET api'},
|
|
73
|
+
].forEach(({input, expected}) => {
|
|
74
|
+
it(`sanitizes ${input}`, () => {
|
|
75
|
+
assert.equal(removeUrlDetailsFromText(input), expected);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('#createFingerprint()', () => {
|
|
81
|
+
it('returns a stable eight-character key that changes with its input', () => {
|
|
82
|
+
const fingerprint = createFingerprint('same error');
|
|
83
|
+
|
|
84
|
+
assert.lengthOf(fingerprint, 8);
|
|
85
|
+
assert.equal(createFingerprint('same error'), fingerprint);
|
|
86
|
+
assert.notEqual(createFingerprint('different error'), fingerprint);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('#stringifyReason()', () => {
|
|
91
|
+
it('serializes strings and objects', () => {
|
|
92
|
+
assert.equal(stringifyReason('failed'), 'failed');
|
|
93
|
+
assert.equal(stringifyReason({message: 'failed'}), '{"message":"failed"}');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('falls back safely when conversion hooks throw', () => {
|
|
97
|
+
const reason = new Proxy(
|
|
98
|
+
{},
|
|
99
|
+
{
|
|
100
|
+
get() {
|
|
101
|
+
throw new Error('unreadable');
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
assert.equal(stringifyReason(reason), 'Unserializable rejection reason');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|