Skip to content

Commit 1f63aa4

Browse files
Merge main into release
2 parents d59563a + aa6db78 commit 1f63aa4

File tree

13 files changed

+220
-28
lines changed

13 files changed

+220
-28
lines changed

.changeset/four-pillows-fetch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/messaging': patch
3+
---
4+
5+
The logging endpoint has been updated to ensure proper logging of WebPush entries. This resolves an issue where BigQuery logs were missing WebPush data. The payload structure has also been updated in alignment with the latest logging requirements as specified in go/firelog.

.github/ISSUE_TEMPLATE/bug_report_v2.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ body:
6363
- Auth
6464
- Component
6565
- Database
66+
- DataConnect
6667
- Firestore
6768
- Functions
6869
- Installations

.github/workflows/test-changed-auth.yml

+25
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,28 @@ jobs:
102102
run: xvfb-run yarn test:changed auth
103103
env:
104104
BROWSERS: 'Firefox'
105+
106+
test-webkit:
107+
name: Test Auth on Webkit if Changed
108+
runs-on: macos-latest
109+
110+
steps:
111+
- name: Checkout Repo
112+
uses: actions/checkout@v4
113+
with:
114+
fetch-depth: 0
115+
- name: Set up Node (20)
116+
uses: actions/setup-node@v3
117+
with:
118+
node-version: 20.x
119+
- name: Test setup and yarn install
120+
run: |
121+
cp config/ci.config.json config/project.json
122+
yarn
123+
npx playwright install webkit
124+
- name: build
125+
run: yarn build:changed auth
126+
- name: Run tests on changed packages
127+
run: yarn test:changed auth
128+
env:
129+
BROWSERS: 'WebkitHeadless'

.github/workflows/test-changed-firestore.yml

+57-1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,62 @@ jobs:
231231
BROWSERS: 'Firefox'
232232
EXPERIMENTAL_MODE: true
233233

