@ht-sdks/events-sdk-js-browser 1.0.4 → 1.1.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.
Files changed (123) hide show
  1. package/README.md +22 -22
  2. package/dist/cjs/browser/index.js +16 -16
  3. package/dist/cjs/browser/index.js.map +1 -1
  4. package/dist/cjs/browser/standalone-analytics.js +1 -1
  5. package/dist/cjs/browser/standalone-analytics.js.map +1 -1
  6. package/dist/cjs/core/analytics/index.js.map +1 -1
  7. package/dist/cjs/core/arguments-resolver/index.js.map +1 -1
  8. package/dist/cjs/core/buffer/index.js.map +1 -1
  9. package/dist/cjs/core/context/index.js.map +1 -1
  10. package/dist/cjs/core/events/index.js.map +1 -1
  11. package/dist/cjs/core/page/add-page-context.js.map +1 -1
  12. package/dist/cjs/generated/version.js +1 -1
  13. package/dist/cjs/lib/global-analytics-helper.js +1 -1
  14. package/dist/cjs/lib/global-analytics-helper.js.map +1 -1
  15. package/dist/cjs/lib/merged-options.js +1 -1
  16. package/dist/cjs/lib/parse-cdn.js +1 -1
  17. package/dist/cjs/lib/parse-cdn.js.map +1 -1
  18. package/dist/cjs/lib/to-facade.js.map +1 -1
  19. package/dist/cjs/plugins/ajs-destination/utils.js +1 -1
  20. package/dist/cjs/plugins/ajs-destination/utils.js.map +1 -1
  21. package/dist/cjs/plugins/analytics-node/index.js.map +1 -1
  22. package/dist/cjs/plugins/env-enrichment/index.js.map +1 -1
  23. package/dist/cjs/plugins/hightouchio/batched-dispatcher.js.map +1 -1
  24. package/dist/cjs/plugins/legacy-video-plugins/index.js +4 -4
  25. package/dist/cjs/plugins/legacy-video-plugins/index.js.map +1 -1
  26. package/dist/cjs/plugins/middleware/index.js.map +1 -1
  27. package/dist/pkg/browser/index.js +15 -15
  28. package/dist/pkg/browser/index.js.map +1 -1
  29. package/dist/pkg/browser/standalone-analytics.js +2 -2
  30. package/dist/pkg/browser/standalone-analytics.js.map +1 -1
  31. package/dist/pkg/core/analytics/index.js.map +1 -1
  32. package/dist/pkg/core/arguments-resolver/index.js.map +1 -1
  33. package/dist/pkg/core/buffer/index.js.map +1 -1
  34. package/dist/pkg/core/context/index.js.map +1 -1
  35. package/dist/pkg/core/events/index.js.map +1 -1
  36. package/dist/pkg/core/page/add-page-context.js.map +1 -1
  37. package/dist/pkg/generated/version.js +1 -1
  38. package/dist/pkg/lib/global-analytics-helper.js +1 -1
  39. package/dist/pkg/lib/global-analytics-helper.js.map +1 -1
  40. package/dist/pkg/lib/merged-options.js +1 -1
  41. package/dist/pkg/lib/parse-cdn.js +1 -1
  42. package/dist/pkg/lib/parse-cdn.js.map +1 -1
  43. package/dist/pkg/lib/to-facade.js.map +1 -1
  44. package/dist/pkg/plugins/ajs-destination/utils.js +1 -1
  45. package/dist/pkg/plugins/ajs-destination/utils.js.map +1 -1
  46. package/dist/pkg/plugins/analytics-node/index.js.map +1 -1
  47. package/dist/pkg/plugins/env-enrichment/index.js.map +1 -1
  48. package/dist/pkg/plugins/hightouchio/batched-dispatcher.js.map +1 -1
  49. package/dist/pkg/plugins/legacy-video-plugins/index.js +6 -6
  50. package/dist/pkg/plugins/legacy-video-plugins/index.js.map +1 -1
  51. package/dist/pkg/plugins/middleware/index.js.map +1 -1
  52. package/dist/types/browser/index.d.ts +12 -12
  53. package/dist/types/browser/index.d.ts.map +1 -1
  54. package/dist/types/browser/standalone-interface.d.ts +1 -1
  55. package/dist/types/browser/standalone-interface.d.ts.map +1 -1
  56. package/dist/types/core/analytics/index.d.ts +3 -3
  57. package/dist/types/core/analytics/index.d.ts.map +1 -1
  58. package/dist/types/core/analytics/interfaces.d.ts +5 -5
  59. package/dist/types/core/analytics/interfaces.d.ts.map +1 -1
  60. package/dist/types/core/arguments-resolver/index.d.ts +2 -2
  61. package/dist/types/core/arguments-resolver/index.d.ts.map +1 -1
  62. package/dist/types/core/buffer/index.d.ts +10 -10
  63. package/dist/types/core/buffer/index.d.ts.map +1 -1
  64. package/dist/types/core/context/index.d.ts +3 -3
  65. package/dist/types/core/context/index.d.ts.map +1 -1
  66. package/dist/types/core/events/index.d.ts +8 -8
  67. package/dist/types/core/events/index.d.ts.map +1 -1
  68. package/dist/types/core/events/interfaces.d.ts +2 -2
  69. package/dist/types/core/events/interfaces.d.ts.map +1 -1
  70. package/dist/types/core/page/add-page-context.d.ts +2 -2
  71. package/dist/types/core/page/add-page-context.d.ts.map +1 -1
  72. package/dist/types/core/page/get-page-context.d.ts +1 -1
  73. package/dist/types/core/stats/remote-metrics.d.ts +1 -1
  74. package/dist/types/generated/version.d.ts +1 -1
  75. package/dist/types/index.d.ts +1 -1
  76. package/dist/types/index.d.ts.map +1 -1
  77. package/dist/types/lib/global-analytics-helper.d.ts +4 -4
  78. package/dist/types/lib/global-analytics-helper.d.ts.map +1 -1
  79. package/dist/types/lib/merged-options.d.ts +1 -1
  80. package/dist/types/lib/to-facade.d.ts +4 -4
  81. package/dist/types/lib/to-facade.d.ts.map +1 -1
  82. package/dist/types/plugins/analytics-node/index.d.ts +2 -2
  83. package/dist/types/plugins/analytics-node/index.d.ts.map +1 -1
  84. package/dist/types/plugins/legacy-video-plugins/index.d.ts +1 -1
  85. package/dist/types/plugins/legacy-video-plugins/index.d.ts.map +1 -1
  86. package/dist/types/plugins/middleware/index.d.ts +4 -4
  87. package/dist/types/plugins/middleware/index.d.ts.map +1 -1
  88. package/dist/umd/{ajs-destination.bundle.5a985a542b0de08e3e49.js → ajs-destination.bundle.48266e86bbbc2531ac42.js} +2 -2
  89. package/dist/umd/{ajs-destination.bundle.5a985a542b0de08e3e49.js.map → ajs-destination.bundle.48266e86bbbc2531ac42.js.map} +1 -1
  90. package/dist/umd/events.min.js +1 -1
  91. package/dist/umd/events.min.js.map +1 -1
  92. package/dist/umd/index.js +1 -1
  93. package/dist/umd/index.js.map +1 -1
  94. package/dist/umd/legacyVideos.bundle.6250709892bb05b68333.js.map +1 -1
  95. package/package.json +2 -2
  96. package/src/browser/index.ts +20 -20
  97. package/src/browser/standalone-analytics.ts +3 -3
  98. package/src/browser/standalone-interface.ts +1 -1
  99. package/src/core/analytics/index.ts +4 -4
  100. package/src/core/analytics/interfaces.ts +5 -5
  101. package/src/core/arguments-resolver/index.ts +2 -2
  102. package/src/core/buffer/index.ts +4 -4
  103. package/src/core/context/index.ts +3 -3
  104. package/src/core/events/index.ts +22 -19
  105. package/src/core/events/interfaces.ts +2 -2
  106. package/src/core/page/add-page-context.ts +2 -2
  107. package/src/core/page/get-page-context.ts +1 -1
  108. package/src/core/stats/remote-metrics.ts +1 -1
  109. package/src/generated/version.ts +1 -1
  110. package/src/index.ts +1 -1
  111. package/src/lib/global-analytics-helper.ts +4 -4
  112. package/src/lib/merged-options.ts +1 -1
  113. package/src/lib/parse-cdn.ts +1 -1
  114. package/src/lib/to-facade.ts +7 -4
  115. package/src/plugins/ajs-destination/types.ts +1 -1
  116. package/src/plugins/ajs-destination/utils.ts +1 -1
  117. package/src/plugins/analytics-node/index.ts +3 -3
  118. package/src/plugins/env-enrichment/index.ts +2 -2
  119. package/src/plugins/hightouchio/batched-dispatcher.ts +3 -3
  120. package/src/plugins/legacy-video-plugins/index.ts +4 -4
  121. package/src/plugins/middleware/index.ts +10 -10
  122. package/src/test-helpers/fixtures/cdn-settings.ts +2 -2
  123. package/src/test-helpers/test-writekeys.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"legacyVideos.bundle.6250709892bb05b68333.js","mappings":"+NAEO,SAAeA,EACpBC,G,2BACCC,SAAO,W,8DACQ,SAAM,oC,cAAhBC,EAAU,SAShBF,EAAUG,SAAWD,E","sources":["webpack://@ht-sdks/events-sdk-js-browser/./src/plugins/legacy-video-plugins/index.ts"],"sourcesContent":["import { Analytics } from '../../core/analytics'\n\nexport async function loadLegacyVideoPlugins(\n analytics: Analytics\n): Promise<void> {\n const plugins = await import(\n // @ts-expect-error\n '@segment/analytics.js-video-plugins/dist/index.umd.js'\n )\n\n // This is super gross, but we need to support the `window.analytics.plugins` namespace\n // that is linked in the segment docs in order to be backwards compatible with ajs-classic\n\n // @ts-expect-error\n analytics._plugins = plugins\n}\n"],"names":["loadLegacyVideoPlugins","analytics","Promise","plugins","_plugins"],"sourceRoot":""}
