Skip to content

Commit

Permalink
Merge pull request #33 from ingestly/remove-id-handling
Browse files Browse the repository at this point in the history
Docs update & Minor improvements
  • Loading branch information
hjmsano authored Apr 12, 2020
2 parents 76ff96f + df2b9c8 commit 6e767bf
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
16 changes: 16 additions & 0 deletions README-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ npm run build

- お好きなイベントに対してカスタムイベントを送信します

### Ingestly.setConsent(acceptance)

- データ利用の目的、例えば「cookie」「measurement」「analytics」や他の任意の分類について同意状態を保存します
- Boolean型で `cookie` を指定すると、SDKがCookieを使うかどうかを制御できます
- もし `measurement``false` をセットすると、SDKはデータを送信しなくなります
- 値はエンドポイントによってCookieとしてセットされます

|key|description|
|:----|:----|
|cookie|Cookie制御に予約|
|measurement|データ送信の有効化/無効化に予約|
|analytics||
|personalization||
|advertisement||
|sharing||

### Ingestly.getQueryVal(keyName)

- このメソッドはGETパラメータの キー-バリュー ペアから、指定したキー名に対応する値を返します
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ You can enable optional tracking features.

- Send a custom beacon on your preferred events.

### Ingestly.setConsent(acceptance)

- Save the acceptance status for purpose of data use such as "cookie", "measurement", "analytics" or any other your own categorization.
- If you set `cookie` as Boolean type, you can control the SDK to use Cookie or not per a browser.
- If you set `false` to `measurement`, the SDK will not send beacons.
- Values will be set as a Cookie by the endpoint.

|key|description|
|:----|:----|
|cookie|reserved for Cookie control.|
|measurement|reserved to enable/disable data transmission.|
|analytics||
|personalization||
|advertisement||
|sharing||

### Ingestly.getQueryVal(keyName)

- This method retrieves a value from GET parameter of URL by specifying a key name.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ingestly-client-javascript",
"version": "1.0.0b",
"version": "1.0.0",
"description": "Ingestly Client JavaScript SDK for modern web analytics.",
"main": "dist/ingestly.js",
"scripts": {
Expand Down
21 changes: 13 additions & 8 deletions src/ingestly.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Emitter from './emitter';
import Events from './events';
import Utils from './utils';

const sdkVersion = '1.0.0b',
const sdkVersion = '1.0.0',
initTimestamp = +new Date();

let config,
Expand Down Expand Up @@ -119,21 +119,26 @@ export default class Ingestly {

/**
* Consent Management
* @param {Object} purposes consent status of purposes for data utilization.
* @param {Object} acceptance consent status for each purpose of data utilization.
*/
setConsent(purposes = {}) {
setConsent(acceptance = {}) {
let optOut = 0;
if (purposes['cookie'] === true) {
if (acceptance['cookie'] === false) {
optOut = 1;
consent['cookie'] = false;
} else {
consent['cookie'] = true;
consent['cookie'] = acceptance['cookie'] ? acceptance['cookie'] : config.useCookie;
}
consent['measurement'] = purposes['measurement'] === false ? true : false;
if (acceptance['measurement'] === false) {
consent['measurement'] = false;
} else {
consent['measurement'] = true;
}
consent['measurement'] = !acceptance['measurement'];
emitter.emit('consent', {
key: config.apiKey,
dc: optOut,
ap: encodeURIComponent(JSON.stringify(purposes)),
ap: encodeURIComponent(JSON.stringify(acceptance)),
});
}

Expand All @@ -150,7 +155,7 @@ export default class Ingestly {
category: category,
sinceInitMs: now - initTimestamp,
sincePrevMs: now - prevTimestamp,
consent: consent
consent: consent,
};
let payload = utils.mergeObj([
this.dataModel,
Expand Down

0 comments on commit 6e767bf

Please sign in to comment.