@simplybusiness/services 2.2.3 → 2.2.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplybusiness/services",
3
3
  "license": "UNLICENSED",
4
- "version": "2.2.3",
4
+ "version": "2.2.4",
5
5
  "description": "Internal library for services",
6
6
  "repository": {
7
7
  "type": "git",
@@ -88,7 +88,8 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@airbrake/browser": "^2.1.9",
91
- "@simplybusiness/mobius": "^9.0.1",
91
+ "@simplybusiness/mobius": "^9.0.2",
92
+ "@snowplow/browser-plugin-ga-cookies": "^3.24.0",
92
93
  "@snowplow/browser-tracker": "^3.24.6",
93
94
  "classnames": "^2.5.1"
94
95
  },
@@ -11,6 +11,7 @@ import {
11
11
  trackSelfDescribingEvent,
12
12
  trackStructEvent,
13
13
  } from "@snowplow/browser-tracker";
14
+ import { GaCookiesPlugin } from "@snowplow/browser-plugin-ga-cookies";
14
15
  import { makeContexts, updateIdentityContext } from "./contexts";
15
16
  import type { EventDefinition, SerialisedEvent, TrackingProps } from "./types";
16
17
 
@@ -86,6 +87,7 @@ export class Snowplow {
86
87
  newTracker(this.pvAvalancheTrackerName, avalancheCollector, {
87
88
  ...baseOptions,
88
89
  eventMethod: eventMethod === "post" ? "beacon" : eventMethod,
90
+ plugins: [GaCookiesPlugin()],
89
91
  });
90
92
 
91
93
  setCookiePath("/");
@@ -98,7 +100,14 @@ export class Snowplow {
98
100
 
99
101
  setContexts(contexts: Record<string, SerialisedEvent>) {
100
102
  this.contexts = updateIdentityContext(contexts, this.uid);
101
- this.pvContext = Object.values(this.contexts);
103
+ this.pvContext = makeContexts(
104
+ [
105
+ "pageViewContext",
106
+ "distributionChannelContext",
107
+ "serviceChannelContext",
108
+ ],
109
+ this.contexts,
110
+ );
102
111
  this.structContext = makeContexts(
103
112
  ["distributionChannelContext", "serviceChannelContext"],
104
113
  this.contexts,
@@ -110,7 +119,7 @@ export class Snowplow {
110
119
  trackView(event?: PageViewEvent) {
111
120
  if (this.trackPageView) {
112
121
  trackPageView({ ...event, context: this.pvContext }, [
113
- this.avalancheTrackerName,
122
+ this.pvAvalancheTrackerName,
114
123
  ]);
115
124
  }
116
125
  return this;
@@ -40,7 +40,16 @@ describe("Snowplow Analytics Class", () => {
40
40
 
41
41
  it("sets contexts on instantiation", () => {
42
42
  expect(testSnowplow.contexts).toEqual(contexts);
43
- expect(testSnowplow.pvContext).toEqual(Object.values(contexts));
43
+ expect(testSnowplow.pvContext).toEqual(
44
+ makeContexts(
45
+ [
46
+ "pageViewContext",
47
+ "distributionChannelContext",
48
+ "serviceChannelContext",
49
+ ],
50
+ contexts,
51
+ ),
52
+ );
44
53
  });
45
54
 
46
55
  it("tracks page view event and adds contexts", async () => {
@@ -63,7 +72,7 @@ describe("Snowplow Analytics Class", () => {
63
72
  await waitFor(() => {
64
73
  expect(innerSpy).toHaveBeenCalledWith(
65
74
  { context: testSnowplow.pvContext },
66
- ["sb-ava"],
75
+ ["sb-ava-pv"],
67
76
  );
68
77
  });
69
78
  });