@10x-media/analytics 1.0.0-beta.14 → 1.0.0-beta.16

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +1 -1
  3. package/dist/adapters/ga4/ga4.d.ts +7 -0
  4. package/dist/adapters/ga4/ga4.js +17 -3
  5. package/dist/adapters/ga4/ga4.js.map +1 -1
  6. package/dist/adapters/plausible/plausible.d.ts +6 -0
  7. package/dist/adapters/plausible/plausible.js +6 -3
  8. package/dist/adapters/plausible/plausible.js.map +1 -1
  9. package/dist/adapters/posthog/cloud.js +20 -0
  10. package/dist/adapters/posthog/cloud.js.map +1 -0
  11. package/dist/adapters/posthog/credentials.js +20 -0
  12. package/dist/adapters/posthog/credentials.js.map +1 -0
  13. package/dist/adapters/posthog/posthog.d.ts +10 -3
  14. package/dist/adapters/posthog/posthog.js +100 -27
  15. package/dist/adapters/posthog/posthog.js.map +1 -1
  16. package/dist/adapters/posthog/projectCheck.js +56 -0
  17. package/dist/adapters/posthog/projectCheck.js.map +1 -0
  18. package/dist/adapters/umami/umami.d.ts +6 -0
  19. package/dist/adapters/umami/umami.js +3 -1
  20. package/dist/adapters/umami/umami.js.map +1 -1
  21. package/dist/capture/trackerConfig.js +29 -6
  22. package/dist/capture/trackerConfig.js.map +1 -1
  23. package/dist/capture/withoutConsent.js +91 -0
  24. package/dist/capture/withoutConsent.js.map +1 -0
  25. package/dist/core/capture.d.ts +41 -11
  26. package/dist/core/captureOptions.js +97 -8
  27. package/dist/core/captureOptions.js.map +1 -1
  28. package/dist/core/contract.d.ts +25 -0
  29. package/dist/core/contract.js.map +1 -1
  30. package/dist/core/options.d.ts +24 -2
  31. package/dist/core/options.js.map +1 -1
  32. package/dist/core/sourceOptions.js +2 -1
  33. package/dist/core/sourceOptions.js.map +1 -1
  34. package/dist/exports/adapters/contract.d.ts +3 -3
  35. package/dist/exports/adapters/ga4.d.ts +4 -4
  36. package/dist/exports/adapters/native.d.ts +5 -5
  37. package/dist/exports/adapters/plausible.d.ts +4 -4
  38. package/dist/exports/adapters/posthog.d.ts +4 -4
  39. package/dist/exports/adapters/umami.d.ts +4 -4
  40. package/dist/exports/next.d.ts +4 -4
  41. package/dist/exports/react.d.ts +3 -2
  42. package/dist/exports/site.d.ts +2 -2
  43. package/dist/exports/testing.d.ts +4 -4
  44. package/dist/exports/tracker.d.ts +3 -2
  45. package/dist/exports/types.d.ts +5 -5
  46. package/dist/index.d.ts +5 -5
  47. package/dist/index.js +2 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/native/collections/hits.js +1 -0
  50. package/dist/native/collections/hits.js.map +1 -1
  51. package/dist/native/engine/engine.js +5 -1
  52. package/dist/native/engine/engine.js.map +1 -1
  53. package/dist/native/engine/planner.js +2 -1
  54. package/dist/native/engine/planner.js.map +1 -1
  55. package/dist/native/engine/toHit.js +4 -2
  56. package/dist/native/engine/toHit.js.map +1 -1
  57. package/dist/native/ingest/endpoint.js +5 -2
  58. package/dist/native/ingest/endpoint.js.map +1 -1
  59. package/dist/native/ingest/normalizeEvent.d.ts +6 -1
  60. package/dist/native/ingest/normalizeEvent.js +17 -7
  61. package/dist/native/ingest/normalizeEvent.js.map +1 -1
  62. package/dist/native/ingest/serverTrack.js +2 -1
  63. package/dist/native/ingest/serverTrack.js.map +1 -1
  64. package/dist/native/ingest/validate.js +3 -0
  65. package/dist/native/ingest/validate.js.map +1 -1
  66. package/dist/native/nativeAdapter.d.ts +10 -1
  67. package/dist/native/nativeAdapter.js +11 -1
  68. package/dist/native/nativeAdapter.js.map +1 -1
  69. package/dist/native/store/aggregate.js +1 -1
  70. package/dist/native/store/aggregate.js.map +1 -1
  71. package/dist/native/store/hitRow.js +3 -0
  72. package/dist/native/store/hitRow.js.map +1 -1
  73. package/dist/native/store/hits.js +3 -1
  74. package/dist/native/store/hits.js.map +1 -1
  75. package/dist/native/store/mongo/aggregatePipelines.js +10 -2
  76. package/dist/native/store/mongo/aggregatePipelines.js.map +1 -1
  77. package/dist/native/store/mongo/pipelines.js +15 -5
  78. package/dist/native/store/mongo/pipelines.js.map +1 -1
  79. package/dist/native/store/parts.js +9 -3
  80. package/dist/native/store/parts.js.map +1 -1
  81. package/dist/native/store/rawRead.js +6 -3
  82. package/dist/native/store/rawRead.js.map +1 -1
  83. package/dist/native/store/sql/aggregateSql.js +6 -2
  84. package/dist/native/store/sql/aggregateSql.js.map +1 -1
  85. package/dist/native/store/sql/columns.js +1 -0
  86. package/dist/native/store/sql/columns.js.map +1 -1
  87. package/dist/native/store/sql/compile.js +19 -7
  88. package/dist/native/store/sql/compile.js.map +1 -1
  89. package/dist/native/store/types.d.ts +7 -1
  90. package/dist/native/store/types.js +10 -0
  91. package/dist/native/store/types.js.map +1 -0
  92. package/dist/plugin/createRuntime.js +10 -1
  93. package/dist/plugin/createRuntime.js.map +1 -1
  94. package/dist/plugin/runtime.js.map +1 -1
  95. package/dist/providers/collection.d.ts +2 -0
  96. package/dist/providers/collection.js +36 -9
  97. package/dist/providers/collection.js.map +1 -1
  98. package/dist/providers/factory.d.ts +9 -1
  99. package/dist/providers/factory.js +14 -5
  100. package/dist/providers/factory.js.map +1 -1
  101. package/dist/providers/hosts.js +14 -6
  102. package/dist/providers/hosts.js.map +1 -1
  103. package/dist/providers/registry.js +2 -1
  104. package/dist/providers/registry.js.map +1 -1
  105. package/dist/react/AnalyticsProvider.d.ts +6 -0
  106. package/dist/react/AnalyticsProvider.js.map +1 -1
  107. package/dist/react/useAnalytics.js +9 -5
  108. package/dist/react/useAnalytics.js.map +1 -1
  109. package/dist/site/AnalyticsScripts.d.ts +4 -3
  110. package/dist/site/AnalyticsScripts.js +18 -4
  111. package/dist/site/AnalyticsScripts.js.map +1 -1
  112. package/dist/surfacing/todaySplit.js +7 -1
  113. package/dist/surfacing/todaySplit.js.map +1 -1
  114. package/dist/tracker/config.d.ts +26 -1
  115. package/dist/tracker/config.js.map +1 -1
  116. package/dist/tracker/createTracker.d.ts +2 -1
  117. package/dist/tracker/createTracker.js +91 -59
  118. package/dist/tracker/createTracker.js.map +1 -1
  119. package/dist/tracker/gate.d.ts +8 -0
  120. package/dist/tracker/gate.js +61 -11
  121. package/dist/tracker/gate.js.map +1 -1
  122. package/dist/tracker/loadScript.js +2 -1
  123. package/dist/tracker/loadScript.js.map +1 -1
  124. package/dist/tracker/registry.js +14 -3
  125. package/dist/tracker/registry.js.map +1 -1
  126. package/dist/tracker/sinks/createSink.js +27 -8
  127. package/dist/tracker/sinks/createSink.js.map +1 -1
  128. package/dist/tracker/sinks/ga4.js +38 -6
  129. package/dist/tracker/sinks/ga4.js.map +1 -1
  130. package/dist/tracker/sinks/native.js +17 -3
  131. package/dist/tracker/sinks/native.js.map +1 -1
  132. package/dist/tracker/sinks/plausible.js +8 -2
  133. package/dist/tracker/sinks/plausible.js.map +1 -1
  134. package/dist/tracker/sinks/posthog.js +108 -16
  135. package/dist/tracker/sinks/posthog.js.map +1 -1
  136. package/dist/tracker/sinks/umami.js +2 -2
  137. package/dist/tracker/sinks/umami.js.map +1 -1
  138. package/dist/tracker/sinks/vendor.js +25 -11
  139. package/dist/tracker/sinks/vendor.js.map +1 -1
  140. package/dist/tracker/types.d.ts +10 -3
  141. package/dist/translations/ar.js +10 -0
  142. package/dist/translations/ar.js.map +1 -1
  143. package/dist/translations/de.js +10 -0
  144. package/dist/translations/de.js.map +1 -1
  145. package/dist/translations/en.js +10 -0
  146. package/dist/translations/en.js.map +1 -1
  147. package/dist/translations/es.js +10 -0
  148. package/dist/translations/es.js.map +1 -1
  149. package/dist/translations/fr.js +10 -0
  150. package/dist/translations/fr.js.map +1 -1
  151. package/dist/translations/id.js +10 -0
  152. package/dist/translations/id.js.map +1 -1
  153. package/dist/translations/keys.d.ts +10 -0
  154. package/dist/translations/keys.js +11 -1
  155. package/dist/translations/keys.js.map +1 -1
  156. package/dist/translations/ko.js +10 -0
  157. package/dist/translations/ko.js.map +1 -1
  158. package/dist/translations/pt.js +10 -0
  159. package/dist/translations/pt.js.map +1 -1
  160. package/dist/translations/ru.js +10 -0
  161. package/dist/translations/ru.js.map +1 -1
  162. package/dist/translations/uk.js +10 -0
  163. package/dist/translations/uk.js.map +1 -1
  164. package/dist/translations/zh.js +10 -0
  165. package/dist/translations/zh.js.map +1 -1
  166. package/dist/view/consentShare.js +15 -0
  167. package/dist/view/consentShare.js.map +1 -0
  168. package/dist/view/sections/OverviewCards.js +38 -28
  169. package/dist/view/sections/OverviewCards.js.map +1 -1
  170. package/dist/widgets/notices.js +6 -1
  171. package/dist/widgets/notices.js.map +1 -1
  172. package/dist/widgets/readMeta.d.ts +4 -0
  173. package/dist/widgets/readMeta.js +5 -0
  174. package/dist/widgets/readMeta.js.map +1 -1
  175. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"notices.js","names":[],"sources":["../../src/widgets/notices.ts"],"sourcesContent":["import { dateTimeFormat, listFormat, relativeTimeFormat } from '../translations/intl'\nimport { keys } from '../translations/keys'\nimport type { Translate } from '../translations/server'\nimport type { SubstitutedSource } from './prepareWidgetRead'\nimport type { ReadNotices } from './readMeta'\n\n/** What a read can carry beyond its numbers, each of which earns a word of caveat. */\nexport type WidgetNoticeFlags = Partial<ReadNotices> &\n\tSubstitutedSource & {\n\t\t/** The read asked about goals and the scope declared none of its own. */\n\t\tnoGoals?: boolean\n\t}\n\n/** What wording a notice needs beyond its key: the reader's language and the moment it is read. */\nexport interface NoticeContext {\n\tt: Translate\n\tlocale: string\n\tnow: Date\n\t/** The reporting timezone a clamped window's days are named in; UTC when absent. */\n\ttimeZone?: string\n}\n\n/** Between notices on the one line: a list separator, not sentence punctuation. */\nexport const NOTICE_SEPARATOR = ' · '\n\nconst SECOND = 1000\nconst MINUTE = 60 * SECOND\nconst HOUR = 60 * MINUTE\n\nconst relativeFormat = (locale: string): Intl.RelativeTimeFormat =>\n\trelativeTimeFormat(locale, { numeric: 'auto' })\n\n/** How long ago `asOf` was, in the reader's language: \"3 minutes ago\". */\nexport const timeAgo = (asOf: string, now: Date, locale: string): string => {\n\tconst elapsed = Math.max(0, now.getTime() - Date.parse(asOf))\n\tconst format = relativeFormat(locale)\n\tif (elapsed < MINUTE) {\n\t\treturn format.format(-Math.round(elapsed / SECOND), 'second')\n\t}\n\tif (elapsed < HOUR) {\n\t\treturn format.format(-Math.floor(elapsed / MINUTE), 'minute')\n\t}\n\treturn format.format(-Math.floor(elapsed / HOUR), 'hour')\n}\n\n/** The day an instant falls on in the reader's language and the reporting zone: \"Mar 3, 2026\". */\nconst dayOf = (instant: string, context: NoticeContext): string =>\n\tdateTimeFormat(context.locale, {\n\t\tmonth: 'short',\n\t\tday: 'numeric',\n\t\tyear: 'numeric',\n\t\ttimeZone: context.timeZone ?? 'UTC',\n\t}).format(new Date(instant))\n\n/** What a clamped read covers, by the bounds it kept, else the generic wording. */\nconst clampedText = (flags: WidgetNoticeFlags, context: NoticeContext): string => {\n\tconst { t } = context\n\tconst from = flags.dataFrom\n\tconst to = flags.dataTo\n\tif (from && to) {\n\t\treturn t(keys.stateClampedBetween, { from: dayOf(from, context), to: dayOf(to, context) })\n\t}\n\tif (from) return t(keys.stateClampedFrom, { date: dayOf(from, context) })\n\tif (to) return t(keys.stateClampedTo, { date: dayOf(to, context) })\n\treturn t(keys.stateClamped)\n}\n\n/**\n * The caveats a read carries, each a sentence, widest-reaching first, so the one that changes what\n * the number means the most is read first. Empty when the read carries none, the common case.\n */\nexport const noticeTexts = (flags: WidgetNoticeFlags, context: NoticeContext): string[] => {\n\tconst { t } = context\n\tconst texts: string[] = []\n\t// The id is not named: it can be an internal one, such as a provider document's.\n\tif (flags.substitutedFrom !== undefined) texts.push(t(keys.stateSourceSubstituted))\n\tif (flags.stale) texts.push(t(keys.viewStale))\n\tif (flags.hostRefused) texts.push(t(keys.viewErrorHostRefused))\n\telse if (flags.sourceError) texts.push(t(keys.viewErrorMisconfigured))\n\tif (flags.timezoneUnresolved) texts.push(t(keys.stateTimezoneUnresolved))\n\tif (flags.partial) texts.push(t(keys.statePartial))\n\tif (flags.capped) texts.push(t(keys.stateCapped))\n\tif (flags.failed) texts.push(t(keys.stateFailed))\n\tif (flags.clamped) texts.push(clampedText(flags, context))\n\tif (flags.filtersUnapplied) texts.push(t(keys.stateFiltersUnapplied))\n\tif (flags.sampled) texts.push(t(keys.stateSampled))\n\tconst currencies = flags.mixedCurrencies ?? []\n\tif (currencies.length > 1) {\n\t\tconst named = listFormat(context.locale, { type: 'conjunction' }).format(currencies)\n\t\ttexts.push(t(keys.stateMixedCurrencies, { currencies: named }))\n\t}\n\t// A conversions number with no goals behind it is a number about nothing, which the plain\n\t// caption would read as \"nobody converted\".\n\tif (flags.goalsUnresolved) texts.push(t(keys.stateGoalsUnresolved))\n\telse if (flags.noGoals) texts.push(t(keys.stateNoGoals))\n\tif (flags.asOf) {\n\t\ttexts.push(t(keys.stateUpdated, { ago: timeAgo(flags.asOf, context.now, context.locale) }))\n\t}\n\treturn texts\n}\n\n/**\n * The caveats as one line: a card is a few centimetres tall, and notices stacked under it would\n * push the number itself out of view.\n */\nexport const widgetNotice = (flags: WidgetNoticeFlags, context: NoticeContext): string =>\n\tnoticeTexts(flags, context).join(NOTICE_SEPARATOR)\n"],"mappings":";;;;AAuBA,MAAa,mBAAmB;AAEhC,MAAM,SAAS;AACf,MAAM,SAAS,KAAK;AACpB,MAAM,OAAO,KAAK;AAElB,MAAM,kBAAkB,WACvB,mBAAmB,QAAQ,EAAE,SAAS,OAAO,CAAC;;AAG/C,MAAa,WAAW,MAAc,KAAW,WAA2B;CAC3E,MAAM,UAAU,KAAK,IAAI,GAAG,IAAI,QAAQ,IAAI,KAAK,MAAM,IAAI,CAAC;CAC5D,MAAM,SAAS,eAAe,MAAM;CACpC,IAAI,UAAU,QACb,OAAO,OAAO,OAAO,CAAC,KAAK,MAAM,UAAU,MAAM,GAAG,QAAQ;CAE7D,IAAI,UAAU,MACb,OAAO,OAAO,OAAO,CAAC,KAAK,MAAM,UAAU,MAAM,GA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AAI,MAAM,QAAQ,MAAM,KAAK,EAAE,KAAK,WAAW,CAAC;CAChD,IAAI,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,OAAO,CAAC;CACzD,IAAI,MAAM,kBAAkB,MAAM,KAAK,EAAE,KAAK,qBAAqB,CAAC;CACpE,IAAI,MAAM,SAAS,MAAM,KAAK,EAAE,KAAK,YAAY,CAAC;CAClD,MAAM,aAAa,MAAM,mBAAmB,CAAC;CAC7C,IAAI,WAAW,SAAS,GAAG;EAC1B,MAAM,QAAQ,WAAW,QAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC,EAAE,OAAO,UAAU;EACnF,MAAM,KAAK,EAAE,KAAK,sBAAsB,EAAE,YAAY,MAAM,CAAC,CAAC;CAC/D;CAGA,IAAI,MAAM,iBAAiB,MAAM,KAAK,EAAE,KAAK,oBAAoB,CAAC;MAC7D,IAAI,MAAM,SAAS,MAAM,KAAK,EAAE,KAAK,YAAY,CAAC;CACvD,IAAI,MAAM,MACT,MAAM,KAAK,EAAE,KAAK,cAAc,EAAE,KAAK,QAAQ,MAAM,MAAM,QAAQ,KAAK,QAAQ,MAAM,EAAE,CAAC,CAAC;CAE3F,OAAO;AACR;;;;;AAMA,MAAa,gBAAgB,OAA0B,YACtD,YAAY,OAAO,OAAO,EAAE,KAAK,gBAAgB"}
1
+ {"version":3,"file":"notices.js","names":[],"sources":["../../src/widgets/notices.ts"],"sourcesContent":["import { dateTimeFormat, listFormat, numberFormat, relativeTimeFormat } from '../translations/intl'\nimport { keys } from '../translations/keys'\nimport type { Translate } from '../translations/server'\nimport type { SubstitutedSource } from './prepareWidgetRead'\nimport type { ReadNotices } from './readMeta'\n\n/** What a read can carry beyond its numbers, each of which earns a word of caveat. */\nexport type WidgetNoticeFlags = Partial<ReadNotices> &\n\tSubstitutedSource & {\n\t\t/** The read asked about goals and the scope declared none of its own. */\n\t\tnoGoals?: boolean\n\t}\n\n/** What wording a notice needs beyond its key: the reader's language and the moment it is read. */\nexport interface NoticeContext {\n\tt: Translate\n\tlocale: string\n\tnow: Date\n\t/** The reporting timezone a clamped window's days are named in; UTC when absent. */\n\ttimeZone?: string\n}\n\n/** Between notices on the one line: a list separator, not sentence punctuation. */\nexport const NOTICE_SEPARATOR = ' · '\n\nconst SECOND = 1000\nconst MINUTE = 60 * SECOND\nconst HOUR = 60 * MINUTE\n\nconst relativeFormat = (locale: string): Intl.RelativeTimeFormat =>\n\trelativeTimeFormat(locale, { numeric: 'auto' })\n\n/** How long ago `asOf` was, in the reader's language: \"3 minutes ago\". */\nexport const timeAgo = (asOf: string, now: Date, locale: string): string => {\n\tconst elapsed = Math.max(0, now.getTime() - Date.parse(asOf))\n\tconst format = relativeFormat(locale)\n\tif (elapsed < MINUTE) {\n\t\treturn format.format(-Math.round(elapsed / SECOND), 'second')\n\t}\n\tif (elapsed < HOUR) {\n\t\treturn format.format(-Math.floor(elapsed / MINUTE), 'minute')\n\t}\n\treturn format.format(-Math.floor(elapsed / HOUR), 'hour')\n}\n\n/** The day an instant falls on in the reader's language and the reporting zone: \"Mar 3, 2026\". */\nconst dayOf = (instant: string, context: NoticeContext): string =>\n\tdateTimeFormat(context.locale, {\n\t\tmonth: 'short',\n\t\tday: 'numeric',\n\t\tyear: 'numeric',\n\t\ttimeZone: context.timeZone ?? 'UTC',\n\t}).format(new Date(instant))\n\n/** What a clamped read covers, by the bounds it kept, else the generic wording. */\nconst clampedText = (flags: WidgetNoticeFlags, context: NoticeContext): string => {\n\tconst { t } = context\n\tconst from = flags.dataFrom\n\tconst to = flags.dataTo\n\tif (from && to) {\n\t\treturn t(keys.stateClampedBetween, { from: dayOf(from, context), to: dayOf(to, context) })\n\t}\n\tif (from) return t(keys.stateClampedFrom, { date: dayOf(from, context) })\n\tif (to) return t(keys.stateClampedTo, { date: dayOf(to, context) })\n\treturn t(keys.stateClamped)\n}\n\n/**\n * The caveats a read carries, each a sentence, widest-reaching first, so the one that changes what\n * the number means the most is read first. Empty when the read carries none, the common case.\n */\nexport const noticeTexts = (flags: WidgetNoticeFlags, context: NoticeContext): string[] => {\n\tconst { t } = context\n\tconst texts: string[] = []\n\t// The id is not named: it can be an internal one, such as a provider document's.\n\tif (flags.substitutedFrom !== undefined) texts.push(t(keys.stateSourceSubstituted))\n\tif (flags.stale) texts.push(t(keys.viewStale))\n\tif (flags.hostRefused) texts.push(t(keys.viewErrorHostRefused))\n\telse if (flags.sourceError) texts.push(t(keys.viewErrorMisconfigured))\n\tif (flags.withoutConsentDropped) texts.push(t(keys.statePosthogCookielessDropped))\n\tif (flags.timezoneUnresolved) texts.push(t(keys.stateTimezoneUnresolved))\n\tif (flags.partial) texts.push(t(keys.statePartial))\n\tif (flags.capped) texts.push(t(keys.stateCapped))\n\tif (flags.failed) texts.push(t(keys.stateFailed))\n\tif (flags.clamped) texts.push(clampedText(flags, context))\n\tif (flags.filtersUnapplied) texts.push(t(keys.stateFiltersUnapplied))\n\tif (flags.sampled) texts.push(t(keys.stateSampled))\n\tif (flags.withoutVisitor) {\n\t\tconst count = numberFormat(context.locale).format(flags.withoutVisitor)\n\t\ttexts.push(t(keys.stateWithoutVisitor, { count }))\n\t}\n\tconst currencies = flags.mixedCurrencies ?? []\n\tif (currencies.length > 1) {\n\t\tconst named = listFormat(context.locale, { type: 'conjunction' }).format(currencies)\n\t\ttexts.push(t(keys.stateMixedCurrencies, { currencies: named }))\n\t}\n\t// A conversions number with no goals behind it is a number about nothing, which the plain\n\t// caption would read as \"nobody converted\".\n\tif (flags.goalsUnresolved) texts.push(t(keys.stateGoalsUnresolved))\n\telse if (flags.noGoals) texts.push(t(keys.stateNoGoals))\n\tif (flags.asOf) {\n\t\ttexts.push(t(keys.stateUpdated, { ago: timeAgo(flags.asOf, context.now, context.locale) }))\n\t}\n\treturn texts\n}\n\n/**\n * The caveats as one line: a card is a few centimetres tall, and notices stacked under it would\n * push the number itself out of view.\n */\nexport const widgetNotice = (flags: WidgetNoticeFlags, context: NoticeContext): string =>\n\tnoticeTexts(flags, context).join(NOTICE_S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AoB,CAAC;MAC7D,IAAI,MAAM,SAAS,MAAM,KAAK,EAAE,KAAK,YAAY,CAAC;CACvD,IAAI,MAAM,MACT,MAAM,KAAK,EAAE,KAAK,cAAc,EAAE,KAAK,QAAQ,MAAM,MAAM,QAAQ,KAAK,QAAQ,MAAM,EAAE,CAAC,CAAC;CAE3F,OAAO;AACR;;;;;AAMA,MAAa,gBAAgB,OAA0B,YACtD,YAAY,OAAO,OAAO,EAAE,KAAK,gBAAgB"}
@@ -34,6 +34,10 @@ interface ReadNotices {
34
34
  * person who came on two days counts twice. Said by the metric's name and explained in a notice.
35
35
  */
36
36
  visitorsSummed?: boolean;
37
+ /** The vendor drops the visits counted without consent, so they are missing from the numbers. */
38
+ withoutConsentDropped?: boolean;
39
+ /** Pageviews recorded without a visitor, which count toward no visitor number; absent when none. */
40
+ withoutVisitor?: number;
37
41
  /** ISO instant the numbers were last brought up to date, set when a snapshot answered. */
38
42
  asOf?: string;
39
43
  /** The ISO code the read's revenue is in, when the source or the install says. */
@@ -19,6 +19,8 @@ const readMeta = (result) => ({
19
19
  failed: (result.meta.failed?.days ?? 0) > 0,
20
20
  timezoneUnresolved: result.meta.timezoneUnresolved === true,
21
21
  visitorsSummed: result.meta.visitorsAre === "sumOfDaily",
22
+ withoutConsentDropped: result.meta.withoutConsentDropped === true,
23
+ ...(result.meta.withoutVisitor?.pageviews ?? 0) > 0 ? { withoutVisitor: result.meta.withoutVisitor?.pageviews } : {},
22
24
  mixedCurrencies: (result.meta.mixedCurrencies?.length ?? 0) > 1 ? [...result.meta.mixedCurrencies ?? []] : [],
23
25
  ...result.meta.asOf ? { asOf: result.meta.asOf } : {},
24
26
  ...result.meta.currency ? { currency: result.meta.currency } : {},
@@ -35,6 +37,7 @@ const mergeNotices = (...reads) => {
35
37
  const currencies = new Set(reads.flatMap((read) => read?.mixedCurrencies ?? []));
36
38
  const asOf = reads.reduce((at, read) => earlierInstant(at, read?.asOf), void 0);
37
39
  const currency = reads.find((read) => read?.currency !== void 0)?.currency;
40
+ const withoutVisitor = Math.max(0, ...reads.map((read) => read?.withoutVisitor ?? 0));
38
41
  return {
39
42
  clamped: anyRead("clamped"),
40
43
  ...dataFrom ? { dataFrom } : {},
@@ -50,6 +53,8 @@ const mergeNotices = (...reads) => {
50
53
  failed: anyRead("failed"),
51
54
  timezoneUnresolved: anyRead("timezoneUnresolved"),
52
55
  visitorsSummed: anyRead("visitorsSummed"),
56
+ withoutConsentDropped: anyRead("withoutConsentDropped"),
57
+ ...withoutVisitor > 0 ? { withoutVisitor } : {},
53
58
  mixedCurrencies: [...currencies].sort(),
54
59
  ...asOf ? { asOf } : {},
55
60
  ...currency ? { currency } : {}
@@ -1 +1 @@
1
- {"version":3,"file":"readMeta.js","names":[],"sources":["../../src/widgets/readMeta.ts"],"sourcesContent":["import type { AnalyticsResult } from '../core/contract'\nimport { earlierInstant } from '../core/values'\n\n/** The caveats a read's numbers carry, which every surface showing them words the same way. */\nexport interface ReadNotices {\n\t/** The source read a shorter window than the one that was asked for. */\n\tclamped: boolean\n\t/** ISO instant the clamped data starts at, when later than the window's start. */\n\tdataFrom?: string\n\t/** ISO instant the clamped data ends at, when earlier than the window's end. */\n\tdataTo?: string\n\t/** The engine served an expired cache entry, while refreshing or after the refresh failed. */\n\tstale: boolean\n\t/** The saved numbers' source last failed with its settings refused: they need a look. */\n\tsourceError: boolean\n\t/** That source's host is one the install does not allow. */\n\thostRefused: boolean\n\t/** The source answered without one of the filters the read carried. */\n\tfiltersUnapplied: boolean\n\t/** The source could not read the scope's goals, so the goal numbers mean nothing. */\n\tgoalsUnresolved: boolean\n\t/** The source counted from a sample, so the numbers are estimates. */\n\tsampled: boolean\n\t/** Some days of the range are not counted yet, so the numbers are a floor. */\n\tpartial: boolean\n\t/** A value the read asks about was grouped into `(other)` on days whose raw hits are gone. */\n\tcapped: boolean\n\t/** Some days' counting was given up: they are left out or read from an earlier count. */\n\tfailed?: boolean\n\t/** The days were cut in UTC because the scope's zone could not be resolved. */\n\ttimezoneUnresolved: boolean\n\t/** The currencies revenue adds without converting them, when there is more than one. */\n\tmixedCurrencies: string[]\n\t/**\n\t * Some visitor number adds up each day's visitors (`meta.visitorsAre: 'sumOfDaily'`), so a\n\t * person who came on two days counts twice. Said by the metric's name and explained in a notice.\n\t */\n\tvisitorsSummed?: boolean\n\t/** ISO instant the numbers were last brought up to date, set when a snapshot answered. */\n\tasOf?: string\n\t/** The ISO code the read's revenue is in, when the source or the install says. */\n\tcurrency?: string\n}\n\n/** The state flags every widget result carries, whatever shape its numbers take. */\nexport interface WidgetReadMeta extends ReadNotices {\n\t/** The source that answered. */\n\tprovider: string\n}\n\n/**\n * One mapping from an adapter result's meta to the flags a surface renders, so a flag cannot go\n * missing on one widget while its neighbour shows it.\n */\nexport const readMeta = (result: AnalyticsResult): WidgetReadMeta => ({\n\tclamped: result.meta.clamped ?? false,\n\t...(result.meta.clamped && result.meta.dataFrom ? { dataFrom: result.meta.dataFrom } : {}),\n\t...(result.meta.clamped && result.meta.dataTo ? { dataTo: result.meta.dataTo } : {}),\n\tstale: result.meta.stale ?? false,\n\tsourceError: result.meta.sourceError !== undefined,\n\thostRefused: result.meta.sourceError === 'host-refused',\n\tfiltersUnapplied: (result.meta.unappliedFilters?.length ?? 0) > 0,\n\tgoalsUnresolved: result.meta.goalsUnresolved === true,\n\tsampled: result.meta.sampled ?? false,\n\tpartial: (result.meta.partial?.missingDays ?? 0) > 0,\n\tcapped: (result.meta.capped?.days ?? 0) > 0,\n\tfailed: (result.meta.failed?.days ?? 0) > 0,\n\ttimezoneUnresolved: result.meta.timezoneUnresolved === true,\n\tvisitorsSummed: result.meta.visitorsAre === 'sumOfDaily',\n\tmixedCurrencies:\n\t\t(result.meta.mixedCurrencies?.length ?? 0) > 1 ? [...(result.meta.mixedCurrencies ?? [])] : [],\n\t...(result.meta.asOf ? { asOf: result.meta.asOf } : {}),\n\t...(result.meta.currency ? { currency: result.meta.currency } : {}),\n\tprovider: result.meta.provider,\n})\n\n/**\n * Several reads behind one surface as one set of caveats: any read's flag is the surface's, the\n * currencies are every read's, and the oldest snapshot says how old the numbers are.\n */\nexport const mergeNotices = (\n\t...reads: ReadonlyArray<Partial<ReadNotices> | undefined>\n): ReadNotices => {\n\tconst anyRead = (\n\t\tflag: Exclude<\n\t\t\tkeyof ReadNotices,\n\t\t\t'mixedCurrencies' | 'asOf' | 'currency' | 'dataFrom' | 'dataTo'\n\t\t>\n\t): boolean => reads.some((read) => read?.[flag] === true)\n\t// The narrowest window any read kept: the latest start, the earliest end.\n\tconst dataFrom = reads.reduce<string | undefined>(\n\t\t(at, read) =>\n\t\t\tread?.dataFrom !== undefined &&\n\t\t\t(at === undefined || Date.parse(read.dataFrom) > Date.parse(at))\n\t\t\t\t? read.dataFrom\n\t\t\t\t: at,\n\t\tundefined\n\t)\n\tconst dataTo = reads.reduce<string | undefined>(\n\t\t(at, read) => earlierInstant(at, read?.dataTo),\n\t\tundefined\n\t)\n\tconst currencies = new Set(reads.flatMap((read) => read?.mixedCurrencies ?? []))\n\tconst asOf = reads.reduce<string | undefined>(\n\t\t(at, read) => earlierInstant(at, read?.asOf),\n\t\tundefined\n\t)\n\tconst currency = reads.find((read) => read?.currency !== undefined)?.currency\n\treturn {\n\t\tclamped: anyRead('clamped'),\n\t\t...(dataFrom ? { dataFrom } : {}),\n\t\t...(dataTo ? { dataTo } : {}),\n\t\tstale: anyRead('stale'),\n\t\tsourceError: anyRead('sourceError'),\n\t\thostRefused: anyRead('hostRefused'),\n\t\tfiltersUnapplied: anyRead('filtersUnapplied'),\n\t\tgoalsUnresolved: anyRead('goalsUnresolved'),\n\t\tsampled: anyRead('sampled'),\n\t\tpartial: anyRead('partial'),\n\t\tcapped: anyRead('capped'),\n\t\tfailed: anyRead('failed'),\n\t\ttimezoneUnresolved: anyRead('timezoneUnresolved'),\n\t\tvisitorsSummed: anyRead('visitorsSummed'),\n\t\tmixedCurrencies: [...currencies].sort(),\n\t\t...(asOf ? { asOf } : {}),\n\t\t...(currency ? {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,CACD;CACA,MAAM,SAAS,MAAM,QACnB,IAAI,SAAS,eAAe,IAAI,MAAM,MAAM,GAC7C,KAAA,CACD;CACA,MAAM,aAAa,IAAI,IAAI,MAAM,SAAS,SAAS,MAAM,mBAAmB,CAAC,CAAC,CAAC;CAC/E,MAAM,OAAO,MAAM,QACjB,IAAI,SAAS,eAAe,IAAI,MAAM,IAAI,GAC3C,KAAA,CACD;CACA,MAAM,WAAW,MAAM,MAAM,SAAS,MAAM,aAAa,KAAA,CAAS,GAAG;CACrE,OAAO;EACN,SAAS,QAAQ,SAAS;EAC1B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EAC/B,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,OAAO,QAAQ,OAAO;EACtB,aAAa,QAAQ,aAAa;EAClC,aAAa,QAAQ,aAAa;EAClC,kBAAkB,QAAQ,kBAAkB;EAC5C,iBAAiB,QAAQ,iBAAiB;EAC1C,SAAS,QAAQ,SAAS;EAC1B,SAAS,QAAQ,SAAS;EAC1B,QAAQ,QAAQ,QAAQ;EACxB,QAAQ,QAAQ,QAAQ;EACxB,oBAAoB,QAAQ,oBAAoB;EAChD,gBAAgB,QAAQ,gBAAgB;EACxC,iBAAiB,CAAC,GAAG,UAAU,EAAE,KAAK;EACtC,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EACvB,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAChC;AACD"}
1
+ {"version":3,"file":"readMeta.js","names":[],"sources":["../../src/widgets/readMeta.ts"],"sourcesContent":["import type { AnalyticsResult } from '../core/contract'\nimport { earlierInstant } from '../core/values'\n\n/** The caveats a read's numbers carry, which every surface showing them words the same way. */\nexport interface ReadNotices {\n\t/** The source read a shorter window than the one that was asked for. */\n\tclamped: boolean\n\t/** ISO instant the clamped data starts at, when later than the window's start. */\n\tdataFrom?: string\n\t/** ISO instant the clamped data ends at, when earlier than the window's end. */\n\tdataTo?: string\n\t/** The engine served an expired cache entry, while refreshing or after the refresh failed. */\n\tstale: boolean\n\t/** The saved numbers' source last failed with its settings refused: they need a look. */\n\tsourceError: boolean\n\t/** That source's host is one the install does not allow. */\n\thostRefused: boolean\n\t/** The source answered without one of the filters the read carried. */\n\tfiltersUnapplied: boolean\n\t/** The source could not read the scope's goals, so the goal numbers mean nothing. */\n\tgoalsUnresolved: boolean\n\t/** The source counted from a sample, so the numbers are estimates. */\n\tsampled: boolean\n\t/** Some days of the range are not counted yet, so the numbers are a floor. */\n\tpartial: boolean\n\t/** A value the read asks about was grouped into `(other)` on days whose raw hits are gone. */\n\tcapped: boolean\n\t/** Some days' counting was given up: they are left out or read from an earlier count. */\n\tfailed?: boolean\n\t/** The days were cut in UTC because the scope's zone could not be resolved. */\n\ttimezoneUnresolved: boolean\n\t/** The currencies revenue adds without converting them, when there is more than one. */\n\tmixedCurrencies: string[]\n\t/**\n\t * Some visitor number adds up each day's visitors (`meta.visitorsAre: 'sumOfDaily'`), so a\n\t * person who came on two days counts twice. Said by the metric's name and explained in a notice.\n\t */\n\tvisitorsSummed?: boolean\n\t/** The vendor drops the visits counted without consent, so they are missing from the numbers. */\n\twithoutConsentDropped?: boolean\n\t/** Pageviews recorded without a visitor, which count toward no visitor number; absent when none. */\n\twithoutVisitor?: number\n\t/** ISO instant the numbers were last brought up to date, set when a snapshot answered. */\n\tasOf?: string\n\t/** The ISO code the read's revenue is in, when the source or the install says. */\n\tcurrency?: string\n}\n\n/** The state flags every widget result carries, whatever shape its numbers take. */\nexport interface WidgetReadMeta extends ReadNotices {\n\t/** The source that answered. */\n\tprovider: string\n}\n\n/**\n * One mapping from an adapter result's meta to the flags a surface renders, so a flag cannot go\n * missing on one widget while its neighbour shows it.\n */\nexport const readMeta = (result: AnalyticsResult): WidgetReadMeta => ({\n\tclamped: result.meta.clamped ?? false,\n\t...(result.meta.clamped && result.meta.dataFrom ? { dataFrom: result.meta.dataFrom } : {}),\n\t...(result.meta.clamped && result.meta.dataTo ? { dataTo: result.meta.dataTo } : {}),\n\tstale: result.meta.stale ?? false,\n\tsourceError: result.meta.sourceError !== undefined,\n\thostRefused: result.meta.sourceError === 'host-refused',\n\tfiltersUnapplied: (result.meta.unappliedFilters?.length ?? 0) > 0,\n\tgoalsUnresolved: result.meta.goalsUnresolved === true,\n\tsampled: result.meta.sampled ?? false,\n\tpartial: (result.meta.partial?.missingDays ?? 0) > 0,\n\tcapped: (result.meta.capped?.days ?? 0) > 0,\n\tfailed: (result.meta.failed?.days ?? 0) > 0,\n\ttimezoneUnresolved: result.meta.timezoneUnresolved === true,\n\tvisitorsSummed: result.meta.visitorsAre === 'sumOfDaily',\n\twithoutConsentDropped: result.meta.withoutConsentDropped === true,\n\t...((result.meta.withoutVisitor?.pageviews ?? 0) > 0\n\t\t? { withoutVisitor: result.meta.withoutVisitor?.pageviews }\n\t\t: {}),\n\tmixedCurrencies:\n\t\t(result.meta.mixedCurrencies?.length ?? 0) > 1 ? [...(result.meta.mixedCurrencies ?? [])] : [],\n\t...(result.meta.asOf ? { asOf: result.meta.asOf } : {}),\n\t...(result.meta.currency ? { currency: result.meta.currency } : {}),\n\tprovider: result.meta.provider,\n})\n\n/**\n * Several reads behind one surface as one set of caveats: any read's flag is the surface's, the\n * currencies are every read's, and the oldest snapshot says how old the numbers are.\n */\nexport const mergeNotices = (\n\t...reads: ReadonlyArray<Partial<ReadNotices> | undefined>\n): ReadNotices => {\n\tconst anyRead = (\n\t\tflag: Exclude<\n\t\t\tkeyof ReadNotices,\n\t\t\t'mixedCurrencies' | 'asOf' | 'currency' | 'dataFrom' | 'dataTo' | 'withoutVisitor'\n\t\t>\n\t): boolean => reads.some((read) => read?.[flag] === true)\n\t// The narrowest window any read kept: the latest start, the earliest end.\n\tconst dataFrom = reads.reduce<string | undefined>(\n\t\t(at, read) =>\n\t\t\tread?.dataFrom !== undefined &&\n\t\t\t(at === undefined || Date.parse(read.dataFrom) > Date.parse(at))\n\t\t\t\t? read.dataFrom\n\t\t\t\t: at,\n\t\tundefined\n\t)\n\tconst dataTo = reads.reduce<string | undefined>(\n\t\t(at, read) => earlierInstant(at, read?.dataTo),\n\t\tundefined\n\t)\n\tconst currencies = new Set(reads.flatMap((read) => read?.mixedCurrencies ?? []))\n\tconst asOf = reads.reduce<string | undefined>(\n\t\t(at, read) => earlierInstant(at, read?.asOf),\n\t\tundefined\n\t)\n\tconst currency = reads.find((read) => read?.currency !== undefined)?.currency\n\t// The reads cover one range, so the widest count is the range's; adding them would double it.\n\tconst withoutVisitor = Math.max(0, ...reads.map((read) => read?.withoutVisitor ?? 0))\n\treturn {\n\t\tclamped: anyRead('clamped'),\n\t\t...(dataFrom ? { dataFrom } : {}),\n\t\t...(dataTo ? { dataTo } : {}),\n\t\tstale: anyRead('stale'),\n\t\tsourceError: anyRead('sourceError'),\n\t\thostRefused: anyRead('hostRefused'),\n\t\tfiltersUnapplied: anyRead('filtersUnapplied'),\n\t\tgoalsUnresolved: anyRead('goalsUnresolved'),\n\t\tsampled: anyRead('sampled'),\n\t\tpartial: anyRead('partial'),\n\t\tcapped: anyRead('capped'),\n\t\tfailed: anyRead('failed'),\n\t\ttimezoneUnresolved: anyRead('timezoneUnresolved'),\n\t\tvisitorsSummed: anyRead('visitorsSummed'),\n\t\twithoutConsentDropped: anyRead('withoutConsentDropped'),\n\t\t...(withoutVisitor > 0 ? { withoutVisitor } : {}),\n\t\tmixedCurrencies: [...currencies].sort(),\n\t\t...(asOf ? { asOf } : {}),\n\t\t...(currency ? { currency } : {}),\n\t}\n}\n"],"mappings":";;;;;;AA0DA,MAAa,YAAY,YAA6C;CACrE,SAAS,OAAO,KAAK,WAAW;CAChC,GAAI,OAAO,KAAK,WAAW,OAAO,KAAK,WAAW,EAAE,UAAU,OAAO,KAAK,SAAS,IAAI,CAAC;CACxF,GAAI,OAAO,KAAK,WAAW,OAAO,KAAK,SAAS,EAAE,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC;CAClF,OAAO,OAAO,KAAK,SAAS;CAC5B,aAAa,OAAO,KAAK,gBAA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ACjB,IAAI,SAAS,eAAe,IAAI,MAAM,IAAI,GAC3C,KAAA,CACD;CACA,MAAM,WAAW,MAAM,MAAM,SAAS,MAAM,aAAa,KAAA,CAAS,GAAG;CAErE,MAAM,iBAAiB,KAAK,IAAI,GAAG,GAAG,MAAM,KAAK,SAAS,MAAM,kBAAkB,CAAC,CAAC;CACpF,OAAO;EACN,SAAS,QAAQ,SAAS;EAC1B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EAC/B,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,OAAO,QAAQ,OAAO;EACtB,aAAa,QAAQ,aAAa;EAClC,aAAa,QAAQ,aAAa;EAClC,kBAAkB,QAAQ,kBAAkB;EAC5C,iBAAiB,QAAQ,iBAAiB;EAC1C,SAAS,QAAQ,SAAS;EAC1B,SAAS,QAAQ,SAAS;EAC1B,QAAQ,QAAQ,QAAQ;EACxB,QAAQ,QAAQ,QAAQ;EACxB,oBAAoB,QAAQ,oBAAoB;EAChD,gBAAgB,QAAQ,gBAAgB;EACxC,uBAAuB,QAAQ,uBAAuB;EACtD,GAAI,iBAAiB,IAAI,EAAE,eAAe,IAAI,CAAC;EAC/C,iBAAiB,CAAC,GAAG,UAAU,EAAE,KAAK;EACtC,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EACvB,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAChC;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10x-media/analytics",
3
- "version": "1.0.0-beta.14",
3
+ "version": "1.0.0-beta.16",
4
4
  "description": "Adapter-based analytics for Payload: providers, a native engine, dashboard widgets, and portable fields.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -176,10 +176,10 @@
176
176
  "tsdown": "0.22.1",
177
177
  "typescript": "5.9.3",
178
178
  "vitest": "4.1.7",
179
+ "@10x-media/fields": "0.1.0-beta.10",
179
180
  "@10x-media/form-builder": "0.1.0-beta.27",
180
- "@10x-media/tsconfig": "0.0.0",
181
181
  "@10x-media/payload-test-harness": "0.0.0",
182
- "@10x-media/fields": "0.1.0-beta.8",
182
+ "@10x-media/tsconfig": "0.0.0",
183
183
  "@10x-media/tsdown-config": "0.0.0",
184
184
  "@10x-media/vitest-config": "0.0.0"
185
185
  },