File tree Expand file tree Collapse file tree 6 files changed +55
-11
lines changed Expand file tree Collapse file tree 6 files changed +55
-11
lines changed Original file line number Diff line number Diff line change @@ -29,4 +29,5 @@ LUX (which stands for Live User eXperience) gives you standard RUM (Real User Mo
2929
3030<list :items =" features " ></list >
3131
32- <alert type =" warning " >This module isn't currently compatible with ` spa ` mode or ` ssr:false ` </alert >
32+ <alert type =" danger " >Not compatible with ` spa ` mode or ` ssr:false ` .<br /> Nuxt 2.12.0+ is required. </alert >
33+
Original file line number Diff line number Diff line change 1111 Fetch
1212 </nuxt-link >
1313 |
14- <nuxt-link to =" /i-am-not-found" >
15- 404
16- </nuxt-link >
17-
14+ <nuxt-link to =" /blog/1" >1</nuxt-link > |
15+ <nuxt-link to =" /blog/2" >2</nuxt-link > |
16+ <nuxt-link to =" /blog/3" >3</nuxt-link >
1817 <nuxt />
1918 </div >
2019</template >
Original file line number Diff line number Diff line change 1+ <template >
2+ <div >
3+ {{ $route.params.id }}
4+ </div >
5+ </template >
6+ <script >
7+ export default {
8+
9+ head (){
10+ return {
11+ title: ' Blog Post # ' + this .$route .params .id ,
12+
13+ }
14+ },
15+ mounted (){
16+ this .$lux .pageLoading (false )
17+ },
18+
19+ }
20+ </script >
Original file line number Diff line number Diff line change 11const { resolve } = require ( 'path' )
22const { readFileSync } = require ( 'fs' )
3+ const semver = require ( 'semver' )
34
45module . exports = function ( moduleOptions ) {
56 if ( this . options . mode === 'spa' ) {
67 throw new Error ( 'Speedcurve LUX Module - SPA Mode is not supported.' )
78 }
89
10+ const currentVersion = semver . coerce ( this . nuxt . constructor . version )
11+ const requiredVersion = semver . coerce ( '2.12.0' )
12+
13+ if ( semver . lt ( currentVersion , requiredVersion ) ) {
14+ throw new Error ( 'Speedcurve LUX Module - Due to a memory leak, Nuxt 2.12.0 or higher is required.' )
15+ }
16+
917 const defaults = {
1018 debugMode : false , // LUX debug mode
1119 enabled : ! this . options . dev , // don't poison metrics from devs
Original file line number Diff line number Diff line change @@ -13,16 +13,30 @@ export default function (ctx, inject) {
1313 const options = Object . assign ( buildOptions , runtimeOptions )
1414 let ignoreLUX = false
1515 let isFirstHit = null
16+ let label = '' // undocumented - we actually need to default/update the label ourselves for SPAs
1617
1718 ctx . $lux = {
1819 // If logFirstHit is true, then let LUX log the first hit and ignore it if user tries to do it themselves
1920 pageLoading ( isLoading = true ) {
2021 if ( process . server || ! window . LUX || ( isFirstHit && options . logFirstHit ) || ignoreLUX ) { return }
21- if ( isLoading ) { window . LUX . init ( ) } else { window . LUX . send ( ) }
22+ if ( isLoading ) {
23+ window . LUX . init ( )
24+ label = ''
25+ } else {
26+ // https://github.com/nuxt/nuxt.js/discussions/8004
27+ // LUX doesn't have a way to stop the timer and not send the beacon so we'll try to wait to get the resolved title
28+ // Ideally SC LUX would let us start/stop, wait..update label.. then send whenever we wanted vs hard-coding send() and stop() as 1 function. Then I'd make this 1s and call it good.
29+ // 20ms may not be good enough for those using transitions (not sure), but we don't really have a better choice right now.
30+ setTimeout ( ( ) => {
31+ window . LUX . label = label || document . title
32+ window . LUX . send ( )
33+ } , 20 )
34+
35+ }
2236 } ,
23- label ( label ) {
24- if ( process . server || ! window . LUX || ! label || ignoreLUX ) { return }
25- window . LUX . label = label
37+ label ( newLabel ) {
38+ if ( process . server || ! window . LUX || ! newLabel || ignoreLUX ) { return }
39+ label = newLabel
2640 } ,
2741 addData ( name , value ) {
2842 if ( process . server || ! window . LUX || ! name || typeof value === 'undefined' || ignoreLUX ) { return }
Original file line number Diff line number Diff line change 2424 "test-static" : " nuxt generate examples/universal" ,
2525 "test-universal" : " nuxt build examples/universal && nuxt start examples/universal"
2626 },
27- "dependencies" : {},
27+ "dependencies" : {
28+ "semver" : " ^7.3.2"
29+ },
2830 "devDependencies" : {
2931 "@babel/core" : " latest" ,
3032 "@babel/preset-env" : " latest" ,
3133 "@commitlint/cli" : " latest" ,
3234 "@commitlint/config-conventional" : " latest" ,
35+ "@nuxt/content-theme-docs" : " ^0.5.3" ,
3336 "@nuxtjs/eslint-config" : " latest" ,
3437 "@nuxtjs/module-test-utils" : " latest" ,
35- "@nuxt/content-theme-docs" : " ^0.5.3" ,
3638 "babel-eslint" : " latest" ,
3739 "babel-jest" : " latest" ,
3840 "eslint" : " latest" ,
You can’t perform that action at this time.
0 commit comments