-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
WIP - Add firebase integration #13954
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
Closed
Closed
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
802cb27
Add firebase integration
obecny cba0df9
Merge branch 'develop' into bo-firebase
obecny f8c5b05
linting
obecny 8c2da44
cleanup
obecny 1d06cdc
udpating semantic conventions for firestore
obecny f479c7a
converting firebase integration test into e2e test
obecny fe51c92
Merge branch 'develop' into bo-firebase
obecny cc2d888
lint
obecny 9b88ee7
cleanup
obecny aad8f85
cleanup
obecny 6a7ec1f
fixing allow rules for firebase
obecny 77ea7ab
addressing comments
obecny 638d2a7
Merge branch 'develop' into bo-firebase
obecny 9ba8052
yarn.lock after merge and install
obecny 6d81f3b
missing firebase dependency
obecny 705f1ae
fixing firebase dependency
obecny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
58 changes: 58 additions & 0 deletions
58
dev-packages/e2e-tests/test-applications/firebase/.gitignore
This file contains hidden or 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,58 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
/build | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
pnpm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# OS | ||
.DS_Store | ||
|
||
# Tests | ||
/coverage | ||
/.nyc_output | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# temp directory | ||
.temp | ||
.tmp | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
test-results |
This file contains hidden or 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,2 @@ | ||
@sentry:registry=http://127.0.0.1:4873 | ||
@sentry-internal:registry=http://127.0.0.1:4873 |
64 changes: 64 additions & 0 deletions
64
dev-packages/e2e-tests/test-applications/firebase/README.md
This file contains hidden or 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,64 @@ | ||
## Assuming you already have installed docker desktop or orbstack etc. or any other docker software | ||
|
||
### Enabling / authorising firebase emulator through docker | ||
|
||
1. Run the docker | ||
|
||
```bash | ||
npm run docker | ||
``` | ||
|
||
2In new tab, enter the docker container by simply running | ||
obecny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```bash | ||
docker exec -it sentry-firebase bash | ||
``` | ||
|
||
3. Now inside docker container run | ||
|
||
```bash | ||
firebase login | ||
``` | ||
|
||
4. You should now see a long link to authenticate with google account, copy the link and open it using your browser | ||
5. Choose the account you want to authenticate with | ||
6. Once you do this you should be able to see something like "Firebase CLI Login Successful" | ||
7. And inside docker container you should see something like "Success! Logged in as <here is the email you have chosen>" | ||
8. Now you can exit docker container | ||
|
||
```bash | ||
exit | ||
``` | ||
|
||
9. Switch back to previous tab, stop the docker container (ctrl+c). | ||
10. You should now be able to run the test, as you have correctly authenticated the firebase emulator | ||
|
||
### Preparing data for CLI | ||
|
||
1. Please authorize the docker first - see the previous section | ||
2. Once you do that you can generate .env file locally, to do that just run | ||
|
||
```bash | ||
npm run createEnvFromConfig | ||
``` | ||
|
||
3. It will create a new file called ".env" inside folder "docker" | ||
4. View the file. There will be 2 params CONFIG_FIREBASE_TOOLS and CONFIG_UPDATE_NOTIFIER_FIREBASE_TOOLS. | ||
5. Now inside the CLI create a new variable under the name CONFIG_FIREBASE_TOOLS and | ||
CONFIG_UPDATE_NOTIFIER_FIREBASE_TOOLS - take values from mentioned .env file | ||
6. File .env is ignored to avoid situation when developer after authorizing firebase with private account will | ||
accidently push the tokens to github. | ||
7. But if we want the users to still have some default to be used for authorisation (on their local development) it will | ||
be enough to commit this file, we just have to authorize it with some "special" account. | ||
|
||
**Some explanation towards environment settings, the environment variable defined directly in "environments" takes | ||
precedence over .env file, that means it will be safe to define it in CLI and still keeps the .env file.** | ||
|
||
### Scripts - helpers | ||
|
||
- createEnvFromConfig - it will use the firebase docker authentication and create .env file which will be used then by | ||
docker whenever you run emulator | ||
- createConfigFromEnv - it will use '.env' file in docker folder to create .config for the firebase to be used to | ||
authenticate whenever you run docker, Docker by default loads .env file itself | ||
|
||
Use these scripts when testing and updating the environment settings on CLI |
14 changes: 14 additions & 0 deletions
14
dev-packages/e2e-tests/test-applications/firebase/createConfigFromEnv.js
This file contains hidden or 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,14 @@ | ||
const path = require('path'); | ||
const dotent = require('dotenv'); | ||
dotent.config({ path: path.resolve(__dirname, './docker/.env') }); | ||
|
||
const createConfigFromEnv = require('./docker/firebase/utils').createConfigFromEnv; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
(async () => { | ||
try { | ||
await createConfigFromEnv(); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
})(); |
10 changes: 10 additions & 0 deletions
10
dev-packages/e2e-tests/test-applications/firebase/createEnvFromConfig.js
This file contains hidden or 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,10 @@ | ||
const createEnvFromConfig = require('./docker/firebase/utils').createEnvFromConfig; | ||
|
||
(async () => { | ||
try { | ||
await createEnvFromConfig(); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
})(); | ||
|
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/firebase/docker/.gitignore
This file contains hidden or 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,6 @@ | ||
.config | ||
cache | ||
firebase/data | ||
firebase/firebase-export-* | ||
*-debug.log | ||
.env |
15 changes: 15 additions & 0 deletions
15
dev-packages/e2e-tests/test-applications/firebase/docker/Dockerfile
This file contains hidden or 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,15 @@ | ||
FROM node:20-alpine | ||
|
||
ARG FIREBASE_VERSION | ||
|
||
RUN apk --no-cache add openjdk11-jre bash curl openssl gettext nano nginx sudo && \ | ||
npm cache clean --force && \ | ||
npm i -g firebase-tools@$FIREBASE_VERSION | ||
|
||
COPY nginx.conf /etc/nginx/ | ||
COPY serve.sh /usr/bin/ | ||
RUN chmod +x /usr/bin/serve.sh | ||
|
||
WORKDIR /srv/firebase | ||
|
||
ENTRYPOINT ["/usr/bin/serve.sh"] |
60 changes: 60 additions & 0 deletions
60
dev-packages/e2e-tests/test-applications/firebase/docker/docker-compose.yml
This file contains hidden or 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,60 @@ | ||
services: | ||
emulator: | ||
container_name: sentry-firebase | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- FIREBASE_VERSION=13.19.0 | ||
stop_grace_period: 1m | ||
environment: | ||
FIREBASE_AUTH_EMULATOR_HOST: "localhost:5507" | ||
FIRESTORE_EMULATOR_HOST: "localhost:5504" | ||
PUBSUB_EMULATOR_HOST: "localhost:5505" | ||
FUNCTIONS_EMULATOR_HOST: "localhost:5503" | ||
FIREBASE_PROJECT: "sentry-15d85" | ||
GCLOUD_PROJECT: "sentry-15d85" | ||
FORCE_COLOR: "true" | ||
DATA_DIRECTORY: "data" | ||
CHOKIDAR_USEPOLLING: "true" | ||
CONFIG_FIREBASE_TOOLS: ${CONFIG_FIREBASE_TOOLS} | ||
CONFIG_UPDATE_NOTIFIER_FIREBASE_TOOLS: ${CONFIG_UPDATE_NOTIFIER_FIREBASE_TOOLS} | ||
ports: | ||
- "5500:4001" # ui | ||
- "5501:4401" # hub | ||
- "5502:4601" # logging | ||
- "5503:5002" # functions | ||
- "5504:8081" # firestore | ||
- "5505:8086" # pubsub | ||
- "5506:9001" # database | ||
- "5507:9100" # auth | ||
- "5508:9200" # Storage | ||
- "5509:6001" # Hosting | ||
- '5510:9081' # firestore (grpc) | ||
- '5511:9230' # cloud_functions_debug | ||
- '9005:9005' # to be able to authenticate using gmail and docker | ||
volumes: | ||
- type: bind | ||
source: ./firebase | ||
target: /srv/firebase | ||
bind: | ||
create_host_path: true | ||
- type: bind | ||
source: ./cache | ||
target: /root/.cache | ||
bind: | ||
create_host_path: true | ||
- type: bind | ||
source: .config | ||
target: /root/.config | ||
bind: | ||
create_host_path: true | ||
- type: bind | ||
source: ./firebase/data | ||
target: /srv/firebase/data | ||
bind: | ||
create_host_path: true | ||
|
||
networks: | ||
default: | ||
driver: bridge |
5 changes: 5 additions & 0 deletions
5
dev-packages/e2e-tests/test-applications/firebase/docker/firebase/.firebaserc
This file contains hidden or 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,5 @@ | ||
{ | ||
"projects": { | ||
"default": "sentry-project-436908" | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
dev-packages/e2e-tests/test-applications/firebase/docker/firebase/.gitignore
This file contains hidden or 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,69 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
firebase-debug.log* | ||
firebase-debug.*.log* | ||
|
||
# Firebase cache | ||
.firebase/ | ||
|
||
# Firebase config | ||
|
||
# Uncomment this if you'd like others to create their own Firebase project. | ||
# For a team working on the same Firebase project(s), it is recommended to leave | ||
# it commented so all members can deploy to the same project(s) in .firebaserc. | ||
# .firebaserc | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# dataconnect generated files | ||
.dataconnect |
3 changes: 3 additions & 0 deletions
3
...es/e2e-tests/test-applications/firebase/docker/firebase/createOrUpdateConfigIfPossible.js
This file contains hidden or 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,3 @@ | ||
const createOrUpdateConfigIfPossible = require('./utils').createOrUpdateConfigIfPossible; | ||
|
||
createOrUpdateConfigIfPossible(); |
7 changes: 7 additions & 0 deletions
7
dev-packages/e2e-tests/test-applications/firebase/docker/firebase/database.rules.json
This file contains hidden or 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,7 @@ | ||
{ | ||
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */ | ||
"rules": { | ||
".read": false, | ||
".write": false | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
dev-packages/e2e-tests/test-applications/firebase/docker/firebase/firebase.json
This file contains hidden or 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,25 @@ | ||
{ | ||
"database": { | ||
"rules": "database.rules.json" | ||
}, | ||
"firestore": { | ||
"rules": "firestore.rules", | ||
"indexes": "firestore.indexes.json" | ||
}, | ||
"emulators": { | ||
"auth": { | ||
"port": 5507 | ||
}, | ||
"firestore": { | ||
"port": 5504 | ||
}, | ||
"database": { | ||
"port": 5506 | ||
}, | ||
"ui": { | ||
"enabled": true, | ||
"port": 5500 | ||
}, | ||
"singleProjectMode": true | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
dev-packages/e2e-tests/test-applications/firebase/docker/firebase/firestore.indexes.json
This file contains hidden or 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,4 @@ | ||
{ | ||
"indexes": [], | ||
"fieldOverrides": [] | ||
} |
8 changes: 8 additions & 0 deletions
8
dev-packages/e2e-tests/test-applications/firebase/docker/firebase/firestore.rules
This file contains hidden or 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 @@ | ||
rules_version = '2'; | ||
service cloud.firestore { | ||
match /databases/{database}/documents { | ||
match /{document=**} { | ||
allow read, write: if request.time < timestamp.date(2024, 10, 27); | ||
obecny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
dev-packages/e2e-tests/test-applications/firebase/docker/firebase/storage.rules
This file contains hidden or 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 @@ | ||
rules_version = '2'; | ||
service firebase.storage { | ||
match /b/{bucket}/o { | ||
match /{file=**} { | ||
allow read, write: if true; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.