Error calculating daily stats

I have commented out the use of Plausible to get the analytics:
//import { getDailyPageViews, getSources } from './plausibleAnalyticsUtils.js';
import { getDailyPageViews, getSources } from './googleAnalyticsUtils.js';
//import { getDailyPageViews, getSources } from './plausibleAnalyticsUtils.js';
import { getDailyPageViews, getSources } from './googleAnalyticsUtils.js';
However, I am getting an error every time the Daily Stats is calculated:
[ Server!] Error calculating daily stats: Error: 2 UNKNOWN: Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported
[ Server!] at callErrorFromStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/call.ts:82:17)
[ Server!] at Object.onReceiveStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/client.ts:360:55)
[ Server!] at Object.onReceiveStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
[ Server!] at Object.onReceiveStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
(...)
[ Server!] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[ Server!] code: 2,
[ Server!] details: 'Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported',
[ Server!] metadata: Metadata { internalRepr: Map(0) {}, options: {} }
[ Server!] }
[ Server!] Error calculating daily stats: Error: 2 UNKNOWN: Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported
[ Server!] at callErrorFromStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/call.ts:82:17)
[ Server!] at Object.onReceiveStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/client.ts:360:55)
[ Server!] at Object.onReceiveStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
[ Server!] at Object.onReceiveStatus (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
(...)
[ Server!] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[ Server!] code: 2,
[ Server!] details: 'Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported',
[ Server!] metadata: Metadata { internalRepr: Map(0) {}, options: {} }
[ Server!] }
28 Replies
kapa.ai
kapa.aiβ€’5mo ago
Hi @Ricardo Batista. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, it seems like you're having an issue with calculating daily stats in your Wasp application. However, the specific error you're encountering isn't directly addressed in the provided sources. In the Discord support thread, a similar issue was discussed where a user was having trouble with the calculateDailyStats function. The community suggested checking the logs in the database if the job fails, and debugging the calculateDailyStats function. They also suggested changing the job to run every minute in the main.wasp file for debugging purposes. However, this may not directly apply to your situation as your error seems to be related to getting metadata from a plugin. Unfortunately, without more specific information related to your issue, it's difficult to provide a more precise solution. I would recommend checking the logs as suggested in the Discord thread, and possibly reaching out to the Wasp community for more specific guidance. Here is the relevant source (https://discord.com/channels/686873244791210014/1215945587841831033) from the knowledge provided. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
Just to complement - I have setup the env variables:
GOOGLE_ANALYTICS_CLIENT_EMAIL=xxx.iam.gserviceaccount.com
GOOGLE_ANALYTICS_PRIVATE_KEY=LS0tL...
GOOGLE_ANALYTICS_PROPERTY_ID=436...
STRIPE_KEY=sk_test_5dfsdfsdf
GOOGLE_ANALYTICS_CLIENT_EMAIL=xxx.iam.gserviceaccount.com
GOOGLE_ANALYTICS_PRIVATE_KEY=LS0tL...
GOOGLE_ANALYTICS_PROPERTY_ID=436...
STRIPE_KEY=sk_test_5dfsdfsdf
martinsos
martinsosβ€’5mo ago
Oh that's a bit peculiar! @Vinny (@Wasp) any ideas?
Atasoy
Atasoyβ€’5mo ago
Is it working if you uncomment plausible ?
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
Also doesn’t work
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
hm. maybe something changed since we pushed Open SaaS. I tested it and it worked, but because we use Plausible, I haven't seen the error I'll have to play with it tomorrow and see
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
I decided to update the files to the latest ones, and got the following error as well (same as before, different message):
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] Error calculating daily stats: Error: 2 UNKNOWN: Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at callErrorFromStatus (/app/node_modules/@grpc/grpc-js/src/call.ts:82:17)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/src/client.ts:360:55)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at <anonymous> (/app/node_modules/@grpc/grpc-js/src/resolving-call.ts:132:24)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] for call at
(...)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] code: 2,
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] details: 'Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported',
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] metadata: Metadata { internalRepr: Map(0) {}, options: {} }
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] }
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] Error calculating daily stats: Error: 2 UNKNOWN: Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at callErrorFromStatus (/app/node_modules/@grpc/grpc-js/src/call.ts:82:17)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/src/client.ts:360:55)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at <anonymous> (/app/node_modules/@grpc/grpc-js/src/resolving-call.ts:132:24)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] for call at
(...)
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] code: 2,
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] details: 'Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported',
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] metadata: Metadata { internalRepr: Map(0) {}, options: {} }
2024-06-24T06:00:08.541 app[e82429ec0e34e8] ams [info] }
If I switch it to Plausible instead of GA, I get a normal error (because I don't have the Plausible credentials):
[ Server!] Error calculating daily stats: TypeError: Failed to parse URL from undefined/v1/stats/aggregate?site_id=undefined&metrics=pageviews
[ Server!] at node:internal/deps/undici/undici:13737:13
[ Server!] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[ Server!] at getTotalPageViews (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/src/server/workers/plausibleAnalyticsUtils.ts:38:20)
[ Server!] at getDailyPageViews (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/src/server/workers/plausibleAnalyticsUtils.ts:28:22)
[ Server!] at calculateDailyStats (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/src/server/workers/calculateDailyStats.ts:43:55)
[ Server!] at async resolveWithinSeconds (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/pg-boss/src/manager.js:34:14)
[ Server!] at async /Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/p-map/index.js:57:22 {
[ Server!] [cause]: TypeError: Invalid URL
[ Server!] at new URL (node:internal/url:804:36)
(...)
[ Server!] at async resolveWithinSeconds (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/pg-boss/src/manager.js:34:14) {
[ Server!] code: 'ERR_INVALID_URL',
[ Server!] input: 'undefined/v1/stats/aggregate?site_id=undefined&metrics=pageviews'
[ Server!] }
[ Server!] }
[ Server!] Error calculating daily stats: TypeError: Failed to parse URL from undefined/v1/stats/aggregate?site_id=undefined&metrics=pageviews
[ Server!] at node:internal/deps/undici/undici:13737:13
[ Server!] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[ Server!] at getTotalPageViews (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/src/server/workers/plausibleAnalyticsUtils.ts:38:20)
[ Server!] at getDailyPageViews (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/src/server/workers/plausibleAnalyticsUtils.ts:28:22)
[ Server!] at calculateDailyStats (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/src/server/workers/calculateDailyStats.ts:43:55)
[ Server!] at async resolveWithinSeconds (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/pg-boss/src/manager.js:34:14)
[ Server!] at async /Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/p-map/index.js:57:22 {
[ Server!] [cause]: TypeError: Invalid URL
[ Server!] at new URL (node:internal/url:804:36)
(...)
[ Server!] at async resolveWithinSeconds (/Users/rbatista19/Documents/VSCode/AIBlogArticles/ai-blog-articles/app/node_modules/pg-boss/src/manager.js:34:14) {
[ Server!] code: 'ERR_INVALID_URL',
[ Server!] input: 'undefined/v1/stats/aggregate?site_id=undefined&metrics=pageviews'
[ Server!] }
[ Server!] }
@Vinny (@Wasp) if you need credentials to test, happy to send you via DM
jordi0lle
jordi0lleβ€’5mo ago
@Ricardo Batista I’ve been having this error since the first deployment but didn’t care that much because my app works just as intended (btw, I’m using GA)
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
Gotcha, so it might happen to others as well πŸ’ͺ🏻
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
@jordi0lle @Ricardo Batista have you tried removing /v1 from the PLAUSIBLE_BASE_URL env var? ${PLAUSIBLE_BASE_URL}/v1/stats/aggregate?site_id=${PLAUSIBLE_SITE_ID}&metrics=pageviews <-- there's a bug, and v1 will appear twice in the URL if not
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
The issue we have is with Google Analytics, not Plausible
jordi0lle
jordi0lleβ€’5mo ago
Nope! I’ll try later on and see if tomorrow the error is there πŸ‘πŸ»
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
@Vinny (@Wasp) did you have a chance to look at this?
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
Nope not yet. Sorry. I will make an issue and definitely check tomorrow Any ideas what it might be? Or where to start?
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
Not sure, it might just be the fact that you guys use Plausible and something changed in GA flow?
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
Yeah that’s what I was thinking too Ricardo, I don't have any problems using the google analytics when running the daily stats jonb
[ Server ] Daily stat found for today, updating it...
[ Server ] β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
[ Server ] β”‚ (index) β”‚ id β”‚ date β”‚ totalViews β”‚ prevDayViewsChangePercent β”‚ userCount β”‚ paidUserCount β”‚ userDelta β”‚ paidUserDelta β”‚ totalRevenue β”‚ totalProfit β”‚
[ Server ] β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
[ Server ] β”‚ dailyStats β”‚ 1 β”‚ 2024-06-26T00:00:00.000Z β”‚ 110649 β”‚ '0' β”‚ 1 β”‚ 1 β”‚ 1 β”‚ 1 β”‚ 39309.01 β”‚ 0 β”‚
[ Server ] β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
[ Server ] Daily stat found for today, updating it...
[ Server ] β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
[ Server ] β”‚ (index) β”‚ id β”‚ date β”‚ totalViews β”‚ prevDayViewsChangePercent β”‚ userCount β”‚ paidUserCount β”‚ userDelta β”‚ paidUserDelta β”‚ totalRevenue β”‚ totalProfit β”‚
[ Server ] β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
[ Server ] β”‚ dailyStats β”‚ 1 β”‚ 2024-06-26T00:00:00.000Z β”‚ 110649 β”‚ '0' β”‚ 1 β”‚ 1 β”‚ 1 β”‚ 1 β”‚ 39309.01 β”‚ 0 β”‚
[ Server ] β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
I think you're not setting up your google analytics correctly with your cookie consent banner what I would suggest is 1) just add the google analytics tag to the app.head property of your main.wasp file: (make sure to add your Google Analytics ID in the two places specified below)
<!-- Google tag (gtag.js) --><script async src='https://www.googletagmanager.com/gtag/js?id=<YOUR-ID>'></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '<YOUR-ID>');</script>
<!-- Google tag (gtag.js) --><script async src='https://www.googletagmanager.com/gtag/js?id=<YOUR-ID>'></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '<YOUR-ID>');</script>
2) restart your wasp app and then check in browser's dev tools if you see the _ga cookies (there should be at least two) 3) if that's working, then you know it's an issue with cookie consent banner. If not, go back and check the analyics docs and follow all the steps again to make sure you're setting up your analytics correctly (e.g. convert your key to base64 by copying the whole key echo -n "-----BEGIN PRIVATE KEY-----\nMIIE ... tQ+A==\n-----END PRIVATE KEY-----\n" | base64)
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
hey @Vinny (@Wasp) thanks! I am not using OpenSaaS to fire the tag, given that I have other tags to fire - so I am relying on Google Tag Manager for the tag firing. Nevertheless, the connection to GA should be done via the GA credentials in .env.server, correct?
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
yeah, so you'll have the GA ID which is in the script tag and then you'll have to set up the API by adding the keys in .env.server it's all outlined in the docs but let me know if you get stuck .env.server
# (OPTIONAL) get your google service account key at https://console.cloud.google.com/iam-admin/serviceaccounts
GOOGLE_ANALYTICS_CLIENT_EMAIL=[email protected]
# Make sure you convert the private key within the JSON file to base64 first with `echo -n "PRIVATE_KEY" | base64`. see the docs for more info.
GOOGLE_ANALYTICS_PRIVATE_KEY=LS02...
# You will find your Property ID in the Google Analytics dashboard. It will look like '987654321'
GOOGLE_ANALYTICS_PROPERTY_ID=123456789
# (OPTIONAL) get your google service account key at https://console.cloud.google.com/iam-admin/serviceaccounts
GOOGLE_ANALYTICS_CLIENT_EMAIL=[email protected]
# Make sure you convert the private key within the JSON file to base64 first with `echo -n "PRIVATE_KEY" | base64`. see the docs for more info.
GOOGLE_ANALYTICS_PRIVATE_KEY=LS02...
# You will find your Property ID in the Google Analytics dashboard. It will look like '987654321'
GOOGLE_ANALYTICS_PROPERTY_ID=123456789
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
The issue in having the script tag is that it would fire twice (one thru OpenSaaS, another thru GTM). But I do have the key in .env.server:
# (OPTIONAL) get your google service account key at https://console.cloud.google.com/iam-admin/serviceaccounts
GOOGLE_ANALYTICS_CLIENT_EMAIL=google-analytics@meeting-reminder...
# Make sure you convert the private key within the JSON file to base64 first with `echo -n "PRIVATE_KEY" | base64`. see the docs for more info.
GOOGLE_ANALYTICS_PRIVATE_KEY=LS0tLS1CRUdJTiBQUklW...
# You will find your Property ID in the Google Analytics dashboard. It will look like '987654321'
GOOGLE_ANALYTICS_PROPERTY_ID=438..
# (OPTIONAL) get your google service account key at https://console.cloud.google.com/iam-admin/serviceaccounts
GOOGLE_ANALYTICS_CLIENT_EMAIL=google-analytics@meeting-reminder...
# Make sure you convert the private key within the JSON file to base64 first with `echo -n "PRIVATE_KEY" | base64`. see the docs for more info.
GOOGLE_ANALYTICS_PRIVATE_KEY=LS0tLS1CRUdJTiBQUklW...
# You will find your Property ID in the Google Analytics dashboard. It will look like '987654321'
GOOGLE_ANALYTICS_PROPERTY_ID=438..
This should be enough, right?
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
it's weird because you have to go to the google cloud console and set it all up, then convert the private key to base64, then go to the analytics console and add the special email etc is the script also in your main.wasp ? ah I see what you mean, if you add it, it would fire twice but I don't think that would cause issues for testing, would it? I don't know how Google Tag Manager works, so if you can test it out in app.head and let me know what happens, then we can start checking off possible issues
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
But it is weird that DailyStats needs to the GA tag to fire... I have GTM tag in main.wasp:
// Google tag manager tag
"<!-- Google Tag Manager --><script>window.dataLayer = window.dataLayer || []; function gtag(){window.dataLayer.push(arguments);} gtag('consent', 'default', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied'}); gtag('consent', 'update', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied'});(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-...');</script>",
// Google tag manager tag
"<!-- Google Tag Manager --><script>window.dataLayer = window.dataLayer || []; function gtag(){window.dataLayer.push(arguments);} gtag('consent', 'default', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied'}); gtag('consent', 'update', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied'});(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-...');</script>",
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
How else would it be able to pull stats like page views if the script isn’t being added to the site?
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
Through GTM it also fires the tag - my point is that you don't need the tag to fire, you need access to the info in GA.
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
Yeah. Makes me think you didn’t convert your key correctly. Did you paste the entire key as a string, with the BEGINNING and ENDING comments? Are you seeing activity on your google analytics dashboard ?
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
Yup, seeing data - but that's unrelated because it is done via GTM. Just gave it a try at generating a new key, and same error:
[ Server!] Error calculating daily stats: Error: 2 UNKNOWN: Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported
[ Server!] Error calculating daily stats: Error: 2 UNKNOWN: Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported
No description
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
checkout the top answer here https://stackoverflow.com/questions/74131595/error-error1e08010cdecoder-routinesunsupported-with-google-auth-library try logging the key on line 4 in the googleAnalyticsUtils (const PRIVATE_KEY = Buffer.from(process.env.GOOGLE_ANALYTICS_PRIVATE_KEY!, 'base64').toString('utf-8');) and comparing it to the key in your JSON file
Your code is failing because the client is being set up with bad credentials. Most likely a corrupted private key.
Vinny (@Wasp)
Vinny (@Wasp)β€’5mo ago
this looks like the solution you're looking for: https://github.com/orgs/vercel/discussions/219#discussioncomment-128702
GitHub
Google Cloud Keyfile.json Β· vercel Β· Discussion #219
I am trying to authenticate with Google Cloud via a Next API route. GCP needs the path to the key JSON file. Not the values in the file, but the actual file. So links to tutorials re: base64 and se...
Ricardo Batista
Ricardo BatistaOPβ€’5mo ago
Man, this is so weird - there must be some small thing I am missing. When I log the key I get exactly the same... Let me send you in private the keys, maybe you can find it Big thanks to @Vinny (@Wasp) for helping out! Got it now, there were three things: 1. I had to use const PRIVATE_KEY = JSON.parse(Buffer.from(process.env.GOOGLE_ANALYTICS_PRIVATE_KEY!, "base64").toString().replace(/\n/g,"")) as per this comment 2. I was encoding with single quotation marks, it should be echo -n ""-----BEGIN PRIVATE KEY---(...)"" | base64 3. I had to enable the Google Analytics Data API in Google Console Maybe you guys can include this in the documentation for future reference?
Want results from more Discord servers?
Add your server