@pendo/agent 2.330.2 → 2.332.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/dist/servers.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "au": {
3
3
  "server": "https://app.au.pendo.io",
4
4
  "assetHost": "cdn.au.pendo.io",
5
- "assetPath": "agent/releases/2.330.2",
5
+ "assetPath": "agent/releases/2.332.0",
6
6
  "env": "prod-au",
7
7
  "designerServer": "https://app.au.pendo.io",
8
8
  "globalBucket": "pendo-au-static",
@@ -11,7 +11,7 @@
11
11
  "eu": {
12
12
  "server": "https://app.eu.pendo.io",
13
13
  "assetHost": "cdn.eu.pendo.io",
14
- "assetPath": "agent/releases/2.330.2",
14
+ "assetPath": "agent/releases/2.332.0",
15
15
  "env": "prod-eu",
16
16
  "designerServer": "https://app.eu.pendo.io",
17
17
  "globalBucket": "pendo-eu-static",
@@ -20,7 +20,7 @@
20
20
  "gov": {
21
21
  "server": "https://app.gov.pendo.io",
22
22
  "assetHost": "cdn.gov.pendo.io",
23
- "assetPath": "agent/releases/2.330.2",
23
+ "assetPath": "agent/releases/2.332.0",
24
24
  "env": "prod-gov",
25
25
  "designerServer": "https://app.gov.pendo.io",
26
26
  "globalBucket": "pendo-govramp-static",
@@ -29,7 +29,7 @@
29
29
  "hsbc": {
30
30
  "server": "https://app.hsbc.pendo.io",
31
31
  "assetHost": "cdn.hsbc.pendo.io",
32
- "assetPath": "agent/releases/2.330.2",
32
+ "assetPath": "agent/releases/2.332.0",
33
33
  "env": "prod-hsbc",
34
34
  "designerServer": "https://app.hsbc.pendo.io",
35
35
  "globalBucket": "pendo-hsbc-static",
@@ -38,7 +38,7 @@
38
38
  "io": {
39
39
  "server": "https://app.pendo.io",
40
40
  "assetHost": "cdn.pendo.io",
41
- "assetPath": "agent/releases/2.330.2",
41
+ "assetPath": "agent/releases/2.332.0",
42
42
  "env": "prod-io",
43
43
  "designerServer": "https://app.pendo.io",
44
44
  "globalBucket": "pendo-io-static",
@@ -47,7 +47,7 @@
47
47
  "jpn": {
48
48
  "server": "https://app.jpn.pendo.io",
49
49
  "assetHost": "cdn.jpn.pendo.io",
50
- "assetPath": "agent/releases/2.330.2",
50
+ "assetPath": "agent/releases/2.332.0",
51
51
  "env": "prod-jpn",
52
52
  "designerServer": "https://app.jpn.pendo.io",
53
53
  "globalBucket": "pendo-jp-prod-static",
@@ -56,7 +56,7 @@
56
56
  "us1": {
57
57
  "server": "us1.https://app.pendo.io",
58
58
  "assetHost": "us1.cdn.pendo.io",
59
- "assetPath": "agent/releases/2.330.2",
59
+ "assetPath": "agent/releases/2.332.0",
60
60
  "env": "prod-us1",
61
61
  "designerServer": "us1.https://app.pendo.io",
62
62
  "globalBucket": "pendo-us1-static",
package/package.json CHANGED
@@ -12,5 +12,5 @@
12
12
  "engines": {
13
13
  "node": ">=12"
14
14
  },
15
- "version": "2.330.2"
15
+ "version": "2.332.0"
16
16
  }
package/setup.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import servers from './dist/servers.json';
2
2
 
3
3
  export async function startAgent(initAgent, options = {}) {
4
- if (!options.apiKey) exit('Missing required option "apiKey"');
4
+ // `publicAppId` is the current option name; `apiKey` is the legacy alias.
5
+ if (options.apiKey && !options.publicAppId) options.publicAppId = options.apiKey;
6
+ if (!options.publicAppId) exit('Missing required option "publicAppId"');
5
7
 
6
8
  const server = await getServerConfig(options);
7
9
  delete options.config;
@@ -20,11 +22,13 @@ export async function startAgent(initAgent, options = {}) {
20
22
  }
21
23
 
22
24
  export async function getServerConfig(options) {
25
+ // `publicAppId` is the current option name; `apiKey` is the legacy alias.
26
+ if (options.apiKey && !options.publicAppId) options.publicAppId = options.apiKey;
23
27
  if (!options.env) exit('Missing option "env", please specify an environment for your Pendo subscription.');
24
28
  let config;
25
29
  if (!options.config || !Object.keys(options.config).length) {
26
30
  const baseConfig = generateBaseAgentConfig(options.env);
27
- const configUrl = new URL(`agent/static/${options.apiKey}/config.json`, `https://${baseConfig.assetHost}`).toString();
31
+ const configUrl = new URL(`agent/static/${options.publicAppId}/config.json`, `https://${baseConfig.assetHost}`).toString();
28
32
  const serverConfig = await fetch(configUrl)
29
33
  .then(response => {
30
34
  if (!response.ok) exit('could not load config.json');
package/setup.test.js ADDED
@@ -0,0 +1,65 @@
1
+ import { startAgent, getServerConfig } from './setup.js';
2
+
3
+ // `setup.js` statically imports the built `./dist/servers.json`, which is a
4
+ // build artifact that does not exist in the source tree. Provide it virtually.
5
+ jest.mock('./dist/servers.json', () => ({
6
+ io: { assetHost: 'cdn.pendo.io', server: 'https://app.pendo.io' }
7
+ }), { virtual: true });
8
+
9
+ describe('npm-web-sdk setup', () => {
10
+ let fetchMock;
11
+ let fakeAgent;
12
+ let pendoInstance;
13
+
14
+ beforeEach(() => {
15
+ fetchMock = jest.fn().mockResolvedValue({
16
+ ok: true,
17
+ json: async() => ({ fromServer: true })
18
+ });
19
+ global.fetch = fetchMock;
20
+ pendoInstance = { initialize: jest.fn() };
21
+ fakeAgent = jest.fn(() => pendoInstance);
22
+ });
23
+
24
+ describe('startAgent', () => {
25
+ // APP-158650: passing `publicAppId` (the documented option) threw
26
+ // `Missing required option "apiKey"` because the wrapper only honored
27
+ // the legacy `apiKey` alias.
28
+ it('accepts publicAppId and uses it to build the config URL (regression: APP-158650)', async() => {
29
+ await startAgent(fakeAgent, { publicAppId: 'PUB-123', env: 'io' });
30
+
31
+ expect(fetchMock).toHaveBeenCalledWith('https://cdn.pendo.io/agent/static/PUB-123/config.json');
32
+ expect(pendoInstance.initialize).toHaveBeenCalledWith(expect.objectContaining({ publicAppId: 'PUB-123' }));
33
+ });
34
+
35
+ it('still accepts the legacy apiKey alias', async() => {
36
+ await startAgent(fakeAgent, { apiKey: 'LEGACY-999', env: 'io' });
37
+
38
+ expect(fetchMock).toHaveBeenCalledWith('https://cdn.pendo.io/agent/static/LEGACY-999/config.json');
39
+ });
40
+
41
+ it('prefers publicAppId when both publicAppId and apiKey are provided', async() => {
42
+ await startAgent(fakeAgent, { publicAppId: 'PUB-123', apiKey: 'LEGACY-999', env: 'io' });
43
+
44
+ expect(fetchMock).toHaveBeenCalledWith('https://cdn.pendo.io/agent/static/PUB-123/config.json');
45
+ });
46
+
47
+ it('throws an error naming publicAppId when neither publicAppId nor apiKey is provided', async() => {
48
+ await expect(startAgent(fakeAgent, { env: 'io' })).rejects.toThrow(/Missing required option "publicAppId"/);
49
+ });
50
+ });
51
+
52
+ describe('getServerConfig', () => {
53
+ it('builds the config URL from publicAppId', async() => {
54
+ await getServerConfig({ publicAppId: 'DIRECT-1', env: 'io' });
55
+
56
+ expect(fetchMock).toHaveBeenCalledWith('https://cdn.pendo.io/agent/static/DIRECT-1/config.json');
57
+ });
58
+
59
+ it('normalizes the legacy apiKey alias to publicAppId', async() => {
60
+ await getServerConfig({ apiKey: 'DIRECT-LEGACY', env: 'io' });
61
+
62
+ expect(fetchMock).toHaveBeenCalledWith('https://cdn.pendo.io/agent/static/DIRECT-LEGACY/config.json');
63
+ });
64
+ });
65
+ });