Skip to content

Commit c7b131d

Browse files
authored
Update: use simplenote:user_id instead of wpcom:user_id for Tracks (#3291)
1 parent 51cf6d3 commit c7b131d

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

RELEASE-NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Updated styles, sass, style linting [#3294](https://github.com/Automattic/simplenote-electron/pull/3294)
88
- Upgraded dependencies [#3292](https://github.com/Automattic/simplenote-electron/pull/3292)
9+
- Updated the ID type used for analytics to avoid sending invalid WPCOM IDs [#3291](https://github.com/Automattic/simplenote-electron/pull/3291)
910

1011
## [v2.23.1]
1112

lib/analytics/tracks.ts

+1-30
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,6 @@ function buildTracks() {
106106
setCookie(key, value, ttl);
107107
};
108108

109-
const loadWpcomIdentity = function () {
110-
const wpcomCookie =
111-
getCookie('wordpress') ||
112-
getCookie('wordpress_sec') ||
113-
getCookie('wordpress_loggedin');
114-
if (wpcomCookie) {
115-
return get(userNameCookie);
116-
}
117-
};
118-
119109
const newAnonId = function () {
120110
const randomBytesLength = 18; // 18 * 4/3 = 24
121111
let randomBytes: number[] | Uint8Array = [];
@@ -133,23 +123,6 @@ function buildTracks() {
133123
return btoa(String.fromCharCode.apply(String, randomBytes as number[]));
134124
};
135125

136-
const loadIdentity = function () {
137-
if (userId) {
138-
return;
139-
}
140-
userId = loadWpcomIdentity();
141-
if (userId) {
142-
userIdType = 'wpcom:user_id';
143-
} else {
144-
userIdType = 'anon';
145-
userId = get(userAnonCookie);
146-
if (!userId) {
147-
userId = newAnonId();
148-
set(userAnonCookie, userId);
149-
}
150-
}
151-
};
152-
153126
const getQueries = function () {
154127
const queries = get(queriesCookie);
155128
return queries ? queries.split(' ') : [];
@@ -238,7 +211,6 @@ function buildTracks() {
238211
};
239212

240213
const send = function (query: Query) {
241-
loadIdentity();
242214
retryQueries();
243215
query._ui = userId;
244216
query._ut = userIdType;
@@ -317,7 +289,7 @@ function buildTracks() {
317289
}
318290

319291
userId = newUserId;
320-
userIdType = 'wpcom:user_id';
292+
userIdType = 'simplenote:user_id';
321293
set(userNameCookie, userId);
322294
const anonId = get(userAnonCookie);
323295
if (anonId) {
@@ -334,7 +306,6 @@ function buildTracks() {
334306
userLogin = null;
335307
set(userNameCookie, '', -1);
336308
set(userAnonCookie, '', -1);
337-
loadIdentity();
338309
};
339310

340311
const setProperties = function (properties: Query) {

0 commit comments

Comments
 (0)