1
+ {"version":3,"file":"legacyVideos.bundle.6250709892bb05b68333.js","mappings":"+NAEO,SAAeA,EACpBC,G,2BACCC,SAAO,W,8DACQ,SAAM,oC,cAAhBC,EAAU,SAShBF,EAASG,SAAWD,E","sources":["webpack://@ht-sdks/events-sdk-js-browser/./src/plugins/legacy-video-plugins/index.ts"],"sourcesContent":["import { Analytics } from '../../core/analytics'\n\nexport async function loadLegacyVideoPlugins(\n htevents: Analytics\n): Promise<void> {\n const plugins = await import(\n // @ts-expect-error\n '@segment/analytics.js-video-plugins/dist/index.umd.js'\n )\n\n // This is super gross, but we need to support the `window.htevents.plugins` namespace\n // that is linked in the hightouch docs in order to be backwards compatible with ajs-classic\n\n // @ts-expect-error\n htevents._plugins = plugins\n}\n"],"names":["loadLegacyVideoPlugins","htevents","Promise","plugins","_plugins"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ht-sdks/events-sdk-js-browser",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ht-sdks/events-sdk-js-mono",
@@ -49,7 +49,7 @@
49
49
  }
50
50
  ],
51
51
  "dependencies": {
52
- "@ht-sdks/events-sdk-js-core": "^1.0.0",
52
+ "@ht-sdks/events-sdk-js-core": "^1.1.0",
53
53
  "@lukeed/uuid": "^2.0.0",
54
54
  "@segment/analytics.js-video-plugins": "^0.2.1",
55
55
  "@segment/facade": "^3.4.9",
@@ -53,7 +53,7 @@ export interface LegacyIntegrationConfiguration {
53
53
  categories: string[]
54
54
  }
55
55
 
56
- // Segment.io specific
56
+ // Hightouch.io specific
57
57
  retryQueue?: boolean
58
58
 
59
59
  // any extra unknown settings
@@ -92,15 +92,15 @@ export interface LegacySettings {
92
92
  }
93
93
  }
