Skip to content

Commit 119b78e

Browse files
authored
Add new Telemetry package (#9214)
Create new telemetry package from template
1 parent 22155fb commit 119b78e

File tree

12 files changed

+337
-0
lines changed

12 files changed

+337
-0
lines changed

packages/telemetry/.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
module.exports = {
19+
extends: '../../config/.eslintrc.js',
20+
parserOptions: {
21+
project: 'tsconfig.json',
22+
// to make vscode-eslint work with monorepo
23+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
24+
tsconfigRootDir: __dirname
25+
}
26+
};

packages/telemetry/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @firebase/telemetry

packages/telemetry/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @firebase/telemetry
2+
3+
This package provides instrumentation functionality for javascript applications.

packages/telemetry/index.node.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* This is the file that people using Node.js will actually import. You should
20+
* only include this file if you have something specific about your
21+
* implementation that mandates having a separate entrypoint. Otherwise you can
22+
* just use index.ts
23+
*/
24+
25+
import { testFxn } from './src';
26+
27+
console.log('Hi Node.js Users!');
28+
testFxn();

packages/telemetry/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { testFxn } from './src';
19+
20+
testFxn();

packages/telemetry/karma.conf.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const karmaBase = require('../../config/karma.base');
19+
20+
const files = [`src/**/*.test.ts`];
21+
22+
module.exports = function (config) {
23+
const karmaConfig = {
24+
...karmaBase,
25+
files,
26+
frameworks: ['mocha']
27+
};
28+
29+
config.set(karmaConfig);
30+
};
31+
32+
module.exports.files = files;

packages/telemetry/package.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"name": "@firebase/telemetry",
3+
"version": "0.0.1",
4+
"private": true,
5+
"description": "The Firebase Web Telemetry package of the Firebase JS SDK",
6+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
7+
"main": "dist/index.node.cjs.js",
8+
"browser": "dist/index.esm.js",
9+
"module": "dist/index.esm.js",
10+
"exports": {
11+
".": {
12+
"types": "./dist/index.d.ts",
13+
"node": {
14+
"import": "./dist/node-esm/index.node.esm.js",
15+
"require": "./dist/index.node.cjs.js"
16+
},
17+
"browser": {
18+
"require": "./dist/index.cjs.js",
19+
"import": "./dist/index.esm.js"
20+
},
21+
"default": "./dist/index.esm.js"
22+
},
23+
"./package.json": "./package.json"
24+
},
25+
"files": [
26+
"dist"
27+
],
28+
"scripts": {
29+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
30+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
31+
"build": "rollup -c",
32+
"build:deps": "lerna run --scope @firebase/telemetry --include-dependencies build",
33+
"dev": "rollup -c -w",
34+
"test": "run-p --npm-path npm lint test:all",
35+
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
36+
"test:all": "run-p --npm-path npm test:browser test:node",
37+
"test:browser": "karma start",
38+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.* --config ../../config/mocharc.node.js",
39+
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
40+
},
41+
"peerDependencies": {
42+
"@firebase/app": "0.x",
43+
"@firebase/app-types": "0.x"
44+
},
45+
"dependencies": {
46+
"tslib": "^2.1.0"
47+
},
48+
"license": "Apache-2.0",
49+
"devDependencies": {
50+
"@firebase/app": "0.14.1",
51+
"rollup": "2.79.2",
52+
"rollup-plugin-typescript2": "0.36.0",
53+
"typescript": "5.5.4"
54+
},
55+
"repository": {
56+
"directory": "packages/telemetry",
57+
"type": "git",
58+
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
59+
},
60+
"bugs": {
61+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
62+
},
63+
"typings": "dist/index.d.ts",
64+
"nyc": {
65+
"extension": [
66+
".ts"
67+
],
68+
"reportDir": "./coverage/node"
69+
}
70+
}

packages/telemetry/rollup.config.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import typescriptPlugin from 'rollup-plugin-typescript2';
19+
import typescript from 'typescript';
20+
import pkg from './package.json';
21+
import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file';
22+
23+
const deps = Object.keys(
24+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
25+
);
26+
27+
const buildPlugins = [typescriptPlugin({ typescript })];
28+
29+
const browserBuilds = [
30+
{
31+
input: 'index.ts',
32+
output: {
33+
file: pkg.module,
34+
format: 'es',
35+
sourcemap: true
36+
},
37+
plugins: buildPlugins,
38+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
39+
},
40+
{
41+
input: 'index.ts',
42+
output: {
43+
file: './dist/index.cjs.js',
44+
format: 'cjs',
45+
sourcemap: true
46+
},
47+
plugins: buildPlugins,
48+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
49+
}
50+
];
51+
52+
const nodeBuilds = [
53+
{
54+
input: 'index.node.ts',
55+
output: {
56+
file: pkg.main,
57+
format: 'cjs',
58+
sourcemap: true
59+
},
60+
plugins: buildPlugins,
61+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
62+
},
63+
{
64+
input: 'index.node.ts',
65+
output: {
66+
file: pkg.exports['.'].node.import,
67+
format: 'es',
68+
sourcemap: true
69+
},
70+
plugins: [...buildPlugins, emitModulePackageFile()],
71+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
72+
}
73+
];
74+
75+
export default [...browserBuilds, ...nodeBuilds];

packages/telemetry/src/index.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { expect } from 'chai';
19+
import { testFxn } from './index';
20+
21+
describe('Simple test', () => {
22+
it('Should skip this test');
23+
it('Should test this function', () => {
24+
expect(testFxn()).to.equal(42);
25+
});
26+
it('Should test this async thing', async () => {
27+
// Do some async assertions, you can use `await` syntax if it helps
28+
const val = await Promise.resolve(42);
29+
expect(val).to.equal(42);
30+
});
31+
});

packages/telemetry/src/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { TestType } from './types/index';
19+
20+
export function testFxn(): number {
21+
const _thing: TestType = {};
22+
console.log('hi');
23+
return 42;
24+
}

0 commit comments

Comments
 (0)