Skip to content

Commit

Permalink
fix(cookie): conset handling and distinctId key (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalMir135 authored May 5, 2023
1 parent 4f17792 commit c920884
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Make gelocation tracking optional.

## [1.0.0-beta.2] - 2023-05-05

### Fixed

- Cookie handling with consent.
- DistinctId key bug.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "analytics-web3",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Spock analytics SDK analytics-web3 is a js module to collect and log all the data and events of DApp for analytics.",
"main": "dist/analytics-web3.min.js",
"license": "UNLICENSED",
Expand Down
2 changes: 1 addition & 1 deletion src/BaseAnalytics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BaseAnalytics {
}

setConsetCookie(cName, cValue, expiry) {
this.store.optOut && setCookie(cName, cValue, expiry);
!this.store.optOut && setCookie(cName, cValue, expiry);
}

trackEvent({ event, properties, logMessage, callback }) {
Expand Down
4 changes: 2 additions & 2 deletions src/UserInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ class UserInfo extends BaseAnalytics {
}

distinctId(userAgent) {
const cachedDistinctId = getCookie(STORAGE.COOKIES.CACHE_DISTINCT_ID);
const cachedDistinctId = getCookie(STORAGE.COOKIES.DISTINCT_ID);
if (notUndefined(cachedDistinctId)) {
return cachedDistinctId;
}

const newDistinctId = this.uuid(userAgent);
const ONE_YEAR = 365 * 24 * 60 * 60 * 1000;
this.setConsetCookie(STORAGE.COOKIES.CACHE_DISTINCT_ID, newDistinctId, ONE_YEAR);
this.setConsetCookie(STORAGE.COOKIES.DISTINCT_ID, newDistinctId, ONE_YEAR);
return newDistinctId;
}

Expand Down

0 comments on commit c920884

Please sign in to comment.