Skip to content

Commit

Permalink
La til Umami
Browse files Browse the repository at this point in the history
  • Loading branch information
eilifjohansen committed Sep 12, 2024
1 parent d6a9178 commit 9005996
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
run: |
cat > .nais/vars.yaml <<EOF
SITEIMPROVE: ${{ secrets.SITEIMPROVE }}
UMAMI: ${{ secrets.UMAMI }}
AMPLITUDE_100000009: ${{ secrets.AMPLITUDE_100000009 }}
AMPLITUDE_100000264: ${{ secrets.AMPLITUDE_100000264 }}
AMPLITUDE_100000243: ${{ secrets.AMPLITUDE_100000243 }}
Expand Down Expand Up @@ -87,6 +88,7 @@ jobs:
run: |
cat > .nais/vars.yaml <<EOF
SITEIMPROVE: ${{ secrets.SITEIMPROVE }}
UMAMI: ${{ secrets.UMAMI }}
AMPLITUDE_100000009: ${{ secrets.AMPLITUDE_100000009 }}
AMPLITUDE_100000264: ${{ secrets.AMPLITUDE_100000264 }}
AMPLITUDE_100000243: ${{ secrets.AMPLITUDE_100000243 }}
Expand Down
2 changes: 2 additions & 0 deletions .nais/dev-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ spec:
env:
- name: SITEIMPROVE
value: {{SITEIMPROVE}}
- name: UMAMI
value: {{UMAMI}}
- name: AMPLITUDE_100000009
value: {{AMPLITUDE_100000009}}
- name: AMPLITUDE_100000264
Expand Down
3 changes: 3 additions & 0 deletions .nais/prod-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ spec:
- host: api.eu.siteimprove.com
- host: siteimprove.com
- host: nav.no
- host: umami.ansatt.nav.no
- host: raw.githubusercontent.com
- host: analytics.eu.amplitude.com
ingresses:
Expand All @@ -47,6 +48,8 @@ spec:
env:
- name: SITEIMPROVE
value: {{SITEIMPROVE}}
- name: UMAMI
value: {{UMAMI}}
- name: AMPLITUDE_100000009
value: {{AMPLITUDE_100000009}}
- name: AMPLITUDE_100000264
Expand Down
36 changes: 36 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,42 @@ app.get('/siteimprov*', (req, res) => {
}
});

app.get('/umami/api/*', (req, res) => {
let apiUrl = "https://umami.ansatt.nav.no/api";
req.url = req.url.replace(/\/umami\/api/, '')
if (req.url.match(/users/)) {
res.end("APIet har blitt blokkert av Team ResearchOps i NAV, ta kontakt med oss for hjelp.")
} else {
const options = {
headers: {Authorization: "Basic " + process.env.UMAMI},
};
axios.get(apiUrl + req.url, options).then(function (response) {
res.json(response.data)
}).catch(function (error) {
console.log(error)
res.end("Kunne ikke koble til Umami APIet: " + error)
});
}
});

app.get('/internumami/api/*', (req, res) => {
let apiUrl = "https://umami.intern.nav.no/api";
req.url = req.url.replace(/\/internumami\/api/, '')
if (req.url.match(/users/)) {
res.end("APIet har blitt blokkert av Team ResearchOps i NAV, ta kontakt med oss for hjelp.")
} else {
const options = {
headers: {Authorization: "Basic " + process.env.UMAMI},
};
axios.get(apiUrl + req.url, options).then(function (response) {
res.json(response.data)
}).catch(function (error) {
console.log(error)
res.end("Kunne ikke koble til Umami APIet: " + error)
});
}
});

// Amplitude Prosjekt: NAV.no - Produksjon
app.get('/amplitude/api/*', (req, res) => {
const requestUrl = req.url.replace(/\/amplitude/, '')
Expand Down

0 comments on commit 9005996

Please sign in to comment.