Member attributes available in JavaScript

Some integrations require access to member.uuid in “code injection” (see Intercom).

Exposing member attributes that are available to themes to JavaScript would be helpful.

This could be achieved by adding @Cathy_Sarisky code in templates:

{{#if @member}}
  <script>
      set memberUUID = "{{@member.uuid}}"
  </script>
{{/if}}

A more “global” approach would be theme-independent.

I would extend the above example to use a member object with properties as they are used in the @member object:

{{#if @member}}
  <script>
      set member = {
        uuid: "{{@member.uuid}}",
        email: "{{@member.email}}",
        ...
      };
  </script>
{{/if}}

With JavaScript, you can already fetch this data by making a request to /members/api/member/ endpoint, right?

1 Like

That is true @muratcorlu, however this data is already fetched by the portal.min.js and the second fetch would be unnecessary (even if it would be a much cleaner solution then my current workaround).

I’m sure that the similar data is also read on the server. That is why I’m proposing to use @member to set the JavaScript member object.