-
Notifications
You must be signed in to change notification settings - Fork 7
/
settings.js
86 lines (75 loc) · 3.48 KB
/
settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const processBoolSetting = (input) => String(input) === "true"
const settings = (inputs) => {
const IS_PREVIEW = process.env.CONTEXT == "deploy-preview"
const FAIL_BUILD_ON_PLUGIN_ERROR =
processBoolSetting(process.env.FAIL_BUILD_ON_PLUGIN_ERROR ?? inputs.failBuildOnPluginError)
const NEWRELIC_ACCOUNT_ID =
process.env.NEWRELIC_ACCOUNT_ID ?? inputs.newrelicAccountId
const NEWRELIC_INGEST_LICENSE_KEY =
process.env.NEWRELIC_INGEST_LICENSE_KEY ?? inputs.newrelicLicenseKey
const NEWRELIC_BROWSER_LICENSE_KEY =
process.env.NEWRELIC_BROWSER_LICENSE_KEY ?? inputs.newrelicBrowserLicenseKey
const NEWRELIC_REGION =
process.env.NEWRELIC_REGION ?? inputs.newrelicRegion
const NEWRELIC_APP_ID = process.env.NEWRELIC_APP_ID ?? inputs.newrelicAppId
const NEWRELIC_API_KEY = process.env.NEWRELIC_API_KEY ?? inputs.newrelicApiKey
const ENABLE_BROWSER_MONITORING =
processBoolSetting(process.env.ENABLE_BROWSER_MONITORING ?? inputs.enableBrowserMonitoring)
const ENABLE_BROWSER_MONITORING_FOR_PREVIEWS =
processBoolSetting(process.env.ENABLE_BROWSER_MONITORING_FOR_PREVIEWS ?? inputs.enableBrowserMonitoringForPreviews)
const DISTRIBUTED_TRACING_ENABLED =
processBoolSetting(process.env.DISTRIBUTED_TRACING_ENABLED ?? inputs.distributedTracingEnabled)
const COOKIES_ENABLED = processBoolSetting(process.env.COOKIES_ENABLED ?? inputs.cookiesEnabled)
const HTML_INJECTION_CONCURRENCY =
process.env.HTML_INJECTION_CONCURRENCY ?? inputs.htmlInjectionConcurrency
const SET_DEPLOYMENT_MARKERS =
processBoolSetting(process.env.SET_DEPLOYMENT_MARKERS ?? inputs.setDeploymentMarkers)
const SET_DEPLOYMENT_MARKERS_FOR_PREVIEWS =
processBoolSetting(process.env.SET_DEPLOYMENT_MARKERS_FOR_PREVIEWS ?? inputs.setDeploymentMarkersForPreviews)
const REVISION_TEMPLATE =
process.env.REVISION_TEMPLATE ?? inputs.revisionTemplate
const RECORD_EVENTS_FOR_PREVIEWS =
processBoolSetting(process.env.RECORD_EVENTS_FOR_PREVIEWS ?? inputs.recordEventsForPreviews)
const SKIP_PRE_BUILD_EVENT =
processBoolSetting(process.env.SKIP_PRE_BUILD_EVENT ?? inputs.skipEvent?.onPreBuild)
const SKIP_BUILD_EVENT =
processBoolSetting(process.env.SKIP_BUILD_EVENT ?? inputs.skipEvent?.onBuild)
const SKIP_POST_BUILD_EVENT =
processBoolSetting(process.env.SKIP_POST_BUILD_EVENT ?? inputs.skipEvent?.onPostBuild)
const SKIP_ERROR_EVENT =
processBoolSetting(process.env.SKIP_ERROR_EVENT ?? inputs.skipEvent?.onError)
const SKIP_SUCCESS_EVENT =
processBoolSetting(process.env.SKIP_SUCCESS_EVENT ?? inputs.skipEvent?.onSuccess)
const SKIP_END_EVENT =
processBoolSetting(process.env.SKIP_END_EVENT ?? inputs.skipEvent?.onEnd)
return {
IS_PREVIEW,
FAIL_BUILD_ON_PLUGIN_ERROR,
NEWRELIC_ACCOUNT_ID,
NEWRELIC_INGEST_LICENSE_KEY,
NEWRELIC_BROWSER_LICENSE_KEY,
NEWRELIC_APP_ID,
NEWRELIC_API_KEY,
ENABLE_BROWSER_MONITORING,
ENABLE_BROWSER_MONITORING_FOR_PREVIEWS,
DISTRIBUTED_TRACING_ENABLED,
COOKIES_ENABLED,
HTML_INJECTION_CONCURRENCY,
SET_DEPLOYMENT_MARKERS,
SET_DEPLOYMENT_MARKERS_FOR_PREVIEWS,
REVISION_TEMPLATE,
RECORD_EVENTS_FOR_PREVIEWS,
SKIP_PRE_BUILD_EVENT,
SKIP_BUILD_EVENT,
SKIP_POST_BUILD_EVENT,
SKIP_ERROR_EVENT,
SKIP_SUCCESS_EVENT,
SKIP_END_EVENT,
NEWRELIC_REGION
}
}
const getErrorResponse = (inputs, build) => {
const { FAIL_BUILD_ON_PLUGIN_ERROR } = settings(inputs)
return FAIL_BUILD_ON_PLUGIN_ERROR ? build.failBuild : build.failPlugin
}
export { settings, getErrorResponse }