如何禁用Google跟踪代码管理器控制台日志记录 [英] How to disable Google Tag Manager console logging
本文介绍了如何禁用Google跟踪代码管理器控制台日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将Google跟踪代码管理器添加到项目后,我在控制台中看到很多其日志条目.有没有办法禁用它?控制台日志充满噪音:
After I added Google Tag Manager to the project I see lots its log entries in the console. Is there a way to disable it? Console log is full of noise:
GoogleTagManager info: Processing logged event: _vs with parameters: {
"_o" = auto;
"_pc" = UIViewController;
"_pi" = "-3988739357756819671";
"_sc" = "Bubbie.MamboBamboViewController";
"_si" = "-3988739357756819670";
}
2017-07-27 12:01:09.744 BubbieHuff[77205:6894827] GoogleTagManager info: Processing logged event: show_view with parameters: {
"_sc" = "Bubbie.MamboBamboViewController";
"_si" = "-3988739357756819670";
name = Mambo;
}
推荐答案
我在将Google跟踪代码管理器和Firebase结合在一起的项目中遇到了这个问题.由于没有公开有关日志记录的标题,因此我找不到关闭它的方法.
I just had this problem in a project that combines Google Tag Manager and Firebase. Since no header about logging is exposed I couldn't find a way to turn it off.
这是我想到的一个猴子补丁,可让您控制来自GTM的信息日志.
This is a monkey patch I came up with that lets you control the info logs from GTM.
+ (void)patchGoogleTagManagerLogging {
Class class = NSClassFromString(@"TAGLogger");
SEL originalSelector = NSSelectorFromString(@"info:");
SEL detourSelector = @selector(detour_info:);
Method originalMethod = class_getClassMethod(class, originalSelector);
Method detourMethod = class_getClassMethod([self class], detourSelector);
class_addMethod(class,
detourSelector,
method_getImplementation(detourMethod),
method_getTypeEncoding(detourMethod));
method_exchangeImplementations(originalMethod, detourMethod);
}
+ (void)detour_info:(NSString*)message {
return; // Disable logging
}
这篇关于如何禁用Google跟踪代码管理器控制台日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文