Skip to content

Commit

Permalink
Merge pull request #7 from adtrace/v2.2.0
Browse files Browse the repository at this point in the history
V2.2.0
  • Loading branch information
namini40 authored Jan 8, 2024
2 parents 578f1c8 + d8aac47 commit dd56422
Show file tree
Hide file tree
Showing 70 changed files with 3,028 additions and 5,564 deletions.
13 changes: 3 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@
"presets": [
"@babel/preset-flow",
["@babel/preset-env", {
"targets": ["> 0.25%", "not dead"]
"targets": ">0.25%, not dead, ie 11"
}]
],
"plugins": [
"es6-promise",
"@babel/plugin-transform-flow-comments",
["@babel/plugin-transform-runtime", {
"version": "7.6.2"
}]
["@babel/plugin-transform-runtime", {"version": "7.18.10"}]
],
"env": {
"test": {
"plugins": ["transform-es2015-modules-commonjs"]
}
},
"overrides": [
{
"test": ["./src/**/*.ts"],
"presets": [
"@babel/preset-typescript",
["@babel/preset-env", {
"targets": ["> 0.25%", "not dead"]
"targets": ">0.25%, not dead, ie 11"
}]
],
"plugins": [
Expand Down
12 changes: 7 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"node": true,
"jest": true
},
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
Expand All @@ -16,8 +16,8 @@
"plugins": ["flowtype"],
"globals": {
"Promise": true,
"__Adtrace__NAMESPACE": true,
"__Adtrace__SDK_VERSION": true,
"__ADTRACE__NAMESPACE": true,
"__ADTRACE__SDK_VERSION": true,
"Utils": true
},
"rules": {
Expand Down Expand Up @@ -51,7 +51,8 @@
],
"eol-last": "error",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/explicit-module-boundary-types": "off"
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-namespace": "warn"
}
},
{
Expand All @@ -66,7 +67,8 @@
"jest/no-disabled-tests": "error",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-var-requires": "off",
"jest/prefer-to-be": "warn"
}
}
]
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@

node_modules/
coverage/

19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
### Version 2.1.1 (1th August 2022)
### Version 2.2.0 (April 2023)
#### Added
- Added a return of Promise from `trackEvent` method.
- Added `setReferrer` method to set referrer and trigger `/sdk_click` request manually.
- Added support of Data Residency.
- Added sending of `deduplication_id` parameter in `event` package.
- Added SRI feature support.
- Added `getWebUUID` method to access SDK generated ID `web_uuid`.
- Added `getAttribution` method to access user's current attribution information.


#### Fixed
- Fixed SDK state synchronization issue between multiple tabs.
- Fixed issue which caused site not to load when cookies are blocked in browser.
- Updated deprecated and vulnerable dependencies.
---

### Version 2.1.1 (August 2022)
#### Fixed
- Fixed top-level Typescript declarations.
- Added Typescript support.
Expand Down
5 changes: 4 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!groovy

