Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Firebase performance monitoring #1805

Merged
merged 14 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions __mocks__/firebase/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import constant from 'lodash-es/constant';

export {default as performance} from 'lodash/noop';

class AuthProvider {
addScope() {}
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"enumify": "1.0.4",
"esprima": "4.0.1",
"firebase": "6.5.0",
"first-input-delay": "0.1.3",
"github-api": "3.3.0",
"hast-util-sanitize": "1.3.1",
"highlight.js": "9.15.10",
Expand Down
7 changes: 7 additions & 0 deletions src/clients/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import uuid from 'uuid/v4';
import once from 'lodash-es/once';
import * as firebase from 'firebase/app'; // eslint-disable-line import/no-namespace
import 'firebase/auth';
import 'firebase/performance';

import {bugsnagClient} from '../util/bugsnag';
import config from '../config';
Expand Down Expand Up @@ -48,19 +49,25 @@ function buildFirebase(appName = undefined) {
const app = firebase.initializeApp(
{
apiKey: config.firebaseApiKey,
appId: config.firebaseAppId,
authDomain: `${config.firebaseApp}.firebaseapp.com`,
databaseURL: `https://${config.firebaseApp}.firebaseio.com`,
projectId: config.firebaseProjectId,
},
appName,
);

const perf = appName === undefined ? firebase.performance(app) : null;

return {
auth: firebase.auth(app),

loadDatabase: once(async () => {
await loadDatabaseSdk();
return firebase.database(app);
}),

perf,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ module.exports = {
warnOnDroppedErrors: process.env.WARN_ON_DROPPED_ERRORS === 'true',

firebaseApp: process.env.FIREBASE_APP,
firebaseAppId: process.env.FIREBASE_APP_ID,
firebaseApiKey: process.env.FIREBASE_API_KEY,
firebaseClientId: process.env.FIREBASE_CLIENT_ID,
firebaseProjectId: process.env.FIREBASE_PROJECT_ID,

feedbackUrl: 'https://gitreports.com/issue/popcodeorg/popcode',

Expand Down
9 changes: 9 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ module.exports = (env = process.env.NODE_ENV || 'development') => {
const plugins = [
new webpack.EnvironmentPlugin({
FIREBASE_APP: 'popcode-development',
FIREBASE_APP_ID: '1:488497217137:web:8a7ee07a38d0590a',
FIREBASE_API_KEY: 'AIzaSyCHlo2RhOkRFFh48g779YSZrLwKjoyCcws',
FIREBASE_CLIENT_ID:
'488497217137-c0mdq8uca6ot5o9u9avo3j5mfsi1q9v5.apps.googleusercontent.com',
FIREBASE_PROJECT_ID: 'popcode-development',
NODE_ENV: env,
WARN_ON_DROPPED_ERRORS: 'false',
GOOGLE_ANALYTICS_TRACKING_ID: 'UA-90316486-2',
Expand Down Expand Up @@ -158,6 +160,7 @@ module.exports = (env = process.env.NODE_ENV || 'development') => {
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'defer',
inline: /(^|~)inline[.~-]/u,
prefetch: {
chunks: 'async',
test: /\.js$/u,
Expand All @@ -168,6 +171,11 @@ module.exports = (env = process.env.NODE_ENV || 'development') => {
attribute: 'type',
value: 'ref',
},
{
test: /^$/u,
attribute: 'type',
value: 'text/javascript',
},
{
test: /(^|~)preview[.~-]/u,
attribute: 'class',
Expand All @@ -185,6 +193,7 @@ module.exports = (env = process.env.NODE_ENV || 'development') => {
entry: isTest
? undefined
: {
inline: 'first-input-delay',
main: './application.js',
preview: './preview.js',
},
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6318,6 +6318,11 @@ first-chunk-stream@^1.0.0:
resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e"
integrity sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=

[email protected]:
version "0.1.3"
resolved "https://registry.yarnpkg.com/first-input-delay/-/first-input-delay-0.1.3.tgz#5506fb95a9537ba9706096b9c159bfd3f38f6f62"
integrity sha512-hZ1mI+BWYIBr8jlp2bDPnRvnmSICBxpZRwdc0nhiQn2uyMxSKZEBbkO8V0/s26AMeX8p/AD4g09+liRrhXvKKQ==

flagged-respawn@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.1.tgz#e7de6f1279ddd9ca9aac8a5971d618606b3aab41"
Expand Down