@adtrackify/at-service-common 1.0.59 → 1.0.61
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/.editorconfig +12 -12
- package/.vscode/settings.json +9 -9
- package/build.js +21 -21
- package/dist/index.d.ts +5 -1
- package/dist/index.js +11 -14
- package/dist/index.js.map +2 -2
- package/jest.config.ts +41 -0
- package/package.json +18 -9
- package/src/__tests__/helpers/subscription-helper.spec.ts +41 -0
- package/src/clients/generic/axios.d.ts +7 -7
- package/src/clients/generic/dynamodb-client.ts +113 -113
- package/src/clients/generic/eventbridge-client.ts +52 -52
- package/src/clients/internal-api/accounts-client.ts +107 -107
- package/src/clients/internal-api/destinations-client.ts +58 -58
- package/src/clients/internal-api/users-auth-client.ts +8 -7
- package/src/clients/third-party/shopify-client.ts +128 -128
- package/src/helpers/input-validation-helper.ts +21 -21
- package/src/helpers/shopify-helper.ts +39 -39
- package/src/helpers/subscription-helper.ts +217 -217
- package/src/libs/http-error.ts +6 -6
- package/src/libs/index.ts +7 -7
- package/src/libs/url.ts +9 -9
- package/src/types/internal-events/event-detail-types.ts +9 -9
- package/tsconfig.json +2 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { createHmac } from 'crypto';
|
|
2
|
-
import * as log from 'lambda-log';
|
|
3
|
-
import { HttpError } from '../libs';
|
|
4
|
-
import { mapObjectToQueryString } from '../libs/url';
|
|
5
|
-
export interface ShopifyRequestValidationParameters {
|
|
6
|
-
code: string,
|
|
7
|
-
hmac?: string,
|
|
8
|
-
shop: string,
|
|
9
|
-
state: string,
|
|
10
|
-
timestamp: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const isShopifyRequestValid = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string): boolean => {
|
|
14
|
-
// remove hmac if it exists
|
|
15
|
-
// map input to query string
|
|
16
|
-
// generate hash using api secret key and validate it matches hmac
|
|
17
|
-
delete validationParams.hmac;
|
|
18
|
-
const hmacString = mapObjectToQueryString(validationParams);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const generatedHash = createHmac('sha256', shopifyAppApiSecret)
|
|
22
|
-
.update(hmacString)
|
|
23
|
-
.digest('hex');
|
|
24
|
-
|
|
25
|
-
return generatedHash === validationHmac;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const validateShopifyRequest = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => {
|
|
29
|
-
log.info('Validating shopify request is authentic', { validationParams });
|
|
30
|
-
const isValid = isShopifyRequestValid(validationParams, validationHmac as string, shopifyAppApiSecret);
|
|
31
|
-
if (!isValid) {
|
|
32
|
-
const message = 'Failed: Shopify Request hmac validation';
|
|
33
|
-
log.error(message);
|
|
34
|
-
throw HttpError.badRequest(message);
|
|
35
|
-
}
|
|
36
|
-
log.info('Sucess: Shopify Request hmac validation');
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
1
|
+
import { createHmac } from 'crypto';
|
|
2
|
+
import * as log from 'lambda-log';
|
|
3
|
+
import { HttpError } from '../libs';
|
|
4
|
+
import { mapObjectToQueryString } from '../libs/url';
|
|
5
|
+
export interface ShopifyRequestValidationParameters {
|
|
6
|
+
code: string,
|
|
7
|
+
hmac?: string,
|
|
8
|
+
shop: string,
|
|
9
|
+
state: string,
|
|
10
|
+
timestamp: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const isShopifyRequestValid = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string): boolean => {
|
|
14
|
+
// remove hmac if it exists
|
|
15
|
+
// map input to query string
|
|
16
|
+
// generate hash using api secret key and validate it matches hmac
|
|
17
|
+
delete validationParams.hmac;
|
|
18
|
+
const hmacString = mapObjectToQueryString(validationParams);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const generatedHash = createHmac('sha256', shopifyAppApiSecret)
|
|
22
|
+
.update(hmacString)
|
|
23
|
+
.digest('hex');
|
|
24
|
+
|
|
25
|
+
return generatedHash === validationHmac;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const validateShopifyRequest = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => {
|
|
29
|
+
log.info('Validating shopify request is authentic', { validationParams });
|
|
30
|
+
const isValid = isShopifyRequestValid(validationParams, validationHmac as string, shopifyAppApiSecret);
|
|
31
|
+
if (!isValid) {
|
|
32
|
+
const message = 'Failed: Shopify Request hmac validation';
|
|
33
|
+
log.error(message);
|
|
34
|
+
throw HttpError.badRequest(message);
|
|
35
|
+
}
|
|
36
|
+
log.info('Sucess: Shopify Request hmac validation');
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -1,218 +1,218 @@
|
|
|
1
|
-
import { SubscriptionPlan, PLAN_BILLING_FREQUENCY } from '@adtrackify/at-tracking-event-types';
|
|
2
|
-
|
|
3
|
-
export const StripeBillingMap: any = {
|
|
4
|
-
dev: {
|
|
5
|
-
'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
|
|
6
|
-
'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
7
|
-
'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
8
|
-
'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
|
|
9
|
-
'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
|
|
10
|
-
'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
|
|
11
|
-
'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
|
|
12
|
-
},
|
|
13
|
-
qa: {
|
|
14
|
-
'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
|
|
15
|
-
'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
16
|
-
'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
17
|
-
'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
|
|
18
|
-
'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
|
|
19
|
-
'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
|
|
20
|
-
'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
|
|
21
|
-
},
|
|
22
|
-
prod: {
|
|
23
|
-
'free': 'price_1KAFsIK7krGh4037RsaAYMEl',
|
|
24
|
-
'starter_monthly': 'price_1KAFsMK7krGh4037Lz3P0ksU',
|
|
25
|
-
'starter_yearly': 'price_1KAFsMK7krGh4037Dj1WmSi8',
|
|
26
|
-
'scale_monthly': 'price_1KAFrxK7krGh4037zWCdaTly',
|
|
27
|
-
'scale_yearly': 'price_1KAFrxK7krGh40375fhymyWP',
|
|
28
|
-
'growth_monthly': 'price_1KAFs7K7krGh4037JChjz5Cr',
|
|
29
|
-
'growth_yearly': 'price_1KAFs7K7krGh4037rZElg12s'
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export const SubscriptionPlanSeedItems: {
|
|
33
|
-
items: SubscriptionPlan[];
|
|
34
|
-
} = {
|
|
35
|
-
items: [ {
|
|
36
|
-
id: 1,
|
|
37
|
-
planName: 'free',
|
|
38
|
-
sku: 'ADT-001',
|
|
39
|
-
description: 'Free Plan - Monthly',
|
|
40
|
-
price: '0',
|
|
41
|
-
displayPrice: '$0',
|
|
42
|
-
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
43
|
-
trialLengthDays: 30,
|
|
44
|
-
trialRequiresCreditCard: false,
|
|
45
|
-
planDesc: [
|
|
46
|
-
'Fixes IOS14.5 tracking',
|
|
47
|
-
'Multi Pixel Support',
|
|
48
|
-
'Enhanced Tracking / Attribution',
|
|
49
|
-
'Unlimited Facebook Conversion API',
|
|
50
|
-
'Unlimited Integrations',
|
|
51
|
-
'Easy no code setup',
|
|
52
|
-
'1,000 tracking events/mo'
|
|
53
|
-
],
|
|
54
|
-
unitPriceText: 'try now - free forever',
|
|
55
|
-
isHighlighted: false,
|
|
56
|
-
isBanner: false
|
|
57
|
-
},
|
|
58
|
-
// STARTER PLANS
|
|
59
|
-
{
|
|
60
|
-
id: 2,
|
|
61
|
-
planName: 'starter_monthly',
|
|
62
|
-
sku: 'ADT-002',
|
|
63
|
-
description: 'Starter Plan - Monthly',
|
|
64
|
-
price: '9.99',
|
|
65
|
-
displayPrice: '$9.99',
|
|
66
|
-
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
67
|
-
trialLengthDays: 30,
|
|
68
|
-
trialRequiresCreditCard: false,
|
|
69
|
-
planDesc: [
|
|
70
|
-
'30-day Risk Free Trial',
|
|
71
|
-
'Fixes IOS14.5 tracking',
|
|
72
|
-
'Multi Pixel Support',
|
|
73
|
-
'Enhanced Tracking / Attribution',
|
|
74
|
-
'Unlimited Facebook Conversion API',
|
|
75
|
-
'Unlimited Integrations',
|
|
76
|
-
'Easy no code setup',
|
|
77
|
-
'2,500 tracking events/mo'
|
|
78
|
-
],
|
|
79
|
-
unitPriceText: '',
|
|
80
|
-
isHighlighted: false,
|
|
81
|
-
isBanner: false,
|
|
82
|
-
}, {
|
|
83
|
-
id: 3,
|
|
84
|
-
planName: 'starter_yearly',
|
|
85
|
-
sku: 'ADT-003',
|
|
86
|
-
description: 'Starter Plan - Yearly',
|
|
87
|
-
price: '96.00',
|
|
88
|
-
displayPrice: '$8',
|
|
89
|
-
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
90
|
-
trialLengthDays: 30,
|
|
91
|
-
trialRequiresCreditCard: false,
|
|
92
|
-
planDesc: [
|
|
93
|
-
'30-day Risk Free Trial',
|
|
94
|
-
'Fixes IOS14.5 tracking',
|
|
95
|
-
'Multi Pixel Support',
|
|
96
|
-
'Enhanced Tracking / Attribution',
|
|
97
|
-
'Unlimited Facebook Conversion API',
|
|
98
|
-
'Unlimited Integrations',
|
|
99
|
-
'Easy no code setup',
|
|
100
|
-
'2,500 tracking events/mo'
|
|
101
|
-
],
|
|
102
|
-
unitPriceText: 'billed yearly ($96) - 20% savings',
|
|
103
|
-
isHighlighted: false,
|
|
104
|
-
isBanner: false
|
|
105
|
-
},
|
|
106
|
-
// SCALE PLANS
|
|
107
|
-
{
|
|
108
|
-
id: 4,
|
|
109
|
-
planName: 'scale_monthly',
|
|
110
|
-
sku: 'ADT-004',
|
|
111
|
-
description: 'Scale Plan - Monthly',
|
|
112
|
-
price: '59.99',
|
|
113
|
-
displayPrice: '$59.99',
|
|
114
|
-
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
115
|
-
trialLengthDays: 30,
|
|
116
|
-
trialRequiresCreditCard: false,
|
|
117
|
-
planDesc: [
|
|
118
|
-
'30-day Risk Free Trial',
|
|
119
|
-
'Fixes IOS14.5 tracking',
|
|
120
|
-
'Multi Pixel Support',
|
|
121
|
-
'Enhanced Tracking / Attribution',
|
|
122
|
-
'Unlimited Facebook Conversion API',
|
|
123
|
-
'Unlimited Integrations',
|
|
124
|
-
'Easy no code setup',
|
|
125
|
-
'25,000 tracking events/mo'
|
|
126
|
-
],
|
|
127
|
-
unitPriceText: 'billed yearly ($96) - 20% savings',
|
|
128
|
-
isHighlighted: true,
|
|
129
|
-
isBanner: true,
|
|
130
|
-
bannerColor: 'blue',
|
|
131
|
-
bannerText: 'MOST POPULAR'
|
|
132
|
-
}, {
|
|
133
|
-
id: 5,
|
|
134
|
-
planName: 'scale_yearly',
|
|
135
|
-
sku: 'ADT-005',
|
|
136
|
-
description: 'Scale Plan - Yearly',
|
|
137
|
-
price: '540.00',
|
|
138
|
-
displayPrice: '$45',
|
|
139
|
-
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
140
|
-
trialLengthDays: 30,
|
|
141
|
-
trialRequiresCreditCard: false,
|
|
142
|
-
planDesc: [
|
|
143
|
-
'30-day Risk Free Trial',
|
|
144
|
-
'Fixes IOS14.5 tracking',
|
|
145
|
-
'Multi Pixel Support',
|
|
146
|
-
'Enhanced Tracking / Attribution',
|
|
147
|
-
'Unlimited Facebook Conversion API',
|
|
148
|
-
'Unlimited Integrations',
|
|
149
|
-
'Easy no code setup',
|
|
150
|
-
'25,000 tracking events/mo'
|
|
151
|
-
],
|
|
152
|
-
unitPriceText: 'billed yearly ($540) - 25% savings',
|
|
153
|
-
isHighlighted: true,
|
|
154
|
-
isBanner: true,
|
|
155
|
-
bannerColor: 'blue',
|
|
156
|
-
bannerText: 'MOST POPULAR'
|
|
157
|
-
},
|
|
158
|
-
// GROWTH PLANS
|
|
159
|
-
{
|
|
160
|
-
id: 6,
|
|
161
|
-
planName: 'growth_monthly',
|
|
162
|
-
sku: 'ADT-006',
|
|
163
|
-
description: 'Growth Plan - Monthly',
|
|
164
|
-
price: '159.99',
|
|
165
|
-
displayPrice: '$159.99',
|
|
166
|
-
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
167
|
-
trialLengthDays: 30,
|
|
168
|
-
trialRequiresCreditCard: false,
|
|
169
|
-
planDesc: [
|
|
170
|
-
'30-day Risk Free Trial',
|
|
171
|
-
'Fixes IOS14.5 tracking',
|
|
172
|
-
'Multi Pixel Support',
|
|
173
|
-
'Enhanced Tracking / Attribution',
|
|
174
|
-
'Unlimited Facebook Conversion API',
|
|
175
|
-
'Unlimited Integrations',
|
|
176
|
-
'Easy no code setup',
|
|
177
|
-
'100,000 tracking events/mo'
|
|
178
|
-
],
|
|
179
|
-
unitPriceText: 'billed yearly ($540) - 25% savings',
|
|
180
|
-
isHighlighted: false,
|
|
181
|
-
isBanner: true,
|
|
182
|
-
bannerColor: 'orange',
|
|
183
|
-
bannerText: 'BEST VALUE'
|
|
184
|
-
}, {
|
|
185
|
-
id: 7,
|
|
186
|
-
planName: 'growth_yearly',
|
|
187
|
-
sku: 'ADT-007',
|
|
188
|
-
description: 'Growth Plan - Yearly',
|
|
189
|
-
price: '1344.00',
|
|
190
|
-
displayPrice: '$112',
|
|
191
|
-
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
192
|
-
trialLengthDays: 30,
|
|
193
|
-
trialRequiresCreditCard: false,
|
|
194
|
-
planDesc: [
|
|
195
|
-
'30-day Risk Free Trial',
|
|
196
|
-
'Fixes IOS14.5 tracking',
|
|
197
|
-
'Multi Pixel Support',
|
|
198
|
-
'Enhanced Tracking / Attribution',
|
|
199
|
-
'Unlimited Facebook Conversion API',
|
|
200
|
-
'Unlimited Integrations',
|
|
201
|
-
'Easy no code setup',
|
|
202
|
-
'100,000 tracking events/mo'
|
|
203
|
-
],
|
|
204
|
-
unitPriceText: 'billed yearly ($1344) - 30% savings',
|
|
205
|
-
isHighlighted: false,
|
|
206
|
-
isBanner: true,
|
|
207
|
-
bannerColor: 'orange',
|
|
208
|
-
bannerText: 'BEST VALUE'
|
|
209
|
-
},
|
|
210
|
-
]
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
export const getPlanDetails = (planId: number, stage: string) => {
|
|
215
|
-
const plan = SubscriptionPlanSeedItems.items.filter(x => x.id === planId)[ 0 ] as any;
|
|
216
|
-
plan.stripePriceId = StripeBillingMap[ stage ][ plan.planName ];
|
|
217
|
-
return plan as SubscriptionPlan;
|
|
1
|
+
import { SubscriptionPlan, PLAN_BILLING_FREQUENCY } from '@adtrackify/at-tracking-event-types';
|
|
2
|
+
|
|
3
|
+
export const StripeBillingMap: any = {
|
|
4
|
+
dev: {
|
|
5
|
+
'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
|
|
6
|
+
'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
7
|
+
'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
8
|
+
'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
|
|
9
|
+
'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
|
|
10
|
+
'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
|
|
11
|
+
'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
|
|
12
|
+
},
|
|
13
|
+
qa: {
|
|
14
|
+
'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
|
|
15
|
+
'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
16
|
+
'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
|
|
17
|
+
'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
|
|
18
|
+
'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
|
|
19
|
+
'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
|
|
20
|
+
'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
|
|
21
|
+
},
|
|
22
|
+
prod: {
|
|
23
|
+
'free': 'price_1KAFsIK7krGh4037RsaAYMEl',
|
|
24
|
+
'starter_monthly': 'price_1KAFsMK7krGh4037Lz3P0ksU',
|
|
25
|
+
'starter_yearly': 'price_1KAFsMK7krGh4037Dj1WmSi8',
|
|
26
|
+
'scale_monthly': 'price_1KAFrxK7krGh4037zWCdaTly',
|
|
27
|
+
'scale_yearly': 'price_1KAFrxK7krGh40375fhymyWP',
|
|
28
|
+
'growth_monthly': 'price_1KAFs7K7krGh4037JChjz5Cr',
|
|
29
|
+
'growth_yearly': 'price_1KAFs7K7krGh4037rZElg12s'
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const SubscriptionPlanSeedItems: {
|
|
33
|
+
items: SubscriptionPlan[];
|
|
34
|
+
} = {
|
|
35
|
+
items: [ {
|
|
36
|
+
id: 1,
|
|
37
|
+
planName: 'free',
|
|
38
|
+
sku: 'ADT-001',
|
|
39
|
+
description: 'Free Plan - Monthly',
|
|
40
|
+
price: '0',
|
|
41
|
+
displayPrice: '$0',
|
|
42
|
+
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
43
|
+
trialLengthDays: 30,
|
|
44
|
+
trialRequiresCreditCard: false,
|
|
45
|
+
planDesc: [
|
|
46
|
+
'Fixes IOS14.5 tracking',
|
|
47
|
+
'Multi Pixel Support',
|
|
48
|
+
'Enhanced Tracking / Attribution',
|
|
49
|
+
'Unlimited Facebook Conversion API',
|
|
50
|
+
'Unlimited Integrations',
|
|
51
|
+
'Easy no code setup',
|
|
52
|
+
'1,000 tracking events/mo'
|
|
53
|
+
],
|
|
54
|
+
unitPriceText: 'try now - free forever',
|
|
55
|
+
isHighlighted: false,
|
|
56
|
+
isBanner: false
|
|
57
|
+
},
|
|
58
|
+
// STARTER PLANS
|
|
59
|
+
{
|
|
60
|
+
id: 2,
|
|
61
|
+
planName: 'starter_monthly',
|
|
62
|
+
sku: 'ADT-002',
|
|
63
|
+
description: 'Starter Plan - Monthly',
|
|
64
|
+
price: '9.99',
|
|
65
|
+
displayPrice: '$9.99',
|
|
66
|
+
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
67
|
+
trialLengthDays: 30,
|
|
68
|
+
trialRequiresCreditCard: false,
|
|
69
|
+
planDesc: [
|
|
70
|
+
'30-day Risk Free Trial',
|
|
71
|
+
'Fixes IOS14.5 tracking',
|
|
72
|
+
'Multi Pixel Support',
|
|
73
|
+
'Enhanced Tracking / Attribution',
|
|
74
|
+
'Unlimited Facebook Conversion API',
|
|
75
|
+
'Unlimited Integrations',
|
|
76
|
+
'Easy no code setup',
|
|
77
|
+
'2,500 tracking events/mo'
|
|
78
|
+
],
|
|
79
|
+
unitPriceText: '',
|
|
80
|
+
isHighlighted: false,
|
|
81
|
+
isBanner: false,
|
|
82
|
+
}, {
|
|
83
|
+
id: 3,
|
|
84
|
+
planName: 'starter_yearly',
|
|
85
|
+
sku: 'ADT-003',
|
|
86
|
+
description: 'Starter Plan - Yearly',
|
|
87
|
+
price: '96.00',
|
|
88
|
+
displayPrice: '$8',
|
|
89
|
+
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
90
|
+
trialLengthDays: 30,
|
|
91
|
+
trialRequiresCreditCard: false,
|
|
92
|
+
planDesc: [
|
|
93
|
+
'30-day Risk Free Trial',
|
|
94
|
+
'Fixes IOS14.5 tracking',
|
|
95
|
+
'Multi Pixel Support',
|
|
96
|
+
'Enhanced Tracking / Attribution',
|
|
97
|
+
'Unlimited Facebook Conversion API',
|
|
98
|
+
'Unlimited Integrations',
|
|
99
|
+
'Easy no code setup',
|
|
100
|
+
'2,500 tracking events/mo'
|
|
101
|
+
],
|
|
102
|
+
unitPriceText: 'billed yearly ($96) - 20% savings',
|
|
103
|
+
isHighlighted: false,
|
|
104
|
+
isBanner: false
|
|
105
|
+
},
|
|
106
|
+
// SCALE PLANS
|
|
107
|
+
{
|
|
108
|
+
id: 4,
|
|
109
|
+
planName: 'scale_monthly',
|
|
110
|
+
sku: 'ADT-004',
|
|
111
|
+
description: 'Scale Plan - Monthly',
|
|
112
|
+
price: '59.99',
|
|
113
|
+
displayPrice: '$59.99',
|
|
114
|
+
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
115
|
+
trialLengthDays: 30,
|
|
116
|
+
trialRequiresCreditCard: false,
|
|
117
|
+
planDesc: [
|
|
118
|
+
'30-day Risk Free Trial',
|
|
119
|
+
'Fixes IOS14.5 tracking',
|
|
120
|
+
'Multi Pixel Support',
|
|
121
|
+
'Enhanced Tracking / Attribution',
|
|
122
|
+
'Unlimited Facebook Conversion API',
|
|
123
|
+
'Unlimited Integrations',
|
|
124
|
+
'Easy no code setup',
|
|
125
|
+
'25,000 tracking events/mo'
|
|
126
|
+
],
|
|
127
|
+
unitPriceText: 'billed yearly ($96) - 20% savings',
|
|
128
|
+
isHighlighted: true,
|
|
129
|
+
isBanner: true,
|
|
130
|
+
bannerColor: 'blue',
|
|
131
|
+
bannerText: 'MOST POPULAR'
|
|
132
|
+
}, {
|
|
133
|
+
id: 5,
|
|
134
|
+
planName: 'scale_yearly',
|
|
135
|
+
sku: 'ADT-005',
|
|
136
|
+
description: 'Scale Plan - Yearly',
|
|
137
|
+
price: '540.00',
|
|
138
|
+
displayPrice: '$45',
|
|
139
|
+
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
140
|
+
trialLengthDays: 30,
|
|
141
|
+
trialRequiresCreditCard: false,
|
|
142
|
+
planDesc: [
|
|
143
|
+
'30-day Risk Free Trial',
|
|
144
|
+
'Fixes IOS14.5 tracking',
|
|
145
|
+
'Multi Pixel Support',
|
|
146
|
+
'Enhanced Tracking / Attribution',
|
|
147
|
+
'Unlimited Facebook Conversion API',
|
|
148
|
+
'Unlimited Integrations',
|
|
149
|
+
'Easy no code setup',
|
|
150
|
+
'25,000 tracking events/mo'
|
|
151
|
+
],
|
|
152
|
+
unitPriceText: 'billed yearly ($540) - 25% savings',
|
|
153
|
+
isHighlighted: true,
|
|
154
|
+
isBanner: true,
|
|
155
|
+
bannerColor: 'blue',
|
|
156
|
+
bannerText: 'MOST POPULAR'
|
|
157
|
+
},
|
|
158
|
+
// GROWTH PLANS
|
|
159
|
+
{
|
|
160
|
+
id: 6,
|
|
161
|
+
planName: 'growth_monthly',
|
|
162
|
+
sku: 'ADT-006',
|
|
163
|
+
description: 'Growth Plan - Monthly',
|
|
164
|
+
price: '159.99',
|
|
165
|
+
displayPrice: '$159.99',
|
|
166
|
+
billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
|
|
167
|
+
trialLengthDays: 30,
|
|
168
|
+
trialRequiresCreditCard: false,
|
|
169
|
+
planDesc: [
|
|
170
|
+
'30-day Risk Free Trial',
|
|
171
|
+
'Fixes IOS14.5 tracking',
|
|
172
|
+
'Multi Pixel Support',
|
|
173
|
+
'Enhanced Tracking / Attribution',
|
|
174
|
+
'Unlimited Facebook Conversion API',
|
|
175
|
+
'Unlimited Integrations',
|
|
176
|
+
'Easy no code setup',
|
|
177
|
+
'100,000 tracking events/mo'
|
|
178
|
+
],
|
|
179
|
+
unitPriceText: 'billed yearly ($540) - 25% savings',
|
|
180
|
+
isHighlighted: false,
|
|
181
|
+
isBanner: true,
|
|
182
|
+
bannerColor: 'orange',
|
|
183
|
+
bannerText: 'BEST VALUE'
|
|
184
|
+
}, {
|
|
185
|
+
id: 7,
|
|
186
|
+
planName: 'growth_yearly',
|
|
187
|
+
sku: 'ADT-007',
|
|
188
|
+
description: 'Growth Plan - Yearly',
|
|
189
|
+
price: '1344.00',
|
|
190
|
+
displayPrice: '$112',
|
|
191
|
+
billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
|
|
192
|
+
trialLengthDays: 30,
|
|
193
|
+
trialRequiresCreditCard: false,
|
|
194
|
+
planDesc: [
|
|
195
|
+
'30-day Risk Free Trial',
|
|
196
|
+
'Fixes IOS14.5 tracking',
|
|
197
|
+
'Multi Pixel Support',
|
|
198
|
+
'Enhanced Tracking / Attribution',
|
|
199
|
+
'Unlimited Facebook Conversion API',
|
|
200
|
+
'Unlimited Integrations',
|
|
201
|
+
'Easy no code setup',
|
|
202
|
+
'100,000 tracking events/mo'
|
|
203
|
+
],
|
|
204
|
+
unitPriceText: 'billed yearly ($1344) - 30% savings',
|
|
205
|
+
isHighlighted: false,
|
|
206
|
+
isBanner: true,
|
|
207
|
+
bannerColor: 'orange',
|
|
208
|
+
bannerText: 'BEST VALUE'
|
|
209
|
+
},
|
|
210
|
+
]
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
export const getPlanDetails = (planId: number, stage: string) => {
|
|
215
|
+
const plan = SubscriptionPlanSeedItems.items.filter(x => x.id === planId)[ 0 ] as any;
|
|
216
|
+
plan.stripePriceId = StripeBillingMap[ stage ][ plan.planName ];
|
|
217
|
+
return plan as SubscriptionPlan;
|
|
218
218
|
};
|
package/src/libs/http-error.ts
CHANGED
|
@@ -27,9 +27,9 @@ const supportedStatusCodes: any = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const supportedStatusCodesMessage = `statusCode must be one of the following: ${JSON.stringify(Object.keys(supportedStatusCodes))}`;
|
|
30
|
-
const onlyStatusCodeMessage = 'Server errors may not specify any parameter except statusCode';
|
|
30
|
+
//const onlyStatusCodeMessage = 'Server errors may not specify any parameter except statusCode';
|
|
31
31
|
|
|
32
|
-
const isNullOrUndefined = (value: any) => value === null || value === undefined;
|
|
32
|
+
//const isNullOrUndefined = (value: any) => value === null || value === undefined;
|
|
33
33
|
|
|
34
34
|
export class HttpError extends Error {
|
|
35
35
|
body: {
|
|
@@ -50,10 +50,10 @@ export class HttpError extends Error {
|
|
|
50
50
|
const isServerError = statusCode > 499;
|
|
51
51
|
|
|
52
52
|
if (isServerError) {
|
|
53
|
-
assert(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
53
|
+
// assert(
|
|
54
|
+
// isNullOrUndefined(message) && isNullOrUndefined(body),
|
|
55
|
+
// onlyStatusCodeMessage
|
|
56
|
+
// );
|
|
57
57
|
|
|
58
58
|
message = supportedStatusCodes[ statusCode ] as string;
|
|
59
59
|
} else {
|
package/src/libs/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from '../helpers/shopify-helper';
|
|
2
|
-
export * from './crypto';
|
|
3
|
-
export * from './dates';
|
|
4
|
-
export * from './http-error';
|
|
5
|
-
export * from './http-status-codes';
|
|
6
|
-
export * from './url';
|
|
7
|
-
|
|
1
|
+
export * from '../helpers/shopify-helper';
|
|
2
|
+
export * from './crypto';
|
|
3
|
+
export * from './dates';
|
|
4
|
+
export * from './http-error';
|
|
5
|
+
export * from './http-status-codes';
|
|
6
|
+
export * from './url';
|
|
7
|
+
|
package/src/libs/url.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// Record<string, string> is any object
|
|
2
|
-
export const mapObjectToQueryString = (inputObj: any): string => {
|
|
3
|
-
const qsp = Object.entries(inputObj).sort((a, b) => a[ 0 ] < b[ 0 ] ? -1 : 1);
|
|
4
|
-
const urlParams = new URLSearchParams();
|
|
5
|
-
qsp.map(p => {
|
|
6
|
-
urlParams.append(p[ 0 ], p[ 1 ] as string);
|
|
7
|
-
});
|
|
8
|
-
const qs = urlParams.toString();
|
|
9
|
-
return qs;
|
|
1
|
+
// Record<string, string> is any object
|
|
2
|
+
export const mapObjectToQueryString = (inputObj: any): string => {
|
|
3
|
+
const qsp = Object.entries(inputObj).sort((a, b) => a[ 0 ] < b[ 0 ] ? -1 : 1);
|
|
4
|
+
const urlParams = new URLSearchParams();
|
|
5
|
+
qsp.map(p => {
|
|
6
|
+
urlParams.append(p[ 0 ], p[ 1 ] as string);
|
|
7
|
+
});
|
|
8
|
+
const qs = urlParams.toString();
|
|
9
|
+
return qs;
|
|
10
10
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export enum ADTRACKIFY_EVENT_TYPES {
|
|
2
|
-
NOTIFY_SHOPIFY_SUBSCRIPTION_CREATED = 'shopifySubscriptionCreated',
|
|
3
|
-
NOTIFY_SUBSCRIPTION_SIGNUP_COMPLETED = 'subscription.signupCompleted',
|
|
4
|
-
REQUEST_SET_ACCOUNT_OWNER = 'setAccountOwner',
|
|
5
|
-
REQUEST_SET_ACCOUNT_SUBSCRIPTION_ID = 'setAccountSubscriptionId',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export enum ADTRACKIFY_EVENT_SOURCES {
|
|
9
|
-
SUBSCRIPTIONS = 'subscriptions',
|
|
1
|
+
export enum ADTRACKIFY_EVENT_TYPES {
|
|
2
|
+
NOTIFY_SHOPIFY_SUBSCRIPTION_CREATED = 'shopifySubscriptionCreated',
|
|
3
|
+
NOTIFY_SUBSCRIPTION_SIGNUP_COMPLETED = 'subscription.signupCompleted',
|
|
4
|
+
REQUEST_SET_ACCOUNT_OWNER = 'setAccountOwner',
|
|
5
|
+
REQUEST_SET_ACCOUNT_SUBSCRIPTION_ID = 'setAccountSubscriptionId',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum ADTRACKIFY_EVENT_SOURCES {
|
|
9
|
+
SUBSCRIPTIONS = 'subscriptions',
|
|
10
10
|
}
|