How to remove old json data? Answered

Post author
Edward Goin

Does memberstack store JSON cookies / cache locally? And if so is there anyway to overrule that? I’ve changed the json in the dashboard but the front end keeps loading old json data that doesn’t even exist anymore with the getMemberJSON function

Even logging member in and out, still getting old json data

https://memberstack.slack.com/files/U0400M2PMHU/F053EEF98R3/video_clip__2023-04-17_11_21_06_.mov  (Sorry for not using loom lol)

Bleurgh:doop was the first JSON I had there. And it keeps loading. Here is the code that is supposed to bring it in. Looks fine to me

 

Comments

17 comments

  • Comment author
    Julian Galluzzo

    It doesn't store locally to my knowledge - I Haven't seen this before. Trying to figure out what the issue is now

    0
  • Comment author
    Edward Goin

    I searched applications: cookies and local storage but didn’t see any JSON data there so I think you’re right that ms doesn’t store it. Weird af

    0
  • Comment author
    Julian Galluzzo

    could you try this:

    1. Clear your cache
    2. Try again
    3. See if it loads new/old json still
    4. If it loads new, try to change it again and see what it's pulling

    This way we could figure out if clearing the cache does the trick - in which case, it must be storing locally somehow, someway, somewhere

    0
  • Comment author
    Edward Goin

    🫠 Gonna have to sign back into all services but ok haha

    0
  • Comment author
    Julian Galluzzo

    you should just be able to clear data only for this one site

    0
  • Comment author
    Edward Goin

    Cleared all, was faster. Still getting blerugh doop

    Absolute madness !

    0
  • Comment author
    Julian Galluzzo

    ah okay, and in that case it seems like its not updating anywhere 🤔 from another test account is the same thing happening?

    0
  • Comment author
    Edward Goin

    I can try the other test account. Gimme a minute

    Wtf getting bleurgh doop on that one too

    Didn’t even have any JSON. It seems blerugh doop is like associated with the entire account/website rather than a member. Not sure how that’s possible

    Maybe a test account bug?

    0
  • Comment author
    Julian Galluzzo

    exactly what I'm thinking, I'm trying to replicate on another test project

    Also, where was bleurgh doop updated from? Back end manually just like you showed in that video, or elsewhere?

    0
  • Comment author
    Edward Goin

    Do I need memberId inside the () at the end of function getMemberJSON()?

    I added it manually in the beginning for Edward.goin@gmail.com to test if I could replace even if a key didn’t match in a key value pair

    The weird thing is updating memberjson appears to work fine. It’s the read

    Adding memberId inside () didn’t help

    0
  • Comment author
    Julian Galluzzo

    try to comment out that return line 212

    Also, could you send me this code perhaps so i can replicate a but more accurate

    0
  • Comment author
    Edward Goin

    first ill try commenting out 212

    ok still bluergh doop with 212 commented out. ill paste the relevant code.

    and here’s the console log

    0
  • Comment author
    Julian Galluzzo

    thanks! Checking now

    one issue, could you send it to me as a code block? When you send it as a slack message it converts a bunch of characters and makes it not work

    in the formatting options on slack, just hit code block then paste

    0
  • Comment author
    Edward Goin

    note i just checked the same on firefox rather than chrome. still getting the bleurgh doop

    so its DEFINITELY not the browser.

    you want me to resend the code in a code snippet. Here it is:

    <script>
      let memberId;
      let data;
    
    function getCurrentDevice() {
      const userAgent = navigator.userAgent;
      console.log('userAgent:', userAgent);
    
      if (/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)) {
        console.log('Detected device: mobile');
        return "mobile";
      } else if (/iPad|Tablet|Playbook|Silk|Kindle|Android(?!.*Mobile)|Opera Tablet/i.test(userAgent)) {
        console.log('Detected device: tablet');
        return "tablet";
      } else {
        console.log('Detected device: desktop');
        return "desktop";
      }
    }
    
    async function updateLastDevice(memberId, currentDevice) {
      console.log('Updating lastDevice for memberId:', memberId, 'to', currentDevice);
      try {
        await window.$memberstackDom.updateMemberJSON({
          json: {
            "lastDevice": currentDevice
          }
        });
        console.log('lastDevice updated');
      } catch (error) {
        console.error('Error updating lastDevice:', error);
      }
    }
    
    async function getMemberJSON(memberId) {
      console.log('Fetching member JSON');
      const memberJSON = await window.$memberstackDom.getMemberJSON();
      console.log('memberJSON:', memberJSON);
      //return memberJSON || null;
    }
    
      window.$memberstackDom.getCurrentMember().then(async ({ data: member }) => {
        if (member) {
          memberId = member.id;
          console.log('memberId:', memberId);
    
          const currentDevice = getCurrentDevice();
          console.log('currentDevice:', currentDevice);
    
          const memberJSON = await getMemberJSON();
          console.log('memberJSON:', memberJSON);
    
          const lastDevice = memberJSON ? memberJSON.lastDevice : null;
          console.log('lastDevice:', lastDevice);
    
          if (lastDevice !== currentDevice) {
            console.log('lastDevice and currentDevice are different');
            await updateLastDevice(memberId, currentDevice);
            //fetchDataAndCache(memberId);
          } else {
            console.log('lastDevice and currentDevice are the same');
            //retrieveDataFromCache(memberId);
          }
        }
      }); </script>

    persisting across multiple members, multiple browsers, and a full cache clear… no hard-coded instances of bleurgh or doop in my code… it HAS to be a memberstack bug right?

    oh fuck this is embarrassing. i think i found the bleurgh doop. your original question.

    exactly what I’m thinking, I’m trying to replicate on another test project

    Also, where was bleurgh doop updated from? Back end manually just like you showed in that video, or elsewhere?

    — i think i see it in a legacy HTML code block. im gonna delete it. if that fixes it, i owed you the biggest apology for wasting your time

    it was inserted manually on the dashboard, i wasn’t wrong about that. but i may have also done the other part too

    0
  • Comment author
    Julian Galluzzo

    Hopefully that does fix it!! No worries if that's the case, if it ever happens again, I know the first thing to investigate 😎

    0
  • Comment author
    Edward Goin

    and thats why you have to finish a task on a day, if u sleep on it you forget these little bastards you leave behind

    yeah its working now. im such a fuckface. sorry if i ruined your morning Julian.

    thank you so much for your help 😞

    0
  • Comment author
    Julian Galluzzo

    Oh ive been there before, don't worry at all 🤣 No problem at all, I'm just glad we got it figured out 🙏 if there's anything else, just let me know! Don't feel bad about it, i totally would have forgot about that too

    0

Please sign in to leave a comment.