Skip to main content

Configuration reference

Snowtype reads its settings from a configuration file in your project root. The file is created when you run snowtype init, and you can edit it directly at any time.

Keep the configuration file in the root of your project, and include it in your version control system.

Terminology

We originally called tracking plans "data products". You'll still find the old term used in some existing APIs and CLI commands.

Configuration file structure

The configuration file is a JSON, JavaScript, or TypeScript object. You can choose format which to use during initialization. As JSON, it has the following structure:

jsonsnowtype.config.json
{
"organizationId": "a654321b-c111-33d3-e321-1f123456789g",
"tracker": "@snowplow/browser-tracker",
"language": "typescript",
"outpath": "./src/snowtype",
"eventSpecificationIds": [
"a123456b-c222-11d1-e123-1f123456789g"
],
"dataProductIds": [
"a123456b-c222-11d1-e123-1f12345678dp"
],
"dataStructures": [
"iglu:com.myorg/custom_web_page/jsonschema/1-1-0"
],
"igluCentralSchemas": [
"iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0"
],
"repositories": ["../data-structures"],
"namespace": "Snowtype",
"options": {
"commands": {
"generate": {
"instructions": true,
"validations": true,
"disallowDevSchemas": true
},
"update": {
"maximumBump": "minor",
"showOnlyProdUpdates": true
},
"patch": {
"regenerateOnPatch": false
}
}
}
}
PropertyTypeDescriptionRequired
organizationIdstringYour Snowplow account organization ID. Used to fetch tracking plans, event specifications, or data structures from Console. Not required if you're only generating code from a local repository.✅/❌
trackerstringThe Snowplow tracker to generate code for. This determines the structure of the generated code and which tracker it will work with.
languagestringThe programming language to generate code in.
outpathstringThe output path where Snowtype writes the generated code, relative to the current working directory when running the script.
dataProductIdsstring[]An array of tracking plan IDs to generate code for.
eventSpecificationIdsstring[]An array of event specification IDs to generate code for.
dataStructuresstring[]An array of schema URIs for data structures published in Console to generate code for.
igluCentralSchemasstring[]An array of schema URIs for Iglu Central schemas to generate code for.
repositoriesstring[]An array of paths to local Snowplow CLI schema repositories to generate code for.
namespacestringSwift tracker only: a namespace prefix for the generated code. For other trackers it will trigger an error.
optionsobjectAdditional settings related to Snowtype behavior. See details below.

To find your organization ID, go to Console > Settings > Manage organization.

File formats

Most of the examples in this documentation show the configuration file in JSON format, but you can also use JavaScript or TypeScript if you prefer. The filename must start with snowtype.config — for example, snowtype.config.json, snowtype.config.js, or snowtype.config.ts.

javascriptsnowtype.config.js
const config = {
"organizationId": "a654321b-c111-33d3-e321-1f123456789g",
"tracker": "@snowplow/browser-tracker",
"language": "typescript",
"outpath": "./src/snowtype",
"eventSpecificationIds": [
"a123456b-c222-11d1-e123-1f123456789g"
],
"dataProductIds": [
"a123456b-c222-11d1-e123-1f12345678dp"
],
"dataStructures": [
"iglu:com.myorg/custom_web_page/jsonschema/1-1-0"
],
"igluCentralSchemas": [
"iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0"
],
"repositories": ["../data-structures"],
"namespace": "Snowtype",
"options": {
"commands": {
"generate": {
"instructions": true,
"validations": true,
"disallowDevSchemas": true
},
"update": {
"maximumBump": "minor",
"showOnlyProdUpdates": true
},
"patch": {
"regenerateOnPatch": false
}
}
}
};

module.exports = config;

Supported trackers and languages

Set tracker and language to a valid combination from this table:

Trackertrackerlanguage
Browser@snowplow/browser-trackerjavascript, typescript
JavaScript@snowplow/javascript-trackerjavascript
iOSsnowplow-ios-trackerswift
Androidsnowplow-android-trackerkotlin
React Native@snowplow/react-native-trackertypescript
Fluttersnowplow-flutter-trackerdart
Node.js@snowplow/node-trackerjavascript, typescript
Gosnowplow-golang-trackergo
Javasnowplow-java-trackerjava
Google Tag Managergoogle-tag-managerjavascript-gtm