234+
compat-test-webkit:
235+
name: Test Firestore Compatible on Webkit
236+
runs-on: macos-latest
237+
needs: build
238+
if: ${{ needs.build.outputs.changed == 'true'}}
239+
steps:
240+
- name: Set up Node (20)
241+
uses: actions/setup-node@v3
242+
with:
243+
node-version: 20.x
244+
- name: Download build archive
245+
uses: actions/download-artifact@v3
246+
with:
247+
name: build.tar.gz
248+
- name: Unzip build artifact
249+
run: tar xf build.tar.gz
250+
- name: Test setup
251+
run: |
252+
cp config/ci.config.json config/project.json
253+
npx playwright install webkit
254+
- name: Run compat tests
255+
run: cd packages/firestore-compat && yarn run test:ci
256+
env:
257+
BROWSERS: 'WebkitHeadless'
258+
259+
test-webkit:
260+
name: Test Firestore on Webkit
261+
strategy:
262+
matrix:
263+
# TODO (dlarocque): Add test:travis once the browser tests are isolated
264+
# Exclude test:travis for now, since it includes node tests, which are failing for
265+
# some reason.
266+
test-name: ["test:browser", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
267+
runs-on: macos-latest
268+
needs: build
269+
if: ${{ needs.build.outputs.changed == 'true'}}
270+
steps:
271+
- name: Download build archive
272+
uses: actions/download-artifact@v3
273+
with:
274+
name: build.tar.gz
275+
- name: Unzip build artifact
276+
run: tar xf build.tar.gz
277+
- name: Set up Node (20)
278+
uses: actions/setup-node@v3
279+
with:
280+
node-version: 20.x
281+
- name: Test setup
282+
run: |
283+
cp config/ci.config.json config/project.json
284+
npx playwright install webkit
285+
- name: Run tests
286+
run: cd packages/firestore && yarn run ${{ matrix.test-name }}
287+
env:
288+
BROWSERS: 'WebkitHeadless'
289+
EXPERIMENTAL_MODE: true
234290
# A job that fails if any required job in the test matrix fails,
235291
# to be used as a required check for merging.
236292
check-required-tests:
@@ -241,4 +297,4 @@ jobs:
241297
steps:
242298
- name: Check test matrix
243299
if: needs.build.result == 'failure' || needs.test-chrome.result == 'failure' || needs.compat-test-chrome.result == 'failure'
244-
run: exit 1
300+
run: exit 1

.github/workflows/test-changed.yml

+26
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,29 @@ jobs:
7878
run: xvfb-run yarn test:changed core
7979
env:
8080
BROWSERS: 'Firefox'
81+
82+
83+
test-webkit:
84+
name: Test Packages With Changed Files in Webkit
85+
runs-on: macos-latest
86+
87+
steps:
88+
- name: Checkout Repo
89+
uses: actions/checkout@v4
90+
with:
91+
fetch-depth: 0
92+
- name: Set up Node (20)
93+
uses: actions/setup-node@v3
94+
with:
95+
node-version: 20.x
96+
- name: Test setup and yarn install
97+
run: |
98+
cp config/ci.config.json config/project.json
99+
yarn
100+
npx playwright install webkit
101+
- name: build
102+
run: yarn build:changed core
103+
- name: Run tests on changed packages
104+
run: yarn test:changed core
105+
env:
106+
BROWSERS: 'WebkitHeadless'

config/karma.base.js

+32-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ const path = require('path');
2020
const webpackTestConfig = require('./webpack.test');
2121
const { argv } = require('yargs');
2222

23+
function determineBrowsers() {
24+
const supportedBrowsers = ['ChromeHeadless', 'WebkitHeadless', 'Firefox'];
25+
26+
if (process.env.BROWSERS) {
27+
const browsers = process.env.BROWSERS.split(',');
28+
29+
const validBrowsers = browsers.filter(browser =>
30+
supportedBrowsers.includes(browser)
31+
);
32+
if (validBrowsers.length === 0) {
33+
console.error(
34+
`The \'BROWSER\' environment variable was set, but no supported browsers were listed. The supported browsers are ${JSON.stringify(
35+
supportedBrowsers
36+
)}.`
37+
);
38+
return [];
39+
} else {
40+
return validBrowsers;
41+
}
42+
} else {
43+
console.log(
44+
"The 'BROWSER' environment variable is undefined. Defaulting to 'ChromeHeadless'."
45+
);
46+
return ['ChromeHeadless'];
47+
}
48+
}
49+
2350
const config = {
2451
// disable watcher
2552
autoWatch: false,
@@ -57,10 +84,11 @@ const config = {
5784
// changes
5885
autoWatch: false,
5986

60-
// start these browsers
61-
// available browser launchers:
62-
// https://npmjs.org/browse/keyword/karma-launcher
63-
browsers: process.env?.BROWSERS?.split(',') ?? ['ChromeHeadless'],
87+
// Browsers to launch for testing
88+
// To use a custom set of browsers, define the BROWSERS environment variable as a comma-seperated list.
89+
// Supported browsers are 'ChromeHeadless', 'WebkitHeadless', and 'Firefox'.
90+
// See: https://karma-runner.github.io/6.4/config/browsers.html
91+
browsers: determineBrowsers(),
6492

6593
webpack: webpackTestConfig,
6694

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@
120120
"karma-firefox-launcher": "2.1.3",
121121
"karma-mocha": "2.0.1",
122122
"karma-mocha-reporter": "2.2.5",
123-
"karma-safari-launcher": "1.0.0",
124123
"karma-sourcemap-loader": "0.4.0",
125124
"karma-spec-reporter": "0.0.36",
126125
"karma-summary-reporter": "3.1.1",
126+
"karma-webkit-launcher": "2.6.0",
127127
"karma-webpack": "5.0.0",
128128
"lcov-result-merger": "3.3.0",
129129
"lerna": "4.0.0",
@@ -139,6 +139,7 @@
139139
"nyc": "15.1.0",
140140
"ora": "5.4.1",
141141
"patch-package": "7.0.2",
142+
"playwright": "1.46.1",
142143
"postinstall-postinstall": "2.1.0",
143144
"prettier": "2.8.7",
144145
"protractor": "5.4.2",

packages/analytics/testing/get-fake-firebase-services.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { FirebaseApp, initializeApp, _registerComponent } from '@firebase/app';
18+
import {
19+
FirebaseApp,
20+
initializeApp,
21+
_registerComponent,
22+
_addOrOverwriteComponent
23+
} from '@firebase/app';
1924
import { Component, ComponentType } from '@firebase/component';
2025
import { _FirebaseInstallationsInternal } from '@firebase/installations';
2126
import { AnalyticsService } from '../src/factory';
@@ -78,5 +83,18 @@ export function getFullApp(fakeAppParams?: {
7883
)
7984
);
8085
const app = initializeApp({ ...fakeConfig, ...fakeAppParams });
86+
_addOrOverwriteComponent(
87+
app,
88+
//@ts-ignore
89+
new Component(
90+
'heartbeat',
91+
() => {
92+
return {
93+
triggerHeartbeat: () => {}
94+
} as any;
95+
},
96+
ComponentType.PUBLIC
97+
)
98+
);
8199
return app;
82100
}

packages/messaging/src/helpers/logToFirelog.test.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ import { MessagingService } from '../messaging-service';
3131
import { Stub } from '../testing/sinon-types';
3232
import { getFakeMessagingService } from '../testing/fakes/messaging-service';
3333

34-
const FIRELOG_ENDPOINT = LogModule._mergeStrings(
35-
'hts/frbslgigp.ogepscmv/ieo/eaylg',
36-
'tp:/ieaeogn-agolai.o/1frlglgc/o'
37-
);
34+
const LOG_ENDPOINT = 'https://play.google.com/log?format=json_proto3';
3835

3936
const FCM_TRANSPORT_KEY = LogModule._mergeStrings(
4037
'AzSCbw63g1R0nCw85jG8',
@@ -68,7 +65,7 @@ describe('logToFirelog', () => {
6865

6966
// assert
7067
expect(fetchStub).to.be.calledOnceWith(
71-
FIRELOG_ENDPOINT.concat('?key=', FCM_TRANSPORT_KEY),
68+
LOG_ENDPOINT.concat('&key=', FCM_TRANSPORT_KEY),
7269
{
7370
method: 'POST',
7471
body: JSON.stringify(LogModule._createLogRequest([getFakeLogEvent()]))

packages/messaging/src/helpers/logToFirelog.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ import {
3636
import { MessagePayloadInternal } from '../interfaces/internal-message-payload';
3737
import { MessagingService } from '../messaging-service';
3838

39-
const FIRELOG_ENDPOINT = _mergeStrings(
40-
'hts/frbslgigp.ogepscmv/ieo/eaylg',
41-
'tp:/ieaeogn-agolai.o/1frlglgc/o'
42-
);
39+
const LOG_ENDPOINT = 'https://play.google.com/log?format=json_proto3';
4340

4441
const FCM_TRANSPORT_KEY = _mergeStrings(
4542
'AzSCbw63g1R0nCw85jG8',
@@ -97,7 +94,7 @@ export async function _dispatchLogEvents(
9794
do {
9895
try {
9996
response = await fetch(
100-
FIRELOG_ENDPOINT.concat('?key=', FCM_TRANSPORT_KEY),
97+
LOG_ENDPOINT.concat('&key=', FCM_TRANSPORT_KEY),
10198
{
10299
method: 'POST',
103100
body: JSON.stringify(logRequest)
@@ -216,7 +213,9 @@ function createAndEnqueueLogEvent(
216213

217214
/* eslint-disable camelcase */
218215
logEvent.event_time_ms = Math.floor(Date.now()).toString();
219-
logEvent.source_extension_json_proto3 = JSON.stringify(fcmEvent);
216+
logEvent.source_extension_json_proto3 = JSON.stringify({
217+
messaging_client_event: fcmEvent
218+
});
220219

221220
if (!!productId) {
222221
logEvent.compliance_data = buildComplianceData(productId);

scripts/ci-test/testConfig.ts

+14
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,25 @@ export interface TestConfig {
2828
alwaysIncludePackages?: string[];
2929
}
3030

31+
// These tests are flaky on WebkitHeadless for some reason, so skip them.
32+
// TODO (dlarocque): Fix the flakes and remove this
33+
const ignoredWebkitCoreTests = process.env?.BROWSERS?.includes('WebkitHeadless')
34+
? [
35+
'@firebase/app-check',
36+
'@firebase/installations',
37+
'@firebase/storage',
38+
'@firebase/storage-compat',
39+
'@firebase/database',
40+
'@firebase/database-compat'
41+
]
42+
: [];
43+
3144
export const testConfig: {
3245
[key: string]: TestConfig | undefined;
3346
} = {
3447
'core': {
3548
'ignorePackages': [
49+
...ignoredWebkitCoreTests,
3650
'@firebase/firestore',
3751
'@firebase/firestore-compat',
3852
'firebase-firestore-integration-test',

0 commit comments

Comments
 (0)