@flareapp/core 2.2.0 → 2.3.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/README.md +4 -1
- package/dist/index.cjs +1152 -0
- package/dist/index.d.cts +544 -0
- package/dist/index.d.mts +544 -0
- package/dist/index.mjs +1104 -0
- package/package.json +4 -1
- package/.oxlintrc.json +0 -7
- package/.release-it.json +0 -13
- package/CHANGELOG.md +0 -16
- package/src/Flare.ts +0 -543
- package/src/Scope.ts +0 -96
- package/src/api/Api.ts +0 -35
- package/src/api/index.ts +0 -1
- package/src/env/index.ts +0 -14
- package/src/index.ts +0 -41
- package/src/stacktrace/NullFileReader.ts +0 -28
- package/src/stacktrace/createStackTrace.ts +0 -74
- package/src/stacktrace/fileReader.ts +0 -96
- package/src/stacktrace/index.ts +0 -4
- package/src/types.ts +0 -81
- package/src/util/assert.ts +0 -9
- package/src/util/assertKey.ts +0 -11
- package/src/util/convertToError.ts +0 -22
- package/src/util/extractCode.ts +0 -11
- package/src/util/flatJsonStringify.ts +0 -45
- package/src/util/glowsToEvents.ts +0 -16
- package/src/util/index.ts +0 -8
- package/src/util/now.ts +0 -3
- package/src/util/redactUrl.ts +0 -83
- package/tests/api.test.ts +0 -95
- package/tests/configure.test.ts +0 -16
- package/tests/contextCollector.test.ts +0 -37
- package/tests/convertToError.test.ts +0 -95
- package/tests/createStackTrace.test.ts +0 -54
- package/tests/extractCode.test.ts +0 -30
- package/tests/fileReader.test.ts +0 -51
- package/tests/flatJsonStringify.test.ts +0 -31
- package/tests/flush.test.ts +0 -47
- package/tests/glows.test.ts +0 -47
- package/tests/glowsToEvents.test.ts +0 -41
- package/tests/helpers/FakeApi.ts +0 -20
- package/tests/helpers/index.ts +0 -1
- package/tests/hooks.test.ts +0 -123
- package/tests/light.test.ts +0 -25
- package/tests/nullFileReader.test.ts +0 -11
- package/tests/publicExports.test.ts +0 -17
- package/tests/redactUrl.test.ts +0 -151
- package/tests/report.test.ts +0 -146
- package/tests/sampleRate.test.ts +0 -88
- package/tests/scope.test.ts +0 -64
- package/tests/setEntryPoint.test.ts +0 -79
- package/tests/setFramework.test.ts +0 -48
- package/tests/setSdkInfo.test.ts +0 -62
- package/tsconfig.json +0 -4
- package/vitest.config.ts +0 -17
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { afterEach, beforeEach, expect, test } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { Flare } from '../src';
|
|
5
|
-
import type { Attributes, Config } from '../src/types';
|
|
6
|
-
import { FakeApi } from './helpers';
|
|
7
|
-
|
|
8
|
-
const originalLocation = Object.getOwnPropertyDescriptor(window, 'location');
|
|
9
|
-
|
|
10
|
-
function setLocation(url: string) {
|
|
11
|
-
Object.defineProperty(window, 'location', { configurable: true, value: new URL(url) });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function browserCollector(_config: Readonly<Config>): Attributes {
|
|
15
|
-
const attrs: Attributes = { 'flare.entry_point.type': 'web' };
|
|
16
|
-
if (typeof window !== 'undefined' && window?.location?.pathname) {
|
|
17
|
-
attrs['flare.entry_point.handler.identifier'] = window.location.pathname;
|
|
18
|
-
attrs['flare.entry_point.handler.type'] = 'browser';
|
|
19
|
-
}
|
|
20
|
-
return attrs;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let fakeApi: FakeApi;
|
|
24
|
-
let client: Flare;
|
|
25
|
-
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
fakeApi = new FakeApi();
|
|
28
|
-
client = new Flare(fakeApi, browserCollector).configure({ key: 'key', debug: true });
|
|
29
|
-
setLocation('https://app.test/users/42');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
afterEach(() => {
|
|
33
|
-
if (originalLocation) {
|
|
34
|
-
Object.defineProperty(window, 'location', originalLocation);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('default entry point handler is pathname + browser', async () => {
|
|
39
|
-
await client.report(new Error('x'));
|
|
40
|
-
|
|
41
|
-
const a = fakeApi.lastReport!.attributes;
|
|
42
|
-
expect(a['flare.entry_point.handler.identifier']).toBe('/users/42');
|
|
43
|
-
expect(a['flare.entry_point.handler.type']).toBe('browser');
|
|
44
|
-
expect(a['flare.entry_point.handler.name']).toBeUndefined();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('setEntryPoint overrides identifier, type, and name', async () => {
|
|
48
|
-
client.setEntryPoint({ identifier: '/users/:id', name: 'UserShow', type: 'vue_route' });
|
|
49
|
-
|
|
50
|
-
await client.report(new Error('x'));
|
|
51
|
-
|
|
52
|
-
const a = fakeApi.lastReport!.attributes;
|
|
53
|
-
expect(a['flare.entry_point.handler.identifier']).toBe('/users/:id');
|
|
54
|
-
expect(a['flare.entry_point.handler.type']).toBe('vue_route');
|
|
55
|
-
expect(a['flare.entry_point.handler.name']).toBe('UserShow');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('setEntryPoint replaces (does not merge) prior call — name survives', async () => {
|
|
59
|
-
client.setEntryPoint({ identifier: '/a', name: 'A', type: 'vue_route' });
|
|
60
|
-
client.setEntryPoint({ name: 'B' });
|
|
61
|
-
|
|
62
|
-
await client.report(new Error('x'));
|
|
63
|
-
|
|
64
|
-
const a = fakeApi.lastReport!.attributes;
|
|
65
|
-
expect(a['flare.entry_point.handler.name']).toBe('B');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('setEntryPoint with only name falls back to collector defaults for identifier and type', async () => {
|
|
69
|
-
client.setEntryPoint({ identifier: '/a', name: 'A', type: 'vue_route' });
|
|
70
|
-
client.setEntryPoint({ name: 'B' });
|
|
71
|
-
|
|
72
|
-
await client.report(new Error('x'));
|
|
73
|
-
|
|
74
|
-
const a = fakeApi.lastReport!.attributes;
|
|
75
|
-
// identifier falls back to default pathname from browser collector
|
|
76
|
-
expect(a['flare.entry_point.handler.identifier']).toBe('/users/42');
|
|
77
|
-
// type falls back to default 'browser' from browser collector
|
|
78
|
-
expect(a['flare.entry_point.handler.type']).toBe('browser');
|
|
79
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { beforeEach, expect, test } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { Flare } from '../src';
|
|
4
|
-
import { FakeApi } from './helpers';
|
|
5
|
-
|
|
6
|
-
let fakeApi: FakeApi;
|
|
7
|
-
let client: Flare;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
fakeApi = new FakeApi();
|
|
11
|
-
client = new Flare(fakeApi).configure({ key: 'key', debug: true });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('setFramework emits context.custom.framework in the report', async () => {
|
|
15
|
-
client.setFramework({ name: 'Foo', version: '1.0.0' });
|
|
16
|
-
await client.report(new Error('test'));
|
|
17
|
-
|
|
18
|
-
const custom = fakeApi.lastReport!.attributes['context.custom'] as Record<string, unknown>;
|
|
19
|
-
expect(custom.framework).toBe('foo');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('setFramework lowercases the framework name in context.custom.framework', async () => {
|
|
23
|
-
client.setFramework({ name: 'SomeFramework', version: '2.0.0' });
|
|
24
|
-
await client.report(new Error('test'));
|
|
25
|
-
|
|
26
|
-
const custom = fakeApi.lastReport!.attributes['context.custom'] as Record<string, unknown>;
|
|
27
|
-
expect(custom.framework).toBe('someframework');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('setFramework does not overwrite user-set context.custom keys', async () => {
|
|
31
|
-
client.setFramework({ name: 'Foo', version: '1.0.0' });
|
|
32
|
-
client.addContext('userId', 42);
|
|
33
|
-
await client.report(new Error('test'));
|
|
34
|
-
|
|
35
|
-
const custom = fakeApi.lastReport!.attributes['context.custom'] as Record<string, unknown>;
|
|
36
|
-
expect(custom.framework).toBe('foo');
|
|
37
|
-
expect(custom.userId).toBe(42);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('no context.custom.framework when setFramework was not called', async () => {
|
|
41
|
-
await client.report(new Error('test'));
|
|
42
|
-
|
|
43
|
-
const custom = fakeApi.lastReport!.attributes['context.custom'];
|
|
44
|
-
// Either no context.custom at all, or no framework key within it.
|
|
45
|
-
if (custom && typeof custom === 'object' && !Array.isArray(custom)) {
|
|
46
|
-
expect((custom as Record<string, unknown>).framework).toBeUndefined();
|
|
47
|
-
}
|
|
48
|
-
});
|
package/tests/setSdkInfo.test.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { beforeEach, expect, test } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { Flare } from '../src';
|
|
5
|
-
import { FakeApi } from './helpers';
|
|
6
|
-
|
|
7
|
-
let fakeApi: FakeApi;
|
|
8
|
-
let client: Flare;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
fakeApi = new FakeApi();
|
|
12
|
-
client = new Flare(fakeApi).configure({ key: 'key', debug: true });
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('default sdk info for a bare Flare instance is @flareapp/core', async () => {
|
|
16
|
-
await client.report(new Error('x'));
|
|
17
|
-
|
|
18
|
-
const a = fakeApi.lastReport!.attributes;
|
|
19
|
-
expect(a['telemetry.sdk.name']).toBe('@flareapp/core');
|
|
20
|
-
expect(typeof a['telemetry.sdk.version']).toBe('string');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('setSdkInfo overrides name and version (last call wins)', async () => {
|
|
24
|
-
client.setSdkInfo({ name: '@flareapp/react', version: '2.0.0' });
|
|
25
|
-
client.setSdkInfo({ name: '@flareapp/vue', version: '2.0.1' });
|
|
26
|
-
|
|
27
|
-
await client.report(new Error('x'));
|
|
28
|
-
|
|
29
|
-
const a = fakeApi.lastReport!.attributes;
|
|
30
|
-
expect(a['telemetry.sdk.name']).toBe('@flareapp/vue');
|
|
31
|
-
expect(a['telemetry.sdk.version']).toBe('2.0.1');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('framework attributes omitted by default', async () => {
|
|
35
|
-
await client.report(new Error('x'));
|
|
36
|
-
|
|
37
|
-
const a = fakeApi.lastReport!.attributes;
|
|
38
|
-
expect(a['flare.framework.name']).toBeUndefined();
|
|
39
|
-
expect(a['flare.framework.version']).toBeUndefined();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('setFramework adds framework attributes and context', async () => {
|
|
43
|
-
client.setFramework({ name: 'React', version: '19.0.0' });
|
|
44
|
-
|
|
45
|
-
await client.report(new Error('x'));
|
|
46
|
-
|
|
47
|
-
const a = fakeApi.lastReport!.attributes;
|
|
48
|
-
expect(a['flare.framework.name']).toBe('React');
|
|
49
|
-
expect(a['flare.framework.version']).toBe('19.0.0');
|
|
50
|
-
const custom = a['context.custom'] as Record<string, unknown>;
|
|
51
|
-
expect(custom.framework).toBe('react');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('setFramework without version omits version attribute', async () => {
|
|
55
|
-
client.setFramework({ name: 'Custom' });
|
|
56
|
-
|
|
57
|
-
await client.report(new Error('x'));
|
|
58
|
-
|
|
59
|
-
const a = fakeApi.lastReport!.attributes;
|
|
60
|
-
expect(a['flare.framework.name']).toBe('Custom');
|
|
61
|
-
expect(a['flare.framework.version']).toBeUndefined();
|
|
62
|
-
});
|
package/tsconfig.json
DELETED
package/vitest.config.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { resolve, dirname } from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
|
|
4
|
-
import { defineConfig } from 'vitest/config';
|
|
5
|
-
|
|
6
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
test: {
|
|
10
|
-
environment: 'node',
|
|
11
|
-
},
|
|
12
|
-
resolve: {
|
|
13
|
-
alias: {
|
|
14
|
-
'@flareapp/core': resolve(__dirname, 'src/index.ts'),
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|