krvajal / use-intercom-hook

5 stars 2 forks source link

Clean previous intercom <script ...> on userId change ? #3

Open 1um opened 5 years ago

1um commented 5 years ago

When new userId/email provided, hook executes Intercom script, which appends a tag to head:

<script async src="https://widget.intercom.io/widget/APP_ID"></script>

After multiple changes, we have multiple lines:

<script async src="https://widget.intercom.io/widget/APP_ID"></script>
<script async src="https://widget.intercom.io/widget/APP_ID"></script>
<script async src="https://widget.intercom.io/widget/APP_ID"></script>
....

Not an issue, but previous <script> might need to be removed.