@@ -7,15 +7,9 @@ import {API} from './api';
7
7
import * as Sentry from '@sentry/browser' ;
8
8
import { getHostname , getAPIUrl , loadDevTools } from './utils' ;
9
9
import { ErrorNotifier } from "./error-notifier" ;
10
-
11
- const mainUrl = getAPIUrl ( 'https://staging.wazimap-ng.openup.org.za' ) ;
12
- const productionUrl = getAPIUrl ( 'https://production.wazimap-ng.openup.org.za' ) ;
13
- let config = new SAConfig ( ) ;
10
+ import { getProfile } from './configurations/profiles'
14
11
15
12
let hostname = getHostname ( ) ;
16
- const defaultProfile = 8 ;
17
- const defaultUrl = productionUrl ;
18
- const defaultConfig = new SAConfig ( ) ;
19
13
20
14
const ENVIRONMENT = `${ process . env . ENVIRONMENT } ` ;
21
15
const GOOGLE_ANALYTICS_ID = `${ process . env . GOOGLE_ANALYTICS_ID } ` ;
@@ -30,84 +24,14 @@ if (SENTRY_DSN !== "undefined" && SENTRY_DSN !== "") {
30
24
console . warn ( "Not initialising Sentry because SENTRY_DSN is not set" ) ;
31
25
}
32
26
33
- const profiles = {
34
- 'wazi.webflow.io' : {
35
- baseUrl : mainUrl ,
36
- config : config
37
- } ,
38
- 'localhost' : {
39
- baseUrl : mainUrl ,
40
- config : config
41
- } ,
42
- 'localhost-dev' : {
43
- baseUrl : 'http://localhost:8000' ,
44
- config : config
45
- } ,
46
- 'geo.vulekamali.gov.za' : {
47
- baseUrl : productionUrl ,
48
- config : config
49
- } ,
50
- 'beta.youthexplorer.org.za' : {
51
- baseUrl : productionUrl ,
52
- config : config
53
- } ,
54
- 'capetownagainstcovid19.openup.org.za' : {
55
- baseUrl : mainUrl ,
56
- config : config
57
- } ,
58
- 'covid-wazi.openup.org.za' : {
59
- baseUrl : productionUrl ,
60
- config : config
61
- } ,
62
- 'wazimap-ng.africa' : {
63
- baseUrl : mainUrl ,
64
- config : config
65
- } ,
66
- 'covid-ibp.openup.org.za' : {
67
- baseUrl : productionUrl ,
68
- config : config
69
- } ,
70
- 'sifar-wazi.openup.org.za' : {
71
- baseUrl : productionUrl ,
72
- config : config
73
- } ,
74
- 'mapyourcity.org.za' : {
75
- baseUrl : productionUrl ,
76
- config : config
77
- } ,
78
- 'giz-projects.openup.org.za' : {
79
- baseUrl : productionUrl ,
80
- config : config
81
- } ,
82
- 'covid-ccij.openup.org.za' : {
83
- baseUrl : mainUrl ,
84
- config : config
85
- } ,
86
- 'cfafrica.wazimap-ng.africa' : {
87
- baseUrl : 'https://api.cfafrica.wazimap-ng.africa' ,
88
- config : config
89
- } ,
90
- 'ccij-water.openup.org.za' : {
91
- baseUrl : productionUrl ,
92
- config : config
93
- }
94
- }
95
-
96
27
async function init ( ) {
97
- let pc = profiles [ hostname ]
98
- if ( pc == undefined ) {
99
- pc = {
100
- profile : defaultProfile ,
101
- baseUrl : defaultUrl ,
102
- config : defaultConfig
103
- }
104
- }
28
+ let pc = getProfile ( hostname )
105
29
106
30
const errorNotifier = new ErrorNotifier ( ) ;
107
31
errorNotifier . registerErrorHandler ( ) ;
108
32
109
33
const api = new API ( pc . baseUrl , pc . config ) ;
110
- const data = await api . getProfileConfiguration ( hostname ) ;
34
+ const data = await api . getProfileConfiguration ( pc . hostname ) ;
111
35
112
36
pc . config . setConfig ( data . configuration || { } )
113
37
pc . config . setVersions ( data . geography_hierarchy || { } )
0 commit comments