Skip to content

Commit

Permalink
Add initial codegen documentation (#696)
Browse files Browse the repository at this point in the history
* Add initial codegen documentation

* Add example usage TypeScript

* Add example usage for mobile

* Add example usage for Go

* Remove brew for now and add discourse help title

---------

Co-authored-by: Miranda Wilson <miranda@snowplowanalytics.com>
Co-authored-by: adatzer <ada@snowplowanalytics.com>
  • Loading branch information
3 people authored Jan 11, 2024
1 parent 8f37e85 commit 65bfb67
Show file tree
Hide file tree
Showing 9 changed files with 437 additions and 0 deletions.
54 changes: 54 additions & 0 deletions docs/collecting-data/code-generation/commands/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: "Commands"
sidebar_position: 4
---

:::info
This page only summarizes the CLI commands and the options for each command. For details on which scenarios they can be used, you can go to the [Working with the CLI page](../using-the-cli/index.md).
:::

## Usage

`snowtype [COMMAND] [OPTIONS] [CONTEXT-SPECIFIC-OPTIONS]`

## Available CLI commands

### `snowtype init`

Initialize the setup of Snowtype code generation in a project. Creates the `snowtype.config.json` file.

**Options**
- `-i, --organizationId` Organization ID.
- `-t, --tracker` Tracker to use. [See available](../using-the-cli/index.md#available-trackerslanguages)
- `-l, --language` Language to use. [See available](../using-the-cli/index.md#available-trackerslanguages)
- `-o, --outpath` Output path.

### `snowtype generate`

Generates tracking code based on configuration on the `snowtype.config.json` file. Can generate/modify the `.snowtype-lock.json` file.

### `snowtype update`

Checks for latest version updates in Data Structures and Tracking Scenarios.

**Options**
- `-y, --yes` Updates all to latest version without prompting. (default: false)

### `snowtype patch`

Adds new Data Structures and Tracking Scenarios in the `snowtype.config.json` file without needing to modify the file by hand.

**Options**
- `-t, --trackingScenarioIds` Tracking Scenario ID/s.
- `-d, --dataStructures` Data structure schema URI/s.
- `-i, --igluCentralSchemas` Iglu central schema URI/s.

### `snowtype help`

Shows a helpful message and brief instructions for the Snowtype CLI usage.

### Global options
- `-h, --help` Shows helpful instructions for the command.
- `-V, --version` Output the package version number.
- `-k, --apiKey` Provide the Snowplow Console API key as a CLI option.
- `-v, --verbose` Enable verbose logging.
19 changes: 19 additions & 0 deletions docs/collecting-data/code-generation/getting-started/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "Getting started with the Snowtype CLI"
sidebar_position: 1
---

## Introduction to the Snowtype CLI

Snowtype is a command-line interface that assists developers in implementing custom Snowplow tracking faster, more accurately and more intuitively. Since Snowplow events are always bound to a schema to ensure data quality, we can use this feature to enable type-checking, provide inline documentation and reduce time writing custom code. All that integrated into **your development workflow**.

## Installation

The Snowtype CLI is distributed through `npm` and soon `brew`. You can choose either one depending on your needs.

```sh
npm install @snowplow/snowtype --save-dev
```

_We will show example commands using `npm` but it should work the same with either system._

21 changes: 21 additions & 0 deletions docs/collecting-data/code-generation/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "Code Generation - automatically generate code for Snowplow tracking SDKs"
sidebar_position: 0
sidebar_label: "Code Generation"
---

:::info
This documentation only applies to [Snowplow BDP](https://snowplow.io/snowplow-bdp/). See the [feature comparison](/docs/feature-comparison/index.md) page for more information about the different Snowplow offerings.
:::

Snowplow has created tooling around assisting development efforts on instrumenting, verifying and maintaining tracking code that works with Snowplow tracking SDKs. This is the `Snowtype CLI`.

```mdx-code-block
import DocCardList from '@theme/DocCardList';
<DocCardList />
```

## Getting help or giving feedback

If you run into any problems, have any questions or want to request a new feature please do sign up on [discourse](https://discourse.snowplow.io/) and add your topic.
53 changes: 53 additions & 0 deletions docs/collecting-data/code-generation/snowtype-config/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "Snowtype configuration options"
sidebar_position: 3
---

The Snowtype CLI configuration will be saved in a`snowtype.config.json` file after initialization. **We highly recommend you keep this file in the root of your project folder.**

## Attributes in `snowtype.config.json`

### `igluCentralSchemas`

The schema tracking URLs for schemas available in [Iglu Central](http://iglucentral.com/).

### `dataStructures`

The schema tracking URLs for Data Structures published in the Console.

### `trackingScenarioIds`

The Tracking Scenario IDs you wish to generate tracking code for. The Tracking Scenario ID is a UUID that can be retrieved as the final part of the URL when visiting a tracking scenario main page.

### `organizationId`

The Organization ID for your Snowplow BDP account. The Organization ID is a UUID that can be retrieved from the URL immediately following the .com when visiting console.

### `tracker`

The target tracker to generate the required code for. [See list of available trackers](../using-the-cli/index.md#available-trackerslanguages).

### `language`

The target language to generate the required code for. [See list of available languages](../using-the-cli/index.md#available-trackerslanguages).

### `outpath`

The outpath relative to the current working directory when running the script.


## Example configuration file

```json
{
"igluCentralSchemas": ["iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0"],
"dataStructures": ["iglu:com.myorg/custom_web_page/jsonschema/1-1-0"],
"trackingScenarioIds": [
"a123456b-c222-11d1-e123-1f123456789g"
],
"organizationId": "a654321b-c111-33d3-e321-1f123456789g",
"tracker": "@snowplow/browser-tracker",
"language": "typescript",
"outpath": "./src/snowtype"
}
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 65bfb67

Please sign in to comment.