@codecademy/tracking 0.14.3-alpha.42d0c9.0 → 0.14.3-alpha.cf879c.0

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/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ### [0.14.3-alpha.42d0c9.0](https://github.com/Codecademy/client-modules/compare/@codecademy/tracking@0.14.2...@codecademy/tracking@0.14.3-alpha.42d0c9.0) (2021-10-20)
6
+ ### [0.14.3-alpha.cf879c.0](https://github.com/Codecademy/client-modules/compare/@codecademy/tracking@0.14.2...@codecademy/tracking@0.14.3-alpha.cf879c.0) (2021-10-20)
7
7
 
8
8
  **Note:** Version bump only for package @codecademy/tracking
9
9
 
@@ -40,11 +40,11 @@ Object.defineProperty(window.document, 'title', {
40
40
  afterEach(function () {
41
41
  return jest.resetAllMocks();
42
42
  });
43
- var mockIsChromeOSPWA = jest.fn();
43
+ var mockClientType = jest.fn();
44
44
  jest.mock('../../integrations/device', function () {
45
45
  return {
46
- get isChromeOSPWA() {
47
- return mockIsChromeOSPWA;
46
+ get getClientType() {
47
+ return mockClientType;
48
48
  }
49
49
 
50
50
  };
@@ -65,6 +65,7 @@ describe('createTracker', function () {
65
65
  };
66
66
  it('calls only to beacon when it exists', function () {
67
67
  var mockBeacon = jest.fn().mockReturnValueOnce(true);
68
+ mockClientType.mockReturnValue('default');
68
69
  Object.defineProperty(navigator, 'sendBeacon', {
69
70
  writable: true,
70
71
  value: mockBeacon
@@ -85,7 +86,7 @@ describe('createTracker', function () {
85
86
  search: window.location.search,
86
87
  title: document.title,
87
88
  url: window.location.href,
88
- source: 'default'
89
+ client: 'default'
89
90
  }));
90
91
  expect(fetch).not.toHaveBeenCalled();
91
92
  });
@@ -16,7 +16,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
16
16
 
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
- import { DeviceAttributes, isChromeOSPWA } from '../integrations/device';
19
+ import { getClientType } from '../integrations/device';
20
20
  /* eslint-disable no-console */
21
21
 
22
22
  var browserSupportsKeepalive = function browserSupportsKeepalive() {
@@ -69,7 +69,7 @@ export var createTracker = function createTracker(_ref) {
69
69
  title: window.document.title,
70
70
  url: window.location.href,
71
71
  referrer: window.document.referrer,
72
- browser: isChromeOSPWA() ? DeviceAttributes.PWA : DeviceAttributes.Default
72
+ client: getClientType()
73
73
  });
74
74
 
75
75
  if (verbose) {
@@ -1,4 +1,4 @@
1
- import { DeviceAttributes, isChromeOSPWA } from './device';
1
+ import { getClientType } from './device';
2
2
  export var conditionallyLoadAnalytics = function conditionallyLoadAnalytics(_ref) {
3
3
  var analytics = _ref.analytics,
4
4
  destinationPreferences = _ref.destinationPreferences,
@@ -18,7 +18,7 @@ export var conditionallyLoadAnalytics = function conditionallyLoadAnalytics(_ref
18
18
  if (user) {
19
19
  var identifyParams = {
20
20
  email: user.email,
21
- source: isChromeOSPWA() ? DeviceAttributes.PWA : DeviceAttributes.Default
21
+ client: getClientType()
22
22
  };
23
23
  analytics.identify(user.id, identifyParams, {
24
24
  integrations: identifyPreferences
@@ -6,8 +6,8 @@ export declare const isChromeOSPWA: () => boolean;
6
6
  * @returns Whether the site is running in ChromeOS
7
7
  */
8
8
  export declare const isChromeOS: () => boolean;
9
- export declare const DeviceAttributes: {
10
- ChromeOS: string;
11
- PWA: string;
12
- Default: string;
13
- };
9
+ export declare enum ClientTypes {
10
+ PWA = "pwa",
11
+ Default = "default"
12
+ }
13
+ export declare const getClientType: () => ClientTypes;
@@ -13,8 +13,13 @@ export var isChromeOS = function isChromeOS() {
13
13
  return typeof navigator !== 'undefined' && // https://stackoverflow.com/questions/29657165/detecting-chrome-os-with-javascript
14
14
  /\bCrOS\b/.test(navigator.userAgent);
15
15
  };
16
- export var DeviceAttributes = {
17
- ChromeOS: 'chrome',
18
- PWA: 'pwa',
19
- Default: 'default'
16
+ export var ClientTypes;
17
+
18
+ (function (ClientTypes) {
19
+ ClientTypes["PWA"] = "pwa";
20
+ ClientTypes["Default"] = "default";
21
+ })(ClientTypes || (ClientTypes = {}));
22
+
23
+ export var getClientType = function getClientType() {
24
+ return isChromeOSPWA() ? ClientTypes.PWA : ClientTypes.Default;
20
25
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codecademy/tracking",
3
3
  "description": "Tracking library for Codecademy apps.",
4
- "version": "0.14.3-alpha.42d0c9.0",
4
+ "version": "0.14.3-alpha.cf879c.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "module": "./dist/index.js",
7
7
  "main": "./dist/index.js",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "44dc3190be567e18bccd6f0000855a1acc32cb93"
39
+ "gitHead": "592aec63ac61777a89dce4bd31168a779611b8ef"
40
40
  }