@testim/testim-cli 3.241.0 → 3.244.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.
@@ -6,10 +6,15 @@ const Analytics = require('analytics-node');
6
6
 
7
7
  const analytics = new Analytics('sJOSIGKa5x5rJEGsaOlCjrgozAf7FnVY', { flushAt: 1 });
8
8
 
9
+ const anonymousId = require('crypto').randomBytes(20).toString('hex');
10
+
9
11
  function identify(data) {
10
12
  if (config.IS_ON_PREM) {
11
13
  return;
12
14
  }
15
+ if (!data || !data.userId) {
16
+ data = { anonymousId };
17
+ }
13
18
  analytics.identify(data);
14
19
  }
15
20
 
@@ -21,11 +26,11 @@ function track(userId, eventName, properties) {
21
26
  if (config.IS_ON_PREM) {
22
27
  return;
23
28
  }
24
- analytics.track({
25
- userId,
29
+ const id = userId ? { userId } : { anonymousId };
30
+ analytics.track(Object.assign(id, {
26
31
  event: eventName,
27
32
  properties,
28
- });
33
+ }));
29
34
  }
30
35
 
31
36
  module.exports = {
@@ -20,7 +20,7 @@ function getTokenHeader() {
20
20
  return testimCustomToken.getCustomTokenV3()
21
21
  .then(brearToken => {
22
22
  if (!brearToken) {
23
- throw new Error('Failed to get token from server');
23
+ return Promise.reject(new Error('Failed to get token from server'));
24
24
  }
25
25
  return { Authorization: `Bearer ${brearToken}` };
26
26
  });
@@ -386,19 +386,6 @@ function uploadArtifact(projectId, testId, testResultId, content, subType, mimeT
386
386
  })).then(() => storagePath);
387
387
  }
388
388
 
389
- const removeHiddenParamsInTestData = (testData, projectDefaults) => {
390
- const testDataValueClone = _.clone(testData);
391
- if (projectDefaults && projectDefaults.hiddenParams) {
392
- const { hiddenParams } = projectDefaults;
393
- (hiddenParams || []).forEach((param) => {
394
- if (testDataValueClone[param]) {
395
- testDataValueClone[param] = constants.test.HIDDEN_PARAM;
396
- }
397
- });
398
- }
399
- return testDataValueClone;
400
- };
401
-
402
389
  const uploadRunDataArtifact = _.memoize(async (projectId, testId, testResultId, runData) => {
403
390
  if (_.isEmpty(runData)) {
404
391
  return undefined;
@@ -410,8 +397,20 @@ const updateTestDataArtifact = _.memoize(async (projectId, testId, testResultId,
410
397
  if (_.isEmpty(testData)) {
411
398
  return undefined;
412
399
  }
400
+ const removeHiddenParamsInTestData = () => {
401
+ const testDataValueClone = _.clone(testData);
402
+ if (projectDefaults && projectDefaults.hiddenParams) {
403
+ const { hiddenParams } = projectDefaults;
404
+ (hiddenParams || []).forEach((param) => {
405
+ if (testDataValueClone[param]) {
406
+ testDataValueClone[param] = constants.test.HIDDEN_PARAM;
407
+ }
408
+ });
409
+ }
410
+ return testDataValueClone;
411
+ };
413
412
 
414
- return await uploadArtifact(projectId, testId, testResultId, JSON.stringify(removeHiddenParamsInTestData(testData, projectDefaults)), 'test-test-data', 'application/json');
413
+ return await uploadArtifact(projectId, testId, testResultId, JSON.stringify(removeHiddenParamsInTestData(testData)), 'test-test-data', 'application/json');
415
414
  }, (projectId, testId, testResultId, testData) => `${hash(testData)}:${testId}:${testResultId}`);
416
415
 
417
416
  function addTestRetry({
@@ -511,5 +510,4 @@ module.exports = {
511
510
  getCloudflareTunnel,
512
511
  forceUpdateCloudflareTunnelRoutes,
513
512
  deleteCloudflareTunnel,
514
- removeHiddenParamsInTestData,
515
513
  };