Skip to content

Commit 755da21

Browse files
authored
Add docs for naming source files w/ ~ prefix (#609)
1 parent 52aaa3f commit 755da21

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/sourcemaps.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,38 @@ will not show any contextual source.
152152
Additional information can be found in the `Releases API documentation
153153
<https://docs.getsentry.com/hosted/api/releases/>`_.
154154

155+
156+
.. _assets_multiple_origins:
157+
158+
.. admonition:: Assets Accessible at Multiple Origins
159+
160+
It's not uncommon for a web application to be accessible at multiple
161+
origins. For example:
162+
163+
* Website is operable over both ``https`` and ``http``
164+
* Geolocated web addresses: e.g. ``https://us.example.com``, ``https://eu.example.com``
165+
* Multiple static CDNs: e.g. ``https://static1.example.com``, ``https://static2.example.com``
166+
* Customer-specific domains/subdomains
167+
168+
In this situation, **identical** JavaScript and source map files may be located
169+
at two or more distinct origins. If you are dealing with such a deployment, you have
170+
two choices for naming your uploaded artifacts:
171+
172+
1. Upload the same artifact multiple times with each possible URL where it appears, for example:
173+
174+
* https://static1.example.com/js/app.js
175+
* https://static2.example.com/js/app.js
176+
177+
2. Alternatively, you can omit the protocol + host and use a special tilde (~) prefixed path like so:
178+
179+
~/js/app.js
180+
181+
The ~ prefix tells Sentry that for a given URL, **any** combination of protocol and hostname whose path is
182+
``/js/app.js`` should use this artifact. **ONLY** use this method if your source/sourcemap files
183+
are identical at all possible protocol/hostname combinations. Note that Sentry will prioritize
184+
full URLs over tilde prefixed paths if found.
185+
186+
155187
.. _upload-sourcemaps-with-cli:
156188

157189
Using Sentry CLI
@@ -243,6 +275,10 @@ Note also that Sentry will resolve relative paths. For example, if you have the
243275
244276
Sentry will resolve ``sourceMappingURL`` relative to ``https://example.com/dist/js/`` (the root path from which ``app.min.js`` was served). You will again need to name your source map with the full URL: ``https://example.com/dist/js/app.min.js.map``.
245277

278+
If you serve the same assets from multiple origins, you can also alternatively use our tilde (~) path prefix to ignore
279+
matching against protocol + hostname. In which case, ``~/dist/js/app.min.js.map``, will also work. See: `Assets Accessible at Multiple Origins
280+
<#assets-multiple-origins>`_.
281+
246282
Verify artifacts are uploaded before errors occur
247283
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248284

0 commit comments

Comments
 (0)