Iterable / iterable-web-sdk

Iterable SDK for interacting with the Iterable API to implement inside JavaScript and Node projects
https://iterable.com
MIT License
9 stars 9 forks source link

Mob 8058 (Web SDK: Click Handling) #328

Closed hani-iterable closed 6 months ago

hani-iterable commented 6 months ago

JIRA Ticket(s) if any

Description

We have implemented Web click handling for embedded OOTB views.

mprew97 commented 6 months ago

Also, this is kind of a late catch, but can we remove instances of manually setting email and user id on local storage in the Web SDK source? We already have methods that customers/devs use to do that. You can see we have a setEmail and setUserId on the initialize() method we are already using for embedded in the react-example app.

We should just be able to fetch from local storage without having to set it, except for when setUser and setUserId is called.

See the method definition in authorization.ts. To use it, you would just call

const { setEmail, setUserId } = initialize(...)

hani-iterable commented 6 months ago

initialize()

@mprew97 Got it, you're asking about the use of the 'initialize()' method. Do we need to pass the userID from the Sample app when calling any method related to Embedded messages, or is there another way to handle this?

mprew97 commented 6 months ago

initialize()

@mprew97 Got it, you're asking about the use of the 'initialize()' method. Do we need to pass the userID from the Sample app when calling any method related to Embedded messages, or is there another way to handle this?

@hani-iterable For API requests, once you call setEmail or setUserId, those automatically get tacked on to all requests. In authorization.ts, see lines 237 - 328. We intercept any request using baseAxiosRequest and add the email or userId to the req.