Skip to content

Commit ad243cd

Browse files
committed
run variants
1 parent 99dca08 commit ad243cd

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

dev-packages/e2e-tests/test-applications/node-firebase/firestore-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"@firebase/app": "^0.13.1",
1111
"@sentry/node": "file:../../../packed/sentry-node-packed.tgz",
1212
"express": "^4.21.2",
13-
"firebase": "^12.0.0"
13+
"firebase": "^12.16.0"
1414
},
1515
"devDependencies": {
1616
"@types/express": "^4.17.13",

dev-packages/e2e-tests/test-applications/node-firebase/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"test": "playwright test",
1212
"clean": "npx rimraf node_modules **/node_modules pnpm-lock.yaml **/dist *-debug.log test-results",
1313
"test:build": "pnpm install && pnpm build",
14+
"test:build:v12_7": "cd firestore-app && pnpm add firebase@12.7.0 -E && cd .. && pnpm install && pnpm build",
1415
"test:assert": "pnpm firebase emulators:exec --project demo-functions 'pnpm test'",
1516
"test:assert:orchestrion": "E2E_ORCHESTRION=true pnpm test:assert"
1617
},
@@ -33,6 +34,11 @@
3334
{
3435
"assert-command": "pnpm test:assert:orchestrion",
3536
"label": "node-firebase (Orchestrion)"
37+
},
38+
{
39+
"build-command": "pnpm test:build:v12_7",
40+
"assert-command": "pnpm test:assert:orchestrion",
41+
"label": "node-firebase (Orchestrion, v12.7.0)"
3642
}
3743
]
3844
}

packages/server-utils/src/orchestrion/config/firebase.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@ import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';
33
// firebase 9+ ships firestore as `@firebase/firestore` (matches the OTel integration's range). Only the
44
// `lite` SDK exposes the free `addDoc`/`getDocs`/`setDoc`/`deleteDoc` functions we trace, and only the
55
// two `node` entry points (CJS `require`, ESM `import`) are reachable from `@sentry/node`; the
6-
// browser/react-native builds are irrelevant here. Each is a top-level `function <name>` declaration, so
7-
// `functionName` matches. They return promises, so `Auto` settles the span on `asyncEnd`.
8-
const FIRESTORE_VERSION_RANGE = '>=3.0.0 <5';
9-
const FIRESTORE_FILES = ['dist/lite/index.node.cjs.js', 'dist/lite/index.node.mjs'];
6+
// browser/react-native builds are irrelevant here. They return promises, so `Auto` settles the span on
7+
// `asyncEnd`.
8+
//
9+
// Where those declarations live moves with the firestore version, so we register two disjoint ranges
10+
// below. Up to 4.10 they are top-level `function <name>` declarations in the `node` entry files. From 4.10
11+
// the lite build code-splits them into a single content-hashed shared chunk (`common-<hash>.node.*`) and
12+
// leaves the entry files re-export-only, so we match the chunk by a regex on its hashed name. The ranges
13+
// must not overlap: matching the re-export-only entry file would make orchestrion throw "failed to find
14+
// injection points". Regex `filePath` matching requires the code-transformer (orchestrion) >=0.17.0.
1015
const FIRESTORE_OPERATIONS = [
1116
{ functionName: 'addDoc', channelName: 'add-doc' },
1217
{ functionName: 'getDocs', channelName: 'get-docs' },
1318
{ functionName: 'setDoc', channelName: 'set-doc' },
1419
{ functionName: 'deleteDoc', channelName: 'delete-doc' },
1520
] as const;
21+
const FIRESTORE_ENTRY_FILES = ['dist/lite/index.node.cjs.js', 'dist/lite/index.node.mjs'];
22+
const FIRESTORE_CHUNK_FILES = [/^dist\/lite\/common-[^/]+\.node\.cjs\.js$/, /^dist\/lite\/common-[^/]+\.node\.mjs$/];
1623

1724
// firebase-functions v2 (CJS-only). The `onX` provider functions *register* a handler and return a
1825
// synchronous cloud function, so `Sync` is required — the span itself is opened later, when the handler
@@ -58,10 +65,19 @@ const FUNCTIONS_TRIGGERS = [
5865
] as const;
5966

6067
export const firebaseConfig = [
61-
...FIRESTORE_FILES.flatMap(filePath =>
68+
// v3.0.0 - v4.10.0
69+
...FIRESTORE_ENTRY_FILES.flatMap(filePath =>
6270
FIRESTORE_OPERATIONS.map(({ functionName, channelName }) => ({
6371
channelName,
64-
module: { name: '@firebase/firestore', versionRange: FIRESTORE_VERSION_RANGE, filePath },
72+
module: { name: '@firebase/firestore', versionRange: '>=3.0.0 <4.10.0', filePath },
73+
functionQuery: { functionName, kind: 'Auto' as const },
74+
})),
75+
),
76+
// v4.10.0 - v5
77+
...FIRESTORE_CHUNK_FILES.flatMap(filePath =>
78+
FIRESTORE_OPERATIONS.map(({ functionName, channelName }) => ({
79+
channelName,
80+
module: { name: '@firebase/firestore', versionRange: '>=4.10.0 <5', filePath },
6581
functionQuery: { functionName, kind: 'Auto' as const },
6682
})),
6783
),

0 commit comments

Comments
 (0)