Skip to content

SDK: analytics?.getAnonymousId #1199

@philibea

Description

@philibea

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;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions