-
-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathsentry_database.h
88 lines (74 loc) · 2.62 KB
/
sentry_database.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef SENTRY_DATABASE_H_INCLUDED
#define SENTRY_DATABASE_H_INCLUDED
#include "sentry_boot.h"
#include "sentry_path.h"
#include "sentry_session.h"
typedef struct sentry_run_s {
sentry_uuid_t uuid;
sentry_path_t *run_path;
sentry_path_t *session_path;
sentry_filelock_t *lock;
} sentry_run_t;
/**
* This creates a new application run including its associated directory and
* lockfile:
* * `<database>/<uuid>.run/`
* * `<database>/<uuid>.run.lock`
*/
sentry_run_t *sentry__run_new(const sentry_path_t *database_path);
/**
* This will clean up all the files belonging to this run.
*/
void sentry__run_clean(sentry_run_t *run);
/**
* Free the previously allocated run.
* Make sure to call `sentry__run_clean` first, to not leave any files or
* directories laying around.
*/
void sentry__run_free(sentry_run_t *run);
/**
* This will serialize and write the given envelope to disk into a file named
* like so:
* `<database>/<uuid>.run/<event-uuid>.envelope`
*/
bool sentry__run_write_envelope(
const sentry_run_t *run, const sentry_envelope_t *envelope);
/**
* This will serialize and write the given session to disk into a file named:
* `<database>/<uuid>.run/session.json`
*/
bool sentry__run_write_session(
const sentry_run_t *run, const sentry_session_t *session);
/**
* This will remove any previously created session file.
* See `sentry__run_write_session`.
*/
bool sentry__run_clear_session(const sentry_run_t *run);
/**
* This function is essential to send crash reports from previous runs of the
* program.
* More specifically, this function will iterate over all the directories
* inside the `database_path`. Directories matching `<database>/<uuid>.run/`
* will be locked, and any files named `<event-uuid>.envelope` or
* `session.json` will be queued for sending to the backend. The files and
* directories matching these criteria will be deleted afterwards.
* The following heuristic is applied to all unclosed sessions: If the session
* was started before the timestamp given by `last_crash`, the session is closed
* as "crashed" with an appropriate duration.
*/
void sentry__process_old_runs(
const sentry_options_t *options, uint64_t last_crash);
/**
* This will write the current ISO8601 formatted timestamp into the
* `<database>/last_crash` file.
*/
bool sentry__write_crash_marker(const sentry_options_t *options);
/**
* This will check whether the `<database>/last_crash` file exists.
*/
bool sentry__has_crash_marker(const sentry_options_t *options);
/**
* This will remove the `<database>/last_crash` file.
*/
bool sentry__clear_crash_marker(const sentry_options_t *options);
#endif