Skip to content

Commit 3c4ea26

Browse files
feat: Add Logging Configurations (#1058)
1 parent 3713d73 commit 3c4ea26

File tree

2 files changed

+133
-15
lines changed

2 files changed

+133
-15
lines changed

src/common/config/state/init.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ const model = () => {
3131
}
3232
}
3333
return {
34-
feature_flags: [],
35-
proxy: {
36-
assets: undefined, // if this value is set, it will be used to overwrite the webpack asset path used to fetch assets
37-
beacon: undefined // likewise for the url to which we send analytics
38-
},
39-
privacy: { cookies_enabled: true }, // *cli - per discussion, default should be true
4034
ajax: { deny_list: undefined, block_internal: true, enabled: true, harvestTimeSeconds: 10, autoStart: true },
4135
distributed_tracing: {
4236
enabled: undefined,
@@ -45,19 +39,24 @@ const model = () => {
4539
cors_use_tracecontext_headers: undefined,
4640
allowed_origins: undefined
4741
},
48-
session: {
49-
expiresMs: DEFAULT_EXPIRES_MS,
50-
inactiveMs: DEFAULT_INACTIVE_MS
51-
},
52-
ssl: undefined,
53-
obfuscate: undefined,
42+
feature_flags: [],
43+
harvest: { tooManyRequestsDelay: 60 },
5444
jserrors: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
45+
logging: { enabled: true, harvestTimeSeconds: 30, autoStart: true, level: 'info' },
5546
metrics: { enabled: true, autoStart: true },
47+
obfuscate: undefined,
5648
page_action: { enabled: true, harvestTimeSeconds: 30, autoStart: true },
5749
page_view_event: { enabled: true, autoStart: true },
5850
page_view_timing: { enabled: true, harvestTimeSeconds: 30, long_task: false, autoStart: true },
59-
session_trace: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
60-
harvest: { tooManyRequestsDelay: 60 },
51+
privacy: { cookies_enabled: true }, // *cli - per discussion, default should be true
52+
proxy: {
53+
assets: undefined, // if this value is set, it will be used to overwrite the webpack asset path used to fetch assets
54+
beacon: undefined // likewise for the url to which we send analytics
55+
},
56+
session: {
57+
expiresMs: DEFAULT_EXPIRES_MS,
58+
inactiveMs: DEFAULT_INACTIVE_MS
59+
},
6160
session_replay: {
6261
// feature settings
6362
autoStart: true,
@@ -100,8 +99,10 @@ const model = () => {
10099
else warn('An invalid session_replay.mask_input_option was provided and will not be used', val)
101100
}
102101
},
102+
session_trace: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
103+
soft_navigations: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
103104
spa: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
104-
soft_navigations: { enabled: true, harvestTimeSeconds: 10, autoStart: true }
105+
ssl: undefined
105106
}
106107
}
107108

tests/unit/common/config/state/init.test.js

+117
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,123 @@ test('getConfigurationValue parses path correctly', () => {
3030
expect(getConfigurationValue('ab', 'page_action.dne')).toBeUndefined()
3131
})
3232

33+
test('init props exist and return expected defaults', () => {
34+
setConfiguration('34567', {})
35+
const config = getConfiguration('34567')
36+
expect(Object.keys(config).length).toEqual(19)
37+
expect(config.ajax).toEqual({
38+
autoStart: true,
39+
block_internal: true,
40+
deny_list: undefined,
41+
enabled: true,
42+
harvestTimeSeconds: 10
43+
})
44+
expect(config.distributed_tracing).toEqual({
45+
allowed_origins: undefined,
46+
cors_use_newrelic_header: undefined,
47+
cors_use_tracecontext_headers: undefined,
48+
enabled: undefined,
49+
exclude_newrelic_header: undefined
50+
})
51+
expect(config.feature_flags).toEqual([])
52+
expect(config.harvest).toEqual({
53+
tooManyRequestsDelay: 60
54+
})
55+
expect(config.jserrors).toEqual({
56+
autoStart: true,
57+
enabled: true,
58+
harvestTimeSeconds: 10
59+
})
60+
expect(config.logging).toEqual({
61+
autoStart: true,
62+
enabled: true,
63+
harvestTimeSeconds: 30,
64+
level: 'info'
65+
})
66+
expect(config.metrics).toEqual({
67+
autoStart: true,
68+
enabled: true
69+
})
70+
expect(config.obfuscate).toEqual(undefined)
71+
expect(config.page_action).toEqual({
72+
autoStart: true,
73+
enabled: true,
74+
harvestTimeSeconds: 30
75+
})
76+
expect(config.page_view_event).toEqual({
77+
autoStart: true,
78+
enabled: true
79+
})
80+
expect(config.page_view_timing).toEqual({
81+
autoStart: true,
82+
enabled: true,
83+
harvestTimeSeconds: 30,
84+
long_task: false
85+
})
86+
expect(config.privacy).toEqual({
87+
cookies_enabled: true
88+
})
89+
expect(config.proxy).toEqual({
90+
assets: undefined,
91+
beacon: undefined
92+
})
93+
expect(config.session).toEqual({
94+
expiresMs: 14400000,
95+
inactiveMs: 1800000
96+
})
97+
expect(config.session_replay).toEqual({
98+
autoStart: true,
99+
block_class: 'nr-block',
100+
block_selector: '[data-nr-block]',
101+
collect_fonts: false,
102+
enabled: false,
103+
error_sampling_rate: 100,
104+
harvestTimeSeconds: 60,
105+
ignore_class: 'nr-ignore',
106+
inline_images: false,
107+
inline_stylesheet: true,
108+
mask_all_inputs: true,
109+
mask_input_options: {
110+
color: false,
111+
date: false,
112+
'datetime-local': false,
113+
email: false,
114+
month: false,
115+
number: false,
116+
password: true,
117+
range: false,
118+
search: false,
119+
select: false,
120+
tel: false,
121+
text: false,
122+
textarea: false,
123+
time: false,
124+
url: false,
125+
week: false
126+
},
127+
mask_text_class: 'nr-mask',
128+
mask_text_selector: '*',
129+
preload: false,
130+
sampling_rate: 10
131+
})
132+
expect(config.session_trace).toEqual({
133+
autoStart: true,
134+
enabled: true,
135+
harvestTimeSeconds: 10
136+
})
137+
expect(config.soft_navigations).toEqual({
138+
autoStart: true,
139+
enabled: true,
140+
harvestTimeSeconds: 10
141+
})
142+
expect(config.spa).toEqual({
143+
autoStart: true,
144+
enabled: true,
145+
harvestTimeSeconds: 10
146+
})
147+
expect(config.ssl).toEqual(undefined)
148+
})
149+
33150
describe('property getters/setters used for validation', () => {
34151
test('invalid values do not pass through', () => {
35152
setConfiguration('12345', {

0 commit comments

Comments
 (0)