Skip to content

Commit 29575be

Browse files
authored
feat(typescript): Add typescript definitions
Fixes #223
1 parent d162b9d commit 29575be

File tree

11 files changed

+515
-75
lines changed

11 files changed

+515
-75
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
charset = utf-8
8+
9+
[*.json]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.js,*.jsx,*.ts]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[{package.json,.travis.yml}]
18+
indent_style = space
19+
indent_size = 2

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ branches:
33
- master
44
matrix:
55
include:
6+
- language: node_js
7+
node_js:
8+
- "8"
9+
env:
10+
- LANE='node'
11+
cache:
12+
yarn: true
13+
script:
14+
- .travis/run.sh
615
- language: android
716
os: linux
817
jdk: oraclejdk8
@@ -30,6 +39,8 @@ matrix:
3039
- extra-google-google_play_services
3140
- extra-google-m2repository
3241
- addon-google_apis-google-16
42+
env:
43+
- LANE='android'
3344
script:
3445
- .travis/run.sh
3546
- language: objective-c

.travis/run.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
#!/bin/sh
2+
3+
if [ "$LANE" = "node" ];
4+
then
5+
yarn install
6+
npm run test-typescript
7+
cd appium
8+
npm install -g react-native-cli
9+
make install
10+
cd example
11+
npm run test
12+
else
13+
214
cd appium
315
bundle install
416
pip wheel --wheel-dir wheelhouse -r requirements.txt
517
npm install -g react-native-cli
618
react-native -v
19+
720
if [ "$LANE" = "ios" ];
821
then
922
make test
1023
else
1124
make test-android
1225
fi
26+
27+
fi

appium/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ copy-local-files-to-example:
2323
cp -r ../android/* example/node_modules/react-native-sentry/android/
2424
cp -r ../ios/Sentry/Sources/Sentry/* example/node_modules/react-native-sentry/ios/Sentry/Sources/Sentry/
2525

26-
test: create-test-bundle new-demo-project copy-local-files-to-example
26+
install: new-demo-project copy-local-files-to-example
27+
28+
test: create-test-bundle install
2729
fastlane build_for_device_farm
2830
fastlane aws_ios_upload_and_run
2931
ruby check_run_failues.rb
3032

31-
test-android: create-android-test-bundle new-demo-project copy-local-files-to-example
33+
test-android: create-android-test-bundle install
3234
fastlane build_android_for_device_farm
3335
fastlane aws_android_upload_and_run
3436
ANDROID=1 ruby check_run_failues.rb
3537

36-
local-android-test: create-android-test-bundle new-demo-project copy-local-files-to-example
38+
local-android-test: create-android-test-bundle install
3739
fastlane build_android_for_device_farm
3840
ANDROID=1 pytest -vv tests/test_android.py
3941

40-
local-test: create-test-bundle new-demo-project copy-local-files-to-example
42+
local-test: create-test-bundle install
4143
fastlane build_for_local_appium
4244
pytest -vv tests/test_ios.py

lib/NativeClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ export class NativeClient {
9090
RNSentry.addExtra(key, value);
9191
}
9292

93-
captureBreadcrumb(crumb) {
94-
RNSentry.captureBreadcrumb(crumb);
93+
captureBreadcrumb(breadcrumb) {
94+
RNSentry.captureBreadcrumb(breadcrumb);
9595
}
9696

9797
clearContext() {

lib/RavenClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export class RavenClient {
6565
Raven.captureException(ex, options);
6666
}
6767

68-
captureBreadcrumb(msg, options) {
69-
Raven.captureBreadcrumb(msg, options);
68+
captureBreadcrumb(breadcrumb) {
69+
Raven.captureBreadcrumb(breadcrumb);
7070
}
7171

7272
captureMessage(message, options) {

lib/Sentry.d.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Type definitions for react-native-sentry
2+
// Project: https://sentry.io
3+
// Definitions by: Daniel Griesser <https://github.com/hazat>
4+
// Definitions: https://github.com/getsentry/react-native-sentry
5+
// TypeScript Version: 2.3
6+
7+
type SentryBreadcrumbType = "navigation" | "http";
8+
9+
interface SentryBreadcrumb {
10+
message?: string;
11+
category?: string;
12+
level?: SentrySeverity;
13+
data?: object;
14+
type?: SentryBreadcrumbType;
15+
}
16+
17+
export enum SentrySeverity {
18+
Fatal = "fatal",
19+
Error = "error",
20+
Warning = "warning",
21+
Info = "info",
22+
Debug = "debug",
23+
Critical = "critical"
24+
}
25+
26+
export enum SentryLog {
27+
None = 0,
28+
Error = 1,
29+
Debug = 2,
30+
Verbose = 3
31+
}
32+
33+
interface SentryOptions {
34+
logLevel?: SentryLog;
35+
instrument?: boolean;
36+
disableNativeIntegration?: boolean;
37+
ignoreModulesExclude?: [string];
38+
ignoreModulesInclude?: [string];
39+
}
40+
41+
export default Sentry;
42+
43+
export class Sentry {
44+
install(): void;
45+
46+
static config(dsn: string, options?: SentryOptions): Sentry;
47+
48+
static isNativeClientAvailable(): boolean;
49+
50+
static crash(): void;
51+
52+
static nativeCrash(): void;
53+
54+
static setEventSentSuccessfully(callback: Function): void;
55+
56+
static setDataCallback(callback: Function): void;
57+
58+
static setUserContext(user: {
59+
id?: string;
60+
username?: string;
61+
email?: string;
62+
extra?: object;
63+
}): void;
64+
65+
static setTagsContext(tags: Object): void;
66+
67+
static setExtraContext(extra: Object): void;
68+
69+
static captureMessage(message: string, options?: object): void;
70+
71+
static captureException(ex: Error, options?: object): void;
72+
73+
static captureBreadcrumb(breadcrumb: SentryBreadcrumb): void;
74+
75+
static clearContext(): Promise<void>;
76+
77+
static context(func: Function, ...args: any[]): void;
78+
static context(options: object, func: Function, ...args: any[]): void;
79+
80+
static wrap(func: Function): Function;
81+
static wrap(options: object, func: Function): Function;
82+
static wrap<T extends Function>(func: T): T;
83+
static wrap<T extends Function>(options: object, func: T): T;
84+
85+
static lastException(): object;
86+
static lastException(): null;
87+
88+
static lastEventId(): object;
89+
static lastEventId(): null;
90+
91+
static setRelease(release: string): void;
92+
93+
static setDist(dist: string): void;
94+
95+
static setVersion(version: string): void;
96+
}

0 commit comments

Comments
 (0)