Skip to content

Commit c70152e

Browse files
author
Jack Crish
committed
update cookie capture
1 parent eb8a62e commit c70152e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/app/containers/MainContainer.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ function MainContainer(): any {
8989
if (!user.debug) {
9090
//set current user cookie if it does not exist in cookies;
9191
if (user.checkDocumentCookie(document)) {
92-
user.getCookie();
92+
console.log(" USER ", user);
9393
mixpanel.people.increment(user.get_dId(), "times");
9494
} else {
95-
user.setCookie();
95+
console.log( "USER ESLE ", user);
96+
document.cookie = user.setCookie();
97+
98+
console.log(" USER AFTER COOKIE SET ", user);
9699
mixpanel.people.set(user.get_dId(), { times: 1 });
97100
}
98101
}

src/app/user_id/user_id.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class MPID{
1212
//create a string of random data
1313
this.cookie = cookie.serialize("reactime", crypto.randomBytes(64).toString('hex') );
1414
this.distinct_id = this.cookie?.reactime?.slice(0, 20);
15-
1615
if(this.cookie){
1716
return this.cookie;
1817
}else{
@@ -22,7 +21,8 @@ class MPID{
2221
}
2322

2423
getCookie(){
25-
if(this.cookie){
24+
if(this.cookie){
25+
//this.distinct_id = parsedCookie?.reactime?.slice(0, 20);
2626
return this.cookie;
2727
}else{
2828
throw new Error("Cookie truthy, but unreturnable");
@@ -37,7 +37,8 @@ class MPID{
3737
this.cookie = parsedCookie?.reactime;
3838
if(!this.distinct_id){
3939
this.distinct_id = parsedCookie?.reactime?.slice(0, 20);
40-
}
40+
}
41+
return true;
4142
}else{
4243
this.setCookie();
4344
return false;
@@ -48,6 +49,9 @@ class MPID{
4849
try{
4950
if(this.distinct_id ) {
5051
return this.distinct_id;
52+
}else{
53+
54+
//return this.checkDocumentCookie
5155
}
5256
}catch( e ){
5357
throw new Error(`unable to set cookie. Reason: ${e}. `);

0 commit comments

Comments
 (0)