Skip to content

Commit

Permalink
Merge branch 'main' into chore/test-that-autocapture-allowlists-are-u…
Browse files Browse the repository at this point in the history
…nioned
  • Loading branch information
pauldambra authored Oct 21, 2024
2 parents e8097a3 + 81e97f1 commit ccaa889
Show file tree
Hide file tree
Showing 30 changed files with 802 additions and 406 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"presets": ["@babel/env", ["@babel/typescript", { "jsxPragma": "h" }]],
"plugins": [
"@babel/plugin-transform-nullish-coalescing-operator",
[
"@babel/transform-react-jsx",
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Server-side rendering and ES5
name: ES5 support check

on:
- pull_request
Expand All @@ -19,8 +19,5 @@ jobs:

- run: pnpm install && pnpm build

- name: Run es-check to check if our bundle is ES5 compatible
run: npx [email protected] es5 dist/{array,main}.js

- name: Require module via node
run: cd dist; node -e "require('./main')"
- name: Run es-check to check if our ie11 bundle is ES5 compatible
run: npx [email protected] es5 dist/array.full.es5.js
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
## 1.174.2 - 2024-10-18

- fix: no need to swallow import errors (#1486)

## 1.174.1 - 2024-10-18

- fix: do not capture entire elements in web vitals (#1483)

## 1.174.0 - 2024-10-17

- Make entire cancel button area clickable (#1473)
- feat: swap the default to identified_only (#1468)

## 1.173.0 - 2024-10-17

- feat(web-analytics): Store nulls for unset campaign params (#1482)

## 1.172.1 - 2024-10-17

- chore: add crossOrigin='anonymous' to snippet script (#1481)

## 1.172.0 - 2024-10-17

- chore: build an es5 bundle and move main to es6 (#1480)

## 1.171.0 - 2024-10-17

- feat: start session recording on url trigger (#1451)
- chore: babel targets in rollup config (#1479)

## 1.170.1 - 2024-10-16

- feat: add stack to stacktraceless "exceptions" (#1472)

## 1.170.0 - 2024-10-16

- fix: web vitals delayed capture (#1474)

## 1.169.1 - 2024-10-16

- chore: skip if Array.from is missing (#1475)

## 1.169.0 - 2024-10-15

- feat: report reason for recording start (#1452)
Expand Down
16 changes: 16 additions & 0 deletions cypress/e2e/error-tracking.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ describe('Exception capture', () => {
cy.wait('@exception-autocapture-script')
})

it('adds stacktrace to captured strings', () => {
cy.get('[data-cy-exception-string-button]').click()

// ugh
cy.wait(1500)

cy.phCaptures({ full: true }).then((captures) => {
expect(captures.map((c) => c.event)).to.deep.equal(['$pageview', '$autocapture', '$exception'])
expect(captures[2].event).to.be.eql('$exception')
expect(captures[2].properties.$exception_list[0].stacktrace.frames.length).to.be.eq(1)
expect(captures[2].properties.$exception_list[0].stacktrace.frames[0].function).to.be.eq(
'HTMLButtonElement.onclick'
)
})
})

it('autocaptures exceptions', () => {
cy.get('[data-cy-button-throws-error]').click()

Expand Down
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posthog-js",
"version": "1.169.0",
"version": "1.174.2",
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
"repository": "https://github.com/PostHog/posthog-js",
"author": "[email protected]",
Expand Down Expand Up @@ -38,30 +38,33 @@
"react/package.json"
],
"dependencies": {
"core-js": "^3.38.1",
"fflate": "^0.4.8",
"preact": "^10.19.3",
"web-vitals": "^4.0.1"
"web-vitals": "^4.2.0"
},
"devDependencies": {
"@babel/core": "7.18.9",
"@babel/plugin-syntax-decorators": "^7.23.3",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.25.8",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/preset-env": "7.18.9",
"@babel/preset-typescript": "^7.18.6",
"@cypress/skip-test": "^2.6.1",
"@jest/globals": "^27.5.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/plugin-typescript": "^12.1.1",
"@rrweb/types": "2.0.0-alpha.13",
"@sentry/types": "8.7.0",
"@testing-library/dom": "^9.3.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/preact": "^3.2.4",
"@types/eslint": "^8.44.6",
"@types/jest": "^27.5.1",
"@types/jest": "^27.5.2",
"@types/node": "^22.5.0",
"@types/react-dom": "^18.0.10",
"@types/sinon": "^17.0.1",
Expand Down Expand Up @@ -97,9 +100,8 @@
"posthog-js": "link:",
"preact-render-to-string": "^6.3.1",
"prettier": "^2.7.1",
"rollup": "^4.9.6",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-ts": "^3.4.5",
"rollup": "^4.24.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-visualizer": "^5.12.0",
"rrweb": "2.0.0-alpha.13",
"rrweb-snapshot": "2.0.0-alpha.13",
Expand Down
6 changes: 5 additions & 1 deletion playground/cypress-full/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@
Send an exception
</button>

<button data-cy-exception-string-button onclick="posthog.captureException('I am a plain old string', { extra_prop: 2 })">
Capture as string
</button>

<br />

<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.full.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getSurveys getActiveMatchingSurveys captureException".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host+"/static/array.full.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getSurveys getActiveMatchingSurveys captureException".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
</script>
</body>
</html>
6 changes: 5 additions & 1 deletion playground/cypress/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@
Capture an exception
</button>

<button data-cy-exception-string-button onclick="posthog.captureException('I am a plain old string', { extra_prop: 2 })">
Capture as string
</button>

<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getSurveys getActiveMatchingSurveys captureException".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getSurveys getActiveMatchingSurveys captureException".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion playground/segment/segment.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script>
!function () {
var analytics = window.analytics = window.analytics || []; if (!analytics.initialize) if (analytics.invoked) window.console && console.error && console.error("Segment snippet included twice."); else {
analytics.invoked = !0; analytics.methods = ["trackSubmit", "trackClick", "trackLink", "trackForm", "pageview", "identify", "reset", "group", "track", "ready", "alias", "debug", "page", "once", "off", "on", "addSourceMiddleware", "addIntegrationMiddleware", "setAnonymousId", "addDestinationMiddleware"]; analytics.factory = function (e) { return function () { var t = Array.prototype.slice.call(arguments); t.unshift(e); analytics.push(t); return analytics } }; for (var e = 0; e < analytics.methods.length; e++) { var key = analytics.methods[e]; analytics[key] = analytics.factory(key) } analytics.load = function (key, e) { var t = document.createElement("script"); t.type = "text/javascript"; t.async = !0; t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"; var n = document.getElementsByTagName("script")[0]; n.parentNode.insertBefore(t, n); analytics._loadOptions = e }; analytics._writeKey = "GOEDfA21zZTtR7clsBuDvmBKAtAdZ6Np";; analytics.SNIPPET_VERSION = "4.15.3";
analytics.invoked = !0; analytics.methods = ["trackSubmit", "trackClick", "trackLink", "trackForm", "pageview", "identify", "reset", "group", "track", "ready", "alias", "debug", "page", "once", "off", "on", "addSourceMiddleware", "addIntegrationMiddleware", "setAnonymousId", "addDestinationMiddleware"]; analytics.factory = function (e) { return function () { var t = Array.prototype.slice.call(arguments); t.unshift(e); analytics.push(t); return analytics } }; for (var e = 0; e < analytics.methods.length; e++) { var key = analytics.methods[e]; analytics[key] = analytics.factory(key) } analytics.load = function (key, e) { var t = document.createElement("script"); t.type = "text/javascript"; t.crossOrigin = "anonymous"; t.async = !0; t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"; var n = document.getElementsByTagName("script")[0]; n.parentNode.insertBefore(t, n); analytics._loadOptions = e }; analytics._writeKey = "GOEDfA21zZTtR7clsBuDvmBKAtAdZ6Np";; analytics.SNIPPET_VERSION = "4.15.3";
analytics.load("GOEDfA21zZTtR7clsBuDvmBKAtAdZ6Np");

analytics.ready(() => {
Expand Down
1 change: 1 addition & 0 deletions playground/session-recordings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
})
}
;((p = t.createElement('script')).type = 'text/javascript'),
(p.crossOrigin = 'anonymous'),
(p.async = !0),
(p.src = 'http://localhost:3001' + '/static/array.full.js'),
(r = t.getElementsByTagName('script')[0]).parentNode.insertBefore(p, r)
Expand Down
3 changes: 2 additions & 1 deletion playground/snippet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
a.init = function(b, d, g) {
s = x.createElement("script");
s.type = "text/javascript";
s.crossOrigin = "anonymous";
s.async = !0;
s.src = d.api_host + "/static/array.full.js";
n = x.getElementsByTagName("script")[0];
Expand Down Expand Up @@ -56,7 +57,7 @@

<script>
if (true) { // minified code
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.full.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host+"/static/array.full.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('BrpS4SctoaCCsyjlnlun3OzyNJAafdlv__jUWaaJWXg', {api_host: 'https://app.posthog.com'})
}
</script>
Expand Down
Loading

0 comments on commit ccaa889

Please sign in to comment.