jitsu icon indicating copy to clipboard operation
jitsu copied to clipboard

SDK: analytics?.getAnonymousId

Open philibea opened this issue 7 months ago • 0 comments

Add the possibility to getAnonymousId. It's use full to set to others provider like Growthbook ( AB testing solution ) attributes

  setAnonymousId: (id: string) => {
      if (opts.debug) {
        console.log("[JITSU DEBUG] Setting anonymous id to " + id);
      }
      //Workaround for analytics.js bug. Underlying setAnonymousId doesn't  set the id immediately,
      //so we got to it manually here. See https://github.com/jitsucom/jitsu/issues/1060
      storage.setItem("__anon_id", id);
      const userState = analytics.user();
      if (userState) {
        userState.anonymousId = id;
      }
      (analytics as any).setAnonymousId(id);
    },

maybe we can have a better type for user function instead of any ?

   user  (): any;

philibea avatar May 30 '25 12:05 philibea