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

Ansatt url for sanity #1136

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
12 changes: 6 additions & 6 deletions src/components/endringslogg/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const hentEndringsLoggEntries = async (
): Promise<Response> =>
fetch(`${backendUrl}/endringslogg`, {
method: 'POST',
mode: 'cors',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json'
},
Expand All @@ -19,7 +19,7 @@ export const hentEndringsLoggEntries = async (
export const trackSeenStatus = async (userId: string, appId: string, documentIds: string[]): Promise<Response> =>
fetch(`${backendUrl}/analytics/sett-endringer`, {
method: 'POST',
mode: 'cors',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json'
},
Expand All @@ -29,7 +29,7 @@ export const trackSeenStatus = async (userId: string, appId: string, documentIds
export const trackSeenForcedModal = async (userId: string, documentIds: string[]): Promise<Response> =>
fetch(`${backendUrl}/analytics/seen-forced-modal`, {
method: 'POST',
mode: 'cors',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json'
},
Expand All @@ -44,7 +44,7 @@ export const trackSessionDuration = async (
): Promise<Response> =>
fetch(`${backendUrl}/analytics/session-duration`, {
method: 'POST',
mode: 'cors',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json'
},
Expand All @@ -54,7 +54,7 @@ export const trackSessionDuration = async (
export const trackLinkClick = async (documentId: string): Promise<Response> =>
fetch(`${backendUrl}/analytics/link-click`, {
method: 'PATCH',
mode: 'cors',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json'
},
Expand All @@ -64,7 +64,7 @@ export const trackLinkClick = async (documentId: string): Promise<Response> =>
export const trackModalOpen = async (documentId: string): Promise<Response> =>
fetch(`${backendUrl}/analytics/modal-open`, {
method: 'PATCH',
mode: 'cors',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json'
},
Expand Down
20 changes: 12 additions & 8 deletions src/middleware/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {FargekategoriDataModell, FiltervalgModell, VeilederModell} from '../model-interfaces';
import {NyttLagretFilter, RedigerLagretFilter, SorteringOgId} from '../ducks/lagret-filter';
import {erDev, loginUrl} from '../utils/url-utils';
import {FrontendEvent} from '../utils/frontend-logger';
import {erDev, getEnv, loginUrl} from '../utils/url-utils';
import {GeografiskBosted} from '../ducks/geografiskBosted';
import {Foedeland} from '../ducks/foedeland';
import {TolkebehovSpraak} from '../ducks/tolkebehov';
Expand All @@ -18,6 +17,14 @@ const MED_CREDENTIALS: RequestInit = {
'Content-Type': 'application/json'
}
};
const MED_CREDENTIALS_ANSATT: RequestInit = {
credentials,
mode: 'no-cors',
headers: {
'Nav-Consumer-Id': 'veilarbportefoljeflatefs',
'Content-Type': 'application/json'
}
};

export interface Session {
created_at?: string;
Expand Down Expand Up @@ -272,6 +279,9 @@ export function lagreSorteringFiltere(sorteringOgIder: SorteringOgId[]): Promise
}

export function hentSystemmeldinger() {
if (getEnv().ingressType === 'ansatt') {
return fetchToJson(`https://poao-sanity.ansatt.dev.nav.no/systemmeldinger`, MED_CREDENTIALS_ANSATT);
}
return fetchToJson(`https://poao-sanity.intern${erDev() ? '.dev' : ''}.nav.no/systemmeldinger`, MED_CREDENTIALS);
}

Expand All @@ -292,12 +302,6 @@ export function hentGeografiskBosted(enhet: string): Promise<GeografiskBosted[]>
return fetchToJson(`/veilarbportefolje/api/enhet/${enhet}/geografiskbosted`, MED_CREDENTIALS);
}

export function sendEventTilPortefolje(event: FrontendEvent) {
const url = `${VEILARBPORTEFOLJE_URL}/logger/event`;
const config = {...MED_CREDENTIALS, method: 'post', body: JSON.stringify(event)};
return fetch(url, config);
}

export const refreshAccessTokens = async (): Promise<SessionMeta> => {
return fetchToJson('/oauth2/session/refresh', {}, false).then(data => Promise.resolve(data as SessionMeta));
};
Expand Down
8 changes: 7 additions & 1 deletion src/utils/url-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ const Env = {
local: {ingressType: 'intern', type: EnvType.local}
} as const;

export const getEndringsloggUrl = () => `https://poao-endringslogg.intern${erDev() ? '.dev' : ''}.nav.no`;
export const getEndringsloggUrl = () => {
if (erDev() && getEnv() === Env.ansattDev) {
return 'https://poao-endringslogg.ansatt.dev.nav.no';
} else {
return `https://poao-endringslogg.intern${erDev() ? '.dev' : ''}.nav.no`;
}
};

export const loginUrl = () => {
if (erMock()) {
Expand Down