Command options

The options object configures the behavior of specific Snowtype commands. You can set these in the configuration file so they apply on every run, or override them with CLI flags. See the commands reference for more details on the flags.

Flag priority

CLI flags take precedence over values set in the configuration file.

generate

The generate options apply when running snowtype generate, which creates the initial code based on your configuration and schemas.

OptionTypeDefaultDescriptionEquivalent flag
instructionsbooleanfalseGenerate a Markdown file with implementation instructions for each event specification--instructions
validationsbooleanfalseInclude runtime client-side validation code in the output--validations
disallowDevSchemasbooleanfalseFail generation if any schema is only deployed to the development environment--disallowDevSchemas
deprecateOnlyOnProdAvailableUpdatesbooleanfalseOnly show deprecation warnings for schemas that have a newer version deployed to production--deprecateOnlyOnProdAvailableUpdates
jsonExample
{
"options": {
"commands": {
"generate": {
"instructions": true,
"validations": true,
"disallowDevSchemas": true
}
}
}
}

update

The update options apply when running snowtype update, which checks for new schema versions and regenerates code if needed.

OptionTypeDefaultDescription
regenerateOnUpdatebooleantrueAutomatically regenerate code after accepting updates.
maximumBump"major" | "minor" | "patch""major"The highest SchemaVer bump level to include in update checks. For example, setting this to "minor" hides major version updates.
showOnlyProdUpdatesbooleanfalseOnly show updates for data structures that have been deployed to the production environment.
jsonExample
{
"options": {
"commands": {
"update": {
"maximumBump": "minor",
"showOnlyProdUpdates": true
}
}
}
}

patch

The patch option applies when running snowtype patch, which adds new sources to your configuration file and optionally regenerates code.

OptionTypeDefaultDescription
regenerateOnPatchbooleantrueAutomatically regenerate code after adding new schemas with snowtype patch.
jsonExample
{
"options": {
"commands": {
"patch": {
"regenerateOnPatch": false
}
}
}
}

Swift namespace

The namespace option applies only when generating Swift code. It adds a prefix to all generated classes, which helps avoid naming conflicts in your project.

For example, setting namespace to "Snowtype":

jsonsnowtype.config.json
{
"tracker": "snowplow-ios-tracker",
"language": "swift",
"outpath": "./Sources/Tracking",
"namespace": "Snowtype"
}

This results in classes accessed with the Snowtype prefix:

swift
let data = Snowtype.AccountConfirmed(
companyCountry: "US",
companyName: "Acme Corp"
)

Setting a namespace when generating code for a non-Swift tracker will trigger an error.

Full configuration type

For TypeScript users, this is the complete type definition for the configuration file:

typescript
type SnowtypeConfig = {
tracker:
| "@snowplow/browser-tracker"
| "@snowplow/javascript-tracker"
| "@snowplow/node-tracker"
| "@snowplow/react-native-tracker"
| "snowplow-android-tracker"
| "snowplow-ios-tracker"
| "snowplow-golang-tracker"
| "snowplow-flutter-tracker"
| "snowplow-java-tracker";
language:
| "typescript"
| "javascript"
| "kotlin"
| "swift"
| "go"
| "dart"
| "java";
outpath: string;
organizationId?: string;
eventSpecificationIds?: string[];
dataProductIds?: string[];
dataStructures?: string[];
igluCentralSchemas?: string[];
repositories?: string[];
namespace?: string;
options?: {
commands: {
generate?: {
instructions?: boolean;
validations?: boolean;
disallowDevSchemas?: boolean;
deprecateOnlyOnProdAvailableUpdates?: boolean;
};
update?: {
regenerateOnUpdate?: boolean;
maximumBump?: "major" | "minor" | "patch";
showOnlyProdUpdates?: boolean;
};
patch?: {
regenerateOnPatch?: boolean;
};
};
};
};