Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/telemetry/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

module.exports = {
extends: '../../config/.eslintrc.js',
parserOptions: {
project: 'tsconfig.json',
// to make vscode-eslint work with monorepo
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
tsconfigRootDir: __dirname
}
};
1 change: 1 addition & 0 deletions packages/telemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @firebase/telemetry
3 changes: 3 additions & 0 deletions packages/telemetry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @firebase/telemetry

This package provides instrumentation functionality for javascript applications.
28 changes: 28 additions & 0 deletions packages/telemetry/index.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* This is the file that people using Node.js will actually import. You should
* only include this file if you have something specific about your
* implementation that mandates having a separate entrypoint. Otherwise you can
* just use index.ts
*/

import { testFxn } from './src';

console.log('Hi Node.js Users!');
testFxn();
20 changes: 20 additions & 0 deletions packages/telemetry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { testFxn } from './src';

testFxn();
35 changes: 35 additions & 0 deletions packages/telemetry/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const karmaBase = require('../../config/karma.base');

const files = [`src/**/*.test.ts`];

module.exports = function (config) {
const karmaConfig = {
...karmaBase,
// files to load into karma
files,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha']
};

config.set(karmaConfig);
};

module.exports.files = files;
70 changes: 70 additions & 0 deletions packages/telemetry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "@firebase/telemetry",
"version": "0.0.1",
"private": true,
"description": "The Firebase Web Telemetry package of the Firebase JS SDK",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.node.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"node": {
"import": "./dist/node-esm/index.node.esm.js",
"require": "./dist/index.node.cjs.js"
},
"browser": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm.js"
},
"default": "./dist/index.esm.js"
},
"./package.json": "./package.json"
},
"files": [
"dist"
],
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c",
"build:deps": "lerna run --scope @firebase/telemetry --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p --npm-path npm lint test:all",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
"test:all": "run-p --npm-path npm test:browser test:node",
"test:browser": "karma start",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.* --config ../../config/mocharc.node.js",
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
},
"peerDependencies": {
"@firebase/app": "0.x",
"@firebase/app-types": "0.x"
},
"dependencies": {
"tslib": "^2.1.0"
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app": "0.14.1",
"rollup": "2.79.2",
"rollup-plugin-typescript2": "0.36.0",
"typescript": "5.5.4"
},
"repository": {
"directory": "packages/telemetry",
"type": "git",
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
},
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"typings": "dist/index.d.ts",
"nyc": {
"extension": [
".ts"
],
"reportDir": "./coverage/node"
}
}
75 changes: 75 additions & 0 deletions packages/telemetry/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import pkg from './package.json';
import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file';

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

const buildPlugins = [typescriptPlugin({ typescript })];

const browserBuilds = [
{
input: 'index.ts',
output: {
file: pkg.module,
format: 'es',
sourcemap: true
},
plugins: buildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
{
input: 'index.ts',
output: {
file: './dist/index.cjs.js',
format: 'cjs',
sourcemap: true
},
plugins: buildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

const nodeBuilds = [
{
input: 'index.node.ts',
output: {
file: pkg.main,
format: 'cjs',
sourcemap: true
},
plugins: buildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
{
input: 'index.node.ts',
output: {
file: pkg.exports['.'].node.import,
format: 'es',
sourcemap: true
},
plugins: [...buildPlugins, emitModulePackageFile()],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

export default [...browserBuilds, ...nodeBuilds];
31 changes: 31 additions & 0 deletions packages/telemetry/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { expect } from 'chai';
import { testFxn } from './index';

describe('Simple test', () => {
it('Should skip this test');
it('Should test this function', () => {
expect(testFxn()).to.equal(42);
});
it('Should test this async thing', async () => {
// Do some async assertions, you can use `await` syntax if it helps
const val = await Promise.resolve(42);
expect(val).to.equal(42);
});
});
24 changes: 24 additions & 0 deletions packages/telemetry/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { TestType } from './types/index';

export function testFxn(): number {
const _thing: TestType = {};
console.log('hi');
return 42;
}
20 changes: 20 additions & 0 deletions packages/telemetry/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export interface TestType {
prop?: string;
}
7 changes: 7 additions & 0 deletions packages/telemetry/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"outDir": "dist"
},
"exclude": ["dist/**/*"]
}
Loading