onclick在通过条件检查是否存在cookie之后,我想跟踪网站页面上的按钮.
非常简单但哪种语法效果最好?
我已经研究了ga与gaq_push前缀GA事件跟踪语法和(原谅我,如果我错了),但他们似乎很相似?
_gaq.push
<script type="text/javascript">
jQuery(document).ready(function () {
if (jQuery.cookie('entry_winagrand_cookie') !== null) {
jQuery('notregisterbtn').on('click', function () {
_gaq.push(['_trackEvent', 'QR_Win_A_Grand', 'Clicked through to Register']);
});
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
ga
<script type="text/javascript">
jQuery(document).ready(function () {
if (jQuery.cookie('entry_winagrand_cookie') !== null) {
jQuery('notregisterbtn').on('click', function () {
ga('send', 'event', 'button', 'click', 'QR_Win_A_Grand', 'Clicked_through_to_register');
});
}
});
</script>
Run Code Online (Sandbox Code Playgroud) 测试useSubscription钩子我发现有点困难,因为该方法在Apollo 文档中被省略/未记录(在撰写本文时)。据推测,应该使用<MockedProvider />from来模拟它@apollo/react-testing,就像该链接中给出的示例中的突变一样。
测试我正在工作的订阅的加载状态:
成分:
const GET_RUNNING_DATA_SUBSCRIPTION = gql`
subscription OnLastPowerUpdate {
onLastPowerUpdate {
result1,
result2,
}
}
`;
const Dashboard: React.FC<RouteComponentProps & Props> = props => {
const userHasProduct = !!props.user.serialNumber;
const [startGetRunningData] = useMutation(START_GET_RUNNING_DATA);
const [stopGetRunningData] = useMutation(STOP_GET_RUNNING_DATA);
useEffect(() => {
startGetRunningData({
variables: { serialNumber: props.user.serialNumber },
});
return () => {
stopGetRunningData();
};
}, [startGetRunningData, stopGetRunningData, props]);
const SubscriptionData = (): any => {
const { data, loading } …Run Code Online (Sandbox Code Playgroud) 在后端,通过firebase的管理SDK生成自定义令牌:
router.use('/get-token', (req, res) => {
var uid = "big-secret";
admin.auth().createCustomToken(uid)
.then(function(customToken) {
res.json({
instanceID: customToken
});
})
.catch(function(error) {
console.log("Error creating custom token:", error);
});
});
Run Code Online (Sandbox Code Playgroud)
然后客户端前端应用程序选择customToken,然后向后端发出请求以验证:
const fbPrivateKey = serviceAccount.private_key;
const key = new NodeRSA(fbPrivateKey).exportKey('pkcs8-public-pem');
router.get('/verifyIdToken', cors(), (req, res) => {
jwt.verify(req.headers.authorization.split('Bearer ')[1], key, { algorithms: ['RS256'] }, function(err, decoded) {
console.log('err', err);
console.log('decoded', decoded);
});
Run Code Online (Sandbox Code Playgroud)
这总是错误的消息: JsonWebTokenError: invalid signature
这需要签名吗?如果有人能解释这个或有任何指针?
更新:
当req.headers.authorization.split('Bearer ')[1]通过jwt.io运行时,表示签名无效,但随后我输入我的私钥(key)并进行验证.
我是否使方法调用不正确或将错误的参数传递给jwt.verify()?
知道什么是从表单输入字段中获取值的最佳实践(在标记之后的标记中是第二个)?
我已经能够得到其余的价值(SKU和价格),但数量很棘手.
JSFIDDLE到整个事情: http ://jsfiddle.net/hslincoln/7HXBQ/33/
下面是一些jQuery,其范围是表的第一个tr,然后尝试进入该行并提取数量值:
var BSKfirstQTY = $(BSKfirstrow).find('td.quantity').text('input value');
Run Code Online (Sandbox Code Playgroud)
但正如你可以从小提琴的结果窗格中看到的那样,它正在喷涌而出[object Object].
注意:将.text()保留为空会导致它在小提示结果窗格中拾取单词Qty(这是标签,而不是数字).
任何帮助将非常感激:)
jquery ×2
apollo ×1
events ×1
firebase ×1
forms ×1
html ×1
input ×1
javascript ×1
jwt ×1
node.js ×1
react-hooks ×1
subscription ×1
tracking ×1