Skip to content

Commit

Permalink
Merge pull request #427 from appwrite/feat-cloud-gtm
Browse files Browse the repository at this point in the history
feat-cloud-gtm
  • Loading branch information
TorstenDittmann authored May 2, 2023
2 parents a0e6b7e + 9bff6df commit 34f115d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 41 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@analytics/google-tag-manager": "^0.5.3",
"@appwrite.io/pink": "^0.0.4",
"@aw-labs/appwrite-console": "^13.1.0",
"@popperjs/core": "^2.11.6",
Expand Down
12 changes: 10 additions & 2 deletions src/lib/actions/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { page } from '$app/stores';
import { user } from '$lib/stores/user';
import { ENV, MODE, VARS } from '$lib/system';
import { ENV, MODE, VARS, isCloud } from '$lib/system';
import googleAnalytics from '@analytics/google-analytics';
import googleTagManager from '@analytics/google-tag-manager';
import { AppwriteException } from '@aw-labs/appwrite-console';
import Analytics from 'analytics';
import { get } from 'svelte/store';
Expand All @@ -11,7 +12,14 @@ const analytics = Analytics({
plugins: [
googleAnalytics({
measurementIds: [VARS.GOOGLE_ANALYTICS || 'G-R4YJ9JN8L4']
})
}),
...(isCloud
? [
googleTagManager({
containerId: [VARS.GOOGLE_TAG || 'GTM-P3T9TBV']
})
]
: [])
]
});

Expand Down
3 changes: 2 additions & 1 deletion src/lib/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const VARS = {
| undefined,
CONSOLE_MODE: import.meta.env?.VITE_CONSOLE_MODE?.toString() as string | undefined,
VERCEL_ENV: import.meta.env?.VITE_VERCEL_ENV?.toString() as string | undefined,
GOOGLE_ANALYTICS: import.meta.env?.VITE_GA_PROJECT?.toString() as string | undefined
GOOGLE_ANALYTICS: import.meta.env?.VITE_GA_PROJECT?.toString() as string | undefined,
GOOGLE_TAG: import.meta.env?.VITE_GTM_PROJECT?.toString() as string | undefined
};

export const ENV = {
Expand Down
76 changes: 38 additions & 38 deletions vite.config.ts.timestamp-1682949685828.mjs
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
// vite.config.ts
import { defineConfig } from "file:///home/thomas/Programming/Work/Appwrite/console/node_modules/vitest/dist/config.js";
import { sveltekit } from "file:///home/thomas/Programming/Work/Appwrite/console/node_modules/@sveltejs/kit/src/exports/vite/index.js";
import { defineConfig } from 'file:///home/thomas/Programming/Work/Appwrite/console/node_modules/vitest/dist/config.js';
import { sveltekit } from 'file:///home/thomas/Programming/Work/Appwrite/console/node_modules/@sveltejs/kit/src/exports/vite/index.js';
var config = defineConfig({
plugins: [sveltekit()],
optimizeDeps: {
include: ["echarts", "prismjs"]
},
ssr: {
noExternal: ["echarts", "prismjs", "@analytics/google-analytics", "analytics"]
},
define: {
"import.meta.env.VERCEL_ANALYTICS_ID": JSON.stringify(process.env.VERCEL_ANALYTICS_ID)
},
legacy: {
buildSsrCjsExternalHeuristics: true
},
server: {
port: 3e3
}
plugins: [sveltekit()],
optimizeDeps: {
include: ['echarts', 'prismjs']
},
ssr: {
noExternal: ['echarts', 'prismjs', '@analytics/google-analytics', 'analytics']
},
define: {
'import.meta.env.VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID)
},
legacy: {
buildSsrCjsExternalHeuristics: true
},
server: {
port: 3e3
}
});
var testConfig = defineConfig({
resolve: {
// hotfix for https://github.com/vitest-dev/vitest/issues/2834
conditions: ["browser"]
},
test: {
include: ["tests/unit/**/*.test.ts"],
environment: "jsdom",
globals: true,
threads: true,
setupFiles: ["./tests/unit/setup.ts"],
deps: {
inline: ["@analytics/type-utils"]
resolve: {
// hotfix for https://github.com/vitest-dev/vitest/issues/2834
conditions: ['browser']
},
test: {
include: ['tests/unit/**/*.test.ts'],
environment: 'jsdom',
globals: true,
threads: true,
setupFiles: ['./tests/unit/setup.ts'],
deps: {
inline: ['@analytics/type-utils']
}
}
}
});
var vite_config_default = process.env.VITEST ? {
...config,
...testConfig
} : config;
export {
vite_config_default as default
};
var vite_config_default = process.env.VITEST
? {
...config,
...testConfig
}
: config;
export { vite_config_default as default };
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvaG9tZS90aG9tYXMvUHJvZ3JhbW1pbmcvV29yay9BcHB3cml0ZS9jb25zb2xlXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvaG9tZS90aG9tYXMvUHJvZ3JhbW1pbmcvV29yay9BcHB3cml0ZS9jb25zb2xlL3ZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9ob21lL3Rob21hcy9Qcm9ncmFtbWluZy9Xb3JrL0FwcHdyaXRlL2NvbnNvbGUvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlc3QvY29uZmlnJztcbmltcG9ydCB7IHN2ZWx0ZWtpdCB9IGZyb20gJ0BzdmVsdGVqcy9raXQvdml0ZSc7XG5cbmNvbnN0IGNvbmZpZyA9IGRlZmluZUNvbmZpZyh7XG4gICAgcGx1Z2luczogW3N2ZWx0ZWtpdCgpXSxcbiAgICBvcHRpbWl6ZURlcHM6IHtcbiAgICAgICAgaW5jbHVkZTogWydlY2hhcnRzJywgJ3ByaXNtanMnXVxuICAgIH0sXG4gICAgc3NyOiB7XG4gICAgICAgIG5vRXh0ZXJuYWw6IFsnZWNoYXJ0cycsICdwc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