# Ebay EPN: Source map error

**URL:** https://meta.discourse.org/t/ebay-epn-source-map-error/232770
**Category:** Development
**Created:** [July 13, 2022, 6:44pm UTC](https://meta.discourse.org/t/ebay-epn-source-map-error/232770 "2022-07-13T18:44:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [July 13, 2022, 6:44pm UTC](https://meta.discourse.org/t/ebay-epn-source-map-error/232770/1 "2022-07-13T18:44:17Z")

</div>

The Ebay affiliate program provides a script that converts links on the clientside. It’s a simple two-line thing:

`<script>window._epn = {campaign: [XXX_ID_XXX], smartPopover:false};</script>`  
`<script src="https://epnt.ebay.com/static/epn-smart-tools.js"></script>`

I realize I can’t simply add these two lines for security reasons. There’s a bit of a discussion here [EPN Smart Links](https://meta.discourse.org/t/epn-smart-links/116293)

I have created a very simple theme component and placed the code in the common/head\_tag.html file:

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/a/3/ca347658084be3a3b0ca11079e788fd96ede7a82.png)

The id is specified on the component page and the console logs the correct id. However, it does not appear to update any URLs.

I have added this [epn-smart-tools.js](https://epnt.ebay.com/static/epn-smart-tools.js) as a content security policy exception. In the brower console I get this warning though:  
 ![image](https://global.discourse-cdn.com/meta/original/4X/e/5/8/e58528244438493089a84976f9299225b273d126.png)

It looks like this “from-url.js.map” referenced in the epn-smart-tools.js is the problem. I wrote a simple html file on my desktop and ran it locally and there doesn’t seem to be an issue - leading me to believe it’s more likely a issue on the discourse end than from my browser.

What these source maps do and how discourse interacts with them are outside the limits of my knowledge. Any advice here? Am I overlooking something?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [July 13, 2022, 8:03pm UTC](https://meta.discourse.org/t/ebay-epn-source-map-error/232770/2 "2022-07-13T20:03:27Z")

</div>

Source maps are optional files that help debugging minified assets. Since you don’t control this asset, and doesn’t have any control over it’s source you should ignore this warning.

---

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [July 14, 2022, 2:41am UTC](https://meta.discourse.org/t/ebay-epn-source-map-error/232770/3 "2022-07-14T02:41:45Z")

</div>

Thanks for the info @Falco and happy birthday.

I figured out the problem was where I added that \<script src="… line.

This worked for me:

```plaintext
<script type="text/discourse-plugin" version="0.8">

  console.log(settings.epn_id);
  window._epn = {campaign: settings.epn_id, smartPopover:false};

  var script = document.createElement('script');
  script.src = 'https://epnt.ebay.com/static/epn-smart-tools.js';
  var head = document.getElementsByTagName("head")[0];
  head.appendChild(script);

</script>

```

The next problem I ran into is that elements that are dynamically loaded are do not have the script applied to them. For instance, if I refresh the page on a topic, the posts that load will have the affiliate link but scrolling to reveal more posts - those ones don’t.

Is there a way to run the script every time a new element is loaded?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [July 14, 2022, 2:56am UTC](https://meta.discourse.org/t/ebay-epn-source-map-error/232770/4 "2022-07-14T02:56:06Z")

</div>

Ideally you would do that on the server side, once a new post is saved. We have a plugin that exactly this for Amazon so you should be able to adapt it for eBay: [GitHub - discourse/discourse-affiliate · GitHub](https://github.com/discourse/discourse-affiliate)

If you still want to do it on the client side, you can follow this helpful tutorial: [Link rewriting for affiliate codes - #8 by Johani](https://meta.discourse.org/t/link-rewriting-for-affiliate-codes/52949/8)
