Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!
SOLVED

GetValOnce - Bug in Cookie Expiration / Max-Age?

Avatar

Level 2
Hi all, I currently have a client, where I migrate the old appMeasurement-Implementation to the new WebSDK Implementation. They currently use s.getValOnce(..). (https://experienceleague.adobe.com/docs/analytics/implementation/vars/plugins/getvalonce.html?lang=e...) Since this needs the App Measurement to work, I rewrote the plugin a bit and I think the cookies times are not set correctly with this plugin. When executing this line: s.getValOnce(s.eVar1,"TestCookie-10Days",10) // Results in D=pageName The result is this Expire Date: "2023-09-21T09:21:59.247Z" which it not 10 days from now. I think its because in the cookieWrite-Function the time is set like this, where "d" defaults to 86400000, which is one day in milliseconds. but this is then multiplied by 60000 which is much more then 10 days.. e.setTime(e.getTime() + 6e4 * d); Do I overlook something or is this a bug within the plugin? Best Eric
1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion

It does thanks... that is very strange then.. also, in Launch, it actually does create an "appMeasurment" file (you just don't edit it directly like the old way - but looks like it might be missing some stuff based on that error)... it does seem like there may be a bug (or 2... or 3) in the plugin... which isn't good.

 

This might require the engineering team (which means opening a ticket and waiting for someone to debug)....

 

OR making your own version of the code....  something far more readable....

 

Basically, it looks like this function just returns a value within a specified time if it doesn't match the last sent version... it shouldn't be hard to make a similar function.

 

 

In pseudo "code"

 

  • Pass the param, the cookie name, the length of time (you can extend to have unit - like min/sec if you think you need that level of control)
  • read the value of the cookie if it exists
    • if it doesn't - write a new cookie with the value and expiry
    • if it does, read the value
      • compare that value with what you are trying to set
      • if it matches, return nothing
      • if it doesn't match, return the new value
        • overwrite the cookie with the new value and expiry

 

That should be the gist of the logic... if you are comfortable with Javascript, this might be the faster option....  Me personally, in this situation, I would probably try and do my own thing rather than waiting... especially since this logic seems pretty straight forward (but I would also make sure to run this through a heavy testing cycle to make sure I didn't miss anything).

 

If you try and debug and modify the existing, if someone else is working on the code, they may not know what you have changed.... If you write your own, it should be obvious (and I would suggest adding a comment specifying why you aren't using the standard plugin )

 

That said, even if you do your own solution, I would still pursue the client care ticket.. if there is a bug (and it really looks like there a few happening there) they should look at that and make sure no one else has issues....

 

I would, but since I don't use that plugin, I have no place where they can see the issues in action....

View solution in original post

8 Replies

Avatar

Community Advisor and Adobe Champion

You said that you "re-wrote the plugin a bit"? Could you provide details, what did you change? What does your code look like? It sounds like maybe what you changed could have caused the issue....

Adobe's plugin codes are really gross to read through (they aren't optimized for human eyes). It would be really easy to miss some of the manipulations that could result in the wrong expiry.

 

The last version of this code was released over a year ago.. it's hard to imagine that such a large bug would go unfound for so long (but not impossible).

 

If you can help provide context around what changes you made, that would be a starting point....

Avatar

Level 2

Hi Jennifer, 

sorry, I did not explain my approach very well, so let my try again. 
1. I have this issue with a client who actually uses the "out of the box" plugin (without any changes to code) via Adobe Launch. There I found the issue. 


To reproduce it, I set up the following on a test website: 

1. Installing App Measurement and instantiate it. (as written in the documentation) 

ericb17371700_0-1660751235750.png

When trying it out I get an error that "this.c_r(..) is not defined (since its part of the app measurement .. I changed it to s.c_r(..)). -> Note: I only did that in my test implementation to get it running, for the client everything is standard via Launch. 

 

This change does not impact the cookie-Max Age. 

 

2. I called new Date().toUTCString() just to get the current time: 

ericb17371700_3-1660751655816.png

 

3. Now I call:

getValOnce("Just a value to get","cookieName",10,"m");

This should get my a cookie, which is valid for 10 minutes. 

What I get is a cookie that is valid for more than a month. (September 28th, 2022)

ericb17371700_2-1660751547108.png

 

And if I look at the code it makes sense, since here I calculate 60000 ms * d (which is for "m" also 60000)

ericb17371700_4-1660751734500.png

 

Do I overlook something very basic here?

Is my test implementation so wrong? Or is it really a bug? 

 

I hope that helps to understand my problem better  

Best

Eric 

 

 

 

Avatar

Correct answer by
Community Advisor and Adobe Champion

It does thanks... that is very strange then.. also, in Launch, it actually does create an "appMeasurment" file (you just don't edit it directly like the old way - but looks like it might be missing some stuff based on that error)... it does seem like there may be a bug (or 2... or 3) in the plugin... which isn't good.

 

This might require the engineering team (which means opening a ticket and waiting for someone to debug)....

 

OR making your own version of the code....  something far more readable....

 

Basically, it looks like this function just returns a value within a specified time if it doesn't match the last sent version... it shouldn't be hard to make a similar function.

 

 

In pseudo "code"

 

  • Pass the param, the cookie name, the length of time (you can extend to have unit - like min/sec if you think you need that level of control)
  • read the value of the cookie if it exists
    • if it doesn't - write a new cookie with the value and expiry
    • if it does, read the value
      • compare that value with what you are trying to set
      • if it matches, return nothing
      • if it doesn't match, return the new value
        • overwrite the cookie with the new value and expiry

 

That should be the gist of the logic... if you are comfortable with Javascript, this might be the faster option....  Me personally, in this situation, I would probably try and do my own thing rather than waiting... especially since this logic seems pretty straight forward (but I would also make sure to run this through a heavy testing cycle to make sure I didn't miss anything).

 

If you try and debug and modify the existing, if someone else is working on the code, they may not know what you have changed.... If you write your own, it should be obvious (and I would suggest adding a comment specifying why you aren't using the standard plugin )

 

That said, even if you do your own solution, I would still pursue the client care ticket.. if there is a bug (and it really looks like there a few happening there) they should look at that and make sure no one else has issues....

 

I would, but since I don't use that plugin, I have no place where they can see the issues in action....

Avatar

Level 2

Hi Jennifer, 

thanks for you comment. 
I actually already wrote an adapted version of it, that works now and since I either way can't use the version of Adobe (which will get fixed soon maybe) for the new WebSDK implementation, since it is connected with the App Measurement, I will go with my own version. 

 

Will you create a (global) client care ticket or is it something that I have to do with my "clients specific client care"?

 

 

Avatar

Community Advisor and Adobe Champion

I don't work for Adobe (I'm just another user like you).. so I think that because you have actual observations, it would best come from you.

Avatar

Employee

Hi everyone, there is a bug with the plugin and we will publishing a fix on Experience League soon.   Sincere apologies for the trouble. 

Avatar

Level 2

Hi kmckell,
thanks for confirming! Looking forward to the fix.

Best

Eric