@zuplo/cli 7.9.18 → 7.9.19
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/node_modules/@posthog/core/dist/error-tracking/chunk-ids.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/error-tracking/chunk-ids.js +36 -22
- package/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs +36 -22
- package/node_modules/@posthog/core/dist/error-tracking/release.d.ts +3 -5
- package/node_modules/@posthog/core/dist/error-tracking/release.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/error-tracking/release.js +4 -0
- package/node_modules/@posthog/core/dist/error-tracking/release.mjs +4 -0
- package/node_modules/@posthog/core/package.json +1 -1
- package/node_modules/@posthog/core/src/error-tracking/chunk-ids.spec.ts +77 -0
- package/node_modules/@posthog/core/src/error-tracking/chunk-ids.ts +50 -25
- package/node_modules/@posthog/core/src/error-tracking/release.spec.ts +34 -0
- package/node_modules/@posthog/core/src/error-tracking/release.ts +10 -5
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-GYEX3OZM.js → chunk-6YPRGG62.js} +31 -31
- package/node_modules/@zuplo/runtime/out/esm/{chunk-GYEX3OZM.js.map → chunk-6YPRGG62.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/content-disposition/README.md +105 -35
- package/node_modules/content-disposition/dist/index.d.ts +72 -0
- package/node_modules/content-disposition/dist/index.js +388 -0
- package/node_modules/content-disposition/dist/index.js.map +1 -0
- package/node_modules/content-disposition/package.json +31 -19
- package/node_modules/express/Readme.md +15 -9
- package/node_modules/express/lib/application.js +2 -2
- package/node_modules/express/lib/request.js +32 -19
- package/node_modules/express/lib/response.js +27 -30
- package/node_modules/express/node_modules/content-type/LICENSE +22 -0
- package/node_modules/express/node_modules/content-type/README.md +71 -0
- package/node_modules/express/node_modules/content-type/dist/index.d.ts +46 -0
- package/node_modules/express/node_modules/content-type/dist/index.js +176 -0
- package/node_modules/express/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/express/node_modules/content-type/package.json +52 -0
- package/node_modules/express/package.json +10 -10
- package/package.json +11 -11
- package/node_modules/content-disposition/index.js +0 -536
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-GYEX3OZM.js.LEGAL.txt → chunk-6YPRGG62.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-ids.d.ts","sourceRoot":"","sources":["../../src/error-tracking/chunk-ids.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK1C,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"chunk-ids.d.ts","sourceRoot":"","sources":["../../src/error-tracking/chunk-ids.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK1C,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAO5C,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,cAAc,GAAG,SAAS,CAwD5F"}
|
|
@@ -28,38 +28,52 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
let parsedStackResults;
|
|
31
|
-
let
|
|
31
|
+
let lastPostHogChunkIds;
|
|
32
|
+
let lastNativeDebugIds;
|
|
32
33
|
let cachedFilenameChunkIds;
|
|
33
34
|
function getFilenameToChunkIdMap(stackParser) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
cachedFilenameChunkIds
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
const posthogChunkIds = globalThis._posthogChunkIds;
|
|
36
|
+
const nativeDebugIds = globalThis._debugIds;
|
|
37
|
+
if (!posthogChunkIds && !nativeDebugIds) return;
|
|
38
|
+
const posthogKeys = posthogChunkIds ? Object.keys(posthogChunkIds) : [];
|
|
39
|
+
const nativeKeys = nativeDebugIds ? Object.keys(nativeDebugIds) : [];
|
|
40
|
+
if (cachedFilenameChunkIds && matchesSnapshot(posthogChunkIds, posthogKeys, lastPostHogChunkIds) && matchesSnapshot(nativeDebugIds, nativeKeys, lastNativeDebugIds)) return cachedFilenameChunkIds;
|
|
41
|
+
lastPostHogChunkIds = posthogChunkIds ? {
|
|
42
|
+
...posthogChunkIds
|
|
43
|
+
} : void 0;
|
|
44
|
+
lastNativeDebugIds = nativeDebugIds ? {
|
|
45
|
+
...nativeDebugIds
|
|
46
|
+
} : void 0;
|
|
47
|
+
cachedFilenameChunkIds = {};
|
|
48
|
+
parsedStackResults ??= {};
|
|
49
|
+
const addChunkIds = (keys, chunkIds)=>{
|
|
50
|
+
for (const stackKey of keys){
|
|
51
|
+
const chunkId = chunkIds[stackKey];
|
|
52
|
+
if (!chunkId) continue;
|
|
53
|
+
const cachedFilename = parsedStackResults?.[stackKey];
|
|
54
|
+
if (cachedFilename) {
|
|
55
|
+
cachedFilenameChunkIds[cachedFilename] = chunkId;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
44
58
|
const parsedStack = stackParser(stackKey);
|
|
45
59
|
for(let i = parsedStack.length - 1; i >= 0; i--){
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
acc[filename] = chunkId;
|
|
51
|
-
parsedStackResults[stackKey] = [
|
|
52
|
-
filename,
|
|
53
|
-
chunkId
|
|
54
|
-
];
|
|
60
|
+
const filename = parsedStack[i]?.filename;
|
|
61
|
+
if (filename) {
|
|
62
|
+
cachedFilenameChunkIds[filename] = chunkId;
|
|
63
|
+
parsedStackResults[stackKey] = filename;
|
|
55
64
|
break;
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
};
|
|
69
|
+
if (nativeDebugIds) addChunkIds(nativeKeys, nativeDebugIds);
|
|
70
|
+
if (posthogChunkIds) addChunkIds(posthogKeys, posthogChunkIds);
|
|
61
71
|
return cachedFilenameChunkIds;
|
|
62
72
|
}
|
|
73
|
+
function matchesSnapshot(chunkIds, keys, snapshot) {
|
|
74
|
+
if (!chunkIds || !snapshot) return chunkIds === snapshot;
|
|
75
|
+
return keys.length === Object.keys(snapshot).length && keys.every((key)=>chunkIds[key] === snapshot[key]);
|
|
76
|
+
}
|
|
63
77
|
__webpack_require__.d(__webpack_exports__, {
|
|
64
78
|
getFilenameToChunkIdMap: ()=>getFilenameToChunkIdMap
|
|
65
79
|
});
|
|
@@ -1,34 +1,48 @@
|
|
|
1
1
|
let parsedStackResults;
|
|
2
|
-
let
|
|
2
|
+
let lastPostHogChunkIds;
|
|
3
|
+
let lastNativeDebugIds;
|
|
3
4
|
let cachedFilenameChunkIds;
|
|
4
5
|
function getFilenameToChunkIdMap(stackParser) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
cachedFilenameChunkIds
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const posthogChunkIds = globalThis._posthogChunkIds;
|
|
7
|
+
const nativeDebugIds = globalThis._debugIds;
|
|
8
|
+
if (!posthogChunkIds && !nativeDebugIds) return;
|
|
9
|
+
const posthogKeys = posthogChunkIds ? Object.keys(posthogChunkIds) : [];
|
|
10
|
+
const nativeKeys = nativeDebugIds ? Object.keys(nativeDebugIds) : [];
|
|
11
|
+
if (cachedFilenameChunkIds && matchesSnapshot(posthogChunkIds, posthogKeys, lastPostHogChunkIds) && matchesSnapshot(nativeDebugIds, nativeKeys, lastNativeDebugIds)) return cachedFilenameChunkIds;
|
|
12
|
+
lastPostHogChunkIds = posthogChunkIds ? {
|
|
13
|
+
...posthogChunkIds
|
|
14
|
+
} : void 0;
|
|
15
|
+
lastNativeDebugIds = nativeDebugIds ? {
|
|
16
|
+
...nativeDebugIds
|
|
17
|
+
} : void 0;
|
|
18
|
+
cachedFilenameChunkIds = {};
|
|
19
|
+
parsedStackResults ??= {};
|
|
20
|
+
const addChunkIds = (keys, chunkIds)=>{
|
|
21
|
+
for (const stackKey of keys){
|
|
22
|
+
const chunkId = chunkIds[stackKey];
|
|
23
|
+
if (!chunkId) continue;
|
|
24
|
+
const cachedFilename = parsedStackResults?.[stackKey];
|
|
25
|
+
if (cachedFilename) {
|
|
26
|
+
cachedFilenameChunkIds[cachedFilename] = chunkId;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
15
29
|
const parsedStack = stackParser(stackKey);
|
|
16
30
|
for(let i = parsedStack.length - 1; i >= 0; i--){
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
acc[filename] = chunkId;
|
|
22
|
-
parsedStackResults[stackKey] = [
|
|
23
|
-
filename,
|
|
24
|
-
chunkId
|
|
25
|
-
];
|
|
31
|
+
const filename = parsedStack[i]?.filename;
|
|
32
|
+
if (filename) {
|
|
33
|
+
cachedFilenameChunkIds[filename] = chunkId;
|
|
34
|
+
parsedStackResults[stackKey] = filename;
|
|
26
35
|
break;
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
};
|
|
40
|
+
if (nativeDebugIds) addChunkIds(nativeKeys, nativeDebugIds);
|
|
41
|
+
if (posthogChunkIds) addChunkIds(posthogKeys, posthogChunkIds);
|
|
32
42
|
return cachedFilenameChunkIds;
|
|
33
43
|
}
|
|
44
|
+
function matchesSnapshot(chunkIds, keys, snapshot) {
|
|
45
|
+
if (!chunkIds || !snapshot) return chunkIds === snapshot;
|
|
46
|
+
return keys.length === Object.keys(snapshot).length && keys.every((key)=>chunkIds[key] === snapshot[key]);
|
|
47
|
+
}
|
|
34
48
|
export { getFilenameToChunkIdMap };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Read the release id injected into
|
|
2
|
+
* Read the release id embedded at build time or injected into a processed bundle.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* runtime). The SDK emits it on `$exception` events so the server resolves the release with a plain
|
|
7
|
-
* foreign-key lookup. Returns `undefined` when nothing was injected or the value is malformed.
|
|
4
|
+
* Framework integrations can compile `POSTHOG_RELEASE_ID` into browser code before asset hashes
|
|
5
|
+
* are finalized. The global remains as a fallback for bundles processed by posthog-cli.
|
|
8
6
|
*/
|
|
9
7
|
export declare function getInjectedReleaseId(): string | undefined;
|
|
10
8
|
//# sourceMappingURL=release.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../src/error-tracking/release.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../src/error-tracking/release.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAUzD"}
|
|
@@ -28,6 +28,10 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
function getInjectedReleaseId() {
|
|
31
|
+
if ("u" > typeof process) {
|
|
32
|
+
const fromEnvironment = process.env.POSTHOG_RELEASE_ID?.trim();
|
|
33
|
+
if (fromEnvironment) return fromEnvironment;
|
|
34
|
+
}
|
|
31
35
|
const injected = globalThis._posthogReleaseId;
|
|
32
36
|
return 'string' == typeof injected && injected.length > 0 ? injected : void 0;
|
|
33
37
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
function getInjectedReleaseId() {
|
|
2
|
+
if ("u" > typeof process) {
|
|
3
|
+
const fromEnvironment = process.env.POSTHOG_RELEASE_ID?.trim();
|
|
4
|
+
if (fromEnvironment) return fromEnvironment;
|
|
5
|
+
}
|
|
2
6
|
const injected = globalThis._posthogReleaseId;
|
|
3
7
|
return 'string' == typeof injected && injected.length > 0 ? injected : void 0;
|
|
4
8
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { StackParser } from './types'
|
|
2
|
+
|
|
3
|
+
const stackParser: StackParser = (stack) => [
|
|
4
|
+
{
|
|
5
|
+
platform: 'web:javascript',
|
|
6
|
+
filename: stack.split('|')[0],
|
|
7
|
+
},
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
describe('getFilenameToChunkIdMap', () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
vi.resetModules()
|
|
13
|
+
delete (globalThis as any)._posthogChunkIds
|
|
14
|
+
delete (globalThis as any)._debugIds
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
delete (globalThis as any)._posthogChunkIds
|
|
19
|
+
delete (globalThis as any)._debugIds
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('maps native debug IDs to filenames', async () => {
|
|
23
|
+
;(globalThis as any)._debugIds = {
|
|
24
|
+
'https://example.com/chunk.js|native': 'native-debug-id',
|
|
25
|
+
}
|
|
26
|
+
const { getFilenameToChunkIdMap } = await import('./chunk-ids')
|
|
27
|
+
|
|
28
|
+
expect(getFilenameToChunkIdMap(stackParser)).toEqual({
|
|
29
|
+
'https://example.com/chunk.js': 'native-debug-id',
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('prefers PostHog chunk IDs over native debug IDs for the same file', async () => {
|
|
34
|
+
;(globalThis as any)._debugIds = {
|
|
35
|
+
'https://example.com/chunk.js|native': 'native-debug-id',
|
|
36
|
+
}
|
|
37
|
+
;(globalThis as any)._posthogChunkIds = {
|
|
38
|
+
'https://example.com/chunk.js|posthog': 'posthog-chunk-id',
|
|
39
|
+
}
|
|
40
|
+
const { getFilenameToChunkIdMap } = await import('./chunk-ids')
|
|
41
|
+
|
|
42
|
+
expect(getFilenameToChunkIdMap(stackParser)).toEqual({
|
|
43
|
+
'https://example.com/chunk.js': 'posthog-chunk-id',
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('refreshes the cached map when native debug IDs are added', async () => {
|
|
48
|
+
;(globalThis as any)._debugIds = {
|
|
49
|
+
'https://example.com/one.js|native': 'one',
|
|
50
|
+
}
|
|
51
|
+
const { getFilenameToChunkIdMap } = await import('./chunk-ids')
|
|
52
|
+
|
|
53
|
+
expect(getFilenameToChunkIdMap(stackParser)).toEqual({ 'https://example.com/one.js': 'one' })
|
|
54
|
+
|
|
55
|
+
;(globalThis as any)._debugIds['https://example.com/two.js|native'] = 'two'
|
|
56
|
+
|
|
57
|
+
expect(getFilenameToChunkIdMap(stackParser)).toEqual({
|
|
58
|
+
'https://example.com/one.js': 'one',
|
|
59
|
+
'https://example.com/two.js': 'two',
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('refreshes the cached map when a debug ID map is replaced with the same number of entries', async () => {
|
|
64
|
+
;(globalThis as any)._debugIds = {
|
|
65
|
+
'https://example.com/one.js|native': 'one',
|
|
66
|
+
}
|
|
67
|
+
const { getFilenameToChunkIdMap } = await import('./chunk-ids')
|
|
68
|
+
|
|
69
|
+
expect(getFilenameToChunkIdMap(stackParser)).toEqual({ 'https://example.com/one.js': 'one' })
|
|
70
|
+
|
|
71
|
+
;(globalThis as any)._debugIds = {
|
|
72
|
+
'https://example.com/two.js|native': 'two',
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
expect(getFilenameToChunkIdMap(stackParser)).toEqual({ 'https://example.com/two.js': 'two' })
|
|
76
|
+
})
|
|
77
|
+
})
|
|
@@ -5,55 +5,80 @@
|
|
|
5
5
|
import type { StackParser } from './types'
|
|
6
6
|
|
|
7
7
|
type StackString = string
|
|
8
|
-
type CachedResult =
|
|
8
|
+
type CachedResult = string
|
|
9
9
|
|
|
10
10
|
type ChunkIdMapType = Record<string, string>
|
|
11
11
|
|
|
12
12
|
let parsedStackResults: Record<StackString, CachedResult> | undefined
|
|
13
|
-
let
|
|
13
|
+
let lastPostHogChunkIds: ChunkIdMapType | undefined
|
|
14
|
+
let lastNativeDebugIds: ChunkIdMapType | undefined
|
|
14
15
|
let cachedFilenameChunkIds: ChunkIdMapType | undefined
|
|
15
16
|
|
|
16
17
|
export function getFilenameToChunkIdMap(stackParser: StackParser): ChunkIdMapType | undefined {
|
|
17
|
-
const
|
|
18
|
-
|
|
18
|
+
const posthogChunkIds = (globalThis as any)._posthogChunkIds as ChunkIdMapType | undefined
|
|
19
|
+
const nativeDebugIds = (globalThis as any)._debugIds as ChunkIdMapType | undefined
|
|
20
|
+
if (!posthogChunkIds && !nativeDebugIds) {
|
|
19
21
|
return undefined
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
const
|
|
24
|
+
const posthogKeys = posthogChunkIds ? Object.keys(posthogChunkIds) : []
|
|
25
|
+
const nativeKeys = nativeDebugIds ? Object.keys(nativeDebugIds) : []
|
|
23
26
|
|
|
24
|
-
if (
|
|
27
|
+
if (
|
|
28
|
+
cachedFilenameChunkIds &&
|
|
29
|
+
matchesSnapshot(posthogChunkIds, posthogKeys, lastPostHogChunkIds) &&
|
|
30
|
+
matchesSnapshot(nativeDebugIds, nativeKeys, lastNativeDebugIds)
|
|
31
|
+
) {
|
|
25
32
|
return cachedFilenameChunkIds
|
|
26
33
|
}
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
lastPostHogChunkIds = posthogChunkIds ? { ...posthogChunkIds } : undefined
|
|
36
|
+
lastNativeDebugIds = nativeDebugIds ? { ...nativeDebugIds } : undefined
|
|
37
|
+
cachedFilenameChunkIds = {}
|
|
38
|
+
parsedStackResults ??= {}
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
const addChunkIds = (keys: string[], chunkIds: ChunkIdMapType): void => {
|
|
41
|
+
for (const stackKey of keys) {
|
|
42
|
+
const chunkId = chunkIds[stackKey]
|
|
43
|
+
if (!chunkId) {
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
34
46
|
|
|
35
|
-
|
|
47
|
+
const cachedFilename = parsedStackResults?.[stackKey]
|
|
48
|
+
if (cachedFilename) {
|
|
49
|
+
cachedFilenameChunkIds![cachedFilename] = chunkId
|
|
50
|
+
continue
|
|
51
|
+
}
|
|
36
52
|
|
|
37
|
-
if (result) {
|
|
38
|
-
acc[result[0]] = result[1]
|
|
39
|
-
} else {
|
|
40
53
|
const parsedStack = stackParser(stackKey)
|
|
41
|
-
|
|
42
54
|
for (let i = parsedStack.length - 1; i >= 0; i--) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (filename && chunkId) {
|
|
48
|
-
acc[filename] = chunkId
|
|
49
|
-
parsedStackResults[stackKey] = [filename, chunkId]
|
|
55
|
+
const filename = parsedStack[i]?.filename
|
|
56
|
+
if (filename) {
|
|
57
|
+
cachedFilenameChunkIds![filename] = chunkId
|
|
58
|
+
parsedStackResults![stackKey] = filename
|
|
50
59
|
break
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
62
|
}
|
|
63
|
+
}
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
if (nativeDebugIds) {
|
|
66
|
+
addChunkIds(nativeKeys, nativeDebugIds)
|
|
67
|
+
}
|
|
68
|
+
if (posthogChunkIds) {
|
|
69
|
+
addChunkIds(posthogKeys, posthogChunkIds)
|
|
70
|
+
}
|
|
57
71
|
|
|
58
72
|
return cachedFilenameChunkIds
|
|
59
73
|
}
|
|
74
|
+
|
|
75
|
+
function matchesSnapshot(
|
|
76
|
+
chunkIds: ChunkIdMapType | undefined,
|
|
77
|
+
keys: string[],
|
|
78
|
+
snapshot: ChunkIdMapType | undefined
|
|
79
|
+
): boolean {
|
|
80
|
+
if (!chunkIds || !snapshot) {
|
|
81
|
+
return chunkIds === snapshot
|
|
82
|
+
}
|
|
83
|
+
return keys.length === Object.keys(snapshot).length && keys.every((key) => chunkIds[key] === snapshot[key])
|
|
84
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getInjectedReleaseId } from './release'
|
|
2
|
+
|
|
3
|
+
describe('getInjectedReleaseId', () => {
|
|
4
|
+
const originalReleaseId = process.env.POSTHOG_RELEASE_ID
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
if (originalReleaseId === undefined) {
|
|
8
|
+
delete process.env.POSTHOG_RELEASE_ID
|
|
9
|
+
} else {
|
|
10
|
+
process.env.POSTHOG_RELEASE_ID = originalReleaseId
|
|
11
|
+
}
|
|
12
|
+
delete (globalThis as any)._posthogReleaseId
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('reads and trims POSTHOG_RELEASE_ID', () => {
|
|
16
|
+
process.env.POSTHOG_RELEASE_ID = ' release-from-environment '
|
|
17
|
+
|
|
18
|
+
expect(getInjectedReleaseId()).toBe('release-from-environment')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('prefers POSTHOG_RELEASE_ID over the injected global', () => {
|
|
22
|
+
process.env.POSTHOG_RELEASE_ID = 'release-from-environment'
|
|
23
|
+
;(globalThis as any)._posthogReleaseId = 'release-from-injection'
|
|
24
|
+
|
|
25
|
+
expect(getInjectedReleaseId()).toBe('release-from-environment')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('falls back to the injected global when the environment value is empty', () => {
|
|
29
|
+
process.env.POSTHOG_RELEASE_ID = ' '
|
|
30
|
+
;(globalThis as any)._posthogReleaseId = 'release-from-injection'
|
|
31
|
+
|
|
32
|
+
expect(getInjectedReleaseId()).toBe('release-from-injection')
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Read the release id injected into
|
|
2
|
+
* Read the release id embedded at build time or injected into a processed bundle.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* runtime). The SDK emits it on `$exception` events so the server resolves the release with a plain
|
|
7
|
-
* foreign-key lookup. Returns `undefined` when nothing was injected or the value is malformed.
|
|
4
|
+
* Framework integrations can compile `POSTHOG_RELEASE_ID` into browser code before asset hashes
|
|
5
|
+
* are finalized. The global remains as a fallback for bundles processed by posthog-cli.
|
|
8
6
|
*/
|
|
9
7
|
export function getInjectedReleaseId(): string | undefined {
|
|
8
|
+
if (typeof process !== 'undefined') {
|
|
9
|
+
const fromEnvironment = process.env.POSTHOG_RELEASE_ID?.trim()
|
|
10
|
+
if (fromEnvironment) {
|
|
11
|
+
return fromEnvironment
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
const injected = (globalThis as any)._posthogReleaseId
|
|
11
16
|
return typeof injected === 'string' && injected.length > 0 ? injected : undefined
|
|
12
17
|
}
|