Skip to content

Commit 636dd78

Browse files
authored
Implement analytics-compat package (#4460)
1 parent 928e439 commit 636dd78

File tree

17 files changed

+1105
-7
lines changed

17 files changed

+1105
-7
lines changed

.changeset/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"firebase-firestore-integration-test",
1515
"firebase-messaging-integration-test",
1616
"@firebase/app-exp",
17+
"@firebase/analytics-compat",
1718
"@firebase/analytics-exp",
1819
"@firebase/auth-exp",
1920
"@firebase/auth-compat",

common/api-review/analytics-exp.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type CustomEventName<T> = T extends EventNameString ? never : T;
3737
// @public
3838
export interface CustomParams {
3939
// (undocumented)
40-
[key: string]: any;
40+
[key: string]: unknown;
4141
}
4242

4343
// @public
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license
3+
* Copyright 2020 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+
const path = require('path');
18+
19+
module.exports = {
20+
'extends': '../../config/.eslintrc.js',
21+
'parserOptions': {
22+
'project': 'tsconfig.json',
23+
'tsconfigRootDir': __dirname
24+
},
25+
rules: {
26+
'import/no-extraneous-dependencies': [
27+
'error',
28+
{
29+
'packageDir': [path.resolve(__dirname, '../../'), __dirname]
30+
}
31+
]
32+
}
33+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @license
3+
* Copyright 2019 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+
// eslint-disable-next-line @typescript-eslint/no-require-imports
19+
const karmaBase = require('../../config/karma.base');
20+
21+
const files = [`**/*.test.ts`];
22+
23+
module.exports = function (config) {
24+
config.set({
25+
...karmaBase,
26+
files,
27+
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] },
28+
frameworks: ['mocha']
29+
});
30+
};
31+
32+
module.exports.files = files;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@firebase/analytics-compat",
3+
"version": "0.0.900",
4+
"description": "",
5+
"private": true,
6+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
7+
"main": "dist/index.cjs.js",
8+
"browser": "dist/index.esm.js",
9+
"module": "dist/index.esm.js",
10+
"esm2017": "dist/index.esm2017.js",
11+
"files": ["dist"],
12+
"license": "Apache-2.0",
13+
"peerDependencies": {
14+
"@firebase/app-compat": "0.x"
15+
},
16+
"devDependencies": {
17+
"@firebase/app-compat": "0.0.900",
18+
"rollup": "2.35.1",
19+
"@rollup/plugin-json": "4.1.0",
20+
"rollup-plugin-typescript2": "0.29.0",
21+
"typescript": "4.0.5"
22+
},
23+
"repository": {
24+
"directory": "packages-exp/analytics-compat",
25+
"type": "git",
26+
"url": "https://github.com/firebase/firebase-js-sdk.git"
27+
},
28+
"bugs": {
29+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
30+
},
31+
"scripts": {
32+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
33+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
34+
"build": "rollup -c",
35+
"build:deps": "lerna run --scope @firebase/analytics-compat --include-dependencies build",
36+
"build:release": "rollup -c rollup.config.release.js",
37+
"dev": "rollup -c -w",
38+
"test": "run-p lint test:browser",
39+
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:browser",
40+
"test:browser": "karma start --single-run",
41+
"test:browser:debug": "karma start --browsers=Chrome --auto-watch"
42+
},
43+
"typings": "dist/analytics-compat-public.d.ts",
44+
"dependencies": {
45+
"@firebase/component": "0.2.0",
46+
"@firebase/analytics-exp": "0.0.900",
47+
"@firebase/analytics-types": "0.4.0",
48+
"@firebase/util": "0.3.4",
49+
"tslib": "^1.11.1"
50+
},
51+
"nyc": {
52+
"extension": [
53+
".ts"
54+
],
55+
"reportDir": "./coverage/node"
56+
}
57+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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 json from '@rollup/plugin-json';
19+
import typescriptPlugin from 'rollup-plugin-typescript2';
20+
import typescript from 'typescript';
21+
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';
22+
23+
/**
24+
* ES5 Builds
25+
*/
26+
const es5BuildPlugins = [
27+
typescriptPlugin({
28+
typescript
29+
}),
30+
json()
31+
];
32+
33+
const es5Builds = es5BuildsNoPlugin.map(build => ({
34+
...build,
35+
plugins: es5BuildPlugins
36+
}));
37+
38+
/**
39+
* ES2017 Builds
40+
*/
41+
const es2017BuildPlugins = [
42+
typescriptPlugin({
43+
typescript,
44+
tsconfigOverride: {
45+
compilerOptions: {
46+
target: 'es2017'
47+
}
48+
}
49+
}),
50+
json({ preferConst: true })
51+
];
52+
53+
const es2017Builds = es2017BuildsNoPlugin.map(build => ({
54+
...build,
55+
plugins: es2017BuildPlugins
56+
}));
57+
58+
export default [...es5Builds, ...es2017Builds];
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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 json from '@rollup/plugin-json';
21+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
22+
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';
23+
24+
/**
25+
* ES5 Builds
26+
*/
27+
const es5BuildPlugins = [
28+
typescriptPlugin({
29+
typescript,
30+
clean: true,
31+
abortOnError: false,
32+
transformers: [importPathTransformer]
33+
}),
34+
json()
35+
];
36+
37+
const es5Builds = es5BuildsNoPlugin.map(build => ({
38+
...build,
39+
plugins: es5BuildPlugins,
40+
treeshake: {
41+
moduleSideEffects: id => id === '@firebase/installations'
42+
}
43+
}));
44+
45+
/**
46+
* ES2017 Builds
47+
*/
48+
const es2017BuildPlugins = [
49+
typescriptPlugin({
50+
typescript,
51+
tsconfigOverride: {
52+
compilerOptions: {
53+
target: 'es2017'
54+
}
55+
},
56+
abortOnError: false,
57+
clean: true,
58+
transformers: [importPathTransformer]
59+
}),
60+
json({
61+
preferConst: true
62+
})
63+
];
64+
65+
const es2017Builds = es2017BuildsNoPlugin.map(build => ({
66+
...build,
67+
plugins: es2017BuildPlugins,
68+
treeshake: {
69+
moduleSideEffects: id => id === '@firebase/installations'
70+
}
71+
}));
72+
73+
export default [...es5Builds, ...es2017Builds];
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
import pkg from './package.json';
18+
19+
const deps = Object.keys(
20+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
21+
);
22+
23+
export const es5BuildsNoPlugin = [
24+
/**
25+
* Browser Builds
26+
*/
27+
{
28+
input: 'src/index.ts',
29+
output: [
30+
{ file: pkg.main, format: 'cjs', sourcemap: true },
31+
{ file: pkg.module, format: 'es', sourcemap: true }
32+
],
33+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
34+
}
35+
];
36+
37+
/**
38+
* ES2017 Builds
39+
*/
40+
export const es2017BuildsNoPlugin = [
41+
{
42+
/**
43+
* Browser Build
44+
*/
45+
input: 'src/index.ts',
46+
output: {
47+
file: pkg.esm2017,
48+
format: 'es',
49+
sourcemap: true
50+
},
51+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
52+
}
53+
];
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
* Officially recommended event names for gtag.js
20+
* Any other string is also allowed.
21+
*/
22+
export enum EventName {
23+
ADD_SHIPPING_INFO = 'add_shipping_info',
24+
ADD_PAYMENT_INFO = 'add_payment_info',
25+
ADD_TO_CART = 'add_to_cart',
26+
ADD_TO_WISHLIST = 'add_to_wishlist',
27+
BEGIN_CHECKOUT = 'begin_checkout',
28+
/**
29+
* @deprecated
30+
* This event name is deprecated and is unsupported in updated
31+
* Enhanced Ecommerce reports.
32+
*/
33+
CHECKOUT_PROGRESS = 'checkout_progress',
34+
EXCEPTION = 'exception',
35+
GENERATE_LEAD = 'generate_lead',
36+
LOGIN = 'login',
37+
PAGE_VIEW = 'page_view',
38+
PURCHASE = 'purchase',
39+
REFUND = 'refund',
40+
REMOVE_FROM_CART = 'remove_from_cart',
41+
SCREEN_VIEW = 'screen_view',
42+
SEARCH = 'search',
43+
SELECT_CONTENT = 'select_content',
44+
SELECT_ITEM = 'select_item',
45+
SELECT_PROMOTION = 'select_promotion',
46+
/** @deprecated */
47+
SET_CHECKOUT_OPTION = 'set_checkout_option',
48+
SHARE = 'share',
49+
SIGN_UP = 'sign_up',
50+
TIMING_COMPLETE = 'timing_complete',
51+
VIEW_CART = 'view_cart',
52+
VIEW_ITEM = 'view_item',
53+
VIEW_ITEM_LIST = 'view_item_list',
54+
VIEW_PROMOTION = 'view_promotion',
55+
VIEW_SEARCH_RESULTS = 'view_search_results'
56+
}

0 commit comments

Comments
 (0)