Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(messaging): add support for exporting delivery metrics to BigQue…
…ry (#9636) * feat(messaging): automatic export to bigquery * feat(messaging): automatic export to bigquery for web * feat(messaging): export to BigQuery * feat(messaging): export to BigQuery * feat(messaging): export to BigQuery * feat(messaging): export to BigQuery on web * feat(messaging): export to BigQuery on web * feat(messaging): export to BigQuery on web * feat(messaging): revert to old service worker with compat * feat(messaging): revert to old service worker with compat * feat(messaging): revert to old service worker with compat * feat(messaging): export to BigQuery * feat(messaging): export to BigQuery
- Loading branch information
Showing
16 changed files
with
1,297 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ | |
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
45 changes: 45 additions & 0 deletions
45
...base_messaging/firebase_messaging/example/bundled-service-worker/firebase-messaging-sw.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { initializeApp } from 'firebase/app'; | ||
import { | ||
experimentalSetDeliveryMetricsExportedToBigQueryEnabled, | ||
getMessaging, | ||
isSupported, | ||
onBackgroundMessage | ||
} from 'firebase/messaging/sw'; | ||
|
||
declare var self: ServiceWorkerGlobalScope; | ||
|
||
self.addEventListener('install', (event) => { | ||
console.log(self); | ||
console.log(event); | ||
}); | ||
|
||
const app = initializeApp({ | ||
apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', | ||
authDomain: 'react-native-firebase-testing.firebaseapp.com', | ||
databaseURL: 'https://react-native-firebase-testing.firebaseio.com', | ||
projectId: 'react-native-firebase-testing', | ||
storageBucket: 'react-native-firebase-testing.appspot.com', | ||
messagingSenderId: '448618578101', | ||
appId: '1:448618578101:web:ecaffe2bc4511738', | ||
}); | ||
|
||
isSupported().then((isSupported) => { | ||
if (isSupported) { | ||
const messaging = getMessaging(app); | ||
|
||
experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging, true); | ||
|
||
onBackgroundMessage(messaging, ({ notification: notification }) => { | ||
const { title, body, image } = notification ?? {}; | ||
|
||
if (!title) { | ||
return; | ||
} | ||
|
||
self.registration.showNotification(title, { | ||
body, | ||
icon: image || '/assets/icons/icon-72x72.png', | ||
}); | ||
}); | ||
} | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/firebase_messaging/firebase_messaging/example/bundled-service-worker/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"dependencies": { | ||
"firebase": "9" | ||
}, | ||
"devDependencies": { | ||
"esbuild": "^0.15.10" | ||
}, | ||
"scripts": { | ||
"build": "esbuild firebase-messaging-sw.ts --outdir=../web --bundle --sourcemap --minify --format=esm" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/firebase_messaging/firebase_messaging/example/bundled-service-worker/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"webworker", | ||
"es6" | ||
] | ||
} | ||
} |
Oops, something went wrong.