Skip to content

Instantly share code, notes, and snippets.

@brandonmp
Created November 18, 2018 02:27
Show Gist options
  • Save brandonmp/c8597bf7b48d308d57c19aaa32bfa8f6 to your computer and use it in GitHub Desktop.
Save brandonmp/c8597bf7b48d308d57c19aaa32bfa8f6 to your computer and use it in GitHub Desktop.
retrieve schema from Segment dashboard
/*
When logged into Segment dashboard and looking at event schema for source, open dev tools and go to Apollo Dev Tools (chrome extension).
In GraphiQL run this query:
query getSourceData($workspaceSlug: String!, $sourceSlug: String!) {
me {
isAdmin
id
__typename
}
workspace(slug: $workspaceSlug) {
source(slug: $sourceSlug) {
id
warehouseSchema{
collection
properties{
key
enabled
}
}
}
}
}
where variables =
{
"workspaceSlug": "your-workspace-slug",
"sourceSlug": "the-source-name" // eg 'javascript'
}
From the results, store data.workspace.source.warehouseSchema in a variable in the Chrome Console
Then run this (where d is the var you kept the data in)
*/
copy(
d
.map(r => r.properties.map(p => [r.collection, p.key]))
.reduce((prev, acc) => [...(prev || []), ...acc], [])
.map(a => a.join("\t"))
.join("\n")
);
// copies a TSV format where event name is first col and prop name is second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment