Skip to content

Commit

Permalink
feat(): Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg committed May 13, 2020
0 parents commit 2ce7531
Show file tree
Hide file tree
Showing 11 changed files with 5,662 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
npm-debug.log
*.pem
!mock-cert.pem
.env
package-lock.json
coverage
lib
.eslintcache
.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trailingComma: "es5"
singleQuote: true
77 changes: 77 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [[email protected]][email]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
[email]: mailto:[email protected]

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
104 changes: 104 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Business Source License 1.1

Parameters

Licensor: Functional Software, Inc.
Licensed Work: Sentry
The Licensed Work is (c) 2019 Functional Software, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided that you do
not use the Licensed Work for an Application Monitoring
Service.

An "Application Monitoring Service" is a commercial offering
that allows third parties (other than your employees and
contractors) to access the functionality of the Licensed
Work so that such third parties directly benefit from the
error-reporting or application monitoring features of the
Licensed Work.

Change Date: 2023-05-01

Change License: Apache License, Version 2.0

For information about alternative licensing arrangements for the Software,
please visit: https://sentry.io/pricing/

Notice

The Business Source License (this document, or the "License") is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.

License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
"Business Source License" is a trademark of MariaDB Corporation Ab.

-----------------------------------------------------------------------------

Business Source License 1.1

Terms

The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.

Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.

If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.

All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.

You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.

Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.

This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).

TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.

MariaDB hereby grants you permission to use this License’s text to license
your works, and to refer to it using the trademark "Business Source License",
as long as you comply with the Covenants of Licensor below.

Covenants of Licensor

In consideration of the right to use this License’s text and the "Business
Source License" name and trademark, Licensor covenants to MariaDB, and to all
other recipients of the licensed work to be provided by Licensor:

1. To specify as the Change License the GPL Version 2.0 or any later version,
or a license that is compatible with GPL Version 2.0 or a later version,
where "compatible" means that software provided under the Change License can
be included in a program with software provided under GPL Version 2.0 or a
later version. Licensor may specify additional Change Licenses without
limitation.

2. To either: (a) specify an additional grant of rights to use that does not
impose any additional restriction on the right granted in this License, as
the Additional Use Grant; or (b) insert the text "None".

3. To specify a Change Date.

4. Not to modify this License in any other way.
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "sentry-development-metrics",
"version": "1.0.0",
"private": true,
"description": "Tracks Sentry development metrics",
"author": "Billy Vong <[email protected]>",
"license": "BSL",
"repository": "https://github.com/getsentry/sentry-development-metrics.git",
"homepage": "https://github.com/getsentry/sentry-development-metrics",
"bugs": "https://github.com/billyvg/sentry-development-metrics/issues",
"main": "lib/index",
"keywords": [
"sentry",
"development-metrics"
],
"scripts": {
"build": "tsc -p tsconfig.json",
"deploy": "yarn build && (yarn deploy:development-metrics)",
"deploy:development-metrics": "gcloud run deploy development-metrics --allow-unauthenticated --project=sentry-dev-tooling --trigger-http --memory=128MB",
"dev": "yarn dev:smee & yarn build --watch & nodemon --exec \"yarn start\"",
"dev:smee": "smee -u https://smee.io/O0PvxCnh7srFDwoS",
"start": "node ./lib/index.js",
"lint": "yarn eslint **/*.ts --fix",
"test": "yarn jest && yarn eslint **/*.ts",
"test:watch": "yarn jest --watch --notify --notifyMode=change --coverage"
},
"dependencies": {
"@sentry/node": "^5.12.3",
"dotenv": "^8.2.0",
"fastify": "^2.14.0",
"fastify-formbody": "^3.1.0"
},
"devDependencies": {
"@types/node": "12",
"@typescript-eslint/eslint-plugin": "^2.19.0",
"@typescript-eslint/parser": "^2.19.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-typescript": "^0.14.0",
"husky": ">=4",
"jest": "^25.1.0",
"lint-staged": ">=10",
"nodemon": "^2.0.0",
"prettier": "^1.19.1",
"ts-jest": "^25.2.0",
"typescript": "^3.6.4"
},
"engines": {
"node": ">= 12.0.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": "eslint --cache --fix"
}
}
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const SENTRY_DSN =
'https://[email protected]/2450415';
export const DEFAULT_PORT = 3000;
66 changes: 66 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import fastify, { FastifyInstance, RouteShorthandOptions } from 'fastify';
import * as Sentry from '@sentry/node';
import { Server, IncomingMessage, ServerResponse } from 'http';

import { DEFAULT_PORT, SENTRY_DSN } from './config';
import { TravisPayload } from './types';

Sentry.init({
dsn: SENTRY_DSN,
release: process.env.VERSION,
});

const server: FastifyInstance<
Server,
IncomingMessage,
ServerResponse
> = fastify({ logger: console });

const opts: RouteShorthandOptions = {
schema: {
response: {
200: {
type: 'object',
properties: {
pong: {
type: 'string',
},
},
},
},
},
};

server.register(require('fastify-formbody'));

server.post('/metrics/travis/webhook', {}, async request => {
const travisSignature = Buffer.from(request.headers.signature, 'base64');
console.log('signature', travisSignature);

const { config, ...payload } = JSON.parse(
request.body.payload
) as TravisPayload;

console.log(payload);
payload.matrix.forEach(({ config }) => console.log(config));
console.log(config);

return {};
});

server.post('/metrics/github/webhook', {}, async request => {
const payload = JSON.parse(request.body.payload);

console.log(payload);

return {};
});

server.listen(Number(process.env.PORT) || DEFAULT_PORT, (err, address) => {
if (err) {
server.log.error(err);
Sentry.captureException(err);
process.exit(0);
}
server.log.info(`server listening on ${address}`);
});
Loading

0 comments on commit 2ce7531

Please sign in to comment.