{"id":19944394,"url":"https://github.com/dataform-co/dataform-segment","last_synced_at":"2025-05-03T16:31:03.701Z","repository":{"id":38301892,"uuid":"229254840","full_name":"dataform-co/dataform-segment","owner":"dataform-co","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-11T07:01:18.000Z","size":98,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T18:11:10.980Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dataform-co.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-20T11:44:27.000Z","updated_at":"2022-06-07T15:54:44.000Z","dependencies_parsed_at":"2024-11-13T00:20:47.257Z","dependency_job_id":"26929e3b-5e7b-4195-8f06-aa402fbbd949","html_url":"https://github.com/dataform-co/dataform-segment","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataform-co%2Fdataform-segment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataform-co%2Fdataform-segment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataform-co%2Fdataform-segment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataform-co%2Fdataform-segment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataform-co","download_url":"https://codeload.github.com/dataform-co/dataform-segment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252216085,"owners_count":21713096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-11-13T00:20:30.462Z","updated_at":"2025-05-03T16:31:03.361Z","avatar_url":"https://github.com/dataform-co.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Common data models for segment data such as `sessions` and a user roll up table built from `identifies`.\n\n## Supported warehouses\n\n- BigQuery\n- Redshift (Beta)\n- Postgres (Beta)\n\n*If you would like us to add support for another warehouse, please get in touch via [email](mailto:team@dataform.co) or [Slack](https://dataform.co/slack)*\n\n## Installation\n\nAdd the package to your `package.json` file in your Dataform project. You can find the most up to package version on the [releases page](https://github.com/dataform-co/dataform-segment/releases).\n\n## Configure the package\n\nCreate a new JS file in your `definitions/` folder and create the segment tables with the following example:\n\n```js\nconst segment = require(\"dataform-segment\");\n\nsegment({\n  // The name of your segment schema.\n  segmentSchema: \"javascript\",\n  // The timeout for splitting sessions in milliseconds.\n  sessionTimeoutMillis: 30 * 60 * 1000,\n  // Default configuration applied to all produced datasets.\n  defaultConfig: {\n    schema: \"dataform_segment\",\n    tags: [\"segment\"],\n    type: \"view\"\n  },\n  // list of custom fields to extract from the pages table\n  customPageFields: [\"url_hash\", \"category\"],\n  // list of custom fields to extract from the identifies table\n  customUserFields: [\"email\", \"name\", \"company_name\", \"created_at\"],\n  // list of custom fields to extract from the tracks table\n  customerTrackFields: [\"browser_type\"],\n  // choose which of tracks, pages and screens to include in the sessionization model\n  includeTracks: true,\n  includePages: true,\n  includeScreens: false,\n});\n```\n\nFor more advanced uses cases, see the [example.js](https://github.com/dataform-co/dataform-segment/blob/master/definitions/example.js).\n\n## Data models\n\nThis primary outputs of this package are the following data models (configurable as tables or views).\n\n### `segment_sessions`\n\nContains a combined view of tracks, pages and screens from segment. Each session is a period of sustained activity, with a new session starting after a 30min+ period of inactivity. Each session contains a repeated field of records which are either tracks or pages. Common fields are extracted out into the top level and type specific fields are kept within two structs: `records.track` and `records.page`.\n\n - To create a web-only sessions table, use `includeTracks: true, includePages: true, includeScreens: false`\n - To create an app-only sessions table, use `includeTracks: true, includePages: false, includeScreens: true`\n - To create a cross-platform sessions table, use `includeTracks: true, includePages: true, includeScreens: true`\n\n_At least one of inicludeTracks, includePages, or inclueScreens must be set as true_\n\n### `segment_users`\n\nAggregates all identifies calls to give a table with one row per user_id. Identify calls with only an anonymous_id are mapped to the matching user_id where possible.\n\n![](https://dataform.sirv.com/dataform-segment-dag-4.png?profile=WebP)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataform-co%2Fdataform-segment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataform-co%2Fdataform-segment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataform-co%2Fdataform-segment/lists"}