feat: Add GA integration, support for GA4 (#4626)

* GA integration settings

* trackingId -> measurementId
Hook up script

* Public page GA tracking
Correct layout of settings

* Remove multiple codepaths for loading GA measurementID, add missing db index

* Remove unneccessary changes, tsc

* test
This commit is contained in:
Tom Moor
2023-01-01 15:29:08 +00:00
committed by GitHub
parent dc795604a4
commit 8e4270c321
29 changed files with 374 additions and 114 deletions

View File

@@ -220,20 +220,6 @@
"Are you sure you want to make {{ userName }} a member?": "Are you sure you want to make {{ userName }} a member?",
"Are you sure you want to make {{ userName }} an admin? Admins can modify team and billing information.": "Are you sure you want to make {{ userName }} an admin? Admins can modify team and billing information.",
"Are you sure you want to suspend {{ userName }}? Suspended users will be prevented from logging in.": "Are you sure you want to suspend {{ userName }}? Suspended users will be prevented from logging in.",
"Account": "Account",
"Notifications": "Notifications",
"API Tokens": "API Tokens",
"Details": "Details",
"Team": "Team",
"Security": "Security",
"Features": "Features",
"Members": "Members",
"Groups": "Groups",
"Shared Links": "Shared Links",
"Import": "Import",
"Webhooks": "Webhooks",
"Integrations": "Integrations",
"Self Hosted": "Self Hosted",
"Insert column after": "Insert column after",
"Insert column before": "Insert column before",
"Insert row after": "Insert row after",
@@ -303,6 +289,21 @@
"Current time": "Current time",
"Current date and time": "Current date and time",
"Could not import file": "Could not import file",
"Account": "Account",
"Notifications": "Notifications",
"API Tokens": "API Tokens",
"Details": "Details",
"Team": "Team",
"Security": "Security",
"Features": "Features",
"Members": "Members",
"Groups": "Groups",
"Shared Links": "Shared Links",
"Import": "Import",
"Webhooks": "Webhooks",
"Integrations": "Integrations",
"Self Hosted": "Self Hosted",
"Google Analytics": "Google Analytics",
"Show path to document": "Show path to document",
"Path to document": "Path to document",
"Group member options": "Group member options",
@@ -702,6 +703,9 @@
"When enabled documents are always editable for team members that have permission. When disabled there is a separate editing view.": "When enabled documents are always editable for team members that have permission. When disabled there is a separate editing view.",
"Public branding": "Public branding",
"Show your teams logo on public pages like login and shared documents.": "Show your teams logo on public pages like login and shared documents.",
"Add a Google Analytics 4 measurement ID to send document views and analytics from the workspace to your own Google Analytics account.": "Add a Google Analytics 4 measurement ID to send document views and analytics from the workspace to your own Google Analytics account.",
"Measurement ID": "Measurement ID",
"Create a \"Web\" stream in your Google Analytics admin dashboard and copy the measurement ID from the generated code snippet to install.": "Create a \"Web\" stream in your Google Analytics admin dashboard and copy the measurement ID from the generated code snippet to install.",
"New group": "New group",
"Groups can be used to organize and manage the people on your team.": "Groups can be used to organize and manage the people on your team.",
"All groups": "All groups",
@@ -774,8 +778,8 @@
"Links to supported services are shown as rich embeds within your documents": "Links to supported services are shown as rich embeds within your documents",
"Collection creation": "Collection creation",
"Allow members to create new collections within the knowledge base": "Allow members to create new collections within the knowledge base",
"Add your self-hosted draw.io installation url here to enable automatic embedding of diagrams within documents.": "Add your self-hosted draw.io installation url here to enable automatic embedding of diagrams within documents.",
"Draw.io deployment": "Draw.io deployment",
"Add your self-hosted draw.io installation url here to enable automatic embedding of diagrams within documents.": "Add your self-hosted draw.io installation url here to enable automatic embedding of diagrams within documents.",
"Sharing is currently disabled.": "Sharing is currently disabled.",
"You can globally enable and disable public document sharing in the <em>security settings</em>.": "You can globally enable and disable public document sharing in the <em>security settings</em>.",
"Documents that have been shared are listed below. Anyone that has the public link can access a read-only version of the document until the link has been revoked.": "Documents that have been shared are listed below. Anyone that has the public link can access a read-only version of the document until the link has been revoked.",

View File

@@ -52,6 +52,10 @@ export type PublicEnv = {
DEFAULT_LANGUAGE: string;
GOOGLE_ANALYTICS_ID: string | undefined;
RELEASE: string | undefined;
analytics: {
service?: IntegrationService;
settings?: IntegrationSettings<IntegrationType.Analytics>;
};
};
export enum AttachmentPreset {
@@ -64,6 +68,13 @@ export enum IntegrationType {
Post = "post",
Command = "command",
Embed = "embed",
Analytics = "analytics",
}
export enum IntegrationService {
Diagrams = "diagrams",
Slack = "slack",
GoogleAnalytics = "google-analytics",
}
export enum CollectionPermission {
@@ -73,6 +84,8 @@ export enum CollectionPermission {
export type IntegrationSettings<T> = T extends IntegrationType.Embed
? { url: string }
: T extends IntegrationType.Analytics
? { measurementId: string }
: T extends IntegrationType.Post
? { url: string; channel: string; channelId: string }
: T extends IntegrationType.Post
@@ -80,7 +93,8 @@ export type IntegrationSettings<T> = T extends IntegrationType.Embed
:
| { url: string }
| { url: string; channel: string; channelId: string }
| { serviceTeamId: string };
| { serviceTeamId: string }
| { measurementId: string };
export enum UserPreference {
/** Whether reopening the app should redirect to the last viewed document. */