-
Trying to get analytics working by following along with the example shown at https://github.com/basvdijk/capacitor4-firebase-analytics-example-project-capawesome-team I'm using SvelteKit set to SPA mode, which is generating the code into a build directory (instead of public). I followed along with the instructions (although I am using SvelteKit instead). When I try to generate a build, I get this error:
Here is script section of the +page.svelte I'm using: <script>
import Counter from './Counter.svelte';
import welcome from '$lib/images/svelte-welcome.webp';
import welcome_fallback from '$lib/images/svelte-welcome.png';
import Geo from './Geo.svelte';
import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
const setEnabled = async () => {
await FirebaseAnalytics.setEnabled({
enabled: true
});
};
const setCurrentScreen = async () => {
await FirebaseAnalytics.setCurrentScreen({
screenName: 'Login',
screenClassOverride: 'LoginPage'
});
};
const initAnalytics = async () => {
await setEnabled();
await setCurrentScreen();
};
initAnalytics();
</script> If I remove this JS code from the file, I can build and I do see real-time user events for the app open, but of course I don't see anything related to the screen view. Any thoughts? Something I'm missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Unfortunately I have no experience with SvelteKit. |
Beta Was this translation helpful? Give feedback.
Found it - it is a SvelteKit specific fix. Had to add a
/routes/+layout.js
withexport const ssr = false;
to force SvelteKit into SPA mode.Oh well, at least now hopefully this will show up in search for anyone else. :)