gpt4 book ai didi

firebase - 在 chrome 扩展程序中使用 Firebase Analytics

转载 作者:行者123 更新时间:2023-12-03 17:01:49 25 4
gpt4 key购买 nike

我正在使用 Firebase Firestore 和 Firebase Auth 来管理 chrome 扩展后台页面中的数据和用户。这很好用。

但是,我正在尝试在同一个后台页面上使用 Firebase Analytics 来记录一些事件,但这绝对不起作用(即使等了几天之后)。

笔记:
- 我已经从我的 firebase 设置面板激活了分析集成
- 我已将配置对象添加到我的 firebase init 中,并使用文档中提到的正确测量 ID。
- 我已经导入了 firebase/analytics SDK
- 如果我 console.log firebase.analytics().logEvent,则该函数存在。但是,如果我执行以下操作:firebase.analytics().logEvent("blabla"),则该事件永远不会出现在我的仪表板上。

以下是我的 background.js 文件的一些部分:

import firebase from 'firebase/app';
import "firebase/analytics";
import "firebase/auth";
import "firebase/firestore";

// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyAl-5jiGpv_FzYK38mWTZZkspJ1u2UV3bk",
authDomain: "email-tracker-backend.firebaseapp.com",
databaseURL: "https://email-tracker-backend.firebaseio.com",
projectId: "email-tracker-backend",
storageBucket: "email-tracker-backend.appspot.com",
messagingSenderId: "83977792643",
appId: "1:83977792643:web:4aea8f58ecf668e4193fb6",
measurementId: "G-DL96DBFLB0"
};

// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);

const analytics = firebase.analytics();

const firestore = app.firestore();

......

console.log("before log") // print out correctly
analytics.logEvent('something'); // this event never appears
console.log(analytics.logEvent); // print out the function correctly


在我的 manifest.js 文件中,我添加了以下内容安全策略,并且我的 background.js 日志中没有与此相关的错误。

content_security_policy: "script-src 'self' 'unsafe-eval' https://cdn.firebase.com https://*.firebaseio.com https://tagmanager.google.com/ https://www.googletagmanager.com/; object-src 'self'; script-src-elem 'self' 'unsafe-eval' https://apis.google.com https://tagmanager.google.com/ https://www.googletagmanager.com/;",


我什至不确定是否可以在 chrome 扩展中使用 firebase 分析。

有谁能够帮助我?

非常感谢和快乐编码。

最佳答案

目前,Chrome 扩展程序不支持 Firebase Analytics。查询 firebase_environments_sdk doc 将来有任何变化。

关于firebase - 在 chrome 扩展程序中使用 Firebase Analytics,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59648480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com