94
94
 
95
- export interface AnalyticsBrowserSettings extends AnalyticsSettings {
95
+ export interface HtEventsBrowserSettings extends AnalyticsSettings {
96
96
  /**
97
- * The settings for the Segment Source.
98
- * If provided, `AnalyticsBrowser` will not fetch remote settings
97
+ * The settings for the Hightouch Source.
98
+ * If provided, `HtEventsBrowser` will not fetch remote settings
99
99
  * for the source.
100
100
  */
101
101
  cdnSettings?: LegacySettings & Record<string, unknown>
102
102
  /**
103
- * If provided, will override the default Segment CDN (https://cdn.hightouch-events.com) for this application.
103
+ * If provided, will override the default Hightouch CDN (https://cdn.hightouch-events.com) for this application.
104
104
  */
105
105
  cdnURL?: string
106
106
  }
@@ -321,7 +321,7 @@ const defaultSettings: LegacySettings = {
321
321
  }
322
322
 
323
323
  async function loadAnalytics(
324
- settings: AnalyticsBrowserSettings,
324
+ settings: HtEventsBrowserSettings,
325
325
  options: InitOptions = {},
326
326
  preInitBuffer: PreInitMethodCallBuffer
327
327
  ): Promise<[Analytics, Context]> {
@@ -406,24 +406,24 @@ async function loadAnalytics(
406
406
  }
407
407
 
408
408
  /**
409
- * The public browser interface for Segment Analytics
409
+ * The public browser interface for Hightouch Events
410
410
  *
411
411
  * @example
412
412
  * ```ts
413
- * export const analytics = new AnalyticsBrowser()
414
- * analytics.load({ writeKey: 'foo' })
413
+ * export const htevents = new HtEventsBrowser()
414
+ * htevents.load({ writeKey: 'foo' })
415
415
  * ```
416
416
  * @link https://github.com/ht-sdks/events-sdk-js-mono/tree/master/packages/browser#readme
417
417
  */
418
- export class AnalyticsBrowser extends AnalyticsBuffered {
418
+ export class HtEventsBrowser extends AnalyticsBuffered {
419
419
  private _resolveLoadStart: (
420
- settings: AnalyticsBrowserSettings,
420
+ settings: HtEventsBrowserSettings,
421
421
  options: InitOptions
422
422
  ) => void
423
423
 
424
424
  constructor() {
425
425
  const { promise: loadStart, resolve: resolveLoadStart } =
426
- createDeferred<Parameters<AnalyticsBrowser['load']>>()
426
+ createDeferred<Parameters<HtEventsBrowser['load']>>()
427
427
 
428
428
  super((buffer) =>
429
429
  loadStart.then(([settings, options]) =>
@@ -447,14 +447,14 @@ export class AnalyticsBrowser extends AnalyticsBuffered {
447
447
  *
448
448
  * @example
449
449
  * ```ts
450
- * export const analytics = new AnalyticsBrowser()
450
+ * export const analytics = new HtEventsBrowser()
451
451
  * analytics.load({ writeKey: 'foo' })
452
452
  * ```
453
453
  */
454
454
  load(
455
- settings: AnalyticsBrowserSettings,
455
+ settings: HtEventsBrowserSettings,
456
456
  options: InitOptions = {}
457
- ): AnalyticsBrowser {
457
+ ): HtEventsBrowser {
458
458
  this._resolveLoadStart(settings, options)
459
459
  return this
460
460
  }
@@ -464,23 +464,23 @@ export class AnalyticsBrowser extends AnalyticsBuffered {
464
464
  *
465
465
  * @example
466
466
  * ```ts
467
- * const ajs = AnalyticsBrowser.load({ writeKey: '<YOUR_WRITE_KEY>' })
467
+ * const ajs = HtEventsBrowser.load({ writeKey: '<YOUR_WRITE_KEY>' })
468
468
  *
469
469
  * ajs.track("foo")
470
470
  * ...
471
471
  * ```
472
472
  */
473
473
  static load(
474
- settings: AnalyticsBrowserSettings,
474
+ settings: HtEventsBrowserSettings,
475
475
  options: InitOptions = {}
476
- ): AnalyticsBrowser {
477
- return new AnalyticsBrowser().load(settings, options)
476
+ ): HtEventsBrowser {
477
+ return new HtEventsBrowser().load(settings, options)
478
478
  }
479
479
 
480
480
  static standalone(
481
481
  writeKey: string,
482
482
  options?: InitOptions
483
483
  ): Promise<Analytics> {
484
- return AnalyticsBrowser.load({ writeKey }, options).then((res) => res[0])
484
+ return HtEventsBrowser.load({ writeKey }, options).then((res) => res[0])
485
485
  }
486
486
  }
@@ -1,6 +1,6 @@
1
- import { AnalyticsBrowser } from '.'
1
+ import { HtEventsBrowser } from '.'
2
2
  import { embeddedWriteKey } from '../lib/embedded-write-key'
3
- import { AnalyticsSnippet } from './standalone-interface'
3
+ import { HtEventsSnippet } from './standalone-interface'
4
4
  import {
5
5
  getGlobalAnalytics,
6
6
  setGlobalAnalytics,
@@ -57,6 +57,6 @@ export async function install(): Promise<void> {
57
57
  }
58
58
 
59
59
  setGlobalAnalytics(
60
- (await AnalyticsBrowser.standalone(writeKey, options)) as AnalyticsSnippet
60
+ (await HtEventsBrowser.standalone(writeKey, options)) as HtEventsSnippet
61
61
  )
62
62
  }
@@ -1,6 +1,6 @@
1
1
  import { Analytics, InitOptions } from '../core/analytics'
2
2
 
3
- export interface AnalyticsSnippet extends AnalyticsStandalone {
3
+ export interface HtEventsSnippet extends AnalyticsStandalone {
4
4
  load: (writeKey: string, options?: InitOptions) => void
5
5
  }
6
6
 
@@ -20,7 +20,7 @@ import {
20
20
  Integrations,
21
21
  Plan,
22
22
  EventProperties,
23
- SegmentEvent,
23
+ HightouchEvent,
24
24
  } from '../events'
25
25
  import type { Plugin } from '../plugin'
26
26
  import { EventQueue } from '../queue/event-queue'
@@ -124,7 +124,7 @@ export interface InitOptions {
124
124
  */
125
125
  highEntropyValuesClientHints?: HighEntropyHint[]
126
126
  /**
127
- * When using the snippet, this is the key that points to the global analytics instance (e.g. window.analytics).
127
+ * When using the snippet, this is the key that points to the global analytics instance (e.g. window.htevents).
128
128
  * default: analytics
129
129
  */
130
130
  globalAnalyticsKey?: string
@@ -481,7 +481,7 @@ export class Analytics
481
481
  }
482
482
 
483
483
  private async _dispatch(
484
- event: SegmentEvent,
484
+ event: HightouchEvent,
485
485
  callback?: Callback
486
486
  ): Promise<DispatchedEvent> {
487
487
  const ctx = new Context(event)
@@ -577,7 +577,7 @@ export class Analytics
577
577
  return this
578
578
  }
579
579
 
580
- normalize(msg: SegmentEvent): SegmentEvent {
580
+ normalize(msg: HightouchEvent): HightouchEvent {
581
581
  console.warn(deprecationWarning)
582
582
  return this.eventFactory.normalize(msg)
583
583
  }
@@ -9,7 +9,7 @@ import type {
9
9
  GroupParams,
10
10
  } from '../arguments-resolver'
11
11
  import type { Context } from '../context'
12
- import type { SegmentEvent } from '../events'
12
+ import type { HightouchEvent } from '../events'
13
13
  import type { Group, User } from '../user'
14
14
  import type { LegacyIntegration } from '../../plugins/ajs-destination/types'
15
15
  import { CoreAnalytics } from '@ht-sdks/events-sdk-js-core'
@@ -58,7 +58,7 @@ export interface AnalyticsClassic extends AnalyticsClassicStubs {
58
58
  noConflict(): Analytics
59
59
 
60
60
  /** @deprecated */
61
- normalize(msg: SegmentEvent): SegmentEvent
61
+ normalize(msg: HightouchEvent): HightouchEvent
62
62
 
63
63
  /** @deprecated */
64
64
  readonly failedInitializations: string[]
@@ -74,7 +74,7 @@ export interface AnalyticsClassic extends AnalyticsClassicStubs {
74
74
  }
75
75
 
76
76
  /**
77
- * Interface implemented by concrete Analytics class (commonly accessible if you use "await" on AnalyticsBrowser.load())
77
+ * Interface implemented by concrete Analytics class (commonly accessible if you use "await" on HtEventsBrowser.load())
78
78
  */
79
79
  export interface AnalyticsCore extends CoreAnalytics {
80
80
  track(...args: EventParams): Promise<DispatchedEvent>
@@ -91,9 +91,9 @@ export interface AnalyticsCore extends CoreAnalytics {
91
91
  }
92
92
 
93
93
  /**
94
- * Interface implemented by AnalyticsBrowser (buffered version of analytics) (commonly accessible through AnalyticsBrowser.load())
94
+ * Interface implemented by HtEventsBrowser (buffered version of analytics) (commonly accessible through HtEventsBrowser.load())
95
95
  */
96
- export type AnalyticsBrowserCore = Omit<AnalyticsCore, 'group' | 'user'> & {
96
+ export type HtEventsBrowserCore = Omit<AnalyticsCore, 'group' | 'user'> & {
97
97
  group(): Promise<Group>
98
98
  group(...args: GroupParams): Promise<DispatchedEvent>
99
99
  user(): Promise<User>
@@ -10,7 +10,7 @@ import {
10
10
  JSONObject,
11
11
  Options,
12
12
  EventProperties,
13
- SegmentEvent,
13
+ HightouchEvent,
14
14
  Traits,
15
15
  GroupTraits,
16
16
  UserTraits,
@@ -21,7 +21,7 @@ import { ID, User } from '../user'
21
21
  * Helper for the track method
22
22
  */
23
23
  export function resolveArguments(
24
- eventName: string | SegmentEvent,
24
+ eventName: string | HightouchEvent,
25
25
  properties?: EventProperties | Callback,
26
26
  options?: Options | Callback,
27
27
  callback?: Callback
@@ -1,7 +1,7 @@
1
1
  import { Analytics } from '../analytics'
2
2
  import { Context } from '../context'
3
3
  import { isThenable } from '../../lib/is-thenable'
4
- import { AnalyticsBrowserCore } from '../analytics/interfaces'
4
+ import { HtEventsBrowserCore } from '../analytics/interfaces'
5
5
  import { version } from '../../generated/version'
6
6
  import { getGlobalAnalytics } from '../../lib/global-analytics-helper'
7
7
  import {
@@ -13,7 +13,7 @@ import {
13
13
  } from '../page'
14
14
 
15
15
  /**
16
- * The names of any AnalyticsBrowser methods that also exist on Analytics
16
+ * The names of any HtEventsBrowser methods that also exist on Analytics
17
17
  */
18
18
  export type PreInitMethodName =
19
19
  | 'screen'
@@ -264,7 +264,7 @@ export type AnalyticsLoader = (
264
264
  ) => Promise<[Analytics, Context]>
265
265
 
266
266
  export class AnalyticsBuffered
267
- implements PromiseLike<[Analytics, Context]>, AnalyticsBrowserCore
267
+ implements PromiseLike<[Analytics, Context]>, HtEventsBrowserCore
268
268
  {
269
269
  instance?: Analytics
270
270
  ctx?: Context
@@ -317,7 +317,7 @@ export class AnalyticsBuffered
317
317
  pageView = this._createMethod('pageview')
318
318
  identify = this._createMethod('identify')
319
319
  reset = this._createMethod('reset')
320
- group = this._createMethod('group') as AnalyticsBrowserCore['group']
320
+ group = this._createMethod('group') as HtEventsBrowserCore['group']
321
321
  track = this._createMethod('track')
322
322
  ready = this._createMethod('ready')
323
323
  alias = this._createMethod('alias')
@@ -5,14 +5,14 @@ import {
5
5
  SerializedContext,
6
6
  CancelationOptions,
7
7
  } from '@ht-sdks/events-sdk-js-core'
8
- import { SegmentEvent } from '../events/interfaces'
8
+ import { HightouchEvent } from '../events/interfaces'
9
9
  import { Stats } from '../stats'
10
10
 
11
- export class Context extends CoreContext<SegmentEvent> {
11
+ export class Context extends CoreContext<HightouchEvent> {
12
12
  static override system() {
13
13
  return new this({ type: 'track', event: 'system' })
14
14
  }
15
- constructor(event: SegmentEvent, id?: string) {
15
+ constructor(event: HightouchEvent, id?: string) {
16
16
  super(event, id, new Stats())
17
17
  }
18
18
  }
@@ -6,7 +6,7 @@ import {
6
6
  Integrations,
7
7
  EventProperties,
8
8
  Traits,
9
- SegmentEvent,
9
+ HightouchEvent,
10
10
  } from './interfaces'
11
11
  import md5 from 'spark-md5'
12
12
  import { addPageContext, PageContext } from '../page'
@@ -22,7 +22,7 @@ export class EventFactory {
22
22
  options?: Options,
23
23
  globalIntegrations?: Integrations,
24
24
  pageCtx?: PageContext
25
- ): SegmentEvent {
25
+ ): HightouchEvent {
26
26
  return this.normalize(
27
27
  {
28
28
  ...this.baseEvent(),
@@ -43,8 +43,8 @@ export class EventFactory {
43
43
  options?: Options,
44
44
  globalIntegrations?: Integrations,
45
45
  pageCtx?: PageContext
46
- ): SegmentEvent {
47
- const event: Partial<SegmentEvent> = {
46
+ ): HightouchEvent {
47
+ const event: Partial<HightouchEvent> = {
48
48
  type: 'page' as const,
49
49
  properties: { ...properties },
50
50
  options: { ...options },
@@ -65,7 +65,7 @@ export class EventFactory {
65
65
  {
66
66
  ...this.baseEvent(),
67
67
  ...event,
68
- } as SegmentEvent,
68
+ } as HightouchEvent,
69
69
  pageCtx
70
70
  )
71
71
  }
@@ -77,8 +77,8 @@ export class EventFactory {
77
77
  options?: Options,
78
78
  globalIntegrations?: Integrations,
79
79
  pageCtx?: PageContext
80
- ): SegmentEvent {
81
- const event: Partial<SegmentEvent> = {
80
+ ): HightouchEvent {
81
+ const event: Partial<HightouchEvent> = {
82
82
  type: 'screen' as const,
83
83
  properties: { ...properties },
84
84
  options: { ...options },
@@ -96,7 +96,7 @@ export class EventFactory {
96
96
  {
97
97
  ...this.baseEvent(),
98
98
  ...event,
99
- } as SegmentEvent,
99
+ } as HightouchEvent,
100
100
  pageCtx
101
101
  )
102
102
  }
@@ -107,7 +107,7 @@ export class EventFactory {
107
107
  options?: Options,
108
108
  globalIntegrations?: Integrations,
109
109
  pageCtx?: PageContext
110
- ): SegmentEvent {
110
+ ): HightouchEvent {
111
111
  return this.normalize(
112
112
  {
113
113
  ...this.baseEvent(),
@@ -127,7 +127,7 @@ export class EventFactory {
127
127
  options?: Options,
128
128
  globalIntegrations?: Integrations,
129
129
  pageCtx?: PageContext
130
- ): SegmentEvent {
130
+ ): HightouchEvent {
131
131
  return this.normalize(
132
132
  {
133
133
  ...this.baseEvent(),
@@ -147,8 +147,8 @@ export class EventFactory {
147
147
  options?: Options,
148
148
  globalIntegrations?: Integrations,
149
149
  pageCtx?: PageContext
150
- ): SegmentEvent {
151
- const base: Partial<SegmentEvent> = {
150
+ ): HightouchEvent {
151
+ const base: Partial<HightouchEvent> = {
152
152
  userId: to,
153
153
  type: 'alias' as const,
154
154
  options: { ...options },
@@ -163,20 +163,20 @@ export class EventFactory {
163
163
  return this.normalize({
164
164
  ...base,
165
165
  ...this.baseEvent(),
166
- } as SegmentEvent)
166
+ } as HightouchEvent)
167
167
  }
168
168
 
169
169
  return this.normalize(
170
170
  {
171
171
  ...this.baseEvent(),
172
172
  ...base,
173
- } as SegmentEvent,
173
+ } as HightouchEvent,
174
174
  pageCtx
175
175
  )
176
176
  }
177
177
 
178
- private baseEvent(): Partial<SegmentEvent> {
179
- const base: Partial<SegmentEvent> = {
178
+ private baseEvent(): Partial<HightouchEvent> {
179
+ const base: Partial<HightouchEvent> = {
180
180
  integrations: {},
181
181
  options: {},
182
182
  }
@@ -198,7 +198,7 @@ export class EventFactory {
198
198
  * Builds the context part of an event based on "foreign" keys that
199
199
  * are provided in the `Options` parameter for an Event
200
200
  */
201
- private context(event: SegmentEvent): [object, object] {
201
+ private context(event: HightouchEvent): [object, object] {
202
202
  const optionsKeys = ['integrations', 'anonymousId', 'timestamp', 'userId']
203
203
 
204
204
  const options = event.options ?? {}
@@ -224,7 +224,10 @@ export class EventFactory {
224
224
  return [context, overrides]
225
225
  }
226
226
 
227
- public normalize(event: SegmentEvent, pageCtx?: PageContext): SegmentEvent {
227
+ public normalize(
228
+ event: HightouchEvent,
229
+ pageCtx?: PageContext
230
+ ): HightouchEvent {
228
231
  // set anonymousId globally if we encounter an override
229
232
  event.options?.anonymousId &&
230
233
  this.user.anonymousId(event.options.anonymousId)
@@ -254,7 +257,7 @@ export class EventFactory {
254
257
  const [context, overrides] = this.context(event)
255
258
  const { options, ...rest } = event
256
259
 
257
- const newEvent: SegmentEvent = {
260
+ const newEvent: HightouchEvent = {
258
261
  timestamp: new Date(),
259
262
  ...rest,
260
263
  context,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CoreOptions,
3
- CoreSegmentEvent,
3
+ CoreHightouchEvent,
4
4
  Callback,
5
5
  Integrations,
6
6
  Plan,
@@ -21,7 +21,7 @@ export type { GroupTraits, UserTraits, Traits }
21
21
 
22
22
  export type EventProperties = Record<string, any>
23
23
 
24
- export interface SegmentEvent extends CoreSegmentEvent {}
24
+ export interface HightouchEvent extends CoreHightouchEvent {}
25
25
 
26
26
  export type {
27
27
  Integrations,
@@ -1,5 +1,5 @@
1
1
  import { pick } from '../../lib/pick'
2
- import { EventProperties, SegmentEvent } from '../events'
2
+ import { EventProperties, HightouchEvent } from '../events'
3
3
  import { getDefaultPageContext } from './get-page-context'
4
4
 
5
5
  /**
@@ -9,7 +9,7 @@ import { getDefaultPageContext } from './get-page-context'
9
9
  * We prefer not to add this information to this function, as it increases the main bundle size.
10
10
  */
11
11
  export const addPageContext = (
12
- event: SegmentEvent,
12
+ event: HightouchEvent,
13
13
  pageCtx = getDefaultPageContext()
14
14
  ): void => {
15
15
  const evtCtx = event.context! // Context should be set earlier in the flow
@@ -1,7 +1,7 @@
1
1
  import { isPlainObject } from '@ht-sdks/events-sdk-js-core'
2
2
 
3
3
  /**
4
- * Final Page Context object expected in the Segment Event context
4
+ * Final Page Context object expected in the Hightouch Event context
5
5
  */
6
6
  export interface PageContext {
7
7
  path: string
@@ -11,7 +11,7 @@ export interface MetricsOptions {
11
11
  }
12
12
 
13
13
  /**
14
- * Type expected by the segment metrics API endpoint
14
+ * Type expected by the hightouch metrics API endpoint
15
15
  */
16
16
  type RemoteMetric = {
17
17
  type: 'Counter'
@@ -1,2 +1,2 @@
1
1
  // This file is generated.
2
- export const version = '1.0.4'
2
+ export const version = '1.1.0'
package/src/index.ts CHANGED
@@ -7,7 +7,7 @@ export * from './core/events'
7
7
  export * from './core/plugin'
8
8
  export * from './core/user'
9
9
 
10
- export type { AnalyticsSnippet } from './browser/standalone-interface'
10
+ export type { HtEventsSnippet } from './browser/standalone-interface'
11
11
  export type { MiddlewareFunction } from './plugins/middleware'
12
12
  export { getGlobalAnalytics } from './lib/global-analytics-helper'
13
13
  export { UniversalStorage, Store, StorageObject } from './core/storage'
@@ -1,4 +1,4 @@
1
- import { AnalyticsSnippet } from '../browser/standalone-interface'
1
+ import { HtEventsSnippet } from '../browser/standalone-interface'
2
2
 
3
3
  /**
4
4
  * Stores the global window analytics key
@@ -8,9 +8,9 @@ let _globalAnalyticsKey = 'htevents'
8
8
  /**
9
9
  * Gets the global analytics/buffer
10
10
  * @param key name of the window property where the buffer is stored (default: analytics)
11
- * @returns AnalyticsSnippet
11
+ * @returns HtEventsSnippet
12
12
  */
13
- export function getGlobalAnalytics(): AnalyticsSnippet | undefined {
13
+ export function getGlobalAnalytics(): HtEventsSnippet | undefined {
14
14
  return (window as any)[_globalAnalyticsKey]
15
15
  }
16
16
 
@@ -26,6 +26,6 @@ export function setGlobalAnalyticsKey(key: string) {
26
26
  * Sets the global analytics object
27
27
  * @param analytics analytics snippet
28
28
  */
29
- export function setGlobalAnalytics(analytics: AnalyticsSnippet): void {
29
+ export function setGlobalAnalytics(analytics: HtEventsSnippet): void {
30
30
  ;(window as any)[_globalAnalyticsKey] = analytics
31
31
  }
@@ -5,7 +5,7 @@ import { LegacySettings } from '../browser'
5
5
  * Merge legacy settings and initialized Integration option overrides.
6
6
  *
7
7
  * This will merge any options that were passed from initialization into
8
- * overrides for settings that are returned by the Segment CDN.
8
+ * overrides for settings that are returned by the Hightouch CDN.
9
9
  *
10
10
  * i.e. this allows for passing options directly into destinations from
11
11
  * the Analytics constructor.
@@ -45,7 +45,7 @@ export const getCDN = (): string => {
45
45
  // it's possible that the CDN is not found in the page because:
46
46
  // - the script is loaded through a proxy
47
47
  // - the script is removed after execution
48
- // in this case, we fall back to the default Segment CDN
48
+ // in this case, we fall back to the default Hightouch CDN
49
49
  return `https://cdn.hightouch-events.com`
50
50
  }
51
51
  }
@@ -8,13 +8,16 @@ import {
8
8
  Screen,
9
9
  Track,
10
10
  } from '@segment/facade'
11
- import { SegmentEvent } from '../core/events'
11
+ import { HightouchEvent } from '../core/events'
12
12
 
13
- export type SegmentFacade = Facade<SegmentEvent> & {
14
- obj: SegmentEvent
13
+ export type SegmentFacade = Facade<HightouchEvent> & {
14
+ obj: HightouchEvent
15
15
  }
16
16
 
17
- export function toFacade(evt: SegmentEvent, options?: Options): SegmentFacade {
17
+ export function toFacade(
18
+ evt: HightouchEvent,
19
+ options?: Options
20
+ ): SegmentFacade {
18
21
  let fcd = new Facade(evt, options)
19
22
 
20
23
  if (evt.type === 'track') {
@@ -18,7 +18,7 @@ export interface LegacyIntegration extends Emitter {
18
18
  alias?: (event: Alias) => void | Promise<void>
19
19
  group?: (event: Group) => void | Promise<void>
20
20
 
21
- // Segment.io specific
21
+ // Hightouch.io specific
22
22
  ontrack?: (event: Track) => void | Promise<void>
23
23
  onidentify?: (event: Identify) => void | Promise<void>
24
24
  onpage?: (event: Page) => void | Promise<void>
@@ -15,7 +15,7 @@ export const isInstallableIntegration = (
15
15
  // checking for iterable is a quick fix we need in place to prevent
16
16
  // errors showing Iterable as a failed destiantion. Ideally, we should
17
17
  // fix the Iterable metadata instead, but that's a longer process.
18
- return !name.startsWith('Segment') && name !== 'Iterable' && deviceMode
18
+ return !name.startsWith('Hightouch') && name !== 'Iterable' && deviceMode
19
19
  }
20
20
 
21
21
  export const isDisabledIntegration = (
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from '../../core/plugin'
2
2
  import { Context } from '../../core/context'
3
- import { SegmentEvent } from '../../core/events'
3
+ import { HightouchEvent } from '../../core/events'
4
4
  import fetch from 'node-fetch'
5
5
  import { version } from '../../generated/version'
6
6
 
@@ -14,9 +14,9 @@ interface AnalyticsNodeSettings {
14
14
  const btoa = (val: string): string => Buffer.from(val).toString('base64')
15
15
 
16
16
  export async function post(
17
- event: SegmentEvent,
17
+ event: HightouchEvent,
18
18
  writeKey: string
19
- ): Promise<SegmentEvent> {
19
+ ): Promise<HightouchEvent> {
20
20
  const res = await fetch(
21
21
  `https://us-east-1.hightouch-events.com/v1/${event.type}`,
22
22
  {
@@ -2,7 +2,7 @@ import jar from 'js-cookie'
2
2
  import type { Context } from '../../core/context'
3
3
  import type { Plugin } from '../../core/plugin'
4
4
  import { version } from '../../generated/version'
5
- import { SegmentEvent } from '../../core/events'
5
+ import { HightouchEvent } from '../../core/events'
6
6
  import { Campaign, PluginType } from '@ht-sdks/events-sdk-js-core'
7
7
  import { getVersionType } from '../../lib/version-type'
8
8
  import { tld } from '../../core/user/tld'
@@ -84,7 +84,7 @@ export function ampId(): string | undefined {
84
84
 
85
85
  function referrerId(
86
86
  query: string,
87
- ctx: SegmentEvent['context'],
87
+ ctx: HightouchEvent['context'],
88
88
  disablePersistance: boolean
89
89
  ): void {
90
90
  const storage = new UniversalStorage<{