Skip to content

Commit a309a31

Browse files
author
farfromrefug
committed
chore: new repo
1 parent 73ffe70 commit a309a31

File tree

18 files changed

+712
-83
lines changed

18 files changed

+712
-83
lines changed

demo-snippets/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@nativescript-community/template-snippet",
3+
"private": true,
4+
"version": "0.0.1",
5+
"dependencies": {
6+
"@nativescript-community/sentry": "*"
7+
},
8+
"devDependencies": {
9+
"@sentry/webpack-plugin": "2.14.2"
10+
}
11+
}

demo-snippets/vue/Basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Sentry from 'src';
1+
import * as Sentry from '@nativescript-community/sentry';
22
import { File, knownFolders, path } from '@nativescript/core';
33
import { TextEncoder } from '@nativescript/core/text';
44
import { createArrayBuffer } from '@nativescript-community/arraybuffers';

demo-snippets/vue/install.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import Vue from 'nativescript-vue';
2+
import * as Sentry from '@nativescript-community/sentry';
3+
import * as Tracing from '@nativescript-community/sentry/tracing';
4+
import { Application, NavigatedData, Page, Trace, Utils, View } from '@nativescript/core';
5+
import { on as applicationOn, launchEvent } from '@nativescript/core/application';
6+
import Basic from './Basic';
7+
8+
Trace.addCategories(Sentry.SentryTraceCategory);
9+
Trace.enable();
10+
11+
declare const SENTRY_DSN: string;
12+
declare const SENTRY_PREFIX: string;
13+
declare const __APP_ID__: string;
14+
declare const __APP_VERSION__: string;
15+
declare const __APP_BUILD_NUMBER__: string;
16+
async function startSentry() {
17+
try {
18+
Sentry.init({
19+
dsn: SENTRY_DSN,
20+
debug: true,
21+
enablePerformanceV2: true,
22+
release: `${__APP_ID__}@${__APP_VERSION__}+${__APP_BUILD_NUMBER__}`,
23+
dist: `${__APP_BUILD_NUMBER__}.${__ANDROID__ ? 'android' : 'ios'}`,
24+
flushSendEvent: true,
25+
enableNativeCrashHandling: true,
26+
attachScreenshot: true,
27+
tracesSampleRate: 1.0,
28+
sampleRate: 1.0,
29+
enableAutoPerformanceTracking: true,
30+
enableAutoSessionTracking: true,
31+
integrations: [
32+
new Tracing.NativescriptTracing({
33+
enableAppStartTracking: true,
34+
enableNativeFramesTracking: true,
35+
// routingInstrumentation: HttpService.sentryTracing,
36+
enableStallTracking: true
37+
})
38+
],
39+
enableUIViewControllerTracing: false,
40+
enableUserInteractionTracing: false,
41+
enableAutoBreadcrumbTracking: false
42+
});
43+
Page.on('navigatingTo', (event: NavigatedData) => {
44+
Sentry.addBreadcrumb({
45+
category: 'navigation',
46+
type: 'navigation',
47+
// We assume that context.name is the name of the route.
48+
message: `Navigation to ${event.object}`,
49+
data: {
50+
isBackNavigation: event.isBackNavigation,
51+
from: `${(event.object as Page).frame?.currentPage}`,
52+
to: `${event.object}`
53+
}
54+
});
55+
});
56+
View.on('showingModally', (event: NavigatedData) => {
57+
Sentry.addBreadcrumb({
58+
category: 'navigation',
59+
type: 'navigation',
60+
// We assume that context.name is the name of the route.
61+
message: `Navigation to Modal ${event.object}`,
62+
data: {
63+
from: `${(event.object as View)._modalParent}`,
64+
to: `${event.object}`
65+
}
66+
});
67+
});
68+
View.on('closingModally', (event: NavigatedData) => {
69+
Sentry.addBreadcrumb({
70+
category: 'navigation',
71+
type: 'navigation',
72+
// We assume that context.name is the name of the route.
73+
message: `Closing modal ${event.object}`,
74+
data: {
75+
from: `${event.object as View}`
76+
}
77+
});
78+
});
79+
setTimeout(() => {
80+
Sentry.withScope((scope) => {
81+
try {
82+
scope.setTag('myTag', 'tag-value');
83+
scope.setExtra('myExtra', 'extra-value');
84+
scope.addBreadcrumb({ message: 'test' });
85+
Sentry.captureMessage('Hello Sentry!');
86+
} catch (error) {
87+
console.error(error);
88+
}
89+
});
90+
}, 1000);
91+
} catch (err) {
92+
console.error(err, err.stack);
93+
}
94+
}
95+
96+
export function installPlugin() {
97+
if (!__ANDROID__ || Utils.android.getApplicationContext()) {
98+
startSentry();
99+
} else {
100+
applicationOn(launchEvent, startSentry);
101+
}
102+
}
103+
104+
export const demos = [{ name: 'Basic', path: 'Basic', component: Basic }];
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');
2+
const nsWebpack = require('@nativescript/webpack');
3+
const { dirname, join, relative, resolve, sep } = require('path');
4+
const { readdirSync, readFileSync } = require('fs');
5+
6+
module.exports = (env, webpack) => {
7+
const platform = env && ((env.android && 'android') || (env.ios && 'ios'));
8+
webpack.chainWebpack((config) => {});
9+
};
10+
11+
module.exports.onWebpackConfig = function (config, env, params) {
12+
13+
const platform = env && ((env.android && 'android') || (env.ios && 'ios'));
14+
const dist = nsWebpack.Utils.platform.getDistPath();
15+
console.log('test', env, params, dist);
16+
const projectRoot = nsWebpack.Utils.project.getProjectRootPath();
17+
const appResourcesPath = env.appResourcesPath;
18+
let appVersion;
19+
let buildNumber;
20+
if (platform === 'android') {
21+
const gradlePath = resolve(projectRoot, appResourcesPath, 'Android/app.gradle');
22+
const gradleData = readFileSync(gradlePath, 'utf8');
23+
appVersion = gradleData.match(/versionName "((?:[0-9]+\.?)+)"/)[1];
24+
buildNumber = gradleData.match(/versionCode ([0-9]+)/)[1];
25+
} else if (platform === 'ios') {
26+
const plistPath = resolve(projectRoot, appResourcesPath, 'iOS/Info.plist');
27+
const plistData = readFileSync(plistPath, 'utf8');
28+
appVersion = plistData.match(/<key>CFBundleShortVersionString<\/key>[\s\n]*<string>(.*?)<\/string>/)[1];
29+
buildNumber = plistData.match(/<key>CFBundleVersion<\/key>[\s\n]*<string>([0-9]*)<\/string>/)[1];
30+
}
31+
// nsWebpack.chainWebpack(config=>{
32+
// config.entry('bundle').prepend('@nativescript-community/sentry/process');
33+
// });
34+
const definitions = config.plugins.find((p) => p.constructor.name === 'DefinePlugin').definitions;
35+
delete definitions['process'];
36+
Object.assign(definitions, {
37+
SENTRY_DSN: `"${process.env.SENTRY_DSN}"`,
38+
SENTRY_PREFIX: `"${process.env.SENTRY_PREFIX}"`,
39+
__APP_ID__: `"${env.appId}"`,
40+
__APP_VERSION__: `"${appVersion}"`,
41+
__APP_BUILD_NUMBER__: `"${buildNumber}"`
42+
});
43+
44+
config.resolve.symlinks = false;
45+
config.devtool = 'source-map';
46+
config.plugins.push(
47+
sentryWebpackPlugin({
48+
org: process.env.SENTRY_ORG,
49+
url: process.env.SENTRY_URL,
50+
project: process.env.SENTRY_PROJECT,
51+
authToken: process.env.SENTRY_AUTH_TOKEN,
52+
release: {
53+
name: `${config.id}@${appVersion}+${buildNumber}`,
54+
dist: `${buildNumber}.${platform}`,
55+
setCommits: false,
56+
create: true,
57+
cleanArtifacts: true
58+
},
59+
sourcemaps: {
60+
ignore: ['tns-java-classes', 'hot-update'],
61+
assets: [dist + '/**/*.js', join(dist, process.env.SOURCEMAP_REL_DIR) + '/*.map']
62+
}
63+
})
64+
);
65+
return config;
66+
};

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"version": "1.0.0",
33
"scripts": {
44
"build": "lerna run build",
5-
"build.all": "npm run build",
5+
"build.watch": "lerna run build.watch",
6+
"build.all": "lerna run build.all",
7+
"build.all.win": "lerna run build.all.win",
8+
"build.angular": "lerna run build.angular",
69
"clean": "rimraf 'packages/**/*.d.ts' 'packages/**/*.js' 'packages/**/*.js.map' 'packages/**/*.metada' 'packages/**/angular/ng-package.json'",
710
"commit_readme_doc_changes": "git add docs/** *.md ; git commit -m \"readme/doc\" ; echo \"commit readme doc done\"",
811
"commitmsg": "commitlint -e $GIT_PARAMS",
@@ -40,7 +43,7 @@
4043
"@sentry/integrations": "^7.102.1",
4144
"@sentry/tracing": "^7.102.1",
4245
"@sentry/types": "^7.102.1",
43-
"@sentry/utils": "^7.102.1"
46+
"@sentry/utils": "^7.103.0"
4447
},
4548
"repository": {
4649
"type": "git",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<application>
7+
<meta-data android:name="io.sentry.auto-init" android:value="false" />
8+
</application>
9+
</manifest>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// buildscript {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
dependencies {
7+
def sentryGradleVersion = hasProperty("sentryGradleVersion") ? sentryGradleVersion : "4.3.0"
8+
println "sentryGradleVersion $sentryGradleVersion"
9+
classpath "io.sentry:sentry-android-gradle-plugin:$sentryGradleVersion"
10+
}
11+
// }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Add compatibility options to be comptible with Java 1.8
2+
apply plugin: 'io.sentry.android.gradle'
3+
android {
4+
compileOptions {
5+
sourceCompatibility = JavaVersion.VERSION_1_8
6+
targetCompatibility = JavaVersion.VERSION_1_8
7+
}
8+
}
9+
dependencies {
10+
def sentryVersion = project.hasProperty("sentryVersion") ? project.sentryVersion : "7.4.0"
11+
println("sentryVersion $sentryVersion")
12+
implementation "io.sentry:sentry-android:$sentryVersion"
13+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"uses": [
3+
"io.sentry.android.core.internal.util:ScreenshotUtils",
4+
"io.sentry.android.core:AndroidLogger",
5+
"io.sentry.android.core:AnrIntegration",
6+
"io.sentry.android.core:AppStartState",
7+
"io.sentry.android.core:BuildInfoProvider",
8+
"io.sentry.android.core:CurrentActivityHolder",
9+
"io.sentry.android.core:NdkIntegration",
10+
"io.sentry.android.core:SentryAndroid",
11+
"io.sentry.exception:ExceptionMechanismException",
12+
"io.sentry.protocol:Message",
13+
"io.sentry.protocol:SdkVersion",
14+
"io.sentry.protocol:SentryException",
15+
"io.sentry.protocol:SentryId",
16+
"io.sentry.protocol:SentryPackage",
17+
"io.sentry.protocol:SentryStackFrame",
18+
"io.sentry.protocol:SentryStackTrace",
19+
"io.sentry.protocol:User",
20+
"io.sentry.transport:AsyncHttpTransport",
21+
"io.sentry.transport:ITransportGate",
22+
"io.sentry.transport:RateLimiter",
23+
"io.sentry:Breadcrumb",
24+
"io.sentry:Integration",
25+
"io.sentry:ILogger",
26+
"io.sentry:ITransportFactory",
27+
"io.sentry:RequestDetails",
28+
"io.sentry:ScopeCallback",
29+
"io.sentry:Sentry",
30+
"io.sentry:Sentry.OptionsConfiguration",
31+
"io.sentry:SentryBaseEvent",
32+
"io.sentry:SentryEvent",
33+
"io.sentry:SentryLevel",
34+
"io.sentry:SentryOptions",
35+
"io.sentry:SentryOptions.BeforeBreadcrumbCallback",
36+
"io.sentry:SentryOptions.BeforeSendCallback",
37+
"io.sentry:UncaughtExceptionHandlerIntegration",
38+
"io.sentry:UserFeedback",
39+
"io.sentry.android.fragment:FragmentLifecycleIntegration",
40+
"java.lang:Boolean",
41+
"java.lang:Integer",
42+
"java.lang:Long",
43+
"java.lang:Thread",
44+
"java.nio.charset:Charset",
45+
"java.nio:CharBuffer",
46+
"java.util:Collection",
47+
"java.util:Map",
48+
"java.util:UUID"
49+
]
50+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pod 'Sentry/HybridSDK', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '8.20.0'

0 commit comments

Comments
 (0)