forked from atlassian/github-for-jira
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from atlassian/main
[pull] main from atlassian:main
- Loading branch information
Showing
54 changed files
with
1,268 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,45 @@ | ||
import { AnalyticClient, ScreenEventProps, TrackEventProps, UIEventProps } from "./types"; | ||
import { axiosRest } from "../api/axiosInstance"; | ||
import { axiosRest, axiosRestWithNoJwt } from "../api/axiosInstance"; | ||
import { reportError } from "../utils"; | ||
const sendAnalytics = (eventType: string, eventProperties: Record<string, unknown>, eventAttributes?: Record<string, unknown>) => { | ||
axiosRest.post(`/rest/app/cloud/analytics-proxy`, | ||
{ | ||
eventType, | ||
eventProperties, | ||
eventAttributes | ||
}).catch(e => { | ||
reportError(e, { | ||
path: "sendAnalytics", | ||
eventType, | ||
...eventProperties, | ||
...eventAttributes | ||
const sendAnalytics = (eventType: string, eventProperties: Record<string, unknown>, eventAttributes?: Record<string, unknown>, requestId?: string) => { | ||
const eventData = { | ||
eventType, | ||
eventProperties, | ||
eventAttributes | ||
}; | ||
const eventError = { | ||
path: "sendAnalytics", | ||
eventType, | ||
...eventProperties, | ||
...eventAttributes | ||
}; | ||
|
||
if (requestId) { | ||
axiosRestWithNoJwt.post(`/rest/app/cloud/deferred/analytics-proxy/${requestId}`, eventData) | ||
.catch(e => { | ||
reportError(e, eventError); | ||
}); | ||
}); | ||
} else { | ||
axiosRest.post(`/rest/app/cloud/analytics-proxy`, eventData) | ||
.catch(e => { | ||
reportError(e, eventError); | ||
}); | ||
} | ||
}; | ||
export const analyticsProxyClient: AnalyticClient = { | ||
sendScreenEvent: function(eventProps: ScreenEventProps, attributes?: Record<string, unknown>) { | ||
sendAnalytics("screen", eventProps, attributes); | ||
sendScreenEvent: function(eventProps: ScreenEventProps, attributes?: Record<string, unknown>, requestId?: string) { | ||
sendAnalytics("screen", eventProps, attributes, requestId); | ||
}, | ||
sendUIEvent: function (eventProps: UIEventProps, attributes?: Record<string, unknown>) { | ||
sendUIEvent: function (eventProps: UIEventProps, attributes?: Record<string, unknown>, requestId?: string) { | ||
sendAnalytics("ui", { | ||
...eventProps, | ||
source: "spa" | ||
}, attributes); | ||
}, attributes, requestId); | ||
}, | ||
sendTrackEvent: function (eventProps: TrackEventProps, attributes?: Record<string, unknown>) { | ||
sendTrackEvent: function (eventProps: TrackEventProps, attributes?: Record<string, unknown>, requestId?: string) { | ||
sendAnalytics("track", { | ||
...eventProps, | ||
source: "spa" | ||
}, attributes); | ||
}, attributes, requestId); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { GetRedirectUrlResponse, ExchangeTokenResponse } from "rest-interfaces"; | ||
import { axiosRest } from "../axiosInstance"; | ||
import { axiosRestWithNoJwt } from "../axiosInstance"; | ||
|
||
export default { | ||
generateOAuthUrl: () => axiosRest.get<GetRedirectUrlResponse>("/rest/app/cloud/oauth/redirectUrl"), | ||
exchangeToken: (code: string, state: string) => axiosRest.post<ExchangeTokenResponse>("/rest/app/cloud/oauth/exchangeToken", { code, state }), | ||
generateOAuthUrl: () => axiosRestWithNoJwt.get<GetRedirectUrlResponse>("/rest/app/cloud/oauth/redirectUrl"), | ||
exchangeToken: (code: string, state: string) => axiosRestWithNoJwt.post<ExchangeTokenResponse>("/rest/app/cloud/oauth/exchangeToken", { code, state }), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { | ||
DeferralParsedRequest, | ||
DeferredInstallationUrlParams, | ||
GetDeferredInstallationUrl | ||
} from "rest-interfaces"; | ||
import { axiosRest, axiosRestWithNoJwt, axiosRestWithNoJwtButWithGitHubToken } from "../axiosInstance"; | ||
|
||
export default { | ||
parseDeferredRequestId: (requestId: string) => axiosRestWithNoJwt.get<DeferralParsedRequest>(`/rest/app/cloud/deferred/parse/${requestId}`), | ||
getDeferredInstallationUrl: (params: DeferredInstallationUrlParams) => | ||
axiosRest.get<GetDeferredInstallationUrl>("/rest/app/cloud/deferred/installation-url", { params }), | ||
connectDeferredOrg: (requestId: string) => axiosRestWithNoJwtButWithGitHubToken.post(`/rest/app/cloud/deferred/connect/${requestId}`) | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.