@cloudcare/browser-rum 3.2.36 → 3.2.38

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.
@@ -1,4 +1,4 @@
1
- import { getCookie, setCookie, UUID, ONE_HOUR, SessionPersistence } from '@cloudcare/browser-core';
1
+ import { getCookie, setCookie, UUID, ONE_HOUR, noop, SessionPersistence } from '@cloudcare/browser-core';
2
2
  export var USR_ID_COOKIE_NAME = '_gc_usr_id';
3
3
  export var ANONYMOUS_ID_EXPIRATION = 60 * 24 * ONE_HOUR;
4
4
  function initUsrCookie(cookieOptions) {
@@ -18,7 +18,11 @@ function initUsrLocalStorage() {
18
18
  return usrCacheId;
19
19
  }
20
20
  export var startCacheUsrCache = function startCacheUsrCache(configuration) {
21
- if (!configuration.sessionStoreStrategyType) return;
21
+ if (!configuration.sessionStoreStrategyType) {
22
+ return {
23
+ getId: noop
24
+ };
25
+ }
22
26
  var usrCacheId;
23
27
  if (configuration.sessionStoreStrategyType.type === SessionPersistence.COOKIE) {
24
28
  usrCacheId = initUsrCookie(configuration.sessionStoreStrategyType.cookieOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getCookie","setCookie","UUID","ONE_HOUR","SessionPersistence","USR_ID_COOKIE_NAME","ANONYMOUS_ID_EXPIRATION","initUsrCookie","cookieOptions","usrCacheId","initUsrLocalStorage","localStorage","getItem","setItem","startCacheUsrCache","configuration","sessionStoreStrategyType","type","COOKIE","getId"],"sources":["../../../src/domain/usr/index.js"],"sourcesContent":["import {\n getCookie,\n setCookie,\n UUID,\n ONE_HOUR,\n SessionPersistence\n} from '@cloudcare/browser-core'\nexport var USR_ID_COOKIE_NAME = '_gc_usr_id'\nexport var ANONYMOUS_ID_EXPIRATION = 60 * 24 * ONE_HOUR\n\nfunction initUsrCookie(cookieOptions) {\n var usrCacheId = getCookie(USR_ID_COOKIE_NAME, cookieOptions)\n if (!usrCacheId) {\n usrCacheId = UUID()\n setCookie(\n USR_ID_COOKIE_NAME,\n usrCacheId,\n ANONYMOUS_ID_EXPIRATION,\n cookieOptions\n )\n }\n return usrCacheId\n}\nfunction initUsrLocalStorage() {\n var usrCacheId = localStorage.getItem(USR_ID_COOKIE_NAME)\n if (!usrCacheId) {\n usrCacheId = UUID()\n localStorage.setItem(USR_ID_COOKIE_NAME, usrCacheId)\n }\n return usrCacheId\n}\nexport var startCacheUsrCache = function (configuration) {\n if (!configuration.sessionStoreStrategyType) return\n let usrCacheId\n if (\n configuration.sessionStoreStrategyType.type === SessionPersistence.COOKIE\n ) {\n usrCacheId = initUsrCookie(\n configuration.sessionStoreStrategyType.cookieOptions\n )\n } else {\n usrCacheId = initUsrLocalStorage()\n }\n\n return {\n getId: function () {\n return usrCacheId\n }\n }\n}\n"],"mappings":"AAAA,SACEA,SAAS,EACTC,SAAS,EACTC,IAAI,EACJC,QAAQ,EACRC,kBAAkB,QACb,yBAAyB;AAChC,OAAO,IAAIC,kBAAkB,GAAG,YAAY;AAC5C,OAAO,IAAIC,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAGH,QAAQ;AAEvD,SAASI,aAAaA,CAACC,aAAa,EAAE;EACpC,IAAIC,UAAU,GAAGT,SAAS,CAACK,kBAAkB,EAAEG,aAAa,CAAC;EAC7D,IAAI,CAACC,UAAU,EAAE;IACfA,UAAU,GAAGP,IAAI,CAAC,CAAC;IACnBD,SAAS,CACPI,kBAAkB,EAClBI,UAAU,EACVH,uBAAuB,EACvBE,aACF,CAAC;EACH;EACA,OAAOC,UAAU;AACnB;AACA,SAASC,mBAAmBA,CAAA,EAAG;EAC7B,IAAID,UAAU,GAAGE,YAAY,CAACC,OAAO,CAACP,kBAAkB,CAAC;EACzD,IAAI,CAACI,UAAU,EAAE;IACfA,UAAU,GAAGP,IAAI,CAAC,CAAC;IACnBS,YAAY,CAACE,OAAO,CAACR,kBAAkB,EAAEI,UAAU,CAAC;EACtD;EACA,OAAOA,UAAU;AACnB;AACA,OAAO,IAAIK,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAaC,aAAa,EAAE;EACvD,IAAI,CAACA,aAAa,CAACC,wBAAwB,EAAE;EAC7C,IAAIP,UAAU;EACd,IACEM,aAAa,CAACC,wBAAwB,CAACC,IAAI,KAAKb,kBAAkB,CAACc,MAAM,EACzE;IACAT,UAAU,GAAGF,aAAa,CACxBQ,aAAa,CAACC,wBAAwB,CAACR,aACzC,CAAC;EACH,CAAC,MAAM;IACLC,UAAU,GAAGC,mBAAmB,CAAC,CAAC;EACpC;EAEA,OAAO;IACLS,KAAK,EAAE,SAAPA,KAAKA,CAAA,EAAc;MACjB,OAAOV,UAAU;IACnB;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getCookie","setCookie","UUID","ONE_HOUR","noop","SessionPersistence","USR_ID_COOKIE_NAME","ANONYMOUS_ID_EXPIRATION","initUsrCookie","cookieOptions","usrCacheId","initUsrLocalStorage","localStorage","getItem","setItem","startCacheUsrCache","configuration","sessionStoreStrategyType","getId","type","COOKIE"],"sources":["../../../src/domain/usr/index.js"],"sourcesContent":["import {\n getCookie,\n setCookie,\n UUID,\n ONE_HOUR,\n noop,\n SessionPersistence\n} from '@cloudcare/browser-core'\nexport var USR_ID_COOKIE_NAME = '_gc_usr_id'\nexport var ANONYMOUS_ID_EXPIRATION = 60 * 24 * ONE_HOUR\n\nfunction initUsrCookie(cookieOptions) {\n var usrCacheId = getCookie(USR_ID_COOKIE_NAME, cookieOptions)\n if (!usrCacheId) {\n usrCacheId = UUID()\n setCookie(\n USR_ID_COOKIE_NAME,\n usrCacheId,\n ANONYMOUS_ID_EXPIRATION,\n cookieOptions\n )\n }\n return usrCacheId\n}\nfunction initUsrLocalStorage() {\n var usrCacheId = localStorage.getItem(USR_ID_COOKIE_NAME)\n if (!usrCacheId) {\n usrCacheId = UUID()\n localStorage.setItem(USR_ID_COOKIE_NAME, usrCacheId)\n }\n return usrCacheId\n}\nexport var startCacheUsrCache = function (configuration) {\n if (!configuration.sessionStoreStrategyType) {\n return {\n getId: noop\n }\n }\n\n let usrCacheId\n if (\n configuration.sessionStoreStrategyType.type === SessionPersistence.COOKIE\n ) {\n usrCacheId = initUsrCookie(\n configuration.sessionStoreStrategyType.cookieOptions\n )\n } else {\n usrCacheId = initUsrLocalStorage()\n }\n\n return {\n getId: function () {\n return usrCacheId\n }\n }\n}\n"],"mappings":"AAAA,SACEA,SAAS,EACTC,SAAS,EACTC,IAAI,EACJC,QAAQ,EACRC,IAAI,EACJC,kBAAkB,QACb,yBAAyB;AAChC,OAAO,IAAIC,kBAAkB,GAAG,YAAY;AAC5C,OAAO,IAAIC,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAGJ,QAAQ;AAEvD,SAASK,aAAaA,CAACC,aAAa,EAAE;EACpC,IAAIC,UAAU,GAAGV,SAAS,CAACM,kBAAkB,EAAEG,aAAa,CAAC;EAC7D,IAAI,CAACC,UAAU,EAAE;IACfA,UAAU,GAAGR,IAAI,CAAC,CAAC;IACnBD,SAAS,CACPK,kBAAkB,EAClBI,UAAU,EACVH,uBAAuB,EACvBE,aACF,CAAC;EACH;EACA,OAAOC,UAAU;AACnB;AACA,SAASC,mBAAmBA,CAAA,EAAG;EAC7B,IAAID,UAAU,GAAGE,YAAY,CAACC,OAAO,CAACP,kBAAkB,CAAC;EACzD,IAAI,CAACI,UAAU,EAAE;IACfA,UAAU,GAAGR,IAAI,CAAC,CAAC;IACnBU,YAAY,CAACE,OAAO,CAACR,kBAAkB,EAAEI,UAAU,CAAC;EACtD;EACA,OAAOA,UAAU;AACnB;AACA,OAAO,IAAIK,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAaC,aAAa,EAAE;EACvD,IAAI,CAACA,aAAa,CAACC,wBAAwB,EAAE;IAC3C,OAAO;MACLC,KAAK,EAAEd;IACT,CAAC;EACH;EAEA,IAAIM,UAAU;EACd,IACEM,aAAa,CAACC,wBAAwB,CAACE,IAAI,KAAKd,kBAAkB,CAACe,MAAM,EACzE;IACAV,UAAU,GAAGF,aAAa,CACxBQ,aAAa,CAACC,wBAAwB,CAACR,aACzC,CAAC;EACH,CAAC,MAAM;IACLC,UAAU,GAAGC,mBAAmB,CAAC,CAAC;EACpC;EAEA,OAAO;IACLO,KAAK,EAAE,SAAPA,KAAKA,CAAA,EAAc;MACjB,OAAOR,UAAU;IACnB;EACF,CAAC;AACH,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-rum",
3
- "version": "3.2.36",
3
+ "version": "3.2.38",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "types": "types/index.d.ts",
7
7
  "dependencies": {
8
- "@cloudcare/browser-core": "3.2.36",
9
- "@cloudcare/browser-worker": "3.2.36"
8
+ "@cloudcare/browser-core": "3.2.38",
9
+ "@cloudcare/browser-worker": "3.2.38"
10
10
  },
11
11
  "description": "Guance Browser SDK RUM Package",
12
12
  "scripts": {
@@ -33,5 +33,5 @@
33
33
  "author": "dataflux",
34
34
  "license": "MIT",
35
35
  "homepage": "https://github.com/DataFlux-cn/datakit-js/README.md",
36
- "gitHead": "2e71187db3e296d45f2a16b4c08d82283d924b81"
36
+ "gitHead": "323e476bf8d7218b87b49c1707b6e6fed7db110d"
37
37
  }
@@ -128,7 +128,6 @@ export function createPreStartStrategy(
128
128
 
129
129
  // Expose the initial configuration regardless of initialization success.
130
130
  cachedInitConfiguration = initConfiguration
131
-
132
131
  // If we are in a Synthetics test configured to automatically inject a RUM instance, we want
133
132
  // to completely discard the customer application RUM instance by ignoring their init() call.
134
133
  // But, we should not ignore the init() call from the Synthetics-injected RUM instance, so the
@@ -191,6 +190,15 @@ export function createPreStartStrategy(
191
190
  },
192
191
 
193
192
  getViewContext: () => {},
193
+
194
+ addTypeAction: function (action, type, commonContext) {
195
+ if (commonContext === undefined) {
196
+ commonContext = getCommonContext()
197
+ }
198
+ bufferApiCalls.add(function (startRumResult) {
199
+ startRumResult.addTypeAction(action, type, commonContext)
200
+ })
201
+ },
194
202
  addAction: function (action, commonContext) {
195
203
  if (commonContext === undefined) {
196
204
  commonContext = getCommonContext()
@@ -17,7 +17,8 @@ import {
17
17
  sanitize,
18
18
  createCustomerDataTrackerManager,
19
19
  CustomerDataCompressionStatus,
20
- displayAlreadyInitializedError
20
+ displayAlreadyInitializedError,
21
+ getType
21
22
  } from '@cloudcare/browser-core'
22
23
  import { buildCommonContext } from '../domain/contexts/commonContext'
23
24
  import { createPreStartStrategy } from './perStartRum'
@@ -184,9 +185,24 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
184
185
  addDebugSession: monitor(function (id) {}),
185
186
  clearDebugSession: monitor(function () {}),
186
187
  getDebugSession: monitor(function () {}),
187
- addAction: monitor(function (name, context) {
188
+ addTypeAction: monitor(function (name, type, context) {
188
189
  const handlingStack = createHandlingStack()
189
190
 
191
+ callMonitored(function () {
192
+ const sourceType = sanitize(type)
193
+ strategy.addAction({
194
+ name: sanitize(name),
195
+ context: sanitize(context),
196
+ startClocks: clocksNow(),
197
+ type:
198
+ getType(sourceType) === 'string' ? sourceType : ActionType.CUSTOM,
199
+ handlingStack: handlingStack
200
+ })
201
+ addTelemetryUsage({ feature: 'add-type-action' })
202
+ })
203
+ }),
204
+ addAction: monitor(function (name, context) {
205
+ const handlingStack = createHandlingStack()
190
206
  callMonitored(function () {
191
207
  strategy.addAction({
192
208
  name: sanitize(name),
@@ -435,7 +435,6 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
435
435
  return s.href === element.href
436
436
  })
437
437
  var cssText = getCssRulesString(stylesheet)
438
-
439
438
  if (cssText && stylesheet) {
440
439
  safeAttrs._cssText = cssText
441
440
  }
@@ -79,7 +79,7 @@ function processAction(action, pageStateHistory) {
79
79
  }
80
80
  : {
81
81
  action: {
82
- loadingTime: 0
82
+ loadingTime: action.context?.duration || 0
83
83
  }
84
84
  }
85
85
  var customerContext = !isAutoAction(action) ? action.context : undefined
@@ -115,5 +115,6 @@ function processAction(action, pageStateHistory) {
115
115
  }
116
116
 
117
117
  function isAutoAction(action) {
118
- return action.type !== ActionType.CUSTOM
118
+ return action.type === ActionType.CLICK
119
+ // return action.type !== ActionType.CUSTOM
119
120
  }
@@ -3,6 +3,7 @@ import {
3
3
  setCookie,
4
4
  UUID,
5
5
  ONE_HOUR,
6
+ noop,
6
7
  SessionPersistence
7
8
  } from '@cloudcare/browser-core'
8
9
  export var USR_ID_COOKIE_NAME = '_gc_usr_id'
@@ -30,7 +31,12 @@ function initUsrLocalStorage() {
30
31
  return usrCacheId
31
32
  }
32
33
  export var startCacheUsrCache = function (configuration) {
33
- if (!configuration.sessionStoreStrategyType) return
34
+ if (!configuration.sessionStoreStrategyType) {
35
+ return {
36
+ getId: noop
37
+ }
38
+ }
39
+
34
40
  let usrCacheId
35
41
  if (
36
42
  configuration.sessionStoreStrategyType.type === SessionPersistence.COOKIE
package/types/index.d.ts CHANGED
@@ -50,6 +50,11 @@ export declare const datafluxRum: {
50
50
  | RumSiteInitConfiguration
51
51
  | undefined
52
52
  addAction: (name: string, context?: object | undefined) => void
53
+ addTypeAction: (
54
+ name: string,
55
+ type?: string,
56
+ context?: object | undefined
57
+ ) => void
53
58
  addError: (error: unknown, context?: object | undefined) => void
54
59
  addTiming: (name: string, time?: number | undefined) => void
55
60
  setUser: (newUser: User) => void