posthog-js 1.138.0 → 1.138.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.full.js +2 -2
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/es.js +1 -1
- package/dist/es.js.map +1 -1
- package/dist/lib/src/extensions/replay/rrweb-plugins/patch.d.ts +3 -0
- package/dist/lib/src/extensions/sentry-integration.d.ts +22 -2
- package/dist/lib/src/extensions/surveys/surveys-utils.d.ts +2 -0
- package/dist/lib/src/extensions/tracing-headers.d.ts +10 -0
- package/dist/lib/src/loader-recorder.d.ts +0 -3
- package/dist/lib/src/loader-tracing-headers.d.ts +1 -0
- package/dist/lib/src/posthog-core.d.ts +2 -1
- package/dist/lib/src/posthog-surveys-types.d.ts +2 -0
- package/dist/lib/src/types.d.ts +5 -0
- package/dist/module.d.ts +29 -2
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/recorder-v2.js +1 -1
- package/dist/recorder-v2.js.map +1 -1
- package/dist/recorder.js +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/surveys-module-previews.js +1 -1
- package/dist/surveys-module-previews.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/dist/tracing-headers.js +2 -0
- package/dist/tracing-headers.js.map +1 -0
- package/lib/package.json +2 -2
- package/lib/src/extensions/replay/rrweb-plugins/patch.d.ts +3 -0
- package/lib/src/extensions/replay/rrweb-plugins/patch.js +39 -0
- package/lib/src/extensions/replay/rrweb-plugins/patch.js.map +1 -0
- package/lib/src/extensions/sentry-integration.d.ts +22 -2
- package/lib/src/extensions/sentry-integration.js +55 -39
- package/lib/src/extensions/sentry-integration.js.map +1 -1
- package/lib/src/extensions/surveys/surveys-utils.d.ts +2 -0
- package/lib/src/extensions/surveys/surveys-utils.jsx +37 -3
- package/lib/src/extensions/surveys/surveys-utils.jsx.map +1 -1
- package/lib/src/extensions/surveys.jsx +5 -20
- package/lib/src/extensions/surveys.jsx.map +1 -1
- package/lib/src/extensions/tracing-headers.d.ts +10 -0
- package/lib/src/extensions/tracing-headers.js +51 -0
- package/lib/src/extensions/tracing-headers.js.map +1 -0
- package/lib/src/loader-recorder.d.ts +0 -3
- package/lib/src/loader-recorder.js +2 -42
- package/lib/src/loader-recorder.js.map +1 -1
- package/lib/src/loader-tracing-headers.d.ts +1 -0
- package/lib/src/loader-tracing-headers.js +87 -0
- package/lib/src/loader-tracing-headers.js.map +1 -0
- package/lib/src/posthog-core.d.ts +2 -1
- package/lib/src/posthog-core.js +5 -1
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-surveys-types.d.ts +2 -0
- package/lib/src/posthog-surveys-types.js.map +1 -1
- package/lib/src/types.d.ts +5 -0
- package/lib/src/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { patch } from './extensions/replay/rrweb-plugins/patch';
|
|
38
|
+
import { assignableWindow, window } from './utils/globals';
|
|
39
|
+
var addTracingHeaders = function (sessionManager, req) {
|
|
40
|
+
var _a = sessionManager.checkAndGetSessionAndWindowId(true), sessionId = _a.sessionId, windowId = _a.windowId;
|
|
41
|
+
req.headers.set('X-POSTHOG-SESSION-ID', sessionId);
|
|
42
|
+
req.headers.set('X-POSTHOG-WINDOW-ID', windowId);
|
|
43
|
+
};
|
|
44
|
+
var patchFetch = function (sessionManager) {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
return patch(window, 'fetch', function (originalFetch) {
|
|
48
|
+
return function (url, init) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
var req;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
req = new Request(url, init);
|
|
53
|
+
addTracingHeaders(sessionManager, req);
|
|
54
|
+
return [2 /*return*/, originalFetch(req)];
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
var patchXHR = function (sessionManager) {
|
|
61
|
+
return patch(
|
|
62
|
+
// we can assert this is present because we've checked previously
|
|
63
|
+
window.XMLHttpRequest.prototype, 'open',
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
function (originalOpen) {
|
|
67
|
+
return function (method, url, async, username, password) {
|
|
68
|
+
if (async === void 0) { async = true; }
|
|
69
|
+
// because this function is returned in its actual context `this` _is_ an XMLHttpRequest
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
var xhr = this;
|
|
73
|
+
// check IE earlier than this, we only initialize if Request is present
|
|
74
|
+
// eslint-disable-next-line compat/compat
|
|
75
|
+
var req = new Request(url);
|
|
76
|
+
addTracingHeaders(sessionManager, req);
|
|
77
|
+
return originalOpen.call(xhr, method, req.url, async, username, password);
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
if (assignableWindow) {
|
|
82
|
+
assignableWindow.postHogTracingHeadersPatchFns = {
|
|
83
|
+
_patchFetch: patchFetch,
|
|
84
|
+
_patchXHR: patchXHR,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=loader-tracing-headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-tracing-headers.js","sourceRoot":"","sources":["../../src/loader-tracing-headers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,yCAAyC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE1D,IAAM,iBAAiB,GAAG,UAAC,cAAgC,EAAE,GAAY;IAC/D,IAAA,KAA0B,cAAc,CAAC,6BAA6B,CAAC,IAAI,CAAC,EAA1E,SAAS,eAAA,EAAE,QAAQ,cAAuD,CAAA;IAClF,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAA;IAClD,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAA;AACpD,CAAC,CAAA;AAED,IAAM,UAAU,GAAG,UAAC,cAAgC;IAChD,6DAA6D;IAC7D,aAAa;IACb,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,UAAC,aAA2B;QACtD,OAAO,UAAgB,GAAsB,EAAE,IAA8B;;;;oBAGnE,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;oBAElC,iBAAiB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;oBAEtC,sBAAO,aAAa,CAAC,GAAG,CAAC,EAAA;;;SAC5B,CAAA;IACL,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAED,IAAM,QAAQ,GAAG,UAAC,cAAgC;IAC9C,OAAO,KAAK;IACR,iEAAiE;IACjE,MAAO,CAAC,cAAc,CAAC,SAAS,EAChC,MAAM;IACN,6DAA6D;IAC7D,aAAa;IACb,UAAC,YAAkD;QAC/C,OAAO,UACH,MAAc,EACd,GAAiB,EACjB,KAAY,EACZ,QAAwB,EACxB,QAAwB;YAFxB,sBAAA,EAAA,YAAY;YAIZ,wFAAwF;YACxF,6DAA6D;YAC7D,aAAa;YACb,IAAM,GAAG,GAAG,IAAsB,CAAA;YAElC,uEAAuE;YACvE,yCAAyC;YACzC,IAAM,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;YAE5B,iBAAiB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;YAEtC,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC7E,CAAC,CAAA;IACL,CAAC,CACJ,CAAA;AACL,CAAC,CAAA;AAED,IAAI,gBAAgB,EAAE;IAClB,gBAAgB,CAAC,6BAA6B,GAAG;QAC7C,WAAW,EAAE,UAAU;QACvB,SAAS,EAAE,QAAQ;KACtB,CAAA;CACJ","sourcesContent":["import { SessionIdManager } from './sessionid'\nimport { patch } from './extensions/replay/rrweb-plugins/patch'\nimport { assignableWindow, window } from './utils/globals'\n\nconst addTracingHeaders = (sessionManager: SessionIdManager, req: Request) => {\n const { sessionId, windowId } = sessionManager.checkAndGetSessionAndWindowId(true)\n req.headers.set('X-POSTHOG-SESSION-ID', sessionId)\n req.headers.set('X-POSTHOG-WINDOW-ID', windowId)\n}\n\nconst patchFetch = (sessionManager: SessionIdManager): (() => void) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return patch(window, 'fetch', (originalFetch: typeof fetch) => {\n return async function (url: URL | RequestInfo, init?: RequestInit | undefined) {\n // check IE earlier than this, we only initialize if Request is present\n // eslint-disable-next-line compat/compat\n const req = new Request(url, init)\n\n addTracingHeaders(sessionManager, req)\n\n return originalFetch(req)\n }\n })\n}\n\nconst patchXHR = (sessionManager: SessionIdManager): (() => void) => {\n return patch(\n // we can assert this is present because we've checked previously\n window!.XMLHttpRequest.prototype,\n 'open',\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (originalOpen: typeof XMLHttpRequest.prototype.open) => {\n return function (\n method: string,\n url: string | URL,\n async = true,\n username?: string | null,\n password?: string | null\n ) {\n // because this function is returned in its actual context `this` _is_ an XMLHttpRequest\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const xhr = this as XMLHttpRequest\n\n // check IE earlier than this, we only initialize if Request is present\n // eslint-disable-next-line compat/compat\n const req = new Request(url)\n\n addTracingHeaders(sessionManager, req)\n\n return originalOpen.call(xhr, method, req.url, async, username, password)\n }\n }\n )\n}\n\nif (assignableWindow) {\n assignableWindow.postHogTracingHeadersPatchFns = {\n _patchFetch: patchFetch,\n _patchXHR: patchXHR,\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { RetryQueue } from './retry-queue';
|
|
|
7
7
|
import { SessionIdManager } from './sessionid';
|
|
8
8
|
import { RequestRouter } from './utils/request-router';
|
|
9
9
|
import { CaptureOptions, CaptureResult, Compression, DecideResponse, EarlyAccessFeatureCallback, IsFeatureEnabledOptions, JsonType, PostHogConfig, Properties, Property, QueuedRequestOptions, RequestCallback, SessionIdChangedCallback, SnippetArrayItem, ToolbarParams } from './types';
|
|
10
|
-
import { SentryIntegration } from './extensions/sentry-integration';
|
|
10
|
+
import { SentryIntegration, SentryIntegrationOptions, sentryIntegration } from './extensions/sentry-integration';
|
|
11
11
|
import { PageViewManager } from './page-view';
|
|
12
12
|
import { PostHogSurveys } from './posthog-surveys';
|
|
13
13
|
import { RateLimiter } from './rate-limiter';
|
|
@@ -56,6 +56,7 @@ export declare class PostHog {
|
|
|
56
56
|
decideEndpointWasHit: boolean;
|
|
57
57
|
analyticsDefaultEndpoint: string;
|
|
58
58
|
SentryIntegration: typeof SentryIntegration;
|
|
59
|
+
sentryIntegration: (options?: SentryIntegrationOptions) => ReturnType<typeof sentryIntegration>;
|
|
59
60
|
private _debugEventEmitter;
|
|
60
61
|
/** DEPRECATED: We keep this to support existing usage but now one should just call .setPersonProperties */
|
|
61
62
|
people: {
|
package/lib/src/posthog-core.js
CHANGED
|
@@ -49,7 +49,7 @@ import { RetryQueue } from './retry-queue';
|
|
|
49
49
|
import { SessionIdManager } from './sessionid';
|
|
50
50
|
import { RequestRouter, RequestRouterRegion } from './utils/request-router';
|
|
51
51
|
import { Compression, } from './types';
|
|
52
|
-
import { SentryIntegration } from './extensions/sentry-integration';
|
|
52
|
+
import { SentryIntegration, sentryIntegration } from './extensions/sentry-integration';
|
|
53
53
|
import { setupSegmentIntegration } from './extensions/segment-integration';
|
|
54
54
|
import { PageViewManager } from './page-view';
|
|
55
55
|
import { PostHogSurveys } from './posthog-surveys';
|
|
@@ -65,6 +65,7 @@ import { Heatmaps } from './heatmaps';
|
|
|
65
65
|
import { ScrollManager } from './scroll-manager';
|
|
66
66
|
import { SimpleEventEmitter } from './utils/simple-event-emitter';
|
|
67
67
|
import { Autocapture } from './autocapture';
|
|
68
|
+
import { TracingHeaders } from './extensions/tracing-headers';
|
|
68
69
|
import { ConsentManager } from './consent';
|
|
69
70
|
var instances = {};
|
|
70
71
|
// some globals for comparisons
|
|
@@ -142,6 +143,7 @@ export var defaultConfig = function () {
|
|
|
142
143
|
disable_compression: false,
|
|
143
144
|
session_idle_timeout_seconds: 30 * 60,
|
|
144
145
|
person_profiles: 'always',
|
|
146
|
+
__add_tracing_headers: false,
|
|
145
147
|
});
|
|
146
148
|
};
|
|
147
149
|
export var configRenames = function (origConfig) {
|
|
@@ -204,6 +206,7 @@ var PostHog = /** @class */ (function () {
|
|
|
204
206
|
this.config = defaultConfig();
|
|
205
207
|
this.decideEndpointWasHit = false;
|
|
206
208
|
this.SentryIntegration = SentryIntegration;
|
|
209
|
+
this.sentryIntegration = function (options) { return sentryIntegration(_this, options); };
|
|
207
210
|
this.__request_queue = [];
|
|
208
211
|
this.__loaded = false;
|
|
209
212
|
this.analyticsDefaultEndpoint = '/e/';
|
|
@@ -306,6 +309,7 @@ var PostHog = /** @class */ (function () {
|
|
|
306
309
|
this.__request_queue = [];
|
|
307
310
|
this.sessionManager = new SessionIdManager(this.config, this.persistence);
|
|
308
311
|
this.sessionPropsManager = new SessionPropsManager(this.sessionManager, this.persistence);
|
|
312
|
+
new TracingHeaders(this).startIfEnabledOrStop();
|
|
309
313
|
this.sessionRecording = new SessionRecording(this);
|
|
310
314
|
this.sessionRecording.startIfEnabledOrStop();
|
|
311
315
|
if (!this.config.disable_scroll_properties) {
|