private SourceRow MapRow(ISourceMapProvider sourceMapProvider, SourceRow src) { var sourceMap = sourceMapProvider.Get(src.File); if (sourceMap == null) { return(src); } if (src.Line == null) { return(src); } if (src.Column == null) { return(src); } var position = sourceMap.OriginalPositionFor((int)src.Line, (int)src.Column); return(new SourceRow { Line = position.Line, Column = position.Column, File = position.Source, Symbol = position.Name }); }
/// <summary> /// Creates a StackTraceDeminifier that only deminifies the method names. StackTrace deminifiers created with this method will use significantly less memory during runtime than the /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetMethodNameOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider, IStackTraceParser stackTraceParser) { ValidateArguments(sourceMapProvider, generatedCodeProvider, stackTraceParser); SourceMapParser sourceMapParser = new SourceMapParser(); IStackFrameDeminifier stackFrameDeminifier = new MethodNameStackFrameDeminifier(new FunctionMapStore(generatedCodeProvider, (url) => sourceMapParser.ParseSourceMap(sourceMapProvider.GetSourceMapContentsForCallstackUrl(url))), new FunctionMapConsumer()); return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser)); }
public static StackTraceDeminifier GetStackTraceDeminfier(ISourceMapProvider sourceMapProvider) { var sourceMapStore = new SourceMapStore(sourceMapProvider); var stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore); var stackTraceParser = new StackTraceParser(); return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser)); }
public Crash Process(Crash crash) { var appVersion = crash.Version; ISourceMapProvider providerOnVersion = _sourceMapProvider.GetByApplicationVersion(crash.Application.Key, appVersion); crash.StackTrace = _stackTraceBeautifier.Beautify(providerOnVersion, crash.StackTrace); return(crash); }
/// <summary> /// Creates a StackTraceDeminifier with full capabilities. StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier. /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider, IStackTraceParser stackTraceParser) { ValidateArguments(sourceMapProvider, generatedCodeProvider, stackTraceParser); ISourceMapStore sourceMapStore = new SourceMapStore(sourceMapProvider); IStackFrameDeminifier stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore, new FunctionMapStore(generatedCodeProvider, sourceMapStore.GetSourceMapForUrl), new FunctionMapConsumer()); return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser)); }
private StackTraceDeminifier GetStackTraceDeminifierWithDependencies() { ISourceMapProvider sourceMapProvider = MockRepository.GenerateStrictMock <ISourceMapProvider>(); sourceMapProvider.Stub(x => x.GetSourceMapContentsForCallstackUrl("http://localhost:11323/crashcauser.min.js")).Return(UnitTestUtils.StreamReaderFromString(SourceMapString)); ISourceCodeProvider sourceCodeProvider = MockRepository.GenerateStrictMock <ISourceCodeProvider>(); sourceCodeProvider.Stub(x => x.GetSourceCode("http://localhost:11323/crashcauser.min.js")).Return(UnitTestUtils.StreamReaderFromString(GeneratedCodeString)); return(StackTraceDeminfierFactory.GetMapOnlyStackTraceDeminfier(sourceMapProvider)); }
private static void ValidateArguments(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider) { if (sourceMapProvider == null) { throw new ArgumentNullException(nameof(sourceMapProvider)); } if (generatedCodeProvider == null) { throw new ArgumentNullException(nameof(generatedCodeProvider)); } }
public string Beautify(ISourceMapProvider sourceMapProvider, string src) { var sb = new StringBuilder(); var rows = ParseStackTrace(src); rows = rows .Select(x => MapRow(sourceMapProvider, x)); foreach (var row in rows) { sb.Append($"{row.File} [{row.Line}, {row.Column}]\r\n"); } return(sb.ToString()); }
/// <summary> /// Creates a StackTraceDeminifier which does not depend on JS files, and is ES2015+ compatible. /// StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier. /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetMapOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, IStackTraceParser stackTraceParser) { if (sourceMapProvider == null) { throw new ArgumentNullException(nameof(sourceMapProvider)); } if (stackTraceParser == null) { throw new ArgumentNullException(nameof(stackTraceParser)); } ISourceMapStore sourceMapStore = new SourceMapStore(sourceMapProvider); IStackFrameDeminifier stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore); return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser)); }
/// <summary> /// Creates a StackTraceDeminifier that only deminifies the method names. StackTrace deminifiers created with this method will use significantly less memory during runtime than the /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetMethodNameOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider) { return(GetMethodNameOnlyStackTraceDeminfier(sourceMapProvider, generatedCodeProvider, new StackTraceParser())); }
/// <summary> /// Creates a StackTraceDeminifier which does not depend on JS files, and is ES2015+ compatible. /// StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier. /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetMapOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider) { return(GetMapOnlyStackTraceDeminfier(sourceMapProvider, new StackTraceParser())); }
public SourceMapStore(ISourceMapProvider sourceMapProvider) { _sourceMapProvider = sourceMapProvider; _sourceMapParser = new SourceMapParser(); _sourceMapCache = new KeyValueCache <string, SourceMap>(sourceCodeUrl => _sourceMapParser.ParseSourceMap(_sourceMapProvider.GetSourceMapContentsForCallstackUrl(sourceCodeUrl))); }