pipeline {
tools {
nodejs 'nodejs_14.20.0'
}
agent {
node {
label 'new'
Expand Down Expand Up @@ -33,7 +36,7 @@ pipeline {
}

steps {
sh "rsync -e 'ssh -o StrictHostKeyChecking=no' -va --rsync-path='mkdir -p /home/panel/web-sdk-demo/current/public/ && rsync' --delete ./demo/ panel@jenkins-2.adtrace.io://home/panel/web-sdk-demo/current/public/"
sh "rsync -e 'ssh -o StrictHostKeyChecking=no' -va --rsync-path='mkdir -p /home/dashboard/web-sdk-demo/current/public/ && rsync' --delete ./demo/ dashboard@jenkins-2.adtrace.com://home/dashboard/web-sdk-demo/current/public/"
}
}
}
Expand Down
79 changes: 67 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<p align="center"><a href="https://adtrace.io" target="_blank" rel="noopener noreferrer"><img width="100" src="https://adtrace.io/fa/wp-content/uploads/2020/09/cropped-logo-sign-07-1.png" alt="Adtrace logo"></a></p>

<p align="center">
<a href='https://www.npmjs.com/package/web-adtrace'><img src='https://img.shields.io/npm/v/web-adtrace.svg'></a>
<a href='https://opensource.org/licenses/MIT'><img src='https://img.shields.io/badge/License-MIT-green.svg'></a>
</p>

## Summary

This is the guide to the Javascript SDK of Adtrace™ for web sites or web apps. You can read more about Adtrace™ at [adtrace.io].

Read this in other languages: [English][en-readme], [Persian][fa-readme]

## Table of contents

Expand All @@ -20,6 +14,9 @@ This is the guide to the Javascript SDK of Adtrace™ for web sites or web apps.
* [Global value parameters](#global-value-parameters)
* [Offline/Online mode](#offline-online-mode)
* [Stop/Restart SDK](#stop-restart-sdk)
* [Get Web UUID](#getters-web-uuid)
* [User attribution](#get-attribution)
* [Set Referrer](#set-referrer)

## <a id="example-app">Example apps</a>

Expand Down Expand Up @@ -58,7 +55,10 @@ Adtrace.initSdk({
environment: 'production'
});
```


> **Important**: For proper attribution method [setReferrer](#set-referrer) should be called as close as possible to SDK initialization.

Here is the full list of available parameters for the `initSdk` method:

### Mandatory params
Expand Down Expand Up @@ -120,6 +120,19 @@ A custom namespace for SDK data storage. If there are multiple applications on t

Please note it's possible to set custom namespace for existing storage with default name, all data will be preserved and moved to the custom namespace. Once custom namespace is set it's not possible to rename it without data loss.

<a id="set-external-device-id">**externalDeviceId**</a> `string`

An external device identifier is a custom value that you can assign to a device or user. They can help you to recognize users across sessions and platforms. They can also help you to deduplicate installs by user so that a user isn't counted as multiple new installs.

You can also use an external device ID as a custom identifier for a device. This can be useful if you use these identifiers elsewhere and want to keep continuity.

```js
Adtrace.initSdk({
// other initialisation options go here
externalDeviceId: 'YOUR_EXTERNAL_DEVICE_ID', // optional
});
```

## <a id="event-tracking">Event tracking</a>

You can use adtrace to track events. Lets say you want to track every tap on a particular button. You would create a new event token in your [panel], which has an associated event token - looking something like `abc123`. In order to track this event from your web app, you should do following:
Expand Down Expand Up @@ -155,7 +168,7 @@ Example:
Adtrace.trackEvent({
// ... other params go here, including mandatory ones
revenue: 10,
currency: 'Toman'
currency: 'USD'
})
```

Expand All @@ -181,15 +194,15 @@ Please note that we don't store any of your custom parameters, but only append t

You can read more about using URL callbacks, including a full list of available values, in our [callbacks guide][callbacks-guide].

<a id="value-params">**eventValueParams**</a> `array`
<a id="value-params">**valueParams**</a> `array`

You can also add parameters to be transmitted to network values, which have been activated in your Adtrace panel.
This works similarly to the callback parameters mentioned above, but can be added by adding `eventValueParams` parameter to the map object passed to `trackEvent` method:
This works similarly to the callback parameters mentioned above, but can be added by adding `valueParams` parameter to the map object passed to `trackEvent` method:

```js
Adtrace.trackEvent({
// ... other params go here, including mandatory ones
eventValueParams: [
valueParams: [
{key: 'key', value: 'value'},
{key: 'foo', value: 'bar'}
]
Expand Down Expand Up @@ -326,6 +339,48 @@ Example:
Adtrace.restart();
```

## <a id="getters-web-uuid">Get `web_uuid`</a>

To identify unique web users in Adtrace, Web SDK generates an ID known as `web_uuid` whenever it tracks first session. The ID is created per subdomain and per browser.
The identifier follows the Universally Unique Identifier (UUID) format.

To get `web_uuid` use the following method:

<a id="get-web-uuid">**getWebUUID**</a>

Example:

```js
const webUUID = Adtrace.getWebUUID();
```

## <a id="getters-attribution">User attribution</a>

You can access your user's current attribution information by using the following method:

<a id="get-attribution">**getAttribution**</a>

Example:

```js
const attribution = Adtrace.getAttribution();
```


## <a id="set-referrer">Setting `referrer`</a>
You may want to set `referrer` to trigger `sdk_click` manually.

To set `referrer` use the following method:

<a id="set-referrer-manually">**setReferrer**</a>

Example:

```js
Adtrace.setReferrer("adtrace_external_click_id%3DEXTERNAL_CLICK_ID");
```

Please note that `referrer` should be properly URL-encoded.


[adtrace.io]: https://adtrace.io
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.2.0
Binary file not shown.
1 change: 0 additions & 1 deletion demo/index.html

This file was deleted.

Loading

0 comments on commit dd56422

Please sign in to comment.