Skip to content

Commit

Permalink
Force .io if URL is not overridden (#497)
Browse files Browse the repository at this point in the history
* Force .io if URL is not overridden

This change forces the re-sending of stored errors to use the .IO domain name, rather than .COM. Due to the recent issue of changing this, some stored errors are being sent and causing further CSP violations.

This change is to address that issue.

* Bump version

* Update CHANGELOG.md

---------

Co-authored-by: Darcy Thomas <[email protected]>
  • Loading branch information
CmdrKeen and darcythomas committed Aug 8, 2023
1 parent e5cbbbf commit b5f9797
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-->


## v2.26.5


### Changed

- Use api.raygun.io endpoint, if URL is not overridden, to send stored events


## v2.26.4


Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raygun4js",
"version": "2.26.4",
"version": "2.26.5",
"homepage": "http://raygun.com",
"authors": [
"Mindscape <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"title": "Raygun4js",
"description": "Raygun.com plugin for JavaScript",
"version": "2.26.4",
"version": "2.26.5",
"homepage": "https://github.com/MindscapeHQ/raygun4js",
"author": {
"name": "MindscapeHQ",
Expand Down
2 changes: 1 addition & 1 deletion raygun4js.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>raygun4js</id>
<version>2.26.4</version>
<version>2.26.5</version>
<title>Raygun4js</title>
<authors>Raygun Limited</authors>
<owners>Raygun Limited</owners>
Expand Down
11 changes: 10 additions & 1 deletion src/raygun.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ var raygunFactory = function(window, $, undefined) {
_setCookieAsSecure = false,
_clientIp,
_captureMissingRequests = false,
detachPromiseRejectionFunction;
detachPromiseRejectionFunction,
_customEndpointSet = false;

var rand = Math.random();
var _publicRaygunFunctions = {
Expand Down Expand Up @@ -129,6 +130,7 @@ var raygunFactory = function(window, $, undefined) {

if (options.apiUrl) {
_raygunApiUrl = options.apiUrl;
_customEndpointSet = true;
}

if (typeof options.wrapAsynchronousCallbacks !== 'undefined') {
Expand All @@ -150,6 +152,7 @@ var raygunFactory = function(window, $, undefined) {

if (options.apiEndpoint) {
_raygunApiUrl = options.apiEndpoint;
_customEndpointSet = true;
}

if (options.from) {
Expand Down Expand Up @@ -585,6 +588,12 @@ var raygunFactory = function(window, $, undefined) {
if (key.indexOf('raygunjs+' + Raygun.Options._raygunApiKey) > -1) {
try {
var payload = JSON.parse(localStorage[key]);

// If the url contains 'raygun.com', replace it with 'raygun.io', but only if not custom set already (proxy, testing, etc)
if (!_customEndpointSet && payload.url.includes('raygun.com')) {
payload.url = payload.url.replace('raygun.com', 'raygun.io');
}

makePostCorsRequest(payload.url, payload.data);
} catch (e) {
Raygun.Utilities.log('Raygun4JS: Invalid JSON object in LocalStorage');
Expand Down

0 comments on commit b5f9797

Please sign in to comment.