-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
29 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
'use server'; | ||
|
||
import { makeEventTracker } from '@codaco/analytics'; | ||
import { cache } from 'react'; | ||
import { api } from '~/trpc/server'; | ||
import { getBaseUrl } from '~/trpc/shared'; | ||
import { env } from '~/env.mjs'; | ||
import { getAppSettings } from '~/server/routers/appSettings'; | ||
|
||
export const getInstallationId = cache(async () => { | ||
const installationId = await api.appSettings.getInstallationId.query(); | ||
|
||
if (installationId) { | ||
return installationId; | ||
} | ||
const appSettings = await getAppSettings(); | ||
|
||
return 'Unknown'; | ||
return appSettings?.installationId ?? 'Unknown'; | ||
}); | ||
|
||
// eslint-disable-next-line no-process-env | ||
const globalAnalyticsEnabled = process.env.NEXT_PUBLIC_ANALYTICS_ENABLED; | ||
|
||
export const trackEvent = | ||
globalAnalyticsEnabled !== 'false' | ||
? makeEventTracker({ | ||
endpoint: getBaseUrl() + '/api/analytics', | ||
}) | ||
: () => {}; | ||
export const trackEvent = !env.DISABLE_ANALYTICS | ||
? makeEventTracker() | ||
: () => null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.