Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixing protocol names
  • Loading branch information
Manoel Aranda Neto committed Oct 24, 2019
commit 199de95cbc1bed411b3f3739cdbf30bcfcc3e404
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import io.sentry.core.ILogger;
import io.sentry.core.MainEventProcessor;
import io.sentry.core.SentryLevel;
import io.sentry.core.SentryOptions;
import java.io.File;
Expand All @@ -20,22 +21,19 @@ static void init(SentryOptions options, Context context, ILogger logger) {
options.setSentryClientName("sentry.java.android/0.0.1");

ManifestMetadataReader.applyMetadata(context, options);
createsEnvelopeDirPath(options, context);

if (options.isEnableNdk()) {
try {
// create sentry-envelopes folder for NDK envelopes
createsEnvelopeDirPath(options, context);

// TODO: Create Integrations interface and use that to initialize NDK
Class<?> cls = Class.forName("io.sentry.android.ndk.SentryNdk");

// TODO: temporary hack
String cacheDirPath = context.getCacheDir().getAbsolutePath() + "/sentry-envelopes";
File f = new File(cacheDirPath);
f.mkdirs();

Method method = cls.getMethod("init", SentryOptions.class, String.class);
Object[] args = new Object[2];
args[0] = options;
args[1] = cacheDirPath;
args[1] = options.getCacheDirPath();
method.invoke(null, args);
} catch (ClassNotFoundException exc) {
options.getLogger().log(SentryLevel.ERROR, "Failed to load SentryNdk.");
Expand All @@ -44,8 +42,8 @@ static void init(SentryOptions options, Context context, ILogger logger) {
}
}

options.addEventProcessor(new DefaultAndroidEventProcessor(context, options));
options.setSerializer(new AndroidSerializer(options.getLogger()));
addProcessors(options, context);
}

private static void createsEnvelopeDirPath(SentryOptions options, Context context) {
Expand All @@ -56,4 +54,9 @@ private static void createsEnvelopeDirPath(SentryOptions options, Context contex
}
options.setCacheDirPath(envelopesDir.getAbsolutePath());
}

private static void addProcessors(SentryOptions options, Context context) {
options.addEventProcessor(new MainEventProcessor(options));
options.addEventProcessor(new DefaultAndroidEventProcessor(context, options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public SentryEvent process(SentryEvent event) {
event.setMessage(getMessage(throwable));
}

// event.set
// List<SentryException> exceptions = new ArrayList<>();
// exceptions.add(extractExceptionQueue(event.getThrowable()));
// event.setException(exceptions);
}

return event;
Expand All @@ -46,7 +48,7 @@ private SentryException extractExceptionQueue(Throwable throwable) {

for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
SentryStackFrame stackFrame = new SentryStackFrame();
stackFrame.setFunction(stackTraceElement.getMethodName());
stackFrame.setRawFunction(stackTraceElement.getMethodName());
stackFrame.setModule(stackTraceElement.getClassName());
stackFrame.setFilename(stackTraceElement.getFileName());
stackFrame.setLineno(stackTraceElement.getLineNumber());
Expand Down
13 changes: 7 additions & 6 deletions sentry-core/src/main/java/io/sentry/core/SentryEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SentryEvent implements IUnknownPropertiesConsumer {
private String dist;
private String logger;
private SentryValues<SentryThread> threads;
private SentryValues<SentryException> exceptions;
private SentryValues<SentryException> exception;
private SentryLevel level;
private String transaction;
private String environment;
Expand All @@ -32,6 +32,7 @@ public class SentryEvent implements IUnknownPropertiesConsumer {
private Map<String, String> tags = new HashMap<>();
private Map<String, Object> extra = new HashMap<>();
private Map<String, Object> unknown;
// TODO modules is missing?

SentryEvent(SentryId eventId, Date timestamp) {
this.eventId = eventId;
Expand Down Expand Up @@ -115,12 +116,12 @@ public void setThreads(List<SentryThread> threads) {
this.threads = new SentryValues<>(threads);
}

public List<SentryException> getExceptions() {
return exceptions.getValues();
public List<SentryException> getException() {
return exception.getValues();
}

public void setExceptions(List<SentryException> exceptions) {
this.exceptions = new SentryValues<>(exceptions);
public void setException(List<SentryException> exception) {
this.exception = new SentryValues<>(exception);
}

public void setEventId(SentryId eventId) {
Expand All @@ -140,7 +141,7 @@ public void setThreads(SentryValues<SentryThread> threads) {
}

public void setExceptions(SentryValues<SentryException> exceptions) {
this.exceptions = exceptions;
this.exception = exceptions;
}

public SentryLevel getLevel() {
Expand Down
12 changes: 6 additions & 6 deletions sentry-core/src/main/java/io/sentry/core/SentryValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import java.util.List;

class SentryValues<T> {
private List<T> items;
private List<T> values;

public SentryValues(List<T> items) {
if (items == null) {
items = new ArrayList<>(0);
public SentryValues(List<T> values) {
if (values == null) {
values = new ArrayList<>(0);
}
this.items = items;
this.values = values;
}

public List<T> getValues() {
return items;
return values;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ public class SentryStackFrame implements IUnknownPropertiesConsumer {
private Map<String, String> vars;
private List<Integer> framesOmitted;
private String filename;
private String function;
private String rawFunction;
private String module;
private Integer lineno;
private Integer colno;
private String absolutePath;
private String absPath;
private String contextLine;
private Boolean inApp;
private String _package;
private String _package; // TODO: _package as its a reserverd word
private String platform;
private Long imageAddress;
private Long SymbolAddress;
private Long instructionOffset;
private Long imageAddr;
private Long symbolAddr;
private Long instructionAddr;
private Map<String, Object> unknown;

public List<String> getPreContext() {
Expand Down Expand Up @@ -65,12 +65,12 @@ public void setFilename(String filename) {
this.filename = filename;
}

public String getFunction() {
return function;
public String getRawFunction() {
return rawFunction;
}

public void setFunction(String function) {
this.function = function;
public void setRawFunction(String rawFunction) {
this.rawFunction = rawFunction;
}

public String getModule() {
Expand All @@ -97,12 +97,12 @@ public void setColno(Integer colno) {
this.colno = colno;
}

public String getAbsolutePath() {
return absolutePath;
public String getAbsPath() {
return absPath;
}

public void setAbsolutePath(String absolutePath) {
this.absolutePath = absolutePath;
public void setAbsPath(String absPath) {
this.absPath = absPath;
}

public String getContextLine() {
Expand Down Expand Up @@ -137,28 +137,28 @@ public void setPlatform(String platform) {
this.platform = platform;
}

public Long getImageAddress() {
return imageAddress;
public Long getImageAddr() {
return imageAddr;
}

public void setImageAddress(Long imageAddress) {
this.imageAddress = imageAddress;
public void setImageAddr(Long imageAddr) {
this.imageAddr = imageAddr;
}

public Long getSymbolAddress() {
return SymbolAddress;
public Long getSymbolAddr() {
return symbolAddr;
}

public void setSymbolAddress(Long symbolAddress) {
SymbolAddress = symbolAddress;
public void setSymbolAddr(Long symbolAddr) {
this.symbolAddr = symbolAddr;
}

public Long getInstructionOffset() {
return instructionOffset;
public Long getInstructionAddr() {
return instructionAddr;
}

public void setInstructionOffset(Long instructionOffset) {
this.instructionOffset = instructionOffset;
public void setInstructionAddr(Long instructionAddr) {
this.instructionAddr = instructionAddr;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/** The Sentry stacktrace. */
public class SentryStackTrace implements IUnknownPropertiesConsumer {
private List<SentryStackFrame> frames;
// TODO registers is missing?
private Map<String, Object> unknown;

/**
Expand Down