Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix 3 #73

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
82 changes: 41 additions & 41 deletions .github/workflows/pr-merge-notification.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
name: Notify on PR Merge

on:
pull_request:
types:
- closed
pull_request:
types:
- closed

jobs:
notify:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
notify:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Send Slack Notification
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{
"text": "A PR has been merged in the repository *${{ github.repository }}*.\n*PR Title:* ${{ github.event.pull_request.title }}\n*Merged By:* ${{ github.event.pull_request.merged_by.login }}\n*PR URL:* ${{ github.event.pull_request.html_url }}"
}' $SLACK_WEBHOOK_URL
steps:
- name: Send Slack Notification
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{
"text": "A PR has been merged in the repository *${{ github.repository }}*.\n*PR Title:* ${{ github.event.pull_request.title }}\n*Merged By:* ${{ github.event.pull_request.merged_by.login }}\n*PR URL:* ${{ github.event.pull_request.html_url }}"
}' $SLACK_WEBHOOK_URL

- name: Send Microsoft Teams Notification
env:
TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
run: |
curl -H 'Content-Type: application/json' -d '{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "PR Merged in ${{ github.repository }}",
"themeColor": "0076D7",
"title": "Pull Request Merged",
"sections": [{
"activityTitle": "A PR has been merged in the repository *${{ github.repository }}*",
"activitySubtitle": "PR Title: ${{ github.event.pull_request.title }}",
"activityImage": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"facts": [{
"name": "Merged By",
"value": "${{ github.event.pull_request.merged_by.login }}"
},
{
"name": "PR URL",
"value": "[Link](${{ github.event.pull_request.html_url }})"
}
],
"markdown": true
}]
}' $TEAMS_WEBHOOK_URL
- name: Send Microsoft Teams Notification
env:
TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
run: |
curl -H 'Content-Type: application/json' -d '{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "PR Merged in ${{ github.repository }}",
"themeColor": "FFA500",
"title": "Pull Request Merged",
"sections": [{
"activityTitle": "A PR has been merged in the repository *${{ github.repository }}*",
"activitySubtitle": "PR Title: ${{ github.event.pull_request.title }}",
"activityImage": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"facts": [{
"name": "Merged By",
"value": "${{ github.event.pull_request.merged_by.login }}"
},
{
"name": "PR URL",
"value": "[Link](${{ github.event.pull_request.html_url }})"
}
],
"markdown": true
}]
}' $TEAMS_WEBHOOK_URL
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,48 @@ jobs:
environment: production
version: vs-code-extension@${{ env.LATEST_TAG }}

notify:
runs-on: ubuntu-latest
needs: [build-package, sentry-release]
steps:
- name: Send Slack Notification
if: success()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{
"text": "The VS Code extension has been successfully published to the Marketplace.\n*Version:* ${{ env.LATEST_TAG }}\n*Repository:* ${{ github.repository }}."
}' $SLACK_WEBHOOK_URL

- name: Send Microsoft Teams Notification
if: success()
env:
TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
run: |
curl -H 'Content-Type: application/json' -d '{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "VS Code Extension Published",
"themeColor": "0076D7",
"title": "VS Code Extension Published",
"sections": [{
"activityTitle": "VS Code extension published",
"activitySubtitle": "Version: ${{ env.LATEST_TAG }}",
"activityImage": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"facts": [{
"name": "Repository",
"value": "${{ github.repository }}"
},
{
"name": "Version",
"value": "${{ env.LATEST_TAG }}"
}
],
"markdown": true
}]
}' $TEAMS_WEBHOOK_URL

cleanup:
runs-on: ubuntu-latest
needs: [setup, build-package, sentry-release]
Expand Down
50 changes: 42 additions & 8 deletions src/helpers/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export class ApiClient {
private errorHandler: ErrorHandler,
private logger: typeof Logger,
) {
this.axiosInstance = axios.create();
this.axiosInstance = axios.create({
timeout: 10000,
timeoutErrorMessage: "The request timed out. Please check your internet connection or try again later.",
});

this.axiosInstance.interceptors.request.use(
async (config: AxiosRequestConfig): Promise<InternalAxiosRequestConfig> => {
Expand Down Expand Up @@ -47,16 +50,47 @@ export class ApiClient {
}

public get<T>(url: string, config?: AxiosRequestConfig): Promise<T> {
return Sentry.startSpan({ name: "api-request", op: "http.client", startTime: new Date() }, async (span) => {
return this.axiosInstance.get<T>(url, config).then((response) => {
span.end(new Date());
return response.data;
});
});
return Sentry.startSpan(
{
name: "api-request",
op: "http.client",
startTime: new Date(),
},
async (span) => {
try {
const response = await this.axiosInstance.get<T>(url, config);
span.end(new Date());
return response.data;
} catch (error: any) {
span.setStatus(error.code);
span.end(new Date());
Sentry.captureException(error);
throw error;
}
},
);
}

public post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {
return this.axiosInstance.post<T>(url, data, config).then((response) => response.data);
return Sentry.startSpan(
{
name: "api-request",
op: "http.client",
startTime: new Date(),
},
async (span) => {
try {
const response = await this.axiosInstance.post<T>(url, data, config);
span.end(new Date());
return response.data;
} catch (error: any) {
span.setStatus(error.code);
span.end(new Date());
Sentry.captureException(error);
throw error;
}
},
);
}

// Add other methods (put, delete, etc.) as needed
Expand Down