Skip to content

Commit 73262a8

Browse files
authored
release-4.3.0 (#300)
1 parent 5c9097f commit 73262a8

7 files changed

Lines changed: 77 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

3-
## 4.1.0 (2025-03-26)
3+
## 4.3.0 (2025-05-22)
4+
* Add a new `fetchPersonalization` API
5+
6+
## 4.2.0 (2025-03-26)
47
* Don't create _td_domain_* cookie
58

69

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Install td-js-sdk on your page by copying the appropriate JavaScript snippet bel
6464

6565
```html
6666
<script type="text/javascript">
67-
!function(t,e){if(void 0===e[t]){e[t]=function(){e[t].clients.push(this),this._init=[Array.prototype.slice.call(arguments)]},e[t].clients=[];for(var r=function(t){return function(){return this["_"+t]=this["_"+t]||[],this["_"+t].push(Array.prototype.slice.call(arguments)),this}},s=["collectTags","addRecord","blockEvents","fetchServerCookie","fetchGlobalID","fetchUserSegments","resetUUID","ready","setSignedMode","setAnonymousMode","set","trackEvent","trackPageview","trackClicks","unblockEvents"],c=0;c<s.length;c++){var o=s[c];e[t].prototype[o]=r(o)}var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.treasuredata.com/sdk/4.2/td.min.js";var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(n,i)}}("Treasure",this);
67+
!function(t,e){if(void 0===e[t]){e[t]=function(){e[t].clients.push(this),this._init=[Array.prototype.slice.call(arguments)]},e[t].clients=[];for(var r=function(t){return function(){return this["_"+t]=this["_"+t]||[],this["_"+t].push(Array.prototype.slice.call(arguments)),this}},s=["collectTags","addRecord","blockEvents","fetchServerCookie","fetchGlobalID","fetchUserSegments","fetchPersonalization","resetUUID","ready","setSignedMode","setAnonymousMode","set","trackEvent","trackPageview","trackClicks","unblockEvents"],c=0;c<s.length;c++){var o=s[c];e[t].prototype[o]=r(o)}var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.treasuredata.com/sdk/4.3/td.min.js";var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(n,i)}}("Treasure",this);
6868
</script>
6969
```
7070

dist/td.js

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,7 @@
27952795

27962796
var config$1 = {
27972797
GLOBAL: 'Treasure',
2798-
VERSION: '4.2.0',
2798+
VERSION: '4.3.0',
27992799
HOST: 'in.treasuredata.com',
28002800
DATABASE: '',
28012801
PATHNAME: '/'
@@ -3419,9 +3419,72 @@
34193419
}
34203420
}).then(successCallback).catch(errorCallback);
34213421
}
3422+
3423+
/**
3424+
* Fetch personalization information
3425+
*
3426+
* @param {object} config - configuration object
3427+
* @param config.endpoint - Personalization endpoint
3428+
* @param config.database - Database name
3429+
* @param config.table - Table name
3430+
* @param config.token - Personalization token
3431+
*
3432+
* @param {object} data - (Optional) payload to send with the request
3433+
* @param {function} successCallback - Callback for successful request
3434+
* @param {function} errorCallback - Callback for failed quest
3435+
*
3436+
* @example
3437+
* var td = new Treasure({...})
3438+
* var successCallback = function (values) {
3439+
* //values format => {
3440+
* "offers": {
3441+
* "offer": {
3442+
* "attributes": {
3443+
* "first_name": "test",
3444+
* "nickname": "tet"
3445+
* },
3446+
* "batch_segments": 55352
3447+
* }
3448+
* }
3449+
* }
3450+
*
3451+
* // celebrate();
3452+
* }
3453+
* var errorCallback = function (error) {
3454+
* // cry();
3455+
* }
3456+
*
3457+
* td.fetchPersonalization({
3458+
* endpoint: 'endpoint',
3459+
* database: 'database',
3460+
* table: 'table',
3461+
* token: 'personalization token'
3462+
* }, null, successCallback, errorCallback)
3463+
*
3464+
*/
3465+
3466+
function fetchPersonalization(config, data, successCallback, errorCallback) {
3467+
invariant(_$5.isObject(config), 'config must be an object, received "' + config + '"');
3468+
invariant(config.endpoint, 'endpoint is invalid');
3469+
invariant(config.database, 'database is invalid');
3470+
invariant(config.table, 'table is invalid');
3471+
invariant(config.token, 'token is invalid');
3472+
successCallback = successCallback || noop$1;
3473+
errorCallback = errorCallback || noop$1;
3474+
var url = ['https://', config.endpoint, '/public/', config.database, '/', config.table].join('');
3475+
var payload = data || {};
3476+
api$1.post(url, payload, {
3477+
headers: {
3478+
'Content-Type': 'application/vnd.treasuredata.v1+json',
3479+
'Authorization': 'TD1 ' + this.client.writeKey,
3480+
'WP13n-Token': config.token
3481+
}
3482+
}).then(successCallback).catch(errorCallback);
3483+
}
34223484
var personalization = {
34233485
configure: configure$1,
3424-
fetchUserSegments: fetchUserSegments
3486+
fetchUserSegments: fetchUserSegments,
3487+
fetchPersonalization: fetchPersonalization
34253488
};
34263489

34273490
var track = {};
@@ -6130,7 +6193,7 @@
61306193
}
61316194

61326195
// Constants
6133-
var TREASURE_KEYS = ['init', 'set', 'collectTags', 'blockEvents', 'unblockEvents', 'setSignedMode', 'setAnonymousMode', 'resetUUID', 'addRecord', 'fetchGlobalID', 'trackPageview', 'trackEvent', 'trackClicks', 'fetchUserSegments', 'fetchServerCookie', 'ready'];
6196+
var TREASURE_KEYS = ['init', 'set', 'collectTags', 'blockEvents', 'unblockEvents', 'setSignedMode', 'setAnonymousMode', 'resetUUID', 'addRecord', 'fetchGlobalID', 'trackPageview', 'trackEvent', 'trackClicks', 'fetchUserSegments', 'fetchPersonalization', 'fetchServerCookie', 'ready'];
61346197

61356198
/*
61366199
* Load clients

dist/td.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
GLOBAL: 'Treasure',
3-
VERSION: '4.2.0',
3+
VERSION: '4.3.0',
44
HOST: 'in.treasuredata.com',
55
DATABASE: '',
66
PATHNAME: '/'

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "td-js-sdk",
3-
"version": "4.2.0",
3+
"version": "4.3.0",
44
"license": "Apache-2.0",
55
"bugs": "https://github.com/treasure-data/td-js-sdk/issues",
66
"description": "Browser JS library for sending events to your Treasure Data account",

0 commit comments

Comments
 (0)