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

custom segment write key #4238

Merged
merged 7 commits into from
Aug 8, 2024
Merged
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
30 changes: 15 additions & 15 deletions .pnp.cjs

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

Binary file not shown.
4 changes: 4 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ navigation:
- page: ReadMe
slug: readme
path: ./pages/docs/comparison/readme.mdx
- section: Analytics
contents:
- page: Segment
path: ./pages/docs/analytics/segment.mdx
- tab: cli-api
layout:
- section: CLI Reference
Expand Down
33 changes: 33 additions & 0 deletions fern/pages/docs/analytics/segment.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Segment
description: Learn how to integrate Fern Docs with Segment to track user behavior and analytics.
---

<Note>
Currently we only support Segment via a custom writeKey in the docs.yml file, however you can add other providers to your docs page through [Custom Javascript](/learn/docs/building-your-docs/custom-css-js).
We are also working on adding support for additional analytics tools via the docs.yml file analytics block!
</Note>

## Add Segment to your Docs

To add Segment to your Docs, you need to add the Segment writeKey to your `docs.yml` file.

### Get your Segment writeKey

1. Log in to your Segment account.
2. Go to the workspace where you want to add the Docs integration.
3. Click on the Source you want to track.'
4. Click on the `Settings` tab.
5. Copy the `Write Key` from the `API Keys` section.

### Add the Segment writeKey to your Docs

In your `docs.yml` file, add the Segment writeKey:

<CodeBlock title="docs.yml">
```yaml
analytics:
segment:
write-key: YOUR_SEGMENT_WRITE_KEY
```
</CodeBlock>
13 changes: 13 additions & 0 deletions packages/cli/configuration/fern/definition/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,26 @@ types:
- jvm
- ts
- js

AnalyticsConfig:
properties:
segment: optional<SegmentConfig>

SegmentConfig:
properties:
write-key: string

DocsConfiguration:
properties:
instances: list<DocsInstance>
title:
type: optional<string>
docs: used as tab bar title, and in the navbar if no logo is defined
analytics:
type: optional<AnalyticsConfig>
docs: |
The `analytics` object allows you to configure analytics for your docs site.
Currently, only Segment is supported.

# navigation
tabs: optional<map<TabId, TabConfig>>
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-fern/fiddle-sdk": "0.0.584",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface ParsedDocsConfiguration {
typography: TypographyConfig | undefined;
layout: WithoutQuestionMarks<DocsV1Write.DocsLayoutConfig> | undefined;
defaultLanguage: DocsV1Write.ProgrammingLanguage | undefined;
analyticsConfig: DocsV1Write.AnalyticsConfig | undefined;

/* integrations */
integrations: DocsV1Write.IntegrationsConfig | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function parseDocsConfiguration({
colors,
typography: rawTypography,
layout,

analytics: analyticsConfig,
/* integrations */
integrations,

Expand Down Expand Up @@ -142,6 +142,7 @@ export async function parseDocsConfiguration({
colors: convertColorsConfiguration(colors, context),
typography,
layout: convertLayoutConfig(layout),
analyticsConfig: rawDocsConfiguration.analytics,

/* integrations */
integrations,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FernDocsConfig from "../../..";

export interface AnalyticsConfig {
segment?: FernDocsConfig.SegmentConfig;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export interface DocsConfiguration {
instances: FernDocsConfig.DocsInstance[];
/** used as tab bar title, and in the navbar if no logo is defined */
title?: string;
/**
* The `analytics` object allows you to configure analytics for your docs site.
* Currently, only Segment is supported.
*/
analytics?: FernDocsConfig.AnalyticsConfig;
tabs?: Record<FernDocsConfig.TabId, FernDocsConfig.TabConfig>;
versions?: FernDocsConfig.VersionConfig[];
landingPage?: FernDocsConfig.PageConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface SegmentConfig {
writeKey: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from "./ProgrammingLanguage";
export * from "./AnalyticsConfig";
export * from "./SegmentConfig";
export * from "./DocsConfiguration";
export * from "./TabId";
export * from "./TabConfig";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../..";
import * as FernDocsConfig from "../../../../api";
import * as core from "../../../../core";

export const AnalyticsConfig: core.serialization.ObjectSchema<
serializers.AnalyticsConfig.Raw,
FernDocsConfig.AnalyticsConfig
> = core.serialization.object({
segment: core.serialization.lazyObject(async () => (await import("../../..")).SegmentConfig).optional(),
});

export declare namespace AnalyticsConfig {
interface Raw {
segment?: serializers.SegmentConfig.Raw | null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const DocsConfiguration: core.serialization.ObjectSchema<
core.serialization.lazyObject(async () => (await import("../../..")).DocsInstance)
),
title: core.serialization.string().optional(),
analytics: core.serialization.lazyObject(async () => (await import("../../..")).AnalyticsConfig).optional(),
tabs: core.serialization
.record(
core.serialization.lazy(async () => (await import("../../..")).TabId),
Expand Down Expand Up @@ -63,6 +64,7 @@ export declare namespace DocsConfiguration {
interface Raw {
instances: serializers.DocsInstance.Raw[];
title?: string | null;
analytics?: serializers.AnalyticsConfig.Raw | null;
tabs?: Record<serializers.TabId.Raw, serializers.TabConfig.Raw> | null;
versions?: serializers.VersionConfig.Raw[] | null;
"landing-page"?: serializers.PageConfiguration.Raw | null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../..";
import * as FernDocsConfig from "../../../../api";
import * as core from "../../../../core";

export const SegmentConfig: core.serialization.ObjectSchema<
serializers.SegmentConfig.Raw,
FernDocsConfig.SegmentConfig
> = core.serialization.object({
writeKey: core.serialization.property("write-key", core.serialization.string()),
});

export declare namespace SegmentConfig {
interface Raw {
"write-key": string;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from "./ProgrammingLanguage";
export * from "./AnalyticsConfig";
export * from "./SegmentConfig";
export * from "./DocsConfiguration";
export * from "./TabId";
export * from "./TabConfig";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-markdown-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"gray-matter": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/docs-resolver": "workspace:*",
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-sdk": "workspace:*",
"@fern-api/logger": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@fern-api/configuration": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-markdown-utils": "workspace:*",
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-generator": "workspace:*",
"@fern-api/ir-sdk": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-resolver/src/DocsDefinitionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class DocsDefinitionResolver {
integrations: this.parsedDocsConfig.integrations,
footerLinks: this.parsedDocsConfig.footerLinks,
defaultLanguage: this.parsedDocsConfig.defaultLanguage,

analyticsConfig: this.parsedDocsConfig.analyticsConfig,
// deprecated
logo: undefined,
logoV2: undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/ete-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/configuration": "workspace:*",
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/logging-execa": "workspace:*",
"@fern-typescript/fetcher": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fern-api/core": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-resolver": "workspace:*",
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-generator": "workspace:*",
"@fern-api/ir-migrations": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/register/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@fern-api/configuration": "workspace:*",
"@fern-api/core": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/ir-generator": "workspace:*",
"@fern-api/ir-sdk": "workspace:*",
"@fern-api/task-context": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-api/fdr-sdk": "0.98.18-aaf13f7f5",
"@fern-api/fdr-sdk": "0.98.18-ff8e48d2c",
"@fern-api/venus-api-sdk": "0.0.38",
"@fern-fern/fdr-test-sdk": "^0.0.5297",
"@fern-fern/fiddle-sdk": "0.0.584"
Expand Down
Loading
Loading