-
Notifications
You must be signed in to change notification settings - Fork 0
/
customDimensions.service.ts
46 lines (45 loc) · 1.17 KB
/
customDimensions.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { CUSTOM_DIMENSIONS_TRACK_EVENT } from '../../constants/track-event.constant'
import { Tracker } from '../../interfaces/tracker'
import { push } from '../paqService/paq.service'
/**
* Sets a custom dimension value to be used later.
*/
export function setCustomDimensionValue(
customDimensionId: string | number,
customDimensionValue: string
) {
push([
CUSTOM_DIMENSIONS_TRACK_EVENT.SET_CUSTOM_DIMENSION_VALUE,
customDimensionId,
customDimensionValue,
])
}
/**
* Removes a custom dimension with the specified ID.
*/
export function deleteCustomDimension(customDimensionId: string | number) {
push([
CUSTOM_DIMENSIONS_TRACK_EVENT.DELETE_CUSTOM_DIMENSION,
customDimensionId,
])
}
/**
* Returns the value of a custom dimension with the specified ID.
*/
export function getCustomDimensionValue(
customDimensionId: string | number
): Promise<string | undefined> {
return new Promise((resolve, reject) => {
try {
push([
function (this: Tracker): void {
resolve(this.getCustomDimensionValue(customDimensionId))
},
])
} catch (e) {
if (e instanceof ReferenceError) {
reject(e)
}
}
})
}