Skip to content

Commit a7dba03

Browse files
author
Luca Forstner
authored
Merge pull request #7335 from getsentry/prepare-release/7.41.0
2 parents 0c6d134 + 2fce1bd commit a7dba03

File tree

24 files changed

+1610
-10
lines changed

24 files changed

+1610
-10
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## 7.41.0
8+
9+
- feat: Ensure we use the same default `environment` everywhere (#7327)
10+
- feat(profiling): Add JS self profiling in the browser (#7273)
11+
- feat(vue): Allow to set `routeLabel: 'path'` to opt-out of using name (#7326)
12+
- fix(profiling): Guard from throwing if profiler constructor throws (#7328)
13+
- fix(react): Use namespace import for react router v6 (#7330)
14+
- fix(remix): Correctly parse `X-Forwarded-For` Http header (#7329)
15+
16+
Work in this release contributed by @OliverJAsh. Thank you for your contribution!
17+
718
## 7.40.0
819

920
- feat(nextjs): Automatically resolve source of errors in dev mode (#7294)

packages/browser/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ export { Replay } from '@sentry/replay';
3232
// __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_BEGIN__
3333
export { makeBrowserOfflineTransport } from './transports/offline';
3434
// __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_END__
35+
36+
// __ROLLUP_EXCLUDE_BROWSER_PROFILING_FROM_BUNDLES_BEGIN__
37+
export { onProfilingStartRouteTransaction } from './profiling/hubextensions';
38+
export { BrowserProfilingIntegration } from './profiling/integration';
39+
// __ROLLUP_EXCLUDE_BROWSER_PROFILING_FROM_BUNDLES_END__
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import type { Event } from '@sentry/types';
2+
3+
/**
4+
* Creates a cache that evicts keys in fifo order
5+
* @param size {Number}
6+
*/
7+
export function makeProfilingCache<Key extends string, Value extends Event>(
8+
size: number,
9+
): {
10+
get: (key: Key) => Value | undefined;
11+
add: (key: Key, value: Value) => void;
12+
delete: (key: Key) => boolean;
13+
clear: () => void;
14+
size: () => number;
15+
} {
16+
// Maintain a fifo queue of keys, we cannot rely on Object.keys as the browser may not support it.
17+
let evictionOrder: Key[] = [];
18+
let cache: Record<string, Value> = {};
19+
20+
return {
21+
add(key: Key, value: Value) {
22+
while (evictionOrder.length >= size) {
23+
// shift is O(n) but this is small size and only happens if we are
24+
// exceeding the cache size so it should be fine.
25+
const evictCandidate = evictionOrder.shift();
26+
27+
if (evictCandidate !== undefined) {
28+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
29+
delete cache[evictCandidate];
30+
}
31+
}
32+
33+
// in case we have a collision, delete the old key.
34+
if (cache[key]) {
35+
this.delete(key);
36+
}
37+
38+
evictionOrder.push(key);
39+
cache[key] = value;
40+
},
41+
clear() {
42+
cache = {};
43+
evictionOrder = [];
44+
},
45+
get(key: Key): Value | undefined {
46+
return cache[key];
47+
},
48+
size() {
49+
return evictionOrder.length;
50+
},
51+
// Delete cache key and return true if it existed, false otherwise.
52+
delete(key: Key): boolean {
53+
if (!cache[key]) {
54+
return false;
55+
}
56+
57+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
58+
delete cache[key];
59+
60+
for (let i = 0; i < evictionOrder.length; i++) {
61+
if (evictionOrder[i] === key) {
62+
evictionOrder.splice(i, 1);
63+
break;
64+
}
65+
}
66+
67+
return true;
68+
},
69+
};
70+
}
71+
72+
export const PROFILING_EVENT_CACHE = makeProfilingCache<string, Event>(20);

0 commit comments

Comments
 (0)