{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Products","product_name":"Integration Hub","type":"markdown"},"seo":{"title":"Migrating to TD JS SDK 4 0","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"migrating-to-td-js-sdk-4-0","__idx":0},"children":["Migrating to TD JS SDK 4 0"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To migrate your application to JS SDK 4.0:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Update the host configuration in your JavaScript snippet with the new ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["records.in"]}," base URL."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, US developers will configure the ingest endpoint to \"",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://us01.records.in.treasuredata.com"},"children":["https://us01.records.in.treasuredata.com"]},"\". For a list of new ingest endpoints by region, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/apis/endpoints/endpoints"},"children":["Treasure Data Sites and baseURLs"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"    var foo = new Treasure({  \n      database: 'your_database',  \n      writeKey: 'your_write_only_key',  \n      // Remove old ingest endpoint  \n      // host: 'in.treasuredata.com'  \n      host: 'us01.records.in.treasuredata.com'  \n    });  \n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":2},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["(Optional) Write SQL to get values for td_browser, td_browser_version,td_os, and td_os_version from td_user_agent."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT   \n  td_user_agent,  \n  TD_PARSE_USER_AGENT(td_user_agent, 'os_family') AS td_os  \n  ,TD_PARSE_USER_AGENT(td_user_agent, 'os_major') AS td_os_version_major  \n  ,TD_PARSE_USER_AGENT(td_user_agent, 'os_minor') AS td_os_version_minor  \n  ,TD_PARSE_USER_AGENT(td_user_agent, 'ua_family') AS td_browser  \n  ,TD_PARSE_USER_AGENT(td_user_agent, 'ua_major') AS td_browser_version_major  \n  ,TD_PARSE_USER_AGENT(td_user_agent, 'ua_minor') AS td_browser_version_minor  \nFROM  \n  pageview;  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/img0001.82336ede1a4f735b47694aa5033bcde7398be4d114d20b8078002823d0fd1b7b.ef656343.png","alt":""},"children":[]}]}]},"headings":[{"value":"Migrating to TD JS SDK 4 0","id":"migrating-to-td-js-sdk-4-0","depth":1}],"frontmatter":{"seo":{"title":"Migrating to TD JS SDK 4 0"}},"lastModified":"2026-03-10T06:52:05.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/migrating-to-td-js-sdk-4-0","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}