Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add Telemetery #212

Draft
wants to merge 3 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ NEXT_PUBLIC_UNSPLASH_TMP_LOCAL_CLIENT_ID=<your-key>
NEXT_PUBLIC_PUSHER_APP_KEY=<your-pusher-app-key>
NEXT_PUBLIC_PUSHER_APP_CLUSTER=<your-pusher-cluster-name>
NEXT_PUBLIC_CORS_GRIDA_API_KEY=get-it-from-https://github.com/gridaco/base/issues/23
NEXT_PUBLIC_SEGMENT_WRITE_KEY=<your-segment-write-key>
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "next start -p 3303"
},
"dependencies": {
"@segment/snippet": "^4.15.3",
"app": "0.0.1",
"languagedetect": "^2.0.0",
"next": "^13.1.6",
Expand Down
23 changes: 22 additions & 1 deletion web/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import React, { useEffect } from "react";
import type { AppProps } from "next/app";
import { useRouter } from "next/router";
import Script from "next/script";
import * as snippet from "@segment/snippet";
import * as gtag from "../lib/gtag";

function WebApp({ Component, pageProps }: AppProps) {
const loadSegment = () => {
const options = {
apiKey: process.env.NEXT_PUBLIC_SEGMENT_WRITE_KEY,
};
if (process.env.NEXT_PUBLIC_NODE_ENV) {
return snippet.max(options);
} else {
return snippet.min(options);
}
};

// region GA
const router = useRouter();
useEffect(() => {
Expand All @@ -17,6 +30,14 @@ function WebApp({ Component, pageProps }: AppProps) {
}, [router.events]);
// endregion GA

return <Component {...pageProps} />;
return (
<>
<Script
dangerouslySetInnerHTML={{ __html: loadSegment() }}
id="segment-snippet"
/>
<Component {...pageProps} />;
</>
);
}
export default WebApp;
26 changes: 26 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2530,6 +2530,25 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@ndhoule/each@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@ndhoule/each/-/each-2.0.1.tgz#bbed372a603e0713a3193c706a73ddebc5b426a9"
integrity sha512-wHuJw6x+rF6Q9Skgra++KccjBozCr9ymtna0FhxmV/8xT/hZ2ExGYR8SV8prg8x4AH/7mzDYErNGIVHuzHeybw==
dependencies:
"@ndhoule/keys" "^2.0.0"

"@ndhoule/keys@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@ndhoule/keys/-/keys-2.0.0.tgz#3d64ae677c65a261747bf3a457c62eb292a4e0ce"
integrity sha512-vtCqKBC1Av6dsBA8xpAO+cgk051nfaI+PnmTZep2Px0vYrDvpUmLxv7z40COlWH5yCpu3gzNhepk+02yiQiZNw==

"@ndhoule/map@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@ndhoule/map/-/map-2.0.1.tgz#f5ca0a47424ea67f46e2a6d499b9e9bc886aefa8"
integrity sha512-WOEf2An9mL4DVY6NHgaRmFC82pZGrmzW4I0hpPPdczDP4Gp5+Q1Nny77x3w0qzENA8+cbgd9+Lx2ClSTLvkB0g==
dependencies:
"@ndhoule/each" "^2.0.1"

"@next/[email protected]":
version "13.2.4"
resolved "https://registry.yarnpkg.com/@next/env/-/env-13.2.4.tgz#8b763700262b2445140a44a8c8d088cef676dbae"
Expand Down Expand Up @@ -3334,6 +3353,13 @@
dependencies:
"@daybrush/utils" "^1.4.0"

"@segment/snippet@^4.15.3":
version "4.15.3"
resolved "https://registry.yarnpkg.com/@segment/snippet/-/snippet-4.15.3.tgz#ac829ec4570b249f559756293f4736e434885de7"
integrity sha512-75kVTYaQGYMkwVjJvCLLOlzxV8jCDxvKG68U88joo/rBx95SIXETcjUmIXF6A7SFRCgz83B+zrZbo+JYsmHkig==
dependencies:
"@ndhoule/map" "^2.0.1"

"@sinclair/typebox@^0.25.16":
version "0.25.24"
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.24.tgz#8c7688559979f7079aacaf31aa881c3aa410b718"
Expand Down