PermissionError while Adding Google Analyitcs on Streamlit Share

Summary

Hi. Thanks for reading in advance.
I am deploying a simple app on streamlit share and want to get records of it by Google Analytics.
I’ve reference this article to do so but facing the error below:

PermissionError: [Errno 13] Permission denied: '/home/adminuser/venv/lib/python3.9/site-packages/streamlit/static/index.bck'

Steps to reproduce

i’ve referenced and just added this code from the discussion to mine in the link above:
It works well in my local(m1 mac, streamlit ver 1.23.1) and I checked tracking going on
However, when I commit it on github and run by streamit share, it throws the PermissionError above.

def inject_ga():
    GA_ID = "google_analytics"

    # Note: Please replace the id from G-XXXXXXXXXX to whatever your
    # web application's id is. You will find this in your Google Analytics account
    
    GA_JS = """
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', 'G-XXXXXXXXXX');
    </script>
    """

    # Insert the script in the head tag of the static template inside your virtual
    index_path = pathlib.Path(st.__file__).parent / "static" / "index.html"
    logging.info(f'editing {index_path}')
    soup = BeautifulSoup(index_path.read_text(), features="html.parser")
    if not soup.find(id=GA_ID):  # if cannot find tag
        bck_index = index_path.with_suffix('.bck')
        if bck_index.exists():
            shutil.copy(bck_index, index_path)  # recover from backup
        else:
            shutil.copy(index_path, bck_index)  # keep a backup
        html = str(soup)
        new_html = html.replace('<head>', '<head>\n' + GA_JS)
        index_path.write_text(new_html)


inject_ga()

One possible cause is I am accessing into google sheets by another account from account used in Google Analytics. However I am negative to that because I couldn’t find any other authentication for setting up GA except for G-XXXX code. (If I’m wrong plz tell me)

Had no idea except that, so sorry if the question was duplicated even though i tried searching. if the info was too vague, i’d be happy to provide you additional ones.

Thanks for your warm support in advance.
Any related links or discussions are also welcome.

Hi, I’m having the exact same issue you reported.

Please let me know if you have discovered any solutions to that.

Thanks in advance!