@@ -35,9 +35,9 @@ describe('Analytics capture() and enabled-flag:', () => {
3535 // 1. enabled=false disables client creation
3636 // ─────────────────────────────────────────────────────────────────
3737 describe ( 'enabled flag:' , ( ) => {
38- test ( 'returns null client when enabled=false even if apiKey is present' , async ( ) => {
38+ test ( 'returns null client when enabled=false even if key is present' , async ( ) => {
3939 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
40- default : { posthog : { enabled : false , apiKey : 'phc_test_key' , host : 'https://eu.i.posthog.com' } } ,
40+ default : { analytics : { posthog : { enabled : false , key : 'phc_test_key' , host : 'https://eu.i.posthog.com' } } } ,
4141 } ) ) ;
4242
4343 const mod = await import ( '../analytics.js' ) ;
@@ -51,9 +51,9 @@ describe('Analytics capture() and enabled-flag:', () => {
5151 expect ( mockPostHogInstance . capture ) . not . toHaveBeenCalled ( ) ;
5252 } ) ;
5353
54- test ( 'returns null client when apiKey is missing even if enabled=true' , async ( ) => {
54+ test ( 'returns null client when key is missing even if enabled=true' , async ( ) => {
5555 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
56- default : { posthog : { enabled : true } } ,
56+ default : { analytics : { posthog : { enabled : true } } } ,
5757 } ) ) ;
5858
5959 const mod = await import ( '../analytics.js' ) ;
@@ -66,9 +66,9 @@ describe('Analytics capture() and enabled-flag:', () => {
6666 expect ( PostHog ) . not . toHaveBeenCalled ( ) ;
6767 } ) ;
6868
69- test ( 'creates client when enabled=true and apiKey is present' , async ( ) => {
69+ test ( 'creates client when enabled=true and key is present' , async ( ) => {
7070 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
71- default : { posthog : { enabled : true , apiKey : 'phc_test_key' , host : 'https://eu.i.posthog.com' } } ,
71+ default : { analytics : { posthog : { enabled : true , key : 'phc_test_key' , host : 'https://eu.i.posthog.com' } } } ,
7272 } ) ) ;
7373
7474 const mod = await import ( '../analytics.js' ) ;
@@ -82,7 +82,7 @@ describe('Analytics capture() and enabled-flag:', () => {
8282
8383 test ( 'passes flushAt and flushInterval to PostHog constructor' , async ( ) => {
8484 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
85- default : { posthog : { enabled : true , apiKey : 'phc_key' , host : 'https://eu.i.posthog.com' , flushAt : 20 , flushInterval : 10000 } } ,
85+ default : { analytics : { posthog : { enabled : true , key : 'phc_key' , host : 'https://eu.i.posthog.com' , flushAt : 20 , flushInterval : 10000 } } } ,
8686 } ) ) ;
8787
8888 const mod = await import ( '../analytics.js' ) ;
@@ -100,7 +100,7 @@ describe('Analytics capture() and enabled-flag:', () => {
100100
101101 test ( 'singleton: two init() calls on the same module instance result in one PostHog client' , async ( ) => {
102102 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
103- default : { posthog : { enabled : true , apiKey : 'phc_key' , host : 'https://eu.i.posthog.com' } } ,
103+ default : { analytics : { posthog : { enabled : true , key : 'phc_key' , host : 'https://eu.i.posthog.com' } } } ,
104104 } ) ) ;
105105
106106 const mod = await import ( '../analytics.js' ) ;
@@ -120,7 +120,7 @@ describe('Analytics capture() and enabled-flag:', () => {
120120 describe ( 'capture() no-ops:' , ( ) => {
121121 test ( 'is a no-op when client is null' , async ( ) => {
122122 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
123- default : { posthog : { enabled : false , apiKey : 'phc_key' } } ,
123+ default : { analytics : { posthog : { enabled : false , key : 'phc_key' } } } ,
124124 } ) ) ;
125125
126126 const mod = await import ( '../analytics.js' ) ;
@@ -134,7 +134,7 @@ describe('Analytics capture() and enabled-flag:', () => {
134134
135135 test ( 'is a no-op when distinctId is missing' , async ( ) => {
136136 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
137- default : { posthog : { enabled : true , apiKey : 'phc_key' , host : 'https://eu.i.posthog.com' } } ,
137+ default : { analytics : { posthog : { enabled : true , key : 'phc_key' , host : 'https://eu.i.posthog.com' } } } ,
138138 } ) ) ;
139139
140140 const mod = await import ( '../analytics.js' ) ;
@@ -148,7 +148,7 @@ describe('Analytics capture() and enabled-flag:', () => {
148148
149149 test ( 'is a no-op when event is missing' , async ( ) => {
150150 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
151- default : { posthog : { enabled : true , apiKey : 'phc_key' , host : 'https://eu.i.posthog.com' } } ,
151+ default : { analytics : { posthog : { enabled : true , key : 'phc_key' , host : 'https://eu.i.posthog.com' } } } ,
152152 } ) ) ;
153153
154154 const mod = await import ( '../analytics.js' ) ;
@@ -167,7 +167,7 @@ describe('Analytics capture() and enabled-flag:', () => {
167167 describe ( 'capture() property injection:' , ( ) => {
168168 beforeEach ( async ( ) => {
169169 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
170- default : { posthog : { enabled : true , apiKey : 'phc_key' , host : 'https://eu.i.posthog.com' , appTag : 'myapp' } } ,
170+ default : { analytics : { posthog : { enabled : true , key : 'phc_key' , host : 'https://eu.i.posthog.com' , appTag : 'myapp' } } } ,
171171 } ) ) ;
172172
173173 const mod = await import ( '../analytics.js' ) ;
@@ -208,7 +208,7 @@ describe('Analytics capture() and enabled-flag:', () => {
208208 } ) ) ;
209209
210210 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
211- default : { posthog : { enabled : true , apiKey : 'phc_key' , host : 'https://eu.i.posthog.com' } } ,
211+ default : { analytics : { posthog : { enabled : true , key : 'phc_key' , host : 'https://eu.i.posthog.com' } } } ,
212212 } ) ) ;
213213
214214 const mod = await import ( '../analytics.js' ) ;
@@ -266,7 +266,7 @@ describe('Analytics capture() and enabled-flag:', () => {
266266 describe ( 'shutdown idempotency:' , ( ) => {
267267 test ( 'two shutdown() calls invoke client.shutdown exactly once' , async ( ) => {
268268 jest . unstable_mockModule ( '../../../config/index.js' , ( ) => ( {
269- default : { posthog : { enabled : true , apiKey : 'phc_key' , host : 'https://eu.i.posthog.com' } } ,
269+ default : { analytics : { posthog : { enabled : true , key : 'phc_key' , host : 'https://eu.i.posthog.com' } } } ,
270270 } ) ) ;
271271
272272 const mod = await import ( '../analytics.js' ) ;
0 commit comments