@statsig/web-analytics 0.0.1-beta.23 → 0.0.1-beta.25

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@statsig/web-analytics",
3
- "version": "0.0.1-beta.23",
3
+ "version": "0.0.1-beta.25",
4
4
  "dependencies": {
5
- "@statsig/client-core": "0.0.1-beta.23",
6
- "@statsig/js-client": "0.0.1-beta.23"
5
+ "@statsig/client-core": "0.0.1-beta.25",
6
+ "@statsig/js-client": "0.0.1-beta.25"
7
7
  },
8
8
  "jsdelivr": "./build/statsig-web-analytics.min.js",
9
9
  "type": "commonjs",
@@ -1,10 +1,9 @@
1
1
  import { StatsigClient } from '@statsig/js-client';
2
2
  export declare class AutoCapture {
3
- private _sdkKey;
4
3
  private _client;
5
4
  private _startTime;
6
5
  private _deepestScroll;
7
- constructor(_sdkKey: string, _client: StatsigClient);
6
+ constructor(_client: StatsigClient);
8
7
  private _addEventHandlers;
9
8
  private _autoLogEvent;
10
9
  private _initialize;
@@ -4,8 +4,7 @@ exports.AutoCapture = void 0;
4
4
  const client_core_1 = require("@statsig/client-core");
5
5
  const Utils_1 = require("./Utils");
6
6
  class AutoCapture {
7
- constructor(_sdkKey, _client) {
8
- this._sdkKey = _sdkKey;
7
+ constructor(_client) {
9
8
  this._client = _client;
10
9
  this._startTime = Date.now();
11
10
  this._deepestScroll = 0;
@@ -124,7 +123,7 @@ class AutoCapture {
124
123
  const event = {
125
124
  eventName: `auto_capture::${name}`,
126
125
  value,
127
- metadata: Object.assign({ sessionId: (0, Utils_1.getWebSessionId)(this._sdkKey), page_url: ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) || '' }, metadata),
126
+ metadata: Object.assign({ sessionId: (0, Utils_1.getWebSessionId)(this._client.getContext().sdkKey), page_url: ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) || '' }, metadata),
128
127
  };
129
128
  this._client.logEvent(event);
130
129
  client_core_1.Log.debug('Enqueued Event', event);
package/src/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { AutoCapture } from './AutoCapture';
2
- import { WebAnalytics } from './WebAnalytics';
3
- export { WebAnalytics, AutoCapture };
2
+ export { AutoCapture };
4
3
  export default __STATSIG__;
package/src/index.js CHANGED
@@ -1,39 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AutoCapture = exports.WebAnalytics = void 0;
4
- const client_core_1 = require("@statsig/client-core");
3
+ exports.AutoCapture = void 0;
5
4
  const AutoCapture_1 = require("./AutoCapture");
6
5
  Object.defineProperty(exports, "AutoCapture", { enumerable: true, get: function () { return AutoCapture_1.AutoCapture; } });
7
- const WebAnalytics_1 = require("./WebAnalytics");
8
- Object.defineProperty(exports, "WebAnalytics", { enumerable: true, get: function () { return WebAnalytics_1.WebAnalytics; } });
9
- __STATSIG__ = Object.assign(Object.assign({}, (__STATSIG__ !== null && __STATSIG__ !== void 0 ? __STATSIG__ : {})), { WebAnalytics: WebAnalytics_1.WebAnalytics,
10
- AutoCapture: AutoCapture_1.AutoCapture });
6
+ __STATSIG__ = Object.assign(Object.assign({}, (__STATSIG__ !== null && __STATSIG__ !== void 0 ? __STATSIG__ : {})), { AutoCapture: AutoCapture_1.AutoCapture });
11
7
  exports.default = __STATSIG__;
12
- function _attemptAutoInit() {
13
- var _a, _b;
14
- if (typeof window === 'undefined' ||
15
- typeof document === 'undefined' ||
16
- !document.currentScript) {
17
- return;
18
- }
19
- const srcUrl = document.currentScript.getAttribute('src');
20
- const baseUrl = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href;
21
- if (!srcUrl || !baseUrl) {
22
- return;
23
- }
24
- try {
25
- const url = new URL(srcUrl, baseUrl);
26
- const params = url.searchParams;
27
- const sdkKey = (_b = params.get('sdkkey')) !== null && _b !== void 0 ? _b : params.get('sdkKey');
28
- if (sdkKey) {
29
- WebAnalytics_1.WebAnalytics.autoInit(sdkKey);
30
- }
31
- else {
32
- client_core_1.Log.error('Statsig Web AutoCapture: No SDK key provided');
33
- }
34
- }
35
- catch (e) {
36
- client_core_1.Log.error('Statsig Web AutoCapture: Invalid source URL');
37
- }
38
- }
39
- _attemptAutoInit();
@@ -1,5 +0,0 @@
1
- export declare class WebAnalytics {
2
- private static _capture;
3
- private static _client;
4
- static autoInit(sdkKey: string): void;
5
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebAnalytics = void 0;
4
- const client_core_1 = require("@statsig/client-core");
5
- const js_client_1 = require("@statsig/js-client");
6
- const AutoCapture_1 = require("./AutoCapture");
7
- class WebAnalytics {
8
- static autoInit(sdkKey) {
9
- var _a;
10
- const current = (_a = __STATSIG__ === null || __STATSIG__ === void 0 ? void 0 : __STATSIG__.instances) === null || _a === void 0 ? void 0 : _a[sdkKey];
11
- if (current instanceof js_client_1.StatsigClient) {
12
- this._client = current;
13
- }
14
- if (!this._client) {
15
- this._client = new js_client_1.StatsigClient(sdkKey, {
16
- userID: `web-analytics-user::${(0, client_core_1.getUUID)()}`,
17
- });
18
- }
19
- this._capture = new AutoCapture_1.AutoCapture(sdkKey, this._client);
20
- this._client.initializeSync();
21
- }
22
- }
23
- exports.WebAnalytics = WebAnalytics;
24
- WebAnalytics._capture = null;
25
- WebAnalytics._